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