Skip to content

Commit

Permalink
Save&Load preferred theme for next launch
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamsyntax committed Jun 18, 2022
1 parent 7f36471 commit 2c10299
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
14 changes: 2 additions & 12 deletions ShadowTH Text Editor/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
using ShadowTH_Text_Editor.Helpers;
using System.Windows;
using System.Windows;

namespace ShadowTH_Text_Editor {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
// TODO: Saved value restoration?
// ThemeHelper.ApplySkin(Skin.Dark);
}
}
public partial class App : Application {}
}
2 changes: 1 addition & 1 deletion ShadowTH Text Editor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ShadowTH_Text_Editor"
mc:Ignorable="d"
x:Name="CoreWindow"
Title="Shadow The Hedgehog Text Editor / FNT Editor v1.5" Height="715" Width="800" MinWidth="600" MinHeight="715" MaxWidth="800" MaxHeight="715" ResizeMode="CanResizeWithGrip" Icon="ShadowFNT.ico" SizeChanged="Window_SizeChanged">
Title="Shadow The Hedgehog Text Editor / FNT Editor v1.5.2" Height="715" Width="800" MinWidth="600" MinHeight="715" MaxWidth="800" MaxHeight="715" ResizeMode="CanResizeWithGrip" Icon="ShadowFNT.ico" SizeChanged="Window_SizeChanged">
<DockPanel>
<StackPanel DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal">
Expand Down
25 changes: 23 additions & 2 deletions ShadowTH Text Editor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public partial class MainWindow : Window {

public MainWindow() {
InitializeComponent();
PreferredThemeCheck();
}

private void Button_SelectFNTSClick(object sender, RoutedEventArgs e) {
Expand Down Expand Up @@ -359,7 +360,7 @@ private void Button_About_Click(object sender, RoutedEventArgs e) {
"Uses VGAudio by Alex Barney for ADX playback\n" +
"Uses modified version of DarkTheme by Otiel\n" +
"Uses Ookii.Dialogs for dialogs\n\n" +
"https://github.com/ShadowTheHedgehogHacking\n\nto check for updates for this software.", "About ShadowTH Text Editor / FNT Editor v1.5");
"https://github.com/ShadowTheHedgehogHacking\n\nto check for updates for this software.", "About ShadowTH Text Editor / FNT Editor v1.5.2");
}

private void ComboBox_LocaleSwitcher_SelectionChanged(object sender, SelectionChangedEventArgs e) {
Expand Down Expand Up @@ -451,13 +452,14 @@ private void CheckBox_DarkMode_Checked(object sender, RoutedEventArgs e)
{
ThemeHelper.ApplySkin(Skin.Dark);
SetGroupBoxBorder(0.1d);

PreferredThemeSave("Dark");
}

private void CheckBox_DarkMode_Unchecked(object sender, RoutedEventArgs e)
{
ThemeHelper.ApplySkin(Skin.Light);
SetGroupBoxBorder(1);
PreferredThemeSave("Light");
}

private void SetGroupBoxBorder(double multiplier)
Expand Down Expand Up @@ -532,5 +534,24 @@ private void Button_ExportChangedFNTsClick(object sender, RoutedEventArgs e) {
}
ClearData();
}

private void PreferredThemeCheck()
{
string themeConfig = AppDomain.CurrentDomain.BaseDirectory + "/theme.ini";
if (File.Exists(themeConfig))
{
foreach (string i in File.ReadAllLines(themeConfig))
{
if (i.StartsWith("Dark"))
CheckBox_DarkMode.IsChecked = true;
}
}
}

private void PreferredThemeSave(string themeName)
{
string themeConfig = AppDomain.CurrentDomain.BaseDirectory + "/theme.ini";
File.WriteAllText(themeConfig, themeName);
}
}
}
2 changes: 1 addition & 1 deletion ShadowTH Text Editor/ShadowTH Text Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>ShadowTH_Text_Editor</RootNamespace>
<UseWPF>true</UseWPF>
<ApplicationIcon>ShadowFNT.ico</ApplicationIcon>
<Version>1.5.0</Version>
<Version>1.5.2</Version>
<Authors>dreamsyntax</Authors>
<Company>ShadowTheHedgehogHacking</Company>
</PropertyGroup>
Expand Down

0 comments on commit 2c10299

Please sign in to comment.