mirror of
https://github.com/Stone-Red-Code/InvLock.git
synced 2026-09-04 09:06:13 +02:00
Implement theme switcher and fix some bugs
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace InvLock.DataContexts;
|
||||
|
||||
internal class MainWindowDataContext : INotifyPropertyChanged
|
||||
internal class MainWindowDataContext
|
||||
{
|
||||
#if DEBUG
|
||||
public string Title => $"{App.AppName} - Dev {AppVersion}";
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
</ui:HyperlinkButton>
|
||||
</Grid>
|
||||
</ui:CardControl.Header>
|
||||
<ComboBox Grid.Column="1" MinWidth="200" SelectedIndex="0">
|
||||
<ComboBox Grid.Column="1" MinWidth="200" SelectedIndex="0" SelectedValue="{Binding Settings.Theme}" SelectedValuePath="Content">
|
||||
<ComboBoxItem Content="Windows default" />
|
||||
<ComboBoxItem Content="Light" />
|
||||
<ComboBoxItem Content="Dark" />
|
||||
@@ -129,7 +129,26 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Report an issue or request a feature" />
|
||||
<ui:SymbolIcon Grid.Column="1" Symbol="Link24" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
|
||||
<TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock/issues"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Anchor>
|
||||
|
||||
<Separator />
|
||||
|
||||
<ui:Anchor Margin="0" Padding="16" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="Transparent" CornerRadius="0" BorderThickness="0" NavigateUri="https://github.com/Stone-Red-Code/InvLock">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="GitHub" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<ui:SymbolIcon Margin="0 0 6 0" Symbol="Link24" />
|
||||
<TextBlock Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="https://github.com/Stone-Red-Code/InvLock"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:Anchor>
|
||||
|
||||
@@ -140,13 +159,9 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="Clone repository" />
|
||||
<TextBlock Grid.Column="1" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="git clone https://github.com/Stone-Red-Code/InvLock" />
|
||||
<TextBlock Grid.Column="0" Text="Version" />
|
||||
<TextBlock Grid.Column="1" Foreground="{ui:ThemeResource TextFillColorSecondaryBrush}" Text="{Binding AppVersion}"/>
|
||||
</Grid>
|
||||
|
||||
<Separator />
|
||||
|
||||
<TextBlock Margin="16" Text="{Binding AppVersion, StringFormat='Version {0}'}" />
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
</StackPanel>
|
||||
|
||||
@@ -3,6 +3,8 @@ using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
|
||||
using Wpf.Ui.Appearance;
|
||||
|
||||
namespace InvLock;
|
||||
|
||||
public class Settings : INotifyPropertyChanged
|
||||
@@ -12,6 +14,7 @@ public class Settings : INotifyPropertyChanged
|
||||
private static readonly string settingsPath = Path.Combine(App.ApplicationDataPath, "settings.json");
|
||||
private bool hideWindows = false;
|
||||
private string lockText = "Lock Screen Active";
|
||||
private string theme = "Windows default";
|
||||
|
||||
private string unlockText = "Lock Screen Inactive";
|
||||
|
||||
@@ -45,6 +48,30 @@ public class Settings : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
public string Theme
|
||||
{
|
||||
get => theme;
|
||||
set
|
||||
{
|
||||
theme = value;
|
||||
|
||||
if (value == "Windows default")
|
||||
{
|
||||
ApplicationThemeManager.ApplySystemTheme();
|
||||
}
|
||||
else if (value == "Light")
|
||||
{
|
||||
ApplicationThemeManager.Apply(ApplicationTheme.Light);
|
||||
}
|
||||
else if (value == "Dark")
|
||||
{
|
||||
ApplicationThemeManager.Apply(ApplicationTheme.Dark);
|
||||
}
|
||||
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static Settings Load()
|
||||
{
|
||||
if (File.Exists(settingsPath))
|
||||
|
||||
Reference in New Issue
Block a user