Removing JSON type converter from ear manager.
authorStephaneLenclud
Tue, 16 Aug 2016 12:59:32 +0200
changeset 235ba14a29944c4
parent 234 0c75dec19d39
child 236 6ba20e02d04f
Removing JSON type converter from ear manager.
Using bindings for some application settings.
Server/ConsumerElectronicControl.cs
Server/EarManager.cs
Server/FormMain.Designer.cs
Server/FormMain.cs
Server/Properties/Settings.Designer.cs
Server/Properties/Settings.settings
Server/Settings.cs
Server/SharpDisplayManager.csproj
SharpLibEar/Manager.cs
     1.1 --- a/Server/ConsumerElectronicControl.cs	Tue Aug 16 12:25:20 2016 +0200
     1.2 +++ b/Server/ConsumerElectronicControl.cs	Tue Aug 16 12:59:32 2016 +0200
     1.3 @@ -82,14 +82,14 @@
     1.4          {
     1.5              MonitorPowerOn = true;
     1.6              //Trigger corresponding event thus executing associated actions
     1.7 -            Manager.Current.TriggerEvent<EventMonitorPowerOn>();            
     1.8 +            Properties.Settings.Default.EarManager.TriggerEvent<EventMonitorPowerOn>();            
     1.9          }
    1.10  
    1.11          private void OnMonitorPowerOff()
    1.12          {
    1.13              MonitorPowerOn = false;
    1.14              //Trigger corresponding event thus executing associated actions
    1.15 -            Manager.Current.TriggerEvent<EventMonitorPowerOff>();
    1.16 +            Properties.Settings.Default.EarManager.TriggerEvent<EventMonitorPowerOff>();
    1.17          }
    1.18  
    1.19          /// <summary>
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/Server/EarManager.cs	Tue Aug 16 12:59:32 2016 +0200
     2.3 @@ -0,0 +1,22 @@
     2.4 +using SharpLib.Utils;
     2.5 +using System;
     2.6 +using System.Collections.Generic;
     2.7 +using System.ComponentModel;
     2.8 +using System.Data;
     2.9 +using System.Linq;
    2.10 +using System.Runtime.Serialization;
    2.11 +using System.Text;
    2.12 +using System.Threading.Tasks;
    2.13 +using Ear = SharpLib.Ear;
    2.14 +
    2.15 +namespace SharpDisplayManager
    2.16 +{
    2.17 +    /// <summary>
    2.18 +    /// Allow saving our EAR manager as JSON within our application settings.
    2.19 +    /// </summary>
    2.20 +    [DataContract]
    2.21 +    [TypeConverter(typeof(TypeConverterJson<EarManager>))]
    2.22 +    public class EarManager: Ear.Manager
    2.23 +    {
    2.24 +    }
    2.25 +}
     3.1 --- a/Server/FormMain.Designer.cs	Tue Aug 16 12:25:20 2016 +0200
     3.2 +++ b/Server/FormMain.Designer.cs	Tue Aug 16 12:59:32 2016 +0200
     3.3 @@ -297,13 +297,15 @@
     3.4              // 
     3.5              this.iCheckBoxStartIdleClient.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     3.6              this.iCheckBoxStartIdleClient.AutoSize = true;
     3.7 +            this.iCheckBoxStartIdleClient.Checked = global::SharpDisplayManager.Properties.Settings.Default.StartIdleClient;
     3.8 +            this.iCheckBoxStartIdleClient.CheckState = System.Windows.Forms.CheckState.Checked;
     3.9 +            this.iCheckBoxStartIdleClient.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "StartIdleClient", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.10              this.iCheckBoxStartIdleClient.Location = new System.Drawing.Point(108, 340);
    3.11              this.iCheckBoxStartIdleClient.Name = "iCheckBoxStartIdleClient";
    3.12              this.iCheckBoxStartIdleClient.Size = new System.Drawing.Size(145, 17);
    3.13              this.iCheckBoxStartIdleClient.TabIndex = 22;
    3.14              this.iCheckBoxStartIdleClient.Text = "Start idle client on startup";
    3.15              this.iCheckBoxStartIdleClient.UseVisualStyleBackColor = true;
    3.16 -            this.iCheckBoxStartIdleClient.CheckedChanged += new System.EventHandler(this.checkBoxStartIdleClient_CheckedChanged);
    3.17              // 
    3.18              // iButtonStartIdleClient
    3.19              // 
    3.20 @@ -456,13 +458,14 @@
    3.21              // 
    3.22              this.checkBoxConnectOnStartup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    3.23              this.checkBoxConnectOnStartup.AutoSize = true;
    3.24 +            this.checkBoxConnectOnStartup.Checked = global::SharpDisplayManager.Properties.Settings.Default.DisplayConnectOnStartup;
    3.25 +            this.checkBoxConnectOnStartup.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "DisplayConnectOnStartup", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.26              this.checkBoxConnectOnStartup.Location = new System.Drawing.Point(113, 350);
    3.27              this.checkBoxConnectOnStartup.Name = "checkBoxConnectOnStartup";
    3.28              this.checkBoxConnectOnStartup.Size = new System.Drawing.Size(119, 17);
    3.29              this.checkBoxConnectOnStartup.TabIndex = 13;
    3.30              this.checkBoxConnectOnStartup.Text = "Connect on stratup ";
    3.31              this.checkBoxConnectOnStartup.UseVisualStyleBackColor = true;
    3.32 -            this.checkBoxConnectOnStartup.CheckedChanged += new System.EventHandler(this.checkBoxConnectOnStartup_CheckedChanged);
    3.33              // 
    3.34              // trackBarBrightness
    3.35              // 
    3.36 @@ -950,6 +953,8 @@
    3.37              // checkBoxCecEnabled
    3.38              // 
    3.39              this.checkBoxCecEnabled.AutoSize = true;
    3.40 +            this.checkBoxCecEnabled.Checked = global::SharpDisplayManager.Properties.Settings.Default.CecEnabled;
    3.41 +            this.checkBoxCecEnabled.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "CecEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.42              this.checkBoxCecEnabled.Location = new System.Drawing.Point(6, 6);
    3.43              this.checkBoxCecEnabled.Name = "checkBoxCecEnabled";
    3.44              this.checkBoxCecEnabled.Size = new System.Drawing.Size(83, 17);
    3.45 @@ -1009,13 +1014,14 @@
    3.46              // iCheckBoxHarmonyEnabled
    3.47              // 
    3.48              this.iCheckBoxHarmonyEnabled.AutoSize = true;
    3.49 +            this.iCheckBoxHarmonyEnabled.Checked = global::SharpDisplayManager.Properties.Settings.Default.HarmonyEnabled;
    3.50 +            this.iCheckBoxHarmonyEnabled.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "HarmonyEnabled", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.51              this.iCheckBoxHarmonyEnabled.Location = new System.Drawing.Point(6, 6);
    3.52              this.iCheckBoxHarmonyEnabled.Name = "iCheckBoxHarmonyEnabled";
    3.53              this.iCheckBoxHarmonyEnabled.Size = new System.Drawing.Size(104, 17);
    3.54              this.iCheckBoxHarmonyEnabled.TabIndex = 22;
    3.55              this.iCheckBoxHarmonyEnabled.Text = "Enable Harmony";
    3.56              this.iCheckBoxHarmonyEnabled.UseVisualStyleBackColor = true;
    3.57 -            this.iCheckBoxHarmonyEnabled.CheckedChanged += new System.EventHandler(this.iCheckBoxHarmonyEnabled_CheckedChanged);
    3.58              // 
    3.59              // iTreeViewHarmony
    3.60              // 
    3.61 @@ -1255,25 +1261,27 @@
    3.62              // 
    3.63              this.checkBoxStartMinimized.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    3.64              this.checkBoxStartMinimized.AutoSize = true;
    3.65 +            this.checkBoxStartMinimized.Checked = global::SharpDisplayManager.Properties.Settings.Default.StartMinimized;
    3.66 +            this.checkBoxStartMinimized.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "StartMinimized", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.67              this.checkBoxStartMinimized.Location = new System.Drawing.Point(6, 285);
    3.68              this.checkBoxStartMinimized.Name = "checkBoxStartMinimized";
    3.69              this.checkBoxStartMinimized.Size = new System.Drawing.Size(96, 17);
    3.70              this.checkBoxStartMinimized.TabIndex = 16;
    3.71              this.checkBoxStartMinimized.Text = "Start minimized";
    3.72              this.checkBoxStartMinimized.UseVisualStyleBackColor = true;
    3.73 -            this.checkBoxStartMinimized.CheckedChanged += new System.EventHandler(this.checkBoxStartMinimized_CheckedChanged);
    3.74              // 
    3.75              // checkBoxMinimizeToTray
    3.76              // 
    3.77              this.checkBoxMinimizeToTray.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    3.78              this.checkBoxMinimizeToTray.AutoSize = true;
    3.79 +            this.checkBoxMinimizeToTray.Checked = global::SharpDisplayManager.Properties.Settings.Default.MinimizeToTray;
    3.80 +            this.checkBoxMinimizeToTray.DataBindings.Add(new System.Windows.Forms.Binding("Checked", global::SharpDisplayManager.Properties.Settings.Default, "MinimizeToTray", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
    3.81              this.checkBoxMinimizeToTray.Location = new System.Drawing.Point(6, 308);
    3.82              this.checkBoxMinimizeToTray.Name = "checkBoxMinimizeToTray";
    3.83              this.checkBoxMinimizeToTray.Size = new System.Drawing.Size(133, 17);
    3.84              this.checkBoxMinimizeToTray.TabIndex = 15;
    3.85              this.checkBoxMinimizeToTray.Text = "Minimize to system tray";
    3.86              this.checkBoxMinimizeToTray.UseVisualStyleBackColor = true;
    3.87 -            this.checkBoxMinimizeToTray.CheckedChanged += new System.EventHandler(this.checkBoxMinimizeToTray_CheckedChanged);
    3.88              // 
    3.89              // checkBoxAutoStart
    3.90              // 
     4.1 --- a/Server/FormMain.cs	Tue Aug 16 12:25:20 2016 +0200
     4.2 +++ b/Server/FormMain.cs	Tue Aug 16 12:59:32 2016 +0200
     4.3 @@ -141,18 +141,17 @@
     4.4  
     4.5          public FormMain()
     4.6          {
     4.7 -            Ear.Manager.Current = Properties.Settings.Default.Events;
     4.8 -            if (Ear.Manager.Current == null)
     4.9 +            if (Properties.Settings.Default.EarManager == null)
    4.10              {
    4.11                  //No actions in our settings yet
    4.12 -                Ear.Manager.Current = new Ear.Manager();
    4.13 -                Properties.Settings.Default.Events = Ear.Manager.Current;
    4.14 +                Properties.Settings.Default.EarManager = new EarManager();
    4.15              }
    4.16              else
    4.17              {
    4.18 -                //We loaded actions from our settings
    4.19 -                //We need to hook them with corresponding events
    4.20 -                Ear.Manager.Current.Init();
    4.21 +                // We loaded events and actions from our settings
    4.22 +                // Internalizer apparently skips constructor so we need to initialize it here
    4.23 +                // Though I reckon that should only be needed when loading an empty EAR manager I guess.
    4.24 +                Properties.Settings.Default.EarManager.Init();
    4.25              }
    4.26              iSkipFrameRendering = false;
    4.27              iClosing = false;
    4.28 @@ -329,7 +328,7 @@
    4.29              //Reset our tree
    4.30              iTreeViewEvents.Nodes.Clear();
    4.31              //Populate registered events
    4.32 -            foreach (Ear.Event e in Ear.Manager.Current.Events)
    4.33 +            foreach (Ear.Event e in Properties.Settings.Default.EarManager.Events)
    4.34              {
    4.35                  //Create our event node
    4.36                  TreeNode eventNode = iTreeViewEvents.Nodes.Add(e.Name);
    4.37 @@ -1238,11 +1237,7 @@
    4.38              CheckFontHeight();
    4.39              //Check if "run on Windows startup" is enabled
    4.40              checkBoxAutoStart.Checked = iStartupManager.Startup;
    4.41 -            //
    4.42 -            checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
    4.43 -            checkBoxMinimizeToTray.Checked = Properties.Settings.Default.MinimizeToTray;
    4.44 -            checkBoxStartMinimized.Checked = Properties.Settings.Default.StartMinimized;
    4.45 -            iCheckBoxStartIdleClient.Checked = Properties.Settings.Default.StartIdleClient;
    4.46 +            //            
    4.47              labelStartFileName.Text = Properties.Settings.Default.StartFileName;
    4.48  
    4.49  
    4.50 @@ -1269,11 +1264,9 @@
    4.51              }
    4.52  
    4.53              //Harmony settings
    4.54 -            iCheckBoxHarmonyEnabled.Checked = Properties.Settings.Default.HarmonyEnabled;
    4.55              iTextBoxHarmonyHubAddress.Text = Properties.Settings.Default.HarmonyHubAddress;
    4.56  
    4.57              //CEC settings
    4.58 -            checkBoxCecEnabled.Checked = Properties.Settings.Default.CecEnabled;
    4.59              comboBoxHdmiPort.SelectedIndex = Properties.Settings.Default.CecHdmiPort - 1;
    4.60  
    4.61              //Mini Display settings
    4.62 @@ -1418,34 +1411,6 @@
    4.63              CheckFontHeight();
    4.64          }
    4.65  
    4.66 -        private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
    4.67 -        {
    4.68 -            //Save our connect on startup setting
    4.69 -            Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
    4.70 -            Properties.Settings.Default.Save();
    4.71 -        }
    4.72 -
    4.73 -        private void checkBoxMinimizeToTray_CheckedChanged(object sender, EventArgs e)
    4.74 -        {
    4.75 -            //Save our "Minimize to tray" setting
    4.76 -            Properties.Settings.Default.MinimizeToTray = checkBoxMinimizeToTray.Checked;
    4.77 -            Properties.Settings.Default.Save();
    4.78 -
    4.79 -        }
    4.80 -
    4.81 -        private void checkBoxStartMinimized_CheckedChanged(object sender, EventArgs e)
    4.82 -        {
    4.83 -            //Save our "Start minimized" setting
    4.84 -            Properties.Settings.Default.StartMinimized = checkBoxStartMinimized.Checked;
    4.85 -            Properties.Settings.Default.Save();
    4.86 -        }
    4.87 -
    4.88 -        private void checkBoxStartIdleClient_CheckedChanged(object sender, EventArgs e)
    4.89 -        {
    4.90 -            Properties.Settings.Default.StartIdleClient = iCheckBoxStartIdleClient.Checked;
    4.91 -            Properties.Settings.Default.Save();
    4.92 -        }
    4.93 -
    4.94          private void checkBoxAutoStart_CheckedChanged(object sender, EventArgs e)
    4.95          {
    4.96              iStartupManager.Startup = checkBoxAutoStart.Checked;
    4.97 @@ -2658,9 +2623,6 @@
    4.98  
    4.99          private void checkBoxCecEnabled_CheckedChanged(object sender, EventArgs e)
   4.100          {
   4.101 -            //Save CEC enabled status
   4.102 -            Properties.Settings.Default.CecEnabled = checkBoxCecEnabled.Checked;
   4.103 -            Properties.Settings.Default.Save();
   4.104              //
   4.105              ResetCec();
   4.106          }
   4.107 @@ -2840,8 +2802,7 @@
   4.108              DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
   4.109              if (res == DialogResult.OK)
   4.110              {
   4.111 -                selectedEvent.Actions.Add(ea.Object);
   4.112 -                Properties.Settings.Default.Events = Ear.Manager.Current;
   4.113 +                selectedEvent.Actions.Add(ea.Object);               
   4.114                  Properties.Settings.Default.Save();
   4.115                  PopulateEventsTreeView();
   4.116              }
   4.117 @@ -2872,7 +2833,6 @@
   4.118                  //Update our action
   4.119                  selectedEvent.Actions[actionIndex]=ea.Object;
   4.120                  //Save and rebuild our event tree view
   4.121 -                Properties.Settings.Default.Events = Ear.Manager.Current;
   4.122                  Properties.Settings.Default.Save();
   4.123                  PopulateEventsTreeView();
   4.124              }
   4.125 @@ -2893,8 +2853,7 @@
   4.126                  return;
   4.127              }
   4.128  
   4.129 -            Ear.Manager.Current.RemoveAction(action);
   4.130 -            Properties.Settings.Default.Events = Ear.Manager.Current;
   4.131 +            Properties.Settings.Default.EarManager.RemoveAction(action);
   4.132              Properties.Settings.Default.Save();
   4.133              PopulateEventsTreeView();
   4.134          }
   4.135 @@ -2938,7 +2897,6 @@
   4.136              currentEvent.Actions[currentIndex-1] = movingUp;
   4.137  
   4.138              //Save and populate our tree again
   4.139 -            Properties.Settings.Default.Events = Ear.Manager.Current;
   4.140              Properties.Settings.Default.Save();
   4.141              PopulateEventsTreeView();
   4.142  
   4.143 @@ -2968,7 +2926,6 @@
   4.144              currentEvent.Actions[currentIndex + 1] = movingDown;
   4.145  
   4.146              //Save and populate our tree again
   4.147 -            Properties.Settings.Default.Events = Ear.Manager.Current;
   4.148              Properties.Settings.Default.Save();
   4.149              PopulateEventsTreeView();
   4.150          }
   4.151 @@ -3038,8 +2995,7 @@
   4.152              DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
   4.153              if (res == DialogResult.OK)
   4.154              {
   4.155 -                Ear.Manager.Current.Events.Add(ea.Object);
   4.156 -                Properties.Settings.Default.Events = Ear.Manager.Current;
   4.157 +                Properties.Settings.Default.EarManager.Events.Add(ea.Object);
   4.158                  Properties.Settings.Default.Save();
   4.159                  PopulateEventsTreeView();
   4.160                  SelectEvent(ea.Object);
   4.161 @@ -3055,8 +3011,7 @@
   4.162                  return;
   4.163              }
   4.164  
   4.165 -            Ear.Manager.Current.Events.Remove(currentEvent);
   4.166 -            Properties.Settings.Default.Events = Ear.Manager.Current;
   4.167 +            Properties.Settings.Default.EarManager.Events.Remove(currentEvent);
   4.168              Properties.Settings.Default.Save();
   4.169              PopulateEventsTreeView();
   4.170          }
   4.171 @@ -3078,7 +3033,6 @@
   4.172              if (res == DialogResult.OK)
   4.173              {
   4.174                  //Save and rebuild our event tree view
   4.175 -                Properties.Settings.Default.Events = Ear.Manager.Current;
   4.176                  Properties.Settings.Default.Save();
   4.177                  PopulateEventsTreeView();
   4.178              }
   4.179 @@ -3170,12 +3124,6 @@
   4.180              //treeViewConfig.ExpandAll();
   4.181          }
   4.182  
   4.183 -        private void iCheckBoxHarmonyEnabled_CheckedChanged(object sender, EventArgs e)
   4.184 -        {
   4.185 -            Properties.Settings.Default.HarmonyEnabled = iCheckBoxHarmonyEnabled.Checked;
   4.186 -            Properties.Settings.Default.Save();
   4.187 -        }
   4.188 -
   4.189          private async void iTreeViewHarmony_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
   4.190          {
   4.191              //Upon function node double click we execute it
     5.1 --- a/Server/Properties/Settings.Designer.cs	Tue Aug 16 12:25:20 2016 +0200
     5.2 +++ b/Server/Properties/Settings.Designer.cs	Tue Aug 16 12:59:32 2016 +0200
     5.3 @@ -156,12 +156,12 @@
     5.4          
     5.5          [global::System.Configuration.UserScopedSettingAttribute()]
     5.6          [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     5.7 -        public global::SharpLib.Ear.Manager Events {
     5.8 +        public global::SharpDisplayManager.EarManager EarManager {
     5.9              get {
    5.10 -                return ((global::SharpLib.Ear.Manager)(this["Events"]));
    5.11 +                return ((global::SharpDisplayManager.EarManager)(this["EarManager"]));
    5.12              }
    5.13              set {
    5.14 -                this["Events"] = value;
    5.15 +                this["EarManager"] = value;
    5.16              }
    5.17          }
    5.18          
     6.1 --- a/Server/Properties/Settings.settings	Tue Aug 16 12:25:20 2016 +0200
     6.2 +++ b/Server/Properties/Settings.settings	Tue Aug 16 12:59:32 2016 +0200
     6.3 @@ -35,7 +35,7 @@
     6.4      <Setting Name="StartIdleClient" Type="System.Boolean" Scope="User">
     6.5        <Value Profile="(Default)">True</Value>
     6.6      </Setting>
     6.7 -    <Setting Name="Events" Type="SharpLib.Ear.Manager" Scope="User">
     6.8 +    <Setting Name="EarManager" Type="SharpDisplayManager.EarManager" Scope="User">
     6.9        <Value Profile="(Default)" />
    6.10      </Setting>
    6.11      <Setting Name="HarmonyEnabled" Type="System.Boolean" Scope="User">
     7.1 --- a/Server/Settings.cs	Tue Aug 16 12:25:20 2016 +0200
     7.2 +++ b/Server/Settings.cs	Tue Aug 16 12:59:32 2016 +0200
     7.3 @@ -17,6 +17,8 @@
     7.4  // along with SharpDisplayManager.  If not, see <http://www.gnu.org/licenses/>.
     7.5  //
     7.6  
     7.7 +using System;
     7.8 +
     7.9  namespace SharpDisplayManager.Properties {
    7.10      
    7.11      
    7.12 @@ -30,18 +32,34 @@
    7.13          public Settings() : base("default") {
    7.14              // // To add event handlers for saving and changing settings, uncomment the lines below:
    7.15              //
    7.16 -            // this.SettingChanging += this.SettingChangingEventHandler;
    7.17 +             this.SettingChanging += this.SettingChangingEventHandler;
    7.18              //
    7.19 -            // this.SettingsSaving += this.SettingsSavingEventHandler;
    7.20 +             this.SettingsSaving += this.SettingsSavingEventHandler;
    7.21              //
    7.22 +            this.SettingsLoaded += this.SettingsLoadedEventHandler;
    7.23 +            //
    7.24 +            this.PropertyChanged += this.PropertyChangedEventHandler;
    7.25          }
    7.26 -        
    7.27 +
    7.28 +        private void PropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    7.29 +        {
    7.30 +            Console.WriteLine($"Settings: property changed {e.PropertyName}");
    7.31 +            Default.Save();
    7.32 +        }
    7.33 +
    7.34          private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
    7.35              // Add code to handle the SettingChangingEvent event here.
    7.36 +            Console.WriteLine($"Settings: changing {e.SettingKey}.{e.SettingName}");
    7.37          }
    7.38 -        
    7.39 +
    7.40 +        private void SettingsLoadedEventHandler(object sender, System.Configuration.SettingsLoadedEventArgs e)
    7.41 +        {
    7.42 +            Console.WriteLine($"Settings: loaded {e.Provider.ApplicationName}");
    7.43 +        }
    7.44 +
    7.45          private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
    7.46              // Add code to handle the SettingsSaving event here.
    7.47 +            Console.WriteLine("Settings: saving");
    7.48          }
    7.49      }
    7.50  }
     8.1 --- a/Server/SharpDisplayManager.csproj	Tue Aug 16 12:25:20 2016 +0200
     8.2 +++ b/Server/SharpDisplayManager.csproj	Tue Aug 16 12:59:32 2016 +0200
     8.3 @@ -177,6 +177,7 @@
     8.4      <Compile Include="CecClient.cs" />
     8.5      <Compile Include="ConsumerElectronicControl.cs" />
     8.6      <Compile Include="ClientData.cs" />
     8.7 +    <Compile Include="EarManager.cs" />
     8.8      <Compile Include="FormEditObject.cs">
     8.9        <SubType>Form</SubType>
    8.10      </Compile>
    8.11 @@ -248,6 +249,7 @@
    8.12      <None Include="Properties\Settings.settings">
    8.13        <Generator>SettingsSingleFileGenerator</Generator>
    8.14        <LastGenOutput>Settings.Designer.cs</LastGenOutput>
    8.15 +      <SubType>Designer</SubType>
    8.16      </None>
    8.17      <Compile Include="Properties\Settings.Designer.cs">
    8.18        <AutoGen>True</AutoGen>
     9.1 --- a/SharpLibEar/Manager.cs	Tue Aug 16 12:25:20 2016 +0200
     9.2 +++ b/SharpLibEar/Manager.cs	Tue Aug 16 12:59:32 2016 +0200
     9.3 @@ -7,22 +7,18 @@
     9.4  using System.Runtime.Serialization;
     9.5  using SharpLib.Utils;
     9.6  
     9.7 +
     9.8  namespace SharpLib.Ear
     9.9  {
    9.10      /// <summary>
    9.11      /// Event Action Router (Ear) is a generic and extensible framework allowing users to execute actions in response to events. 
    9.12      /// Users can implement their own events and actions.
    9.13      /// </summary>
    9.14 -    [TypeConverter(typeof(TypeConverterJson<Manager>))]
    9.15      [DataContract]
    9.16 +    [KnownType("DerivedTypes")]
    9.17      public class Manager
    9.18      {
    9.19          /// <summary>
    9.20 -        /// Access the currently installed EAR manager. 
    9.21 -        /// </summary>
    9.22 -        public static Manager Current = null;
    9.23 -
    9.24 -        /// <summary>
    9.25          /// Our events instances.
    9.26          /// </summary>
    9.27          [DataMember]
    9.28 @@ -77,5 +73,15 @@
    9.29                  }
    9.30              }
    9.31          }
    9.32 +
    9.33 +        /// <summary>
    9.34 +        /// Allow extending our data contract.
    9.35 +        /// See KnownType above.
    9.36 +        /// </summary>
    9.37 +        /// <returns></returns>
    9.38 +        private static IEnumerable<Type> DerivedTypes()
    9.39 +        {
    9.40 +            return SharpLib.Utils.Reflection.GetDerivedTypes<Manager>();
    9.41 +        }
    9.42      }
    9.43  }
    9.44 \ No newline at end of file