Add persistent storage for settings
parent
00539be873
commit
d97eeafdcb
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="WpfMaiTouchEmulator.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<WpfMaiTouchEmulator.Properties.Settings>
|
||||
<setting name="IsDebugEnabled" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="IsAutomaticPositioningEnabled" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="IsAutomaticPortConnectingEnabled" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="IsExitWithSinmaiEnabled" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</WpfMaiTouchEmulator.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
|
@ -16,7 +16,7 @@ namespace WpfMaiTouchEmulator;
|
|||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private MaiTouchSensorButtonStateManager buttonState;
|
||||
private readonly MaiTouchSensorButtonStateManager buttonState;
|
||||
private MaiTouchComConnector connector;
|
||||
private readonly TouchPanel _touchPanel;
|
||||
|
||||
|
@ -48,8 +48,16 @@ public partial class MainWindow : Window
|
|||
_touchPanel.onTouch = (value) => { buttonState.PressButton(value); };
|
||||
_touchPanel.onRelease = (value) => { buttonState.ReleaseButton(value); };
|
||||
_touchPanel.Show();
|
||||
_touchPanel.SetDebugMode(true);
|
||||
DataContext = new MainWindowViewModel() { IsDebugEnabled = true, IsAutomaticPortConnectingEnabled = true, IsAutomaticPositioningEnabled = true, IsExitWithSinmaiEnabled = true };
|
||||
DataContext = new MainWindowViewModel()
|
||||
{
|
||||
IsDebugEnabled = Properties.Settings.Default.IsDebugEnabled,
|
||||
IsAutomaticPortConnectingEnabled = Properties.Settings.Default.IsAutomaticPortConnectingEnabled,
|
||||
IsAutomaticPositioningEnabled = Properties.Settings.Default.IsAutomaticPositioningEnabled,
|
||||
IsExitWithSinmaiEnabled = Properties.Settings.Default.IsExitWithSinmaiEnabled
|
||||
};
|
||||
|
||||
var dataContext = (MainWindowViewModel)DataContext;
|
||||
_touchPanel.SetDebugMode(dataContext.IsDebugEnabled);
|
||||
AutomaticTouchPanelPositioningLoop();
|
||||
ExitWithSinmaiLoop();
|
||||
}
|
||||
|
@ -100,6 +108,8 @@ public partial class MainWindow : Window
|
|||
var dataContext = (MainWindowViewModel)DataContext;
|
||||
var enabled = !dataContext.IsDebugEnabled;
|
||||
dataContext.IsDebugEnabled = !enabled;
|
||||
Properties.Settings.Default.IsDebugEnabled = dataContext.IsDebugEnabled;
|
||||
Properties.Settings.Default.Save();
|
||||
_touchPanel.SetDebugMode(dataContext.IsDebugEnabled);
|
||||
}
|
||||
|
||||
|
@ -108,6 +118,8 @@ public partial class MainWindow : Window
|
|||
var dataContext = (MainWindowViewModel)DataContext;
|
||||
var enabled = !dataContext.IsAutomaticPositioningEnabled;
|
||||
dataContext.IsAutomaticPositioningEnabled = !enabled;
|
||||
Properties.Settings.Default.IsAutomaticPositioningEnabled = enabled;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void automaticPortConnecting_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -115,6 +127,8 @@ public partial class MainWindow : Window
|
|||
var dataContext = (MainWindowViewModel)DataContext;
|
||||
var enabled = !dataContext.IsAutomaticPortConnectingEnabled;
|
||||
dataContext.IsAutomaticPortConnectingEnabled = !enabled;
|
||||
Properties.Settings.Default.IsAutomaticPortConnectingEnabled = dataContext.IsAutomaticPortConnectingEnabled;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
private void exitWithSinmai_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -122,5 +136,7 @@ public partial class MainWindow : Window
|
|||
var dataContext = (MainWindowViewModel)DataContext;
|
||||
var enabled = !dataContext.IsExitWithSinmaiEnabled;
|
||||
dataContext.IsExitWithSinmaiEnabled = !enabled;
|
||||
Properties.Settings.Default.IsExitWithSinmaiEnabled = dataContext.IsExitWithSinmaiEnabled;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WpfMaiTouchEmulator.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsDebugEnabled {
|
||||
get {
|
||||
return ((bool)(this["IsDebugEnabled"]));
|
||||
}
|
||||
set {
|
||||
this["IsDebugEnabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsAutomaticPositioningEnabled {
|
||||
get {
|
||||
return ((bool)(this["IsAutomaticPositioningEnabled"]));
|
||||
}
|
||||
set {
|
||||
this["IsAutomaticPositioningEnabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsAutomaticPortConnectingEnabled {
|
||||
get {
|
||||
return ((bool)(this["IsAutomaticPortConnectingEnabled"]));
|
||||
}
|
||||
set {
|
||||
this["IsAutomaticPortConnectingEnabled"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsExitWithSinmaiEnabled {
|
||||
get {
|
||||
return ((bool)(this["IsExitWithSinmaiEnabled"]));
|
||||
}
|
||||
set {
|
||||
this["IsExitWithSinmaiEnabled"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WpfMaiTouchEmulator.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="IsDebugEnabled" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="IsAutomaticPositioningEnabled" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="IsAutomaticPortConnectingEnabled" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="IsExitWithSinmaiEnabled" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
|
@ -13,4 +13,19 @@
|
|||
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue