Skip to content

Commit cf4e2ad

Browse files
Merge branch 'develop'
# Conflicts: # installer/InvLock-Installer.exe # src/InvLock/DataContexts/MainWindowDataContext.cs # src/InvLock/InvLock.csproj
2 parents 9a53be9 + 81c8d9e commit cf4e2ad

File tree

9 files changed

+179
-17
lines changed

9 files changed

+179
-17
lines changed

installer/Installer.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; Script generated by the Inno Setup Script Wizard.
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

4-
#expr Exec('cmd.exe /C', 'dotnet build -o "' + SourcePath + '\publish" -c Release ' + SourcePath + '..\src\InvLock\')
4+
#expr Exec('cmd.exe', '/C dotnet build -o "' + SourcePath + '\publish" -c Release ' + SourcePath + '..\src\InvLock\')
55

66
#define MyAppName "InvLock"
7-
#define MyAppVersion GetVersionNumbersString("/publish/InvLock.exe")
7+
#define MyAppVersion GetStringFileInfo("/publish/InvLock.exe","ProductVersion")
88
#define MyAppPublisher "Stone_Red"
99
#define MyAppExeName "InvLock.exe"
1010

src/InvLock/App.xaml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,136 @@
99
<ResourceDictionary.MergedDictionaries>
1010
<ui:ThemesDictionary Theme="Dark" />
1111
<ui:ControlsDictionary />
12+
<ResourceDictionary
13+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
14+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
15+
xmlns:system="clr-namespace:System;assembly=System.Runtime">
16+
17+
<system:Double x:Key="ToggleButtonWidth">40</system:Double>
18+
<system:Double x:Key="ToggleButtonHeight">20</system:Double>
19+
<Thickness x:Key="ToggleSwitchBorderThemeThickness">1</Thickness>
20+
<Thickness x:Key="ToggleSwitchContentLeftMargin">0,0,8,0</Thickness>
21+
22+
<Style x:Key="ToggleSwitchContentLeftStyle" TargetType="{x:Type ui:ToggleSwitch}">
23+
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
24+
<Setter Property="Background" Value="{DynamicResource ToggleSwitchFillOn}" />
25+
<Setter Property="Foreground" Value="{DynamicResource ToggleSwitchContentForeground}" />
26+
<Setter Property="BorderBrush" Value="Transparent" />
27+
<Setter Property="BorderThickness" Value="{StaticResource ToggleSwitchBorderThemeThickness}" />
28+
<Setter Property="Padding" Value="0" />
29+
<Setter Property="HorizontalAlignment" Value="Left" />
30+
<Setter Property="VerticalAlignment" Value="Center" />
31+
<Setter Property="HorizontalContentAlignment" Value="Left" />
32+
<Setter Property="VerticalContentAlignment" Value="Center" />
33+
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
34+
<Setter Property="OverridesDefaultStyle" Value="True" />
35+
<Setter Property="Template">
36+
<Setter.Value>
37+
<ControlTemplate TargetType="{x:Type ui:ToggleSwitch}">
38+
<Grid Margin="{TemplateBinding Padding}" Background="Transparent">
39+
<Grid.ColumnDefinitions>
40+
<ColumnDefinition Width="*" />
41+
<ColumnDefinition Width="Auto" />
42+
</Grid.ColumnDefinitions>
43+
44+
<ContentPresenter
45+
x:Name="ContentPresenter"
46+
Grid.Column="0"
47+
Margin="{StaticResource ToggleSwitchContentLeftMargin}"
48+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
49+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
50+
Content="{TemplateBinding Content}"
51+
ContentTemplate="{TemplateBinding ContentTemplate}"
52+
RecognizesAccessKey="True"
53+
TextElement.Foreground="{TemplateBinding Foreground}" />
54+
55+
<Grid
56+
Grid.Column="1"
57+
Width="{StaticResource ToggleButtonWidth}"
58+
Height="{StaticResource ToggleButtonHeight}">
59+
<Rectangle
60+
x:Name="ToggleRectangle"
61+
Width="{StaticResource ToggleButtonWidth}"
62+
Height="{StaticResource ToggleButtonHeight}"
63+
Fill="{DynamicResource ToggleSwitchFillOff}"
64+
RadiusX="10" RadiusY="10"
65+
Stroke="{DynamicResource ToggleSwitchStrokeOff}"
66+
StrokeThickness="1" />
67+
<Rectangle
68+
x:Name="ActiveToggleRectangle"
69+
Width="{StaticResource ToggleButtonWidth}"
70+
Height="{StaticResource ToggleButtonHeight}"
71+
Fill="{TemplateBinding Background}"
72+
Opacity="0.0"
73+
RadiusX="10" RadiusY="10" />
74+
<Rectangle
75+
x:Name="ToggleEllipse"
76+
Width="12" Height="12"
77+
Fill="{DynamicResource ToggleSwitchKnobFillOff}"
78+
RadiusX="7" RadiusY="7">
79+
<Rectangle.RenderTransform>
80+
<TranslateTransform X="-9" />
81+
</Rectangle.RenderTransform>
82+
</Rectangle>
83+
<Rectangle
84+
x:Name="ActiveToggleEllipse"
85+
Width="12" Height="12"
86+
Fill="{DynamicResource ToggleSwitchKnobFillOn}"
87+
Opacity="0.0"
88+
RadiusX="7" RadiusY="7">
89+
<Rectangle.RenderTransform>
90+
<TranslateTransform X="-9" />
91+
</Rectangle.RenderTransform>
92+
</Rectangle>
93+
</Grid>
94+
</Grid>
95+
96+
<ControlTemplate.Triggers>
97+
<Trigger Property="IsChecked" Value="True">
98+
<Trigger.EnterActions>
99+
<BeginStoryboard Name="SlideRight">
100+
<Storyboard>
101+
<DoubleAnimation Storyboard.TargetName="ToggleRectangle" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
102+
<DoubleAnimation Storyboard.TargetName="ActiveToggleRectangle" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
103+
<DoubleAnimation Storyboard.TargetName="ToggleEllipse" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
104+
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
105+
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="(Rectangle.RenderTransform).(TranslateTransform.X)" To="9" Duration="0:0:0.167" />
106+
</Storyboard>
107+
</BeginStoryboard>
108+
</Trigger.EnterActions>
109+
<Trigger.ExitActions>
110+
<BeginStoryboard>
111+
<Storyboard>
112+
<DoubleAnimation Storyboard.TargetName="ToggleRectangle" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
113+
<DoubleAnimation Storyboard.TargetName="ActiveToggleRectangle" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
114+
<DoubleAnimation Storyboard.TargetName="ToggleEllipse" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.16" />
115+
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:0.16" />
116+
<DoubleAnimation Storyboard.TargetName="ActiveToggleEllipse" Storyboard.TargetProperty="(Rectangle.RenderTransform).(TranslateTransform.X)" To="-9" Duration="0:0:0.167" />
117+
</Storyboard>
118+
</BeginStoryboard>
119+
</Trigger.ExitActions>
120+
</Trigger>
121+
122+
<MultiTrigger>
123+
<MultiTrigger.Conditions>
124+
<Condition Property="Content" Value="{x:Null}" />
125+
<Condition Property="IsChecked" Value="True" />
126+
</MultiTrigger.Conditions>
127+
<Setter TargetName="ContentPresenter" Property="Content" Value="{Binding OnContent, RelativeSource={RelativeSource TemplatedParent}}" />
128+
</MultiTrigger>
129+
<MultiTrigger>
130+
<MultiTrigger.Conditions>
131+
<Condition Property="Content" Value="{x:Null}" />
132+
<Condition Property="IsChecked" Value="False" />
133+
</MultiTrigger.Conditions>
134+
<Setter TargetName="ContentPresenter" Property="Content" Value="{Binding OffContent, RelativeSource={RelativeSource TemplatedParent}}" />
135+
</MultiTrigger>
136+
</ControlTemplate.Triggers>
137+
</ControlTemplate>
138+
</Setter.Value>
139+
</Setter>
140+
</Style>
141+
</ResourceDictionary>
12142
</ResourceDictionary.MergedDictionaries>
13143
</ResourceDictionary>
14144
</Application.Resources>

src/InvLock/DataContexts/MainWindowDataContext.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using SharpHook.Native;
66

77
using System.ComponentModel;
8+
using System.Diagnostics;
89
using System.Reflection;
910
using System.Runtime.CompilerServices;
1011

@@ -22,7 +23,15 @@ internal partial class MainWindowDataContext(Func<LockWindow?> lockWindowAccesso
2223

2324
public string AppName => App.AppName;
2425

25-
public string AppVersion => Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";
26+
public string AppVersion
27+
{
28+
get
29+
{
30+
Assembly assembly = Assembly.GetExecutingAssembly();
31+
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
32+
return fileVersionInfo.ProductVersion ?? "Unknown";
33+
}
34+
}
2635

2736
public Settings Settings { get; } = Settings.Load();
2837

src/InvLock/InvLock.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<UseWPF>true</UseWPF>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
11-
<Version>1.1.0.0</Version>
12-
<AssemblyVersion>1.1.0.0</AssemblyVersion>
13-
<FileVersion>1.1.0.0</FileVersion>
11+
<Version>1.1.0.20251229</Version>
12+
<AssemblyVersion>1.1.0.1229</AssemblyVersion>
13+
<FileVersion>1.1.0.20251229</FileVersion>
1414
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
1515
</PropertyGroup>
1616

src/InvLock/LockWindow.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private void ActivateLockScreen()
122122
MinimizeWindows();
123123
}
124124

125-
Dispatcher.Invoke(() =>
125+
_ = Dispatcher.Invoke(async () =>
126126
{
127127
lastMousePosition = WpfScreenHelper.MouseHelper.MousePosition;
128128

@@ -136,10 +136,13 @@ private void ActivateLockScreen()
136136
Height = bounds.Height,
137137
Left = bounds.Left,
138138
Top = bounds.Top,
139+
Topmost = true
139140
};
140141

141142
blurWindows.Add(blurWindow);
142143
blurWindow.Show();
144+
145+
blurWindow.Topmost = false;
143146
}
144147

145148
_ = WindowsApi.SetCursorPosition(new Point(100000, 100000));

src/InvLock/MainWindow.xaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
WindowBackdropType="Mica"
1919
WindowCornerPreference="Round"
2020
WindowStartupLocation="CenterScreen"
21-
WindowState="Minimized"
2221
Loaded="Window_Loaded"
2322
Closing="FluentWindow_Closing"
2423
Closed="FluentWindow_Closed"
@@ -90,28 +89,28 @@
9089
<ui:TextBlock Grid.Row="1" Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" FontSize="12" Text="Start InvLock when you sign in to Windows" />
9190
</Grid>
9291
</ui:CardControl.Header>
93-
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding IsAutoStartEnabled}" OffContent="Off" OnContent="On" />
92+
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding IsAutoStartEnabled}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
9493
</ui:CardControl>
9594

9695
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=Window24}" Height="75">
9796
<ui:CardControl.Header>
9897
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Show desktop while locked" />
9998
</ui:CardControl.Header>
100-
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.HideWindows}" OffContent="Off" OnContent="On" />
99+
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.HideWindows}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
101100
</ui:CardControl>
102101

103102
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=Blur24}" Height="75">
104103
<ui:CardControl.Header>
105104
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Blur screen while locked" />
106105
</ui:CardControl.Header>
107-
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.BlurScreen}" OffContent="Off" OnContent="On" />
106+
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.BlurScreen}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
108107
</ui:CardControl>
109108

110109
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=WindowShield24}" Height="75">
111110
<ui:CardControl.Header>
112111
<ui:TextBlock Grid.Row="0" FontTypography="Body" Text="Use windows lock screen to unlock" />
113112
</ui:CardControl.Header>
114-
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.UseWindowsLockScreen}" OffContent="Off" OnContent="On" />
113+
<ui:ToggleSwitch Grid.Column="1" IsChecked="{Binding Settings.UseWindowsLockScreen}" Style="{StaticResource ToggleSwitchContentLeftStyle}" OffContent="Off" OnContent="On" />
115114
</ui:CardControl>
116115

117116
<ui:CardControl Margin="0,0,0,12" Icon="{ui:SymbolIcon Symbol=LockClosed24}" Height="75">

src/InvLock/MainWindow.xaml.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public partial class MainWindow : FluentWindow
1818

1919
public MainWindow()
2020
{
21+
SystemThemeWatcher.Watch(this);
22+
2123
mainWindowDataContext = new MainWindowDataContext(() => lockWindow);
2224
DataContext = mainWindowDataContext;
2325

2426
InitializeComponent();
25-
26-
SystemThemeWatcher.Watch(this);
2727
}
2828

2929
internal void RestoreWindow()
@@ -51,10 +51,20 @@ private void QuitMenuItem_Click(object sender, RoutedEventArgs e)
5151

5252
private void Window_Loaded(object sender, RoutedEventArgs e)
5353
{
54-
Close();
55-
5654
lockWindow = new LockWindow(mainWindowDataContext.Settings);
5755
lockWindow.Show();
56+
57+
if (mainWindowDataContext.Settings.FirstRun)
58+
{
59+
mainWindowDataContext.Settings.FirstRun = false;
60+
RestoreWindow();
61+
}
62+
else
63+
{
64+
ShowInTaskbar = false;
65+
WindowState = WindowState.Minimized;
66+
Visibility = Visibility.Collapsed;
67+
}
5868
}
5969

6070
private void NotifyIcon_LeftClick(Wpf.Ui.Tray.Controls.NotifyIcon sender, RoutedEventArgs e)

src/InvLock/Settings.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Settings : INotifyPropertyChanged
2020
private bool blurScreen = false;
2121
private string lockText = "Lock Screen Active";
2222
private string theme = "Windows default";
23+
private bool firstRun = true;
2324
private HashSet<KeyCode> lockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
2425
private HashSet<KeyCode> unlockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
2526

@@ -76,6 +77,16 @@ public HashSet<KeyCode> LockShortcut
7677
}
7778
}
7879

80+
public bool FirstRun
81+
{
82+
get => firstRun;
83+
set
84+
{
85+
firstRun = value;
86+
OnPropertyChanged();
87+
}
88+
}
89+
7990
[JsonIgnore]
8091
public string LockShortcutText => string.Join(" + ", LockShortcut.Select(key => key.ToString()[2..]));
8192

src/MsixPackaging/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Identity
1010
Name="StoneRed.9985F47BE4F2"
1111
Publisher="CN=6D1FD759-1951-428A-9B03-964461C7DBF5"
12-
Version="1.0.0.0" />
12+
Version="1.1.0.0" />
1313

1414
<Properties>
1515
<DisplayName>InvLock</DisplayName>

0 commit comments

Comments
 (0)