-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Settings window, to optionally change the default file path for F…
…avorites
- Loading branch information
Showing
14 changed files
with
189 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Leosac.WpfApp; | ||
|
||
namespace Leosac.KeyManager.Library.UI | ||
{ | ||
public class KMSettings : PermanentConfig<KMSettings> | ||
{ | ||
private string? _favoritesPath; | ||
public string? FavoritesPath | ||
{ | ||
get => _favoritesPath; | ||
set => SetProperty(ref _favoritesPath, value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<Window x:Class="Leosac.KeyManager.SettingsWindow" | ||
xmlns="http:https://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:libui="clr-namespace:Leosac.KeyManager.Library.UI;assembly=KeyManager.Library.UI" | ||
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:Leosac.KeyManager" | ||
xmlns:materialDesign="http:https://materialdesigninxaml.net/winfx/xaml/themes" | ||
xmlns:properties="clr-namespace:Leosac.KeyManager.Properties" | ||
mc:Ignorable="d" | ||
d:DataContext="{d:DesignInstance libui:KMSettings}" | ||
TextElement.Foreground="{DynamicResource MaterialDesignBody}" | ||
TextElement.FontWeight="Regular" | ||
TextElement.FontSize="11" | ||
TextOptions.TextFormattingMode="Ideal" | ||
TextOptions.TextRenderingMode="Auto" | ||
Background="{DynamicResource MaterialDesignPaper}" | ||
FontFamily="{DynamicResource MaterialDesignFont}" | ||
Title="Settings" Height="450" Width="800" | ||
Closing="Window_Closing"> | ||
<DockPanel LastChildFill="True"> | ||
<WrapPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right" Margin="5,5,50,5"> | ||
<Button Content="{x:Static properties:Resources.Close}" Width="200" IsDefault="True" x:Name="btnClose" Click="BtnClose_Click" /> | ||
</WrapPanel> | ||
<Grid> | ||
<TabControl> | ||
<TabItem Header="{x:Static properties:Resources.General}"> | ||
<StackPanel> | ||
<DockPanel LastChildFill="True"> | ||
<Button Content="{x:Static properties:Resources.Browse}" Click="Browse_Click" DockPanel.Dock="Right" Margin="5" /> | ||
<TextBox Text="{Binding FavoritesPath}" Margin="5,5,5,15" | ||
materialDesign:HintAssist.HelperText="{x:Static properties:Resources.FavoritesPathHelper}" | ||
materialDesign:HintAssist.Hint="{x:Static properties:Resources.FavoritesPath}"/> | ||
</DockPanel> | ||
</StackPanel> | ||
</TabItem> | ||
</TabControl> | ||
</Grid> | ||
</DockPanel> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Leosac.KeyManager.Library.UI; | ||
using Microsoft.Win32; | ||
using System.Windows; | ||
|
||
namespace Leosac.KeyManager | ||
{ | ||
/// <summary> | ||
/// Interaction logic for SettingsWindow.xaml | ||
/// </summary> | ||
public partial class SettingsWindow : Window | ||
{ | ||
public SettingsWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) | ||
{ | ||
if (DataContext is KMSettings settings) | ||
{ | ||
settings.SaveToFile(); | ||
} | ||
} | ||
|
||
private void BtnClose_Click(object sender, RoutedEventArgs e) | ||
{ | ||
this.Close(); | ||
} | ||
|
||
private void Browse_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var ofd = new OpenFileDialog(); | ||
ofd.Filter = "JSON files (*.json)|*.json"; | ||
ofd.CheckFileExists = false; | ||
if (ofd.ShowDialog() == true && DataContext is KMSettings settings) | ||
{ | ||
settings.FavoritesPath = ofd.FileName; | ||
} | ||
} | ||
} | ||
} |