Skip to content

Commit

Permalink
Add migrating user settings for installer
Browse files Browse the repository at this point in the history
  • Loading branch information
Leapward-Koex committed Nov 19, 2024
1 parent f239e9b commit f39fead
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<setting name="BorderColour" serializeAs="String">
<value />
</setting>
<setting name="UserSettingsUpgradeRequired" serializeAs="String">
<value>True</value>
</setting>
</WpfMaiTouchEmulator.Properties.Settings>
</userSettings>
</configuration>
13 changes: 13 additions & 0 deletions 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();
CheckForUserSettingsUpgrade();
DataContext = new MainWindowViewModel()
{
IsDebugEnabled = Properties.Settings.Default.IsDebugEnabled,
Expand Down Expand Up @@ -154,6 +155,18 @@ private async void ExitWithSinmaiLoop()
}
}

private static void CheckForUserSettingsUpgrade()
{
if (!Properties.Settings.Default.UserSettingsUpgradeRequired)
{
return;
}

Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UserSettingsUpgradeRequired = false;
Properties.Settings.Default.Save();
}

private void ShowSetupInstructionsDialog()
{
var dataContext = (MainWindowViewModel)DataContext;
Expand Down
12 changes: 12 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
<Setting Name="BorderColour" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UserSettingsUpgradeRequired" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit f39fead

Please sign in to comment.