Skip to content

Commit

Permalink
Update csharpier to 0.29.1
Browse files Browse the repository at this point in the history
Format files
  • Loading branch information
FaithBeam committed Sep 8, 2024
1 parent 991d838 commit c62cc7f
Show file tree
Hide file tree
Showing 21 changed files with 119 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.0",
"version": "0.29.1",
"commands": [
"dotnet-csharpier"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void DefaultProfileSendsKeys()
{
SimulatedKeystrokesType = new MouseButtonPressedActionType(),
BlockOriginalMouseInput = true,
Keys = "wee"
Keys = "wee",
};
var testProvider = new TestProvider();
using var hook = new SimpleReactiveGlobalHook(globalHookProvider: testProvider);
Expand All @@ -51,7 +51,7 @@ public void DefaultProfileSendsKeys()
var evtDn = new UioHookEvent
{
Type = EventType.MousePressed,
Mouse = new MouseEventData { Button = MouseButton.Button3, }
Mouse = new MouseEventData { Button = MouseButton.Button3 },
};
// var evtUp = new UioHookEvent
// {
Expand All @@ -78,7 +78,7 @@ public void NonDefaultProfileSendsKeys()
{
SimulatedKeystrokesType = new MouseButtonPressedActionType(),
BlockOriginalMouseInput = true,
Keys = "wee"
Keys = "wee",
};
var testProvider = new TestProvider();
using var hook = new SimpleReactiveGlobalHook(globalHookProvider: testProvider);
Expand All @@ -103,7 +103,7 @@ public void NonDefaultProfileSendsKeys()
var evtDn = new UioHookEvent
{
Type = EventType.MousePressed,
Mouse = new MouseEventData { Button = MouseButton.Button3, }
Mouse = new MouseEventData { Button = MouseButton.Button3 },
};
// var evtUp = new UioHookEvent
// {
Expand All @@ -130,7 +130,7 @@ public void NonDefaultProfileNotSendKeys()
{
SimulatedKeystrokesType = new MouseButtonPressedActionType(),
BlockOriginalMouseInput = true,
Keys = "wee"
Keys = "wee",
};
var testProvider = new TestProvider();
using var hook = new SimpleReactiveGlobalHook(globalHookProvider: testProvider);
Expand All @@ -156,7 +156,7 @@ public void NonDefaultProfileNotSendKeys()
var evtDn = new UioHookEvent
{
Type = EventType.MousePressed,
Mouse = new MouseEventData { Button = MouseButton.Button3, }
Mouse = new MouseEventData { Button = MouseButton.Button3 },
};
// var evtUp = new UioHookEvent
// {
Expand All @@ -181,7 +181,7 @@ public void DefaultProfileSendsKeysReleased()
{
SimulatedKeystrokesType = new MouseButtonReleasedActionType(),
BlockOriginalMouseInput = true,
Keys = "wee"
Keys = "wee",
};
var testProvider = new TestProvider();
using var hook = new SimpleReactiveGlobalHook(globalHookProvider: testProvider);
Expand All @@ -206,7 +206,7 @@ public void DefaultProfileSendsKeysReleased()
var evtUp = new UioHookEvent
{
Type = EventType.MouseReleased,
Mouse = new MouseEventData { Button = MouseButton.Button3, }
Mouse = new MouseEventData { Button = MouseButton.Button3 },
};
RunHookAndWaitForStart(hook, testProvider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public enum ButtonMappings
Nothing,
Disabled,
SimulatedKeystrokes,
RightClick
RightClick,
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public enum YMouseButton : ushort
MouseWheelUp,
MouseWheelDown,
MouseWheelLeft,
MouseWheelRight
MouseWheelRight,
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
public enum MouseButtonState
{
Pressed,
Released
Released,
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public ProfilesService(IUnitOfWorkFactory unitOfWorkFactory)
CurrentProfile = change.Reason switch
{
ChangeReason.Add => change.Current,
ChangeReason.Remove
=> _profiles
.Items.Where(x => x.DisplayPriority < change.Current.DisplayPriority)
.MaxBy(x => x.DisplayPriority)
?? throw new Exception("Unable to get next lower priority on remove"),
ChangeReason.Remove => _profiles
.Items.Where(x => x.DisplayPriority < change.Current.DisplayPriority)
.MaxBy(x => x.DisplayPriority)
?? throw new Exception("Unable to get next lower priority on remove"),
ChangeReason.Update => change.Current,
_ => throw new Exception("Unhandled change reason")
_ => throw new Exception("Unhandled change reason"),
};
});

Expand Down Expand Up @@ -111,7 +110,7 @@ private void CheckDefaultProfile()
MouseWheelUp = new NothingMapping(),
MouseWheelDown = new NothingMapping(),
MouseWheelLeft = new NothingMapping(),
MouseWheelRight = new NothingMapping()
MouseWheelRight = new NothingMapping(),
};
repository.Add(defaultProfile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ public enum WheelScrollDirection
VerticalUp = 1,
VerticalDown = 2,
HorizontalRight = 3,
HorizontalLeft = 4
HorizontalLeft = 4,
}
40 changes: 23 additions & 17 deletions YMouseButtonControl.Core/ViewModels/Implementations/AppViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,29 @@ is IClassicDesktopStyleApplicationLifetime lifetime
}
});
var runAtStartupCanExecute = this.WhenAnyValue(x => x.RunAtStartupIsEnabled);
RunAtStartupCommand = ReactiveCommand.Create(() =>
{
if (startupInstallerService.InstallStatus())
{
// uninstall
startupInstallerService.Uninstall();
RunAtStartupIsChecked = false;
RunAtStartupHeader = string.Format(RunAtStartupHeaderFmt, RunAtStartupNotChecked);
}
else
RunAtStartupCommand = ReactiveCommand.Create(
() =>
{
// install
startupInstallerService.Install();
RunAtStartupIsChecked = true;
RunAtStartupHeader = string.Format(RunAtStartupHeaderFmt, RunAtStartupChecked);
}
}, runAtStartupCanExecute);
if (startupInstallerService.InstallStatus())
{
// uninstall
startupInstallerService.Uninstall();
RunAtStartupIsChecked = false;
RunAtStartupHeader = string.Format(
RunAtStartupHeaderFmt,
RunAtStartupNotChecked
);
}
else
{
// install
startupInstallerService.Install();
RunAtStartupIsChecked = true;
RunAtStartupHeader = string.Format(RunAtStartupHeaderFmt, RunAtStartupChecked);
}
},
runAtStartupCanExecute
);
}

public string ToolTipText => $"YMouseButtonControl v{GetType().Assembly.GetName().Version}";
Expand All @@ -70,7 +76,7 @@ public bool RunAtStartupIsEnabled
get => _runAtStartupIsEnabled;
set => this.RaiseAndSetIfChanged(ref _runAtStartupIsEnabled, value);
}

public bool RunAtStartupIsChecked
{
get => _runAtStartupIsChecked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ProcessSelectorDialogViewModel(IProcessMonitorService processMonitorServi
{
Name = SelectedProcessModel!.Process.MainModule!.ModuleName,
Description = SelectedProcessModel.Process.MainWindowTitle,
Process = SelectedProcessModel.Process.MainModule.ModuleName
Process = SelectedProcessModel.Process.MainModule.ModuleName,
},
canExecuteOkCommand
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public SimulatedKeystrokesDialogViewModel(
CustomKeys = CustomKeys,
SimulatedKeystrokesType = SimulatedKeystrokesType,
Description = Description,
BlockOriginalMouseInput = BlockOriginalMouseInput
BlockOriginalMouseInput = BlockOriginalMouseInput,
},
canExecuteOkCmd
);
Expand Down Expand Up @@ -215,7 +215,7 @@ public bool BlockOriginalMouseInput
{ "F21", "{F21}" },
{ "F22", "{F22}" },
{ "F23", "{F23}" },
{ "F24", "{F24}" }
{ "F24", "{F24}" },
};

public static Dictionary<string, string> NumericKeypadKeys =>
Expand Down Expand Up @@ -263,7 +263,7 @@ public bool BlockOriginalMouseInput
{ "Next Track", "{MEDIANEXT}" },
{ "Previous Track", "{MEDIAPREV}" },
{ "Select Track", "{MEDIASELECT}" },
{ "Eject Media", "{MEDIAEJECT}" }
{ "Eject Media", "{MEDIAEJECT}" },
};

public static Dictionary<string, string> BrowserKeys =>
Expand Down Expand Up @@ -314,7 +314,7 @@ public int CaretIndex
() => new RepeatedlyWhileButtonDownActionType(),
() => new StickyRepeatActionType(),
() => new StickyHoldActionType(),
() => new AsMousePressedAndReleasedActionType()
() => new AsMousePressedAndReleasedActionType(),
];

private string? _computedXy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Interaction<
Keys = result.CustomKeys,
PriorityDescription = result.Description,
SimulatedKeystrokesType = result.SimulatedKeystrokesType,
BlockOriginalMouseInput = result.BlockOriginalMouseInput
BlockOriginalMouseInput = result.BlockOriginalMouseInput,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SimulateKeyboardResult SimulateKeyPress(string? key)
{
Result = eventSimulator
.SimulateKeyPress(KeyCodes[key ?? throw new NullReferenceException(key)])
.ToString()
.ToString(),
};
}

Expand All @@ -43,7 +43,7 @@ public SimulateKeyboardResult SimulateKeyRelease(string? key)
{
Result = eventSimulator
.SimulateKeyRelease(KeyCodes[key ?? throw new NullReferenceException(key)])
.ToString()
.ToString(),
};
}

Expand Down Expand Up @@ -300,7 +300,7 @@ private static List<ParsedKey> ParseKeys(string? keys)
{
Key = substr,
IsModifier = false,
Value = (ushort)KeyCodes[substr]
Value = (ushort)KeyCodes[substr],
}
);
i++;
Expand Down Expand Up @@ -504,6 +504,6 @@ private static List<ParsedKey> ParseKeys(string? keys)
{ "rmb", MouseButton.Button2 },
{ "mmb", MouseButton.Button3 },
{ "mb4", MouseButton.Button4 },
{ "mb5", MouseButton.Button5 }
{ "mb5", MouseButton.Button5 },
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,52 +87,43 @@ private void OnMouseWheel(NewMouseWheelEventArgs args)
private bool ShouldSuppressEvent(NewMouseHookEventArgs args) =>
args.Button switch
{
YMouseButton.MouseButton1
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton1.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton2
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton2.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton3
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton3.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton4
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton4.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton5
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton5.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelUp
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelUp.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelDown
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelDown.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelLeft
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelLeft.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelRight
=> _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelRight.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
_ => throw new ArgumentOutOfRangeException()
YMouseButton.MouseButton1 => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton1.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton2 => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton2.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton3 => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton3.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton4 => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton4.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseButton5 => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseButton5.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelUp => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelUp.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelDown => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelDown.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelLeft => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelLeft.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
YMouseButton.MouseWheelRight => _profilesService.Profiles.Any(p =>
p is { Checked: true, MouseWheelRight.BlockOriginalMouseInput: true }
&& (args.ActiveWindow?.Contains(p.Process) ?? false)
),
_ => throw new ArgumentOutOfRangeException(),
};

private void SubscribeToEvents()
Expand Down
2 changes: 1 addition & 1 deletion YMouseButtonControl.Linux.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
global using NUnit.Framework;
global using NUnit.Framework;
2 changes: 1 addition & 1 deletion YMouseButtonControl.Linux.Tests/StartupInstallerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public void I_can_uninstall()
Assert.That(sut.InstallStatus(), Is.False);
});
}
}
}
Loading

0 comments on commit c62cc7f

Please sign in to comment.