diff --git a/App.config b/App.config new file mode 100644 index 0000000..a932b55 --- /dev/null +++ b/App.config @@ -0,0 +1,24 @@ + + + + +
+ + + + + + True + + + True + + + True + + + True + + + + \ No newline at end of file diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 8321bfd..eb50551 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -16,7 +16,7 @@ namespace WpfMaiTouchEmulator; /// 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(); } } \ No newline at end of file diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..57430c3 --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,74 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..c2ef187 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,18 @@ + + + + + + True + + + True + + + True + + + True + + + \ No newline at end of file diff --git a/WpfMaiTouchEmulator.csproj b/WpfMaiTouchEmulator.csproj index 3e11290..67f153a 100644 --- a/WpfMaiTouchEmulator.csproj +++ b/WpfMaiTouchEmulator.csproj @@ -13,4 +13,19 @@ + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + +