Beispiel #1
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public MouseButtonMessage(Point location, XMouseButtons mouseButton, ButtonActions buttonAction, uint clickCount, ModifierFlags modifierFlags)
			: this(location, mouseButton, buttonAction, clickCount, 
						(modifierFlags & ModifierFlags.Control) == ModifierFlags.Control,
						(modifierFlags & ModifierFlags.Alt) == ModifierFlags.Alt,
						(modifierFlags & ModifierFlags.Shift) == ModifierFlags.Shift)
		{
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberOrderHelper"/> struct.
        /// </summary>
        /// <param name="member">The member to wrap.</param>
        public MemberOrderHelper(MemberDeclarationSyntax member)
        {
            this.Member = member;
            var modifiers = member.GetModifiers();

            this.modifierFlags = GetModifierFlags(modifiers);
            this.accessibilty = AccessLevelHelper.GetAccessLevel(modifiers);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberOrderHelper"/> struct.
        /// </summary>
        /// <param name="member">The member to wrap.</param>
        /// <param name="checks">The element ordering checks.</param>
        internal MemberOrderHelper(MemberDeclarationSyntax member, ElementOrderingChecks checks)
        {
            this.Member = member;
            var modifiers = member.GetModifiers();
            var type = member.Kind();
            type = type == SyntaxKind.EventFieldDeclaration ? SyntaxKind.EventDeclaration : type;

            this.elementPriority = checks.ElementType ? TypeMemberOrder.IndexOf(type) : 0;
            this.modifierFlags = GetModifierFlags(modifiers, checks);
            if (checks.AccessLevel)
            {
                if ((type == SyntaxKind.ConstructorDeclaration && this.modifierFlags.HasFlag(ModifierFlags.Static))
                    || (type == SyntaxKind.MethodDeclaration && ((MethodDeclarationSyntax)member).ExplicitInterfaceSpecifier != null)
                    || (type == SyntaxKind.PropertyDeclaration && ((PropertyDeclarationSyntax)member).ExplicitInterfaceSpecifier != null)
                    || (type == SyntaxKind.IndexerDeclaration && ((IndexerDeclarationSyntax)member).ExplicitInterfaceSpecifier != null))
                {
                    this.accessibilty = AccessLevel.Public;
                }
                else
                {
                    this.accessibilty = AccessLevelHelper.GetAccessLevel(modifiers);
                    if (this.accessibilty == AccessLevel.NotSpecified)
                    {
                        if (member.Parent.IsKind(SyntaxKind.CompilationUnit) || member.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
                        {
                            this.accessibilty = AccessLevel.Internal;
                        }
                        else
                        {
                            this.accessibilty = AccessLevel.Private;
                        }
                    }
                }
            }
            else
            {
                this.accessibilty = AccessLevel.Public;
            }
        }
Beispiel #4
0
 public void Deconstruct(out double x, out double y, out ModifierFlags modifier)
 {
     x        = X;
     y        = Y;
     modifier = Modifier;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputArgs"/> struct.
 /// </summary>
 /// <param name="x">The input X position.</param>
 /// <param name="y">The input Y position.</param>
 /// <param name="modifier">The input modifier flags.</param>
 public InputArgs(double x, double y, ModifierFlags modifier)
 {
     this.X        = x;
     this.Y        = y;
     this.Modifier = modifier;
 }
		/// <summary>
		/// Constructor that accepts <see cref="ModifierFlags"/> as input.
		/// </summary>
		/// <param name="modifiers"></param>
		public MouseWheelHandlerAttribute(ModifierFlags modifiers)
		{
			_shortcut = new MouseWheelShortcut(modifiers);
		}
Beispiel #7
0
 public static bool HasModifier(INode node, ModifierFlags flags)
 {
     return((GetModifierFlags(node) & flags) != 0);
 }
		private static string GetName(ModifierFlags value, IDictionary<ModifierFlags, string> map)
		{
			if (map.ContainsKey(value))
				return map[value];
			else if (Enum.IsDefined(typeof (ModifierFlags), (int) value))
				return Enum.GetName(typeof (ModifierFlags), (int) value);
			return string.Empty;
		}
        public static ModifierFlags GetModifierFlags(this MemberDeclarationSyntax member)
        {
            ModifierFlags result = 0;

            foreach (var modifier in member.GetModifiers())
            {
                switch (modifier.Kind())
                {
                case SyntaxKind.PublicKeyword:
                    result |= ModifierFlags.Public;
                    break;

                case SyntaxKind.ProtectedKeyword:
                    result |= ModifierFlags.Protected;
                    break;

                case SyntaxKind.InternalKeyword:
                    result |= ModifierFlags.Internal;
                    break;

                case SyntaxKind.PrivateKeyword:
                    result |= ModifierFlags.Private;
                    break;

                case SyntaxKind.VirtualKeyword:
                    result |= ModifierFlags.Virtual;
                    break;

                case SyntaxKind.AbstractKeyword:
                    result |= ModifierFlags.Abstract;
                    break;

                case SyntaxKind.NewKeyword:
                    result |= ModifierFlags.New;
                    break;

                case SyntaxKind.OverrideKeyword:
                    result |= ModifierFlags.Override;
                    break;

                case SyntaxKind.SealedKeyword:
                    result |= ModifierFlags.Sealed;
                    break;

                case SyntaxKind.StaticKeyword:
                    result |= ModifierFlags.Static;
                    break;

                case SyntaxKind.ExternKeyword:
                    result |= ModifierFlags.Extern;
                    break;

                case SyntaxKind.ReadOnlyKeyword:
                    result |= ModifierFlags.ReadOnly;
                    break;

                case SyntaxKind.ConstKeyword:
                    result |= ModifierFlags.Const;
                    break;

                case SyntaxKind.VolatileKeyword:
                    result |= ModifierFlags.Volatile;
                    break;

                case SyntaxKind.UnsafeKeyword:
                    result |= ModifierFlags.Unsafe;
                    break;

                case SyntaxKind.AsyncKeyword:
                    result |= ModifierFlags.Async;
                    break;

                case SyntaxKind.PartialKeyword:
                    result |= ModifierFlags.Partial;
                    break;
                }
            }

            return(result);
        }
		private void AssertEquivalency(string sModifiers, ModifierFlags eModifiers, CultureInfo culture, string message)
		{
			AssertStringFormat(sModifiers, eModifiers, culture, message);
			AssertStringParse(sModifiers, eModifiers, culture, message);
		}
 /// <summary>
 /// Constructor.
 /// </summary>
 public DefaultMouseToolButtonAttribute(XMouseButtons mouseButton, ModifierFlags modifierFlags)
 {
     _shortcut = new MouseButtonShortcut(mouseButton, modifierFlags);
 }
Beispiel #12
0
 protected virtual void OnGlobalMouseButtonComboShortcutChanged()
 {
     this.NotifyPropertyChanged("GlobalMouseButtonCombo");
     this.GlobalMouseButtons = _globalMouseButtonCombo.MouseButtons;
     this.GlobalModifiers    = _globalMouseButtonCombo.Modifiers;
 }
Beispiel #13
0
            protected override DragDropOption CheckDropLocalItems(IList <IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
            {
                DragDropOption allowedActions = base.CheckDropLocalItems(droppingItems, targetIndex, actions, modifiers);

                if (allowedActions == DragDropOption.None && modifiers == ModifierFlags.Shift)
                {
                    bool allow = true;
                    foreach (IGalleryItem droppingItem in droppingItems)
                    {
                        if (!(droppingItem is IStudyComposerItem))
                        {
                            allow &= false;
                        }
                    }

                    if (allow)
                    {
                        return(DragDropOption.Copy);
                    }
                }
                return(allowedActions);
            }
Beispiel #14
0
            protected override DragDropOption PerformDropLocalItems(IList <IGalleryItem> droppedItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
            {
                DragDropOption performedActions = base.PerformDropLocalItems(droppedItems, targetIndex, actions, modifiers);

                if (performedActions == DragDropOption.None && modifiers == ModifierFlags.Shift)
                {
                    bool allow = true;
                    foreach (IGalleryItem droppedItem in droppedItems)
                    {
                        if (droppedItem is IStudyComposerItem)
                        {
                            IStudyComposerItem item = (IStudyComposerItem)droppedItem;
                            base.DataSource.Insert(targetIndex, item.Clone());
                        }
                    }
                    performedActions = DragDropOption.Copy;
                }
                return(performedActions);
            }
Beispiel #15
0
            protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
            {
                SeriesItem     series = (SeriesItem)targetItem;
                DragDropOption action = DragDropOption.None;

                foreach (IGalleryItem droppingItem in droppingItems)
                {
                    if (droppingItem is ImageItem)
                    {
                        ImageItem image = (ImageItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            if (!series.Images.Contains(image))
                            {
                                series.Images.Add(image.Copy());
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            series.Images.Add(image.Copy());
                            action = DragDropOption.Copy;
                        }
                    }
                }
                return(action);
            }
Beispiel #16
0
            protected override DragDropOption CheckDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
            {
                SeriesItem series  = (SeriesItem)targetItem;
                bool       allowed = true;

                foreach (IGalleryItem droppingItem in droppingItems)
                {
                    if (droppingItem is ImageItem)
                    {
                        ImageItem image = (ImageItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            allowed &= !(series.Images.Contains(image));                             // disallow moves where the item is already in the target tree
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            allowed &= true;
                        }
                    }
                    else
                    {
                        allowed &= false;
                    }
                }

                if (allowed)
                {
                    if (modifiers == ModifierFlags.None)
                    {
                        return(DragDropOption.Move);
                    }
                    else if (modifiers == ModifierFlags.Shift)
                    {
                        return(DragDropOption.Copy);
                    }
                }
                return(DragDropOption.None);
            }
Beispiel #17
0
            protected override DragDropOption PerformDropForeignItems(IList <IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
            {
                StudyItem      study  = (StudyItem)targetItem;
                DragDropOption action = DragDropOption.None;

                foreach (IGalleryItem droppingItem in droppingItems)
                {
                    if (droppingItem is SeriesItem)
                    {
                        SeriesItem series = (SeriesItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            if (!study.Series.Contains(series))
                            {
                                study.Series.Add(series.Copy());
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            study.Series.Add(series.Copy());
                            action = DragDropOption.Copy;
                        }
                    }
                    else if (droppingItem is ImageItem)
                    {
                        ImageItem image = (ImageItem)droppingItem;
                        if (modifiers == ModifierFlags.None)
                        {
                            SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1);
                            StudyNode  studyNode  = (StudyNode)GetNodeAncestor(seriesNode, 1);
                            if (study.Node != studyNode)
                            {
                                SeriesItem series = new SeriesItem(seriesNode.Copy(false));
                                series.Images.Add(image.Copy());
                                series.UpdateIcon();
                                study.Series.Add(series);
                                action = DragDropOption.Move;
                            }
                        }
                        else if (modifiers == ModifierFlags.Shift)
                        {
                            SeriesNode seriesNode = (SeriesNode)GetNodeAncestor(image.Node, 1);
                            SeriesItem series     = new SeriesItem(seriesNode.Copy(false));
                            series.Images.Add(image.Copy());
                            series.UpdateIcon();
                            study.Series.Add(series);
                            action = DragDropOption.Copy;
                        }
                    }
                }
                return(action);
            }
Beispiel #18
0
 public ActionControl AddBinding(Binding b, ModifierFlags flags)
 {
     bindings.Add(b, flags);
     return(this);
 }
Beispiel #19
0
 public MouseImageViewerToolPropertyComponent(AbstractActionModelTreeNode selectedNode, XMouseButtons activeMouseButtons, XMouseButtons globalMouseButtons, ModifierFlags globalModifiers, bool initiallyActive)
     : base(selectedNode)
 {
     _activeMouseButtons     = activeMouseButtons;
     _globalMouseButtonCombo = new XMouseButtonCombo(globalMouseButtons, globalModifiers);
     _globalMouseButtons     = globalMouseButtons;
     _globalModifiers        = globalModifiers;
     _initiallyActive        = initiallyActive;
 }
 /// <summary>
 /// Constructor that accepts <see cref="ModifierFlags"/> as input.
 /// </summary>
 /// <param name="modifiers"></param>
 public MouseWheelHandlerAttribute(ModifierFlags modifiers)
 {
     _shortcut = new MouseWheelShortcut(modifiers);
 }
Beispiel #21
0
        protected override IVariableDeclarationModel InstantiateVariableDeclaration(Type variableTypeToCreate,
                                                                                    TypeHandle variableDataType, string variableName, ModifierFlags modifierFlags, bool isExposed,
                                                                                    IConstant initializationModel, SerializableGUID guid, Action <IVariableDeclarationModel, IConstant> initializationCallback = null)
        {
            var vdm = base.InstantiateVariableDeclaration(variableTypeToCreate, variableDataType, variableName, modifierFlags, isExposed, initializationModel, guid, initializationCallback);

            if (vdm is VariableDeclarationModel testVdm)
            {
                testVdm.SetGraphModel(this);
            }

            return(vdm);
        }
 /// <summary>
 /// Formats a <see cref="ModifierFlags"/> value as a string using the <see cref="CultureInfo.CurrentUICulture">current thread's UI CultureInfo</see>.
 /// </summary>
 /// <param name="value">The <see cref="ModifierFlags"/> value to be formatted.</param>
 /// <returns>The string representation of the given <paramref name="value"/>.</returns>
 public static string Format(ModifierFlags value)
 {
     return(Format(value, CultureInfo.CurrentUICulture));
 }
Beispiel #23
0
 public CreateGraphVariableDeclarationAction(string name, bool isExposed, TypeHandle typeHandle, ModifierFlags modifierFlags = ModifierFlags.None)
 {
     Name          = name;
     IsExposed     = isExposed;
     TypeHandle    = typeHandle;
     ModifierFlags = modifierFlags;
 }
		private void AssertStringParse(string sModifiers, ModifierFlags eModifiers, CultureInfo culture, string message)
		{
			ModifierFlags actualEnum = (ModifierFlags) _converter.ConvertFromString(null, culture, sModifiers);
			//System.Diagnostics.Trace.WriteLine(actualEnum);
			Assert.AreEqual((int) eModifiers, (int) actualEnum, message + ": converting " + sModifiers + " which is " + actualEnum.ToString());
		}
 /// <summary>
 /// Initializes an <see cref="XMouseButtonCombo"/> with the specified pressed mouse buttons.
 /// </summary>
 /// <param name="mouseButtons">The pressed mouse buttons.</param>
 public XMouseButtonCombo(XMouseButtons mouseButtons)
 {
     _mouseButtons = mouseButtons;
     _modifiers    = ModifierFlags.None;
 }
Beispiel #26
0
 /// <summary>
 /// Constructor that takes a <see cref="ModifierFlags"/> as input.
 /// </summary>
 public Modifiers(ModifierFlags modifierFlags)
 {
     _modifierFlags = modifierFlags;
 }
 /// <summary>
 /// Initializes an <see cref="XMouseButtonCombo"/> with the specified pressed mouse buttons.
 /// </summary>
 /// <param name="mouseButtons">The pressed mouse buttons.</param>
 /// <param name="modifiers">The pressed keyboard modifiers.</param>
 public XMouseButtonCombo(XMouseButtons mouseButtons, ModifierFlags modifiers)
 {
     _mouseButtons = mouseButtons;
     _modifiers    = mouseButtons != XMouseButtons.None ? modifiers : ModifierFlags.None;
 }
 /// <summary>
 /// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item.
 /// </summary>
 /// <param name="droppedData">The data object to drop.</param>
 /// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param>
 /// <param name="actions">The interaction to take.</param>
 /// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
 /// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
 protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
 {
     return(DragDropOption.None);
 }
Beispiel #29
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MouseButtonShortcut(XMouseButtons mouseButton, ModifierFlags modifierFlags)
     : this(mouseButton, new Modifiers(modifierFlags))
 {
 }
Beispiel #30
0
 public void Deconstruct(out double x, out double y, out ModifierFlags modifier)
 {
     x        = this.X;
     y        = this.Y;
     modifier = this.Modifier;
 }
Beispiel #31
0
 /// <summary>
 /// 根据枚举来指定特殊修饰符
 /// </summary>
 /// <param name="modifierEnum">特殊修饰符枚举</param>
 /// <returns></returns>
 public T Modifier(ModifierFlags modifierEnum)
 {
     _status.Add(modifierEnum);
     return(Link);
 }
Beispiel #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputArgs"/> struct.
 /// </summary>
 /// <param name="x">The input X position.</param>
 /// <param name="y">The input Y position.</param>
 /// <param name="modifier">The input modifier flags.</param>
 public InputArgs(double x, double y, ModifierFlags modifier)
 {
     X        = x;
     Y        = y;
     Modifier = modifier;
 }
		/// <summary>
		/// Checks for allowed drag &amp; drop actions involving the specified foreign data and the given target on this component.
		/// </summary>
		/// <param name="droppingData">The <see cref="IDragDropObject"/> object that encapsulates all forms of the foreign data.</param>
		/// <param name="targetItem">The target item that the user is trying to drop on to.</param>
		/// <param name="actions"></param>
		/// <param name="modifiers">The modifier keys that are being held by the user.</param>
		/// <returns>The allowed <see cref="DragDropKind"/> action for this attempted drag &amp; drop operation.</returns>
		public override sealed DragDropOption CheckDrop(IDragDropObject droppingData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			DragDropOption allowedActions;
			IList<IGalleryItem> droppingItems = ExtractGalleryItemList(droppingData);
			if (droppingItems != null)
			{
				if (_draggedItems == droppingItems)
				{
					allowedActions = CheckDropLocalItems(droppingItems, targetItem, actions, modifiers);
				}
				else
				{
					allowedActions = CheckDropForeignItems(droppingItems, targetItem, actions, modifiers);
				}
			}
			else
			{
				allowedActions = CheckDropForeignObject(droppingData, targetItem, actions, modifiers);
			}
			return actions & allowedActions;
		}
        public static MemberDeclarationSyntax UpdateModifiers(this MemberDeclarationSyntax member, ModifierFlags flags)
        {
            // The starting token for this member may change, so we need to save
            // the leading trivia and reattach it after updating the modifiers.
            // We also need to remove it here to avoid duplicates.
            var leadingTrivia = member.GetLeadingTrivia();
            member = member.WithLeadingTrivia(SyntaxTriviaList.Empty);

            var newModifierList = new List<SyntaxToken>();
            foreach (var modifierDefinition in s_modifierDefinitions)
            {
                if ((flags & modifierDefinition.Key) != 0)
                {
                    newModifierList.Add(SyntaxFactory.Token(modifierDefinition.Value));
                }
            }

            var newModifiers = SyntaxFactory.TokenList(newModifierList);
            var newMember = (MemberDeclarationSyntax)member.WithModifiers(SyntaxFactory.TokenList(newModifierList));

            return newMember.WithLeadingTrivia(leadingTrivia);
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="droppedData"></param>
		/// <param name="targetItem"></param>
		/// <param name="action"></param>
		/// <param name="modifiers"></param>
		/// <returns></returns>
		public override sealed DragDropOption PerformDrop(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption action, ModifierFlags modifiers)
		{
			DragDropOption performedAction;
			IList<IGalleryItem> droppedItems = ExtractGalleryItemList(droppedData);
			if (droppedItems != null)
			{
				if (_draggedItems == droppedItems)
				{
					performedAction = PerformDropLocalItems(droppedItems, targetItem, action, modifiers);
				}
				else
				{
					performedAction = PerformDropForeignItems(droppedItems, targetItem, action, modifiers);
				}
			}
			else
			{
				performedAction = PerformDropForeignObject(droppedData, targetItem, action, modifiers);
			}
			return performedAction;
		}
Beispiel #36
0
 private void AssertEquivalency(string sModifiers, ModifierFlags eModifiers, CultureInfo culture, string message)
 {
     AssertStringFormat(sModifiers, eModifiers, culture, message);
     AssertStringParse(sModifiers, eModifiers, culture, message);
 }
		/// <summary>
		/// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery to the specified target index is allowed.
		/// </summary>
		/// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param>
		/// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param>
		/// <param name="actions">The interactions that are being allowed by the data source.</param>
		/// <param name="modifiers">The modifier keys that currently being pressed.</param>
		/// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns>
		protected virtual DragDropOption CheckDropLocalItems(IList<IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
		{
			DragDropOption allowedActions = DragDropOption.None;
			if (modifiers == ModifierFlags.None) {
				// check for null drops and drops to a point within the source data
				if (droppingItems.Count == 0)
					return DragDropOption.None;

				int draggedIndex = base.DataSource.IndexOf(droppingItems[0]);
				if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppingItems.Count)
					return DragDropOption.None;

				// we are dragging an item, and the item we want to drop is the same as that which we are dragging
				// then this is a reordering operation
				allowedActions = actions & DragDropOption.Move;
			}
			return allowedActions;
		}
        public static MemberDeclarationSyntax UpdateModifiers(this MemberDeclarationSyntax member, ModifierFlags flags)
        {
            // The starting token for this member may change, so we need to save
            // the leading trivia and reattach it after updating the modifiers.
            // We also need to remove it here to avoid duplicates.
            var leadingTrivia = member.GetLeadingTrivia();

            member = member.WithLeadingTrivia(SyntaxTriviaList.Empty);

            var newModifierList = new List <SyntaxToken>();

            foreach (var modifierDefinition in s_modifierDefinitions)
            {
                if ((flags & modifierDefinition.Key) != 0)
                {
                    newModifierList.Add(SyntaxFactory.Token(modifierDefinition.Value));
                }
            }

            var newModifiers = SyntaxFactory.TokenList(newModifierList);
            var newMember    = (MemberDeclarationSyntax)member.WithModifiers(SyntaxFactory.TokenList(newModifierList));

            return(newMember.WithLeadingTrivia(leadingTrivia));
        }
		/// <summary>
		/// Checks if drag-dropping <see cref="IGalleryItem"/>s from outside this gallery to the specified target index is allowed.
		/// </summary>
		/// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param>
		/// <param name="targetIndex">The target index at which the <paramref name="droppingItems"/> are being dropped.</param>
		/// <param name="actions">The interactions that are being allowed by the data source.</param>
		/// <param name="modifiers">The modifier keys that currently being pressed.</param>
		/// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns>
		protected virtual DragDropOption CheckDropForeignItems(IList<IGalleryItem> droppingItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
Beispiel #40
0
 /// <summary>
 /// Creates a new variable declaration in the graph.
 /// </summary>
 /// <param name="self">The graph to add a variable declaration to.</param>
 /// <param name="variableDataType">The type of data the new variable declaration to create represents.</param>
 /// <param name="variableName">The name of the new variable declaration to create.</param>
 /// <param name="modifierFlags">The modifier flags of the new variable declaration to create.</param>
 /// <param name="isExposed">Whether the variable is exposed externally or not.</param>
 /// <param name="initializationModel">The initialization model of the new variable declaration to create. Can be <code>null</code>.</param>
 /// <param name="guid">The SerializableGUID to assign to the newly created item.</param>
 /// <param name="initializationCallback">An initialization method to be called right after the variable declaration is created.</param>
 /// <param name="spawnFlags">The flags specifying how the variable declaration is to be spawned.</param>
 /// <typeparam name="TDeclType">The type of variable declaration to create.</typeparam>
 /// <returns>The newly created variable declaration.</returns>
 public static TDeclType CreateGraphVariableDeclaration <TDeclType>(this IGraphModel self, TypeHandle variableDataType,
                                                                    string variableName, ModifierFlags modifierFlags, bool isExposed, IConstant initializationModel = null,
                                                                    SerializableGUID guid = default, Action <TDeclType, IConstant> initializationCallback = null,
                                                                    SpawnFlags spawnFlags = SpawnFlags.Default)
     where TDeclType : class, IVariableDeclarationModel
 {
     return((TDeclType)self.CreateGraphVariableDeclaration(typeof(TDeclType), variableDataType, variableName,
                                                           modifierFlags, isExposed, initializationModel, guid, (d, c) => initializationCallback?.Invoke((TDeclType)d, c), spawnFlags));
 }
		/// <summary>
		/// Checks if drag-dropping <see cref="IGalleryItem"/>s from within this gallery on top of the specified item is allowed.
		/// </summary>
		/// <param name="droppingItems">The list of <see cref="IGalleryItem"/>s to drop.</param>
		/// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppingItems"/> are being dropped.</param>
		/// <param name="actions">The interactions that are being allowed by the data source.</param>
		/// <param name="modifiers">The modifier keys that currently being pressed.</param>
		/// <returns>The allowed interactions for dropping the <paramref name="droppingItems"/> here.</returns>
		protected virtual DragDropOption CheckDropLocalItems(IList<IGalleryItem> droppingItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
Beispiel #42
0
		public ActionControl AddBinding(Binding b, ModifierFlags flags) {
			bindings.Add(b, flags);
			return this;
		}
		/// <summary>
		/// Formats a <see cref="ModifierFlags"/> value as a string using the <see cref="CultureInfo.CurrentUICulture">current thread's UI CultureInfo</see>.
		/// </summary>
		/// <param name="value">The <see cref="ModifierFlags"/> value to be formatted.</param>
		/// <returns>The string representation of the given <paramref name="value"/>.</returns>
		public static string Format(ModifierFlags value)
		{
			return Format(value, CultureInfo.CurrentUICulture);
		}
		private void AssertStringFormat(string sModifiers, ModifierFlags eModifiers, CultureInfo culture, string message)
		{
			string actualString = _converter.ConvertToString(null, culture, eModifiers);
			//System.Diagnostics.Trace.WriteLine(actualString);
			Assert.AreEqual(sModifiers, actualString, message + ": converting " + (int) eModifiers + " which is " + eModifiers.ToString());
		}
		/// <summary>
		/// Formats a <see cref="ModifierFlags"/> value as a string using the <see cref="CultureInfo.InvariantCulture"/>.
		/// </summary>
		/// <param name="value">The <see cref="ModifierFlags"/> value to be formatted.</param>
		/// <returns>The string representation of the given <paramref name="value"/>.</returns>
		public static string FormatInvariant(ModifierFlags value)
		{
			return Format(value, CultureInfo.InvariantCulture);
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		public ModifiedMouseToolButtonAttribute(XMouseButtons mouseButton, ModifierFlags modifierFlags)
			: base(mouseButton, modifierFlags)
		{
		}
		/// <summary>
		/// Parses a string as an <see cref="ModifierFlags"/> value using the specified <see cref="CultureInfo"/>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="culture">The <see cref="CultureInfo"/> for which the string should be parsed.</param>
		/// <param name="result">The <see cref="ModifierFlags"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="ModifierFlags.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParse(string s, CultureInfo culture, out ModifierFlags result)
		{
			try
			{
				result = Parse(s, culture);
				return true;
			}
			catch (FormatException)
			{
				result = ModifierFlags.None;
				return false;
			}
		}
		/// <summary>
		/// Performs a drag-drop of <see cref="IGalleryItem"/>s from within this gallery to the specified target index.
		/// </summary>
		/// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param>
		/// <param name="targetIndex">The target index at which the <paramref name="droppedItems"/> are being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropLocalItems(IList<IGalleryItem> droppedItems, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
		{
			DragDropOption performedAction = DragDropOption.None;
			if (modifiers == ModifierFlags.None)
			{
				// check for null drops and drops to a point within the source data
				if (droppedItems.Count == 0)
					return DragDropOption.None;

				int draggedIndex = base.DataSource.IndexOf(droppedItems[0]);
				if (targetIndex >= draggedIndex && targetIndex < draggedIndex + droppedItems.Count)
					return DragDropOption.None;

				// we are dragging something, and the item we want to drop is the same as that which we are dragging
				// then this is a reordering operation
				if (droppedItems != this.DraggedItems)
					return DragDropOption.None;

				if (draggedIndex < targetIndex)
					targetIndex -= droppedItems.Count;

				Stack<IGalleryItem> stack = new Stack<IGalleryItem>();
				foreach (IGalleryItem droppedItem in droppedItems) {
					base.DataSource.Remove(droppedItem);
					stack.Push(droppedItem);
				}
				while (stack.Count > 0) {
					base.DataSource.Insert(targetIndex, stack.Pop());
				}
				this.DraggedItems = null;

				performedAction = DragDropOption.Move;
			}
			return performedAction;
		}
Beispiel #49
0
 /// <summary>
 /// Gets whether or not this object is equal to <paramref name="other"/>.
 /// </summary>
 public bool Equals(ModifierFlags other)
 {
     return(this.ModifierFlags == other);
 }
		/// <summary>
		/// Formats a <see cref="ModifierFlags"/> value as a string using the specified <see cref="CultureInfo"/>.
		/// </summary>
		/// <param name="value">The <see cref="ModifierFlags"/> value to be formatted.</param>
		/// <param name="culture">The <see cref="CultureInfo"/> for which the value should be formatted.</param>
		/// <returns>The string representation of the given <paramref name="value"/>.</returns>
		public static string Format(ModifierFlags value, CultureInfo culture)
		{
			return Default.ConvertToString(null, culture, value);
		}
		/// <summary>
		/// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery to the specified index.
		/// </summary>
		/// <param name="droppedData">The data object to drop.</param>
		/// <param name="targetIndex">The target index at which the <paramref name="droppedData"/> is being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, int targetIndex, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
		/// <summary>
		/// Parses a string as an <see cref="ModifierFlags"/> value using the <see cref="CultureInfo.CurrentUICulture">current thread's UI CultureInfo</see>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="result">The <see cref="ModifierFlags"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="ModifierFlags.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParse(string s, out ModifierFlags result)
		{
			return TryParse(s, CultureInfo.CurrentUICulture, out result);
		}
		/// <summary>
		/// Performs a drag-drop of <see cref="IGalleryItem"/>s from outside this gallery on top of the specified item.
		/// </summary>
		/// <param name="droppedItems">The list of <see cref="IGalleryItem"/>s to drop.</param>
		/// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedItems"/> are being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedItems"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropForeignItems(IList<IGalleryItem> droppedItems, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
		/// <summary>
		/// Parses a string as an <see cref="ModifierFlags"/> value using the <see cref="CultureInfo.InvariantCulture"/>.
		/// </summary>
		/// <param name="s">The string to be parsed.</param>
		/// <param name="result">The <see cref="ModifierFlags"/> value parsed from <paramref name="s"/> if the string was successfully parsed; <see cref="ModifierFlags.None"/> otherwise.</param>
		/// <returns>True if the string was successfully parsed; False otherwise.</returns>
		public static bool TryParseInvariant(string s, out ModifierFlags result)
		{
			return TryParse(s, CultureInfo.InvariantCulture, out result);
		}
		/// <summary>
		/// Performs a drag-drop of a non-<see cref="IGalleryItem"/> object from outside this gallery on top of the specified item.
		/// </summary>
		/// <param name="droppedData">The data object to drop.</param>
		/// <param name="targetItem">The target <see cref="IGalleryItem"/> at which the <paramref name="droppedData"/> is being dropped.</param>
		/// <param name="actions">The interaction to take.</param>
		/// <param name="modifiers">The modifier keys that were pressed at the time of the drop.</param>
		/// <returns>The actual interaction on the <paramref name="droppedData"/> that was taken.</returns>
		protected virtual DragDropOption PerformDropForeignObject(IDragDropObject droppedData, IGalleryItem targetItem, DragDropOption actions, ModifierFlags modifiers)
		{
			return DragDropOption.None;
		}
		/// <summary>
		/// Constructor.
		/// </summary>
		public DefaultMouseToolButtonAttribute(XMouseButtons mouseButton, ModifierFlags modifierFlags)
		{
			_shortcut = new MouseButtonShortcut(mouseButton, modifierFlags);
		}
Beispiel #57
0
 /// <summary>
 /// Initializes a new CreateGraphVariableDeclarationCommand.
 /// </summary>
 /// <param name="name">The name of the variable to create.</param>
 /// <param name="isExposed">Whether or not the variable is exposed.</param>
 /// <param name="typeHandle">The type of data the new variable declaration to create represents.</param>
 /// <param name="variableType">The type of variable declaration to create.</param>
 /// <param name="modifierFlags">The modifiers to apply to the newly created variable.</param>
 /// <param name="guid">The SerializableGUID to assign to the newly created item. If none is provided, a new
 /// SerializableGUID will be generated for it.</param>
 public CreateGraphVariableDeclarationCommand(string name, bool isExposed, TypeHandle typeHandle, Type variableType,
                                              ModifierFlags modifierFlags = ModifierFlags.None, SerializableGUID guid = default)
     : this(name, isExposed, typeHandle, modifierFlags, guid)
 {
     VariableType = variableType;
 }