Skip to content

Commit

Permalink
支持程序启动时锁定屏幕
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Jun 11, 2024
1 parent 47b5850 commit 994b00c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class AppSettings
/// </summary>
public bool LockAnimation { get; set; } = true;

/// <summary>
/// 程序启动时锁定
/// </summary>
public bool LockOnStartup { get; set; } = false;

/// <summary>
/// 自动锁定的秒数
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
Label="@(Lang["MouseDownActivePwd"])"
Color="Color.Primary" />

<MudSwitch @bind-Value="@(AppSettings.LockOnStartup)"
@bind-Value:after="SaveSettings"
Label="@(Lang["LockOnStartup"])"
Color="Color.Primary" />

<div class="d-flex align-center mt-2">
<MudText Typo="Typo.button">@(Lang["LockShortcutKey"])</MudText>
<MudButton Class="ml-3"
Expand Down
9 changes: 9 additions & 0 deletions src/Resources/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Resources/Lang.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,7 @@
<data name="ResetSettingsMessage" xml:space="preserve">
<value>Are you sure you want to reset all settings?</value>
</data>
<data name="LockOnStartup" xml:space="preserve">
<value>Lock screen on startup</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Resources/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,7 @@
<data name="ResetSettingsMessage" xml:space="preserve">
<value></value>
</data>
<data name="LockOnStartup" xml:space="preserve">
<value></value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/Resources/Lang.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,7 @@
<data name="ResetSettingsMessage" xml:space="preserve">
<value>确定要重置所有设置并重启程序吗?</value>
</data>
<data name="LockOnStartup" xml:space="preserve">
<value>程序启动时锁定屏幕</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/WindowMain.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:ui="http://schemas.modernwpf.com/2019"
mc:Ignorable="d"
Title="透明锁屏"
Height="450"
Height="490"
Width="530"
ResizeMode="NoResize"
WindowState="Normal"
Expand Down
5 changes: 5 additions & 0 deletions src/WindowMain.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public WindowMain(KeyboardHook keyboardHook, AppSettings appSettings, ILocker lo
};
}

if (_appSettings.LockOnStartup)
{
_logger.Write("程序启动时锁定屏幕");
_locker.Lock();
}
}

private void Window_Loaded(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 994b00c

Please sign in to comment.