173 references to MouseAction
PresentationCore (70)
System\Windows\Input\Command\MouseActionConverter.cs (30)
11/// Converter class for converting between a <see langword="string"/> and <see cref="MouseAction"/>. 16/// Used to check whether we can convert a <see langword="string"/> into a <see cref="MouseAction"/>. 44return IsDefinedMouseAction((MouseAction)context.Instance); 48/// Converts <paramref name="source"/> of <see langword="string"/> type to its <see cref="MouseAction"/> represensation. 53/// <returns>A <see cref="MouseAction"/> representing the <see langword="string"/> specified by <paramref name="source"/>.</returns> 62_ when mouseActionToken.IsEmpty => MouseAction.None, // Special casing as produced by "ConvertTo" 63_ when mouseActionToken.Equals("None", StringComparison.OrdinalIgnoreCase) => MouseAction.None, 64_ when mouseActionToken.Equals("LeftClick", StringComparison.OrdinalIgnoreCase) => MouseAction.LeftClick, 65_ when mouseActionToken.Equals("RightClick", StringComparison.OrdinalIgnoreCase) => MouseAction.RightClick, 66_ when mouseActionToken.Equals("MiddleClick", StringComparison.OrdinalIgnoreCase) => MouseAction.MiddleClick, 67_ when mouseActionToken.Equals("WheelClick", StringComparison.OrdinalIgnoreCase) => MouseAction.WheelClick, 68_ when mouseActionToken.Equals("LeftDoubleClick", StringComparison.OrdinalIgnoreCase) => MouseAction.LeftDoubleClick, 69_ when mouseActionToken.Equals("RightDoubleClick", StringComparison.OrdinalIgnoreCase) => MouseAction.RightDoubleClick, 70_ when mouseActionToken.Equals("MiddleDoubleClick", StringComparison.OrdinalIgnoreCase) => MouseAction.MiddleDoubleClick, 76/// Converts a <paramref name="value"/> of <see cref="MouseAction"/> to its <see langword="string"/> represensation. 82/// <returns>A <see langword="string"/> representing the <see cref="MouseAction"/> specified by <paramref name="value"/>.</returns> 90MouseAction mouseAction = (MouseAction)value; 93MouseAction.None => string.Empty, 94MouseAction.LeftClick => "LeftClick", 95MouseAction.RightClick => "RightClick", 96MouseAction.MiddleClick => "MiddleClick", 97MouseAction.WheelClick => "WheelClick", 98MouseAction.LeftDoubleClick => "LeftDoubleClick", 99MouseAction.RightDoubleClick => "RightDoubleClick", 100MouseAction.MiddleDoubleClick => "MiddleDoubleClick", 101_ => throw new InvalidEnumArgumentException(nameof(value), (int)mouseAction, typeof(MouseAction)) 110internal static bool IsDefinedMouseAction(MouseAction mouseAction) 112return mouseAction >= MouseAction.None && mouseAction <= MouseAction.MiddleDoubleClick;
System\Windows\Input\Command\MouseActionValueSerializer.cs (4)
41return value is MouseAction && MouseActionConverter.IsDefinedMouseAction((MouseAction)value); 52TypeConverter converter = TypeDescriptor.GetConverter(typeof(MouseAction)); 67TypeConverter converter = TypeDescriptor.GetConverter(typeof(MouseAction));
System\Windows\Input\Command\MouseBinding.cs (7)
47internal MouseBinding(ICommand command, MouseAction mouseAction) 114DependencyProperty.Register("MouseAction", typeof(MouseAction), typeof(MouseBinding), new UIPropertyMetadata(MouseAction.None, new PropertyChangedCallback(OnMouseActionPropertyChanged))); 119public MouseAction MouseAction 123return (MouseAction)GetValue(MouseActionProperty); 134mouseBinding.SynchronizeGestureFromProperties((MouseAction)(e.NewValue)); 196private void SynchronizeGestureFromProperties(MouseAction mouseAction)
System\Windows\Input\Command\MouseGesture.cs (24)
47public MouseGesture(MouseAction mouseAction): this(mouseAction, ModifierKeys.None) 56public MouseGesture( MouseAction mouseAction,ModifierKeys modifiers) // acclerator action 59throw new InvalidEnumArgumentException("mouseAction", (int)mouseAction, typeof(MouseAction)); 81public MouseAction MouseAction 89if (!MouseGesture.IsDefinedMouseAction((MouseAction)value)) 90throw new InvalidEnumArgumentException("value", (int)value, typeof(MouseAction)); 93_mouseAction = (MouseAction)value; 130MouseAction mouseAction = GetMouseAction(inputEventArgs); 131if(mouseAction != MouseAction.None) 140internal static bool IsDefinedMouseAction(MouseAction mouseAction) 142return (mouseAction >= MouseAction.None && mouseAction <= MouseAction.MiddleDoubleClick); 173internal static MouseAction GetMouseAction(InputEventArgs inputArgs) 175MouseAction MouseAction = MouseAction.None; 182MouseAction = MouseAction.WheelClick; 193MouseAction = MouseAction.LeftDoubleClick; 195MouseAction = MouseAction.LeftClick; 202MouseAction = MouseAction.RightDoubleClick; 204MouseAction = MouseAction.RightClick; 211MouseAction = MouseAction.MiddleDoubleClick; 213MouseAction = MouseAction.MiddleClick; 230private MouseAction _mouseAction = MouseAction.None;
System\Windows\Input\Command\MouseGestureConverter.cs (5)
60return new MouseGesture(MouseAction.None, ModifierKeys.None); 75TypeConverter mouseActionConverter = TypeDescriptor.GetConverter(typeof(System.Windows.Input.MouseAction)); 93return new MouseGesture((MouseAction)mouseAction, (ModifierKeys)modifierKeys); 99return new MouseGesture((MouseAction)mouseAction); 163TypeConverter mouseActionConverter = TypeDescriptor.GetConverter(typeof(System.Windows.Input.MouseAction));
PresentationCore.Tests (103)
System\Windows\Input\Command\KeyGestureConverter.Tests.cs (4)
68yield return new object?[] { false, true, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Alt), typeof(string) }; 69yield return new object?[] { false, true, MouseAction.WheelClick, typeof(string) }; 139yield return new object?[] { CultureInfo.InvariantCulture, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control) }; 212yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), typeof(string) };
System\Windows\Input\Command\MouseGestureConverter.Tests.cs (56)
16[InlineData(false, typeof(MouseAction))] 43yield return new object[] { true, true, new MouseGesture(MouseAction.None, ModifierKeys.Control), typeof(string) }; 44yield return new object[] { true, true, new MouseGesture(MouseAction.None, ModifierKeys.Alt), typeof(string) }; 45yield return new object[] { true, true, new MouseGesture(MouseAction.MiddleDoubleClick, ModifierKeys.Shift), typeof(string) }; 46yield return new object[] { true, true, new MouseGesture(MouseAction.LeftDoubleClick, ModifierKeys.Control | ModifierKeys.Windows | ModifierKeys.Alt), typeof(string) }; 47yield return new object[] { true, true, new MouseGesture(MouseAction.WheelClick, ModifierKeys.Control | ModifierKeys.Windows), typeof(string) }; 48yield return new object[] { true, true, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Alt | ModifierKeys.Windows), typeof(string) }; 49yield return new object[] { true, true, new MouseGesture(MouseAction.RightClick, ModifierKeys.Alt | ModifierKeys.Control), typeof(string) }; 50yield return new object[] { true, true, new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.Alt | ModifierKeys.Windows | ModifierKeys.Control), typeof(string) }; 51yield return new object[] { true, true, new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.None), typeof(string) }; 62yield return new object?[] { false, true, new MouseGesture(MouseAction.None, ModifierKeys.Control), null }; 63yield return new object?[] { false, true, new MouseGesture(MouseAction.WheelClick, ModifierKeys.Control | ModifierKeys.Windows), typeof(KeyGesture) }; 64yield return new object?[] { false, true, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Alt | ModifierKeys.Windows), typeof(MouseGesture) }; 65yield return new object?[] { false, true, new MouseGesture(MouseAction.None, ModifierKeys.Control), typeof(MouseAction) }; 66yield return new object?[] { false, true, new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.Alt | ModifierKeys.Windows | ModifierKeys.Control), typeof(Key) }; 67yield return new object?[] { false, true, new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.None), typeof(ModifierKeys) }; 70yield return new object?[] { false, true, MouseAction.WheelClick, typeof(string) }; 93yield return new object?[] { new MouseGesture(MouseAction.None, ModifierKeys.None), null, CultureInfo.InvariantCulture, string.Empty }; 94yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.None), null, new CultureInfo("ru-RU"), "LeftClick" }; 95yield return new object?[] { new MouseGesture(MouseAction.None, ModifierKeys.Control), null, CultureInfo.InvariantCulture, "Ctrl+" }; 96yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), null, CultureInfo.InvariantCulture, "Ctrl+LeftClick" }; 97yield return new object?[] { new MouseGesture(MouseAction.MiddleDoubleClick, ModifierKeys.Alt), null, new CultureInfo("no-NO"), "Alt+MiddleDoubleClick" }; 98yield return new object?[] { new MouseGesture(MouseAction.WheelClick, ModifierKeys.Shift), null, CultureInfo.InvariantCulture, "Shift+WheelClick" }; 99yield return new object?[] { new MouseGesture(MouseAction.LeftDoubleClick, ModifierKeys.Windows), null, CultureInfo.InvariantCulture, "Windows+LeftDoubleClick" }; 100yield return new object?[] { new MouseGesture(MouseAction.RightClick, ModifierKeys.Control | ModifierKeys.Alt), null, CultureInfo.InvariantCulture, "Ctrl+Alt+RightClick" }; 101yield return new object?[] { new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.Control | ModifierKeys.Windows | ModifierKeys.Alt), null, CultureInfo.InvariantCulture, "Ctrl+Alt+Windows+RightDoubleClick" }; 104yield return new object?[] { new MouseGesture(MouseAction.None, ModifierKeys.Alt), null, CultureInfo.InvariantCulture, "Alt+ " }; 105yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.None), null, CultureInfo.InvariantCulture, " LeftClick " }; 106yield return new object?[] { new MouseGesture(MouseAction.None, ModifierKeys.None), null, CultureInfo.InvariantCulture, " " }; 107yield return new object?[] { new MouseGesture(MouseAction.WheelClick, ModifierKeys.Shift), null, CultureInfo.InvariantCulture, "Shift +WheelClick" }; 108yield return new object?[] { new MouseGesture(MouseAction.MiddleClick, ModifierKeys.Windows | ModifierKeys.Shift), null, new CultureInfo("no-NO"), " Shift + Windows + MiddleClick " }; 109yield return new object?[] { new MouseGesture(MouseAction.LeftDoubleClick, ModifierKeys.Windows), null, CultureInfo.InvariantCulture, "Windows+ LeftDoubleClick " }; 110yield return new object?[] { new MouseGesture(MouseAction.RightClick, ModifierKeys.Control | ModifierKeys.Alt), null, CultureInfo.InvariantCulture, "Ctrl+Alt+ RightClick" }; 130yield return new object?[] { CultureInfo.InvariantCulture, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control) }; 133yield return new object?[] { CultureInfo.InvariantCulture, MouseAction.LeftDoubleClick }; 156yield return new object?[] { string.Empty, null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.None, ModifierKeys.None) }; 157yield return new object?[] { "Alt+", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.None, ModifierKeys.Alt) }; 158yield return new object?[] { "Windows+", null, new CultureInfo("de-DE"), new MouseGesture(MouseAction.None, ModifierKeys.Windows) }; 159yield return new object?[] { "Shift+", null, new CultureInfo("ru-RU"), new MouseGesture(MouseAction.None, ModifierKeys.Shift) }; 160yield return new object?[] { "LeftClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.LeftClick) }; 161yield return new object?[] { "Ctrl+LeftClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control) }; 162yield return new object?[] { "Alt+RightClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.RightClick, ModifierKeys.Alt) }; 163yield return new object?[] { "Windows+WheelClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.WheelClick, ModifierKeys.Windows) }; 164yield return new object?[] { "Alt+RightDoubleClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.RightDoubleClick, ModifierKeys.Alt) }; 165yield return new object?[] { "Ctrl+Alt+Windows+WheelClick", null, new CultureInfo("de-DE"), new MouseGesture(MouseAction.WheelClick, ModifierKeys.Control | ModifierKeys.Windows | ModifierKeys.Alt) }; 166yield return new object?[] { "Alt+Windows+MiddleDoubleClick", null, new CultureInfo("ru-RU"), new MouseGesture(MouseAction.MiddleDoubleClick, ModifierKeys.Alt | ModifierKeys.Windows) }; 167yield return new object?[] { "Ctrl+Alt+Windows+MiddleClick", null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.MiddleClick, ModifierKeys.Alt | ModifierKeys.Windows | ModifierKeys.Control) }; 176Assert.Throws<ArgumentNullException>(() => converter.ConvertTo(null, CultureInfo.InvariantCulture, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), null)); 193yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), typeof(MouseGesture) }; 194yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), typeof(KeyGesture) }; 195yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), typeof(MouseAction) }; 196yield return new object?[] { new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control), typeof(Key) }; 197yield return new object?[] { new MouseGesture(MouseAction.WheelClick, ModifierKeys.Control), typeof(ModifierKeys) }; 200yield return new object?[] { MouseAction.MiddleDoubleClick, typeof(string) };
System\Windows\Input\MouseActionConverter.Tests.cs (43)
17[InlineData(false, typeof(MouseAction))] 40yield return new object[] { true, true, MouseAction.None, typeof(string) }; 41yield return new object[] { true, true, MouseAction.MiddleDoubleClick, typeof(string) }; 44yield return new object[] { false, true, MouseAction.MiddleDoubleClick + 1, typeof(string) }; 47yield return new object[] { false, false, MouseAction.None, typeof(string) }; 48yield return new object[] { false, false, MouseAction.MiddleDoubleClick, typeof(string) }; 49yield return new object?[] { false, true, null, typeof(MouseAction) }; 51yield return new object?[] { false, false, MouseAction.MiddleDoubleClick, typeof(string) }; 55yield return new object[] { false, true, MouseAction.MiddleDoubleClick + 1, typeof(string) }; 71public void ConvertFrom_ReturnsExpected(MouseAction expected, ITypeDescriptorContext context, CultureInfo? cultureInfo, string value) 75Assert.Equal(expected, (MouseAction)converter.ConvertFrom(context, cultureInfo, value)); 83yield return new object?[] { MouseAction.None, null, CultureInfo.InvariantCulture, string.Empty }; 84yield return new object?[] { MouseAction.None, null, CultureInfo.InvariantCulture, "None" }; 87yield return new object?[] { MouseAction.None, null, CultureInfo.InvariantCulture, string.Empty }; 88yield return new object?[] { MouseAction.LeftClick, null, new CultureInfo("ru-RU"), "LeftClick" }; 89yield return new object?[] { MouseAction.RightClick, null, CultureInfo.InvariantCulture, "RightClick" }; 90yield return new object?[] { MouseAction.MiddleClick, null, CultureInfo.InvariantCulture, "MiddleClick" }; 91yield return new object?[] { MouseAction.WheelClick, null, new CultureInfo("no-NO"), "WheelClick" }; 92yield return new object?[] { MouseAction.LeftDoubleClick, null, CultureInfo.InvariantCulture, "LeftDoubleClick" }; 93yield return new object?[] { MouseAction.RightDoubleClick, null, CultureInfo.InvariantCulture, "RightDoubleClick" }; 94yield return new object?[] { MouseAction.MiddleDoubleClick, null, CultureInfo.InvariantCulture, "MiddleDoubleClick" }; 97yield return new object?[] { MouseAction.None, null, CultureInfo.InvariantCulture, " " }; 98yield return new object?[] { MouseAction.None, null, new CultureInfo("ru-RU"), " NoNE " }; 99yield return new object?[] { MouseAction.LeftClick, null, CultureInfo.InvariantCulture, " LeFTCliCK " }; 100yield return new object?[] { MouseAction.WheelClick, null, CultureInfo.InvariantCulture, " WHEELCLICK" }; 101yield return new object?[] { MouseAction.MiddleClick, null, new CultureInfo("no-NO"), " MiDDLeCliCK " }; 102yield return new object?[] { MouseAction.LeftDoubleClick, null, CultureInfo.InvariantCulture, " leftdoubleclick " }; 103yield return new object?[] { MouseAction.RightClick, null, CultureInfo.InvariantCulture, " rightclick" }; 111[InlineData(MouseAction.None)] 137yield return new object?[] { string.Empty, null, CultureInfo.InvariantCulture, MouseAction.None }; 138yield return new object?[] { "LeftClick", null, CultureInfo.InvariantCulture, MouseAction.LeftClick }; 139yield return new object?[] { "RightClick", null, new CultureInfo("ru-RU"), MouseAction.RightClick }; 140yield return new object?[] { "MiddleClick", null, CultureInfo.InvariantCulture, MouseAction.MiddleClick }; 141yield return new object?[] { "WheelClick", null, new CultureInfo("no-NO"), MouseAction.WheelClick }; 142yield return new object?[] { "LeftDoubleClick", null, CultureInfo.InvariantCulture, MouseAction.LeftDoubleClick }; 143yield return new object?[] { "RightDoubleClick", null, null, MouseAction.RightDoubleClick }; 144yield return new object?[] { "MiddleDoubleClick", null, null, MouseAction.MiddleDoubleClick }; 153Assert.Throws<ArgumentNullException>(() => converter.ConvertTo(MouseAction.None, destinationType: null!)); 160[InlineData(MouseAction.None, typeof(int))] 161[InlineData(MouseAction.LeftClick, typeof(byte))] 175Assert.Throws<InvalidCastException>(() => converter.ConvertTo(null, null, (int)(MouseAction.MiddleDoubleClick), typeof(string))); 183Assert.Throws<InvalidEnumArgumentException>(() => converter.ConvertTo(null, null, (MouseAction)(MouseAction.MiddleDoubleClick + 1), typeof(string)));