diff --git a/InvLock/Assets/logo.ico b/InvLock/Assets/logo.ico
new file mode 100644
index 0000000..1ae5705
Binary files /dev/null and b/InvLock/Assets/logo.ico differ
diff --git a/InvLock/DataContexts/MainWindowDataContext.cs b/InvLock/DataContexts/MainWindowDataContext.cs
index a23cc3d..65e5860 100644
--- a/InvLock/DataContexts/MainWindowDataContext.cs
+++ b/InvLock/DataContexts/MainWindowDataContext.cs
@@ -1,16 +1,22 @@
-using System.Reflection;
+using System.ComponentModel;
+using System.Reflection;
namespace InvLock.DataContexts;
-internal class MainWindowDataContext
+internal class MainWindowDataContext : INotifyPropertyChanged
{
#if DEBUG
public string Title => $"{App.AppName} - Dev {AppVersion}";
#else
- public string Title => $"{App.AppName} - {AppVersion}";
+
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ public string Title => $"{App.AppName} - {AppVersion}";
#endif
public string AppName => App.AppName;
public string AppVersion => Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "Unknown";
+
+ public Settings Settings { get; } = Settings.Load();
}
\ No newline at end of file
diff --git a/InvLock/InvLock.csproj b/InvLock/InvLock.csproj
index e303716..f523019 100644
--- a/InvLock/InvLock.csproj
+++ b/InvLock/InvLock.csproj
@@ -7,13 +7,22 @@
enable
true
true
+ Assets\logo.ico
+
+
+
+
+
+
+
+
diff --git a/InvLock/LockWindow.xaml.cs b/InvLock/LockWindow.xaml.cs
index ab76645..ce1ea40 100644
--- a/InvLock/LockWindow.xaml.cs
+++ b/InvLock/LockWindow.xaml.cs
@@ -15,14 +15,14 @@ namespace InvLock;
///
public partial class LockWindow : Window
{
- private const bool HideWindows = false;
private readonly SimpleGlobalHook hook = new SimpleGlobalHook();
private readonly Dictionary pressedKeys = [];
+ private readonly Settings settings;
private List windows = [];
private bool isOpen = true;
private bool suppressInput = false;
- public LockWindow()
+ public LockWindow(Settings settings)
{
InitializeComponent();
@@ -42,6 +42,8 @@ public partial class LockWindow : Window
Owner = w;
+ this.settings = settings;
+
hook.MouseMoved += Hook_Mouse;
hook.MouseDragged += Hook_Mouse;
hook.MousePressed += Hook_Mouse;
@@ -59,7 +61,7 @@ public partial class LockWindow : Window
private void ActivateLockScreen()
{
- if (HideWindows)
+ if (settings.HideWindows)
{
MinimizeWindows();
}
@@ -71,7 +73,7 @@ public partial class LockWindow : Window
{
_ = Activate();
- textBlock.Text = "Lock Screen Active";
+ textBlock.Text = settings.LockText;
textBlock.Stroke = (Brush)FindResource("PaletteRedBrush");
Animation();
@@ -120,7 +122,7 @@ public partial class LockWindow : Window
{
if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionUnlock)
{
- if (HideWindows)
+ if (settings.HideWindows)
{
RestoreWindows();
}
@@ -131,7 +133,7 @@ public partial class LockWindow : Window
await Task.Delay(500);
- textBlock.Text = "Lock Screen Inactive";
+ textBlock.Text = settings.UnlockText;
textBlock.Stroke = (Brush)FindResource("PaletteGreenBrush");
Animation();
diff --git a/InvLock/MainWindow.xaml b/InvLock/MainWindow.xaml
index 0a978fb..e2b90ba 100644
--- a/InvLock/MainWindow.xaml
+++ b/InvLock/MainWindow.xaml
@@ -31,15 +31,22 @@
-
+
+
+
+
+
-
+
+
+
+
@@ -80,21 +87,21 @@
-
+
-
+
-
+
diff --git a/InvLock/MainWindow.xaml.cs b/InvLock/MainWindow.xaml.cs
index 856c523..4bc68f3 100644
--- a/InvLock/MainWindow.xaml.cs
+++ b/InvLock/MainWindow.xaml.cs
@@ -12,12 +12,13 @@ namespace InvLock;
///
public partial class MainWindow : FluentWindow
{
+ private readonly MainWindowDataContext mainWindowDataContext = new MainWindowDataContext();
private LockWindow? lockWindow;
private bool blockWindowClosing = true;
public MainWindow()
{
- DataContext = new MainWindowDataContext();
+ DataContext = mainWindowDataContext;
InitializeComponent();
@@ -51,7 +52,7 @@ public partial class MainWindow : FluentWindow
{
Close();
- lockWindow = new LockWindow();
+ lockWindow = new LockWindow(mainWindowDataContext.Settings);
lockWindow.Show();
}
@@ -62,6 +63,8 @@ public partial class MainWindow : FluentWindow
private void FluentWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
+ mainWindowDataContext.Settings.Save();
+
if (blockWindowClosing)
{
e.Cancel = true;
diff --git a/InvLock/Settings.cs b/InvLock/Settings.cs
index c0ef541..33a03ee 100644
--- a/InvLock/Settings.cs
+++ b/InvLock/Settings.cs
@@ -1,8 +1,69 @@
-namespace InvLock;
+using System.ComponentModel;
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Text.Json;
-internal class Settings
+namespace InvLock;
+
+public class Settings : INotifyPropertyChanged
{
- public bool HideWindows { get; set; } = false;
- public string LockText { get; set; } = "Lock Screen Active";
- public string UnlockText { get; set; } = "Lock Screen Inactive";
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ private static readonly string settingsPath = Path.Combine(App.ApplicationDataPath, "settings.json");
+ private bool hideWindows = false;
+ private string lockText = "Lock Screen Active";
+
+ private string unlockText = "Lock Screen Inactive";
+
+ public bool HideWindows
+ {
+ get => hideWindows;
+ set
+ {
+ hideWindows = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public string LockText
+ {
+ get => lockText;
+ set
+ {
+ lockText = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public string UnlockText
+ {
+ get => unlockText;
+ set
+ {
+ unlockText = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public static Settings Load()
+ {
+ if (File.Exists(settingsPath))
+ {
+ string json = File.ReadAllText(settingsPath);
+ return JsonSerializer.Deserialize(json) ?? new Settings();
+ }
+
+ return new Settings();
+ }
+
+ public void Save()
+ {
+ string json = JsonSerializer.Serialize(this);
+ File.WriteAllText(settingsPath, json);
+ }
+
+ protected void OnPropertyChanged([CallerMemberName] string? name = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
+ }
}
\ No newline at end of file