mirror of
https://github.com/Stone-Red-Code/InvLock.git
synced 2026-09-04 00:56:10 +02:00
Fix startup behavior and properly focus blur windows
This commit is contained in:
@@ -5,6 +5,7 @@ using InvLock.Utilities;
|
|||||||
using SharpHook.Native;
|
using SharpHook.Native;
|
||||||
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
@@ -22,7 +23,15 @@ internal partial class MainWindowDataContext(Func<LockWindow?> lockWindowAccesso
|
|||||||
|
|
||||||
public string AppName => App.AppName;
|
public string AppName => App.AppName;
|
||||||
|
|
||||||
public string AppVersion => Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";
|
public string AppVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);
|
||||||
|
return fileVersionInfo.ProductVersion ?? "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Settings Settings { get; } = Settings.Load();
|
public Settings Settings { get; } = Settings.Load();
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public partial class LockWindow : Window
|
|||||||
MinimizeWindows();
|
MinimizeWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dispatcher.Invoke(() =>
|
_ = Dispatcher.Invoke(async () =>
|
||||||
{
|
{
|
||||||
lastMousePosition = WpfScreenHelper.MouseHelper.MousePosition;
|
lastMousePosition = WpfScreenHelper.MouseHelper.MousePosition;
|
||||||
|
|
||||||
@@ -136,11 +136,13 @@ public partial class LockWindow : Window
|
|||||||
Height = bounds.Height,
|
Height = bounds.Height,
|
||||||
Left = bounds.Left,
|
Left = bounds.Left,
|
||||||
Top = bounds.Top,
|
Top = bounds.Top,
|
||||||
|
Topmost = true
|
||||||
};
|
};
|
||||||
|
|
||||||
blurWindows.Add(blurWindow);
|
blurWindows.Add(blurWindow);
|
||||||
blurWindow.Show();
|
blurWindow.Show();
|
||||||
_ = blurWindow.Activate();
|
|
||||||
|
blurWindow.Topmost = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = WindowsApi.SetCursorPosition(new Point(100000, 100000));
|
_ = WindowsApi.SetCursorPosition(new Point(100000, 100000));
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
WindowBackdropType="Mica"
|
WindowBackdropType="Mica"
|
||||||
WindowCornerPreference="Round"
|
WindowCornerPreference="Round"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
WindowState="Minimized"
|
|
||||||
ShowInTaskbar="False"
|
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
Closing="FluentWindow_Closing"
|
Closing="FluentWindow_Closing"
|
||||||
Closed="FluentWindow_Closed"
|
Closed="FluentWindow_Closed"
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ public partial class MainWindow : FluentWindow
|
|||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
|
SystemThemeWatcher.Watch(this);
|
||||||
|
|
||||||
mainWindowDataContext = new MainWindowDataContext(() => lockWindow);
|
mainWindowDataContext = new MainWindowDataContext(() => lockWindow);
|
||||||
DataContext = mainWindowDataContext;
|
DataContext = mainWindowDataContext;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
SystemThemeWatcher.Watch(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RestoreWindow()
|
internal void RestoreWindow()
|
||||||
@@ -53,6 +53,18 @@ public partial class MainWindow : FluentWindow
|
|||||||
{
|
{
|
||||||
lockWindow = new LockWindow(mainWindowDataContext.Settings);
|
lockWindow = new LockWindow(mainWindowDataContext.Settings);
|
||||||
lockWindow.Show();
|
lockWindow.Show();
|
||||||
|
|
||||||
|
if (mainWindowDataContext.Settings.FirstRun)
|
||||||
|
{
|
||||||
|
mainWindowDataContext.Settings.FirstRun = false;
|
||||||
|
RestoreWindow();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowInTaskbar = false;
|
||||||
|
WindowState = WindowState.Minimized;
|
||||||
|
Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyIcon_LeftClick(Wpf.Ui.Tray.Controls.NotifyIcon sender, RoutedEventArgs e)
|
private void NotifyIcon_LeftClick(Wpf.Ui.Tray.Controls.NotifyIcon sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class Settings : INotifyPropertyChanged
|
|||||||
private bool blurScreen = false;
|
private bool blurScreen = false;
|
||||||
private string lockText = "Lock Screen Active";
|
private string lockText = "Lock Screen Active";
|
||||||
private string theme = "Windows default";
|
private string theme = "Windows default";
|
||||||
|
private bool firstRun = true;
|
||||||
private HashSet<KeyCode> lockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
|
private HashSet<KeyCode> lockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
|
||||||
private HashSet<KeyCode> unlockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
|
private HashSet<KeyCode> unlockShortcut = [KeyCode.VcLeftControl, KeyCode.VcLeftShift, KeyCode.VcL];
|
||||||
|
|
||||||
@@ -76,6 +77,16 @@ public class Settings : INotifyPropertyChanged
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FirstRun
|
||||||
|
{
|
||||||
|
get => firstRun;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
firstRun = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string LockShortcutText => string.Join(" + ", LockShortcut.Select(key => key.ToString()[2..]));
|
public string LockShortcutText => string.Join(" + ", LockShortcut.Select(key => key.ToString()[2..]));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user