Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Jan 22, 2025
1 parent 63c25df commit 81f10d3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/ComputerLock/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void Init()
return sp.GetRequiredService<AppSettingsProvider>().LoadSettings();
});
services.AddSingleton(LogManager.GetLogger());
services.AddSingleton<KeyboardHook>();
services.AddSingleton<HotKeyHook>();
services.AddSingleton<MouseHook>();
services.AddSingleton<UpdateHelper>();
services.AddSingleton<AutostartHook>();
Expand Down
4 changes: 2 additions & 2 deletions src/ComputerLock/Hooks/HotKeyHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace ComputerLock.Hooks
{
//引用:https://stackoverflow.com/questions/2450373/set-global-hotkeys-using-c-sharp

public sealed class KeyboardHook : IDisposable
public sealed class HotKeyHook : IDisposable
{
// Registers a hot key with Windows.
[DllImport("user32.dll")]
Expand Down Expand Up @@ -62,7 +62,7 @@ public void Dispose()
private Window _window = new Window();
const int _currentId = 1;

public KeyboardHook()
public HotKeyHook()

Check warning on line 65 in src/ComputerLock/Hooks/HotKeyHook.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable event 'KeyPressed' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the event as nullable.
{
// register the event of the inner native window.
_window.KeyPressed += delegate (object sender, KeyPressedEventArgs args)

Check warning on line 68 in src/ComputerLock/Hooks/HotKeyHook.cs

View workflow job for this annotation

GitHub Actions / build

Nullability of reference types in type of parameter 'sender' of 'anonymous method' doesn't match the target delegate 'EventHandler<KeyPressedEventArgs>' (possibly because of nullability attributes).
Expand Down
8 changes: 4 additions & 4 deletions src/ComputerLock/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class Index
private ILocker Locker { get; set; } = default!;

[Inject]
private KeyboardHook KeyboardHook { get; set; } = default!;
private HotKeyHook HotKeyHook { get; set; } = default!;

[Inject]
private IWindowTitleBar WindowTitleBar { get; set; } = default!;
Expand All @@ -47,7 +47,7 @@ protected override async Task OnInitializedAsync()
RegisterHotKey();
}

KeyboardHook.KeyPressed += (_, _) =>
HotKeyHook.KeyPressed += (_, _) =>
{
Logger.Write("快捷键解锁");
Locker.Lock();
Expand Down Expand Up @@ -205,7 +205,7 @@ public void RegisterHotKey()
}
Logger.Write("注册锁屏热键");
Keys key = (Keys)Convert.ToInt32(result.result);
KeyboardHook.RegisterHotKey(keys, key);
HotKeyHook.RegisterHotKey(keys, key);

_shortcutKeyText = AppSettings.ShortcutKeyDisplayForLock;
}
Expand All @@ -221,7 +221,7 @@ public void UnregisterHotKey()
try
{
Logger.Write("释放锁屏热键");
KeyboardHook.UnregisterHotKey();
HotKeyHook.UnregisterHotKey();
}
catch (Exception ex)
{
Expand Down
8 changes: 4 additions & 4 deletions src/ComputerLock/WindowMain.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ComputerLock;
public partial class WindowMain : Window, IDisposable
{
private readonly KeyboardHook _keyboardHook;
private readonly HotKeyHook _hotKeyHook;
private readonly AppSettings _appSettings;
private readonly UserActivityMonitor? _activityMonitor;
private readonly ILocker _locker;
Expand All @@ -14,11 +14,11 @@ public partial class WindowMain : Window, IDisposable
private readonly NotifyIcon _notifyIcon = new();
private readonly ContextMenuStrip _contextMenuStrip = new();

public WindowMain(KeyboardHook keyboardHook, AppSettings appSettings, ILocker locker, UserActivityMonitor activityMonitor, ILogger logger)
public WindowMain(HotKeyHook hotKeyHook, AppSettings appSettings, ILocker locker, UserActivityMonitor activityMonitor, ILogger logger)
{
InitializeComponent();

_keyboardHook = keyboardHook;
_hotKeyHook = hotKeyHook;
_appSettings = appSettings;
_locker = locker;
_logger = logger;
Expand Down Expand Up @@ -156,6 +156,6 @@ public void Dispose()
_logger.Write("系统资源释放,系统关闭");
_notifyIcon.Dispose();
_activityMonitor?.Dispose();
_keyboardHook.Dispose();
_hotKeyHook.Dispose();
}
}

0 comments on commit 81f10d3

Please sign in to comment.