/[RomCheater]/trunk/RomCheater/RomCheaterConfigDialog.cs
ViewVC logotype

Diff of /trunk/RomCheater/RomCheaterConfigDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/RomCheaterConfigDialog.cs	2013/06/17 10:29:30	692
+++ trunk/RomCheater/RomCheaterConfigDialog.cs	2014/04/15 14:52:10	812
@@ -23,6 +23,8 @@
 using RomCheater.Logging;
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
+using RomCheater.UserSettingsSupport;
+using Enterprise.Logging;
 
 
 namespace RomCheater
@@ -33,6 +35,9 @@
         private loggerflags lFlags;
 #endif
 
+        SettingSubscriber MainSettingsSubscriber;
+        SettingSubscriber LoggingettingsSubscriber;
+
         private PluginLoader loader = null;
         public RomCheaterConfigDialog()
         {
@@ -45,6 +50,10 @@
             //    flags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value);
             //    logger.SetLoggingFlags(flags);                
             //}
+            MainSettingsSubscriber = new SettingSubscriber();
+            LoggingettingsSubscriber = new SettingSubscriber();
+            MainSettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default);
+            LoggingettingsSubscriber.AddSubscriber(this, RomCheater.Logging.Properties.Settings.Default);
         }
         public RomCheaterConfigDialog(PluginLoader loader)
             : this()
@@ -53,10 +62,10 @@
         }
         private void RomCheaterConfigDialog_Load(object sender, EventArgs e)
         {
-            logger.Info.WriteLine("Loading user settings...");
+            gLog.Info.WriteLine("Loading user settings...");
             load_loggerflags();
             setup_plugin_entries();
-            logger.Info.WriteLine("Loaded user settings.");
+            gLog.Info.WriteLine("Loaded user settings.");
         }
 
         private void setup_plugin_entries()
@@ -77,7 +86,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin);
+                    gLog.Verbose.Debug.WriteLine("    loading LastConfigPlugin: {0}", MainSettingsSubscriber.GetValue("LastConfigPlugin"));
                     comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -86,7 +95,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastInputPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin);
+                    gLog.Verbose.Debug.WriteLine("    loading LastInputPlugin: {0}", MainSettingsSubscriber.GetValue("LastInputPlugin"));
                     comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -95,7 +104,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin);
+                    gLog.Verbose.Debug.WriteLine("    loading LastWindowPlugin: {0}", MainSettingsSubscriber.GetValue("LastWindowPlugin"));
                     comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -105,9 +114,9 @@
 
         private void load_loggerflags()
         {
-            logger.Info.WriteLine("  Loading logger flags...");
-            loggerflags logflags = Logging.Properties.Settings.Default.LoggingFlags;
-
+            gLog.Info.WriteLine("  Loading logger flags...");
+            object o_flags = LoggingettingsSubscriber.GetValue("LoggingFlags");
+            loggerflags logflags = (ushort)Convert.ChangeType(o_flags, typeof(ushort));
             if (logflags != logger.GetLoggingFlags())
             {
                 logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing)
@@ -154,11 +163,11 @@
             }
             //grpLoggingFlags.AutoSize = true;
             //grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-            logger.Info.WriteLine("  Loaded logger flags.");
+            gLog.Info.WriteLine("  Loaded logger flags.");
         }
         private void btnSave_Click(object sender, EventArgs e)
         {
-            logger.Info.WriteLine("Saving user settings...");
+            gLog.Info.WriteLine("Saving user settings...");
             SaveSettings();
             this.Close();
         }
@@ -170,32 +179,37 @@
         {
             SaveLoggingFlags();
             SaveSelectedPlugins();
-            RomCheater.Properties.Settings.Default.Save();
-            Logging.Properties.Settings.Default.Save();
-            logger.Info.WriteLine("Saved user settings.");
+            MainSettingsSubscriber.SaveSettings();
+            LoggingettingsSubscriber.SaveSettings();
+            //RomCheater.Properties.Settings.Default.Save();
+            //Logging.Properties.Settings.Default.Save();
+            gLog.Info.WriteLine("Saved user settings.");
         }
         private void SaveSelectedPlugins()
         {
-            logger.VerboseDebug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastConfigPlugin = comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString();
-            logger.VerboseDebug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastInputPlugin = comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString();
-            logger.VerboseDebug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastWindowPlugin = comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString();
+            gLog.Verbose.Debug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
+            MainSettingsSubscriber.SetValue("LastConfigPlugin",comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
+
+            gLog.Verbose.Debug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());            
+            MainSettingsSubscriber.SetValue("LastInputPlugin", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
+
+            gLog.Verbose.Debug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());            
+            MainSettingsSubscriber.SetValue("LastWindowPlugin", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
         }
         private void SaveLoggingFlags()
         {
-            logger.Debug.WriteLine("Saving Logger flags...");
+            gLog.Debug.WriteLine("Saving Logger flags...");
             ushort logflags = loggerflags.NONE;
             foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
             {
                 if (!cb.Checked) continue;
                 ushort value = Convert.ToUInt16(cb.Tag);
                 logflags = (ushort)(logflags | value);
-                logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
+                gLog.Verbose.Debug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
             }
-            Logging.Properties.Settings.Default.LoggingFlags = (ushort)logflags;
-            logger.Debug.WriteLine("Saved Logger flags.");
+
+            LoggingettingsSubscriber.SetValue("LoggingFlags", (ushort)logflags);
+            gLog.Debug.WriteLine("Saved Logger flags.");
         }
 
         private void RomCheaterConfigDialog_FormClosing(object sender, FormClosingEventArgs e)

 

  ViewVC Help
Powered by ViewVC 1.1.22