1.1 --- a/Server/FormMain.cs Tue Aug 16 12:25:20 2016 +0200
1.2 +++ b/Server/FormMain.cs Tue Aug 16 12:59:32 2016 +0200
1.3 @@ -141,18 +141,17 @@
1.4
1.5 public FormMain()
1.6 {
1.7 - Ear.Manager.Current = Properties.Settings.Default.Events;
1.8 - if (Ear.Manager.Current == null)
1.9 + if (Properties.Settings.Default.EarManager == null)
1.10 {
1.11 //No actions in our settings yet
1.12 - Ear.Manager.Current = new Ear.Manager();
1.13 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.14 + Properties.Settings.Default.EarManager = new EarManager();
1.15 }
1.16 else
1.17 {
1.18 - //We loaded actions from our settings
1.19 - //We need to hook them with corresponding events
1.20 - Ear.Manager.Current.Init();
1.21 + // We loaded events and actions from our settings
1.22 + // Internalizer apparently skips constructor so we need to initialize it here
1.23 + // Though I reckon that should only be needed when loading an empty EAR manager I guess.
1.24 + Properties.Settings.Default.EarManager.Init();
1.25 }
1.26 iSkipFrameRendering = false;
1.27 iClosing = false;
1.28 @@ -329,7 +328,7 @@
1.29 //Reset our tree
1.30 iTreeViewEvents.Nodes.Clear();
1.31 //Populate registered events
1.32 - foreach (Ear.Event e in Ear.Manager.Current.Events)
1.33 + foreach (Ear.Event e in Properties.Settings.Default.EarManager.Events)
1.34 {
1.35 //Create our event node
1.36 TreeNode eventNode = iTreeViewEvents.Nodes.Add(e.Name);
1.37 @@ -1238,11 +1237,7 @@
1.38 CheckFontHeight();
1.39 //Check if "run on Windows startup" is enabled
1.40 checkBoxAutoStart.Checked = iStartupManager.Startup;
1.41 - //
1.42 - checkBoxConnectOnStartup.Checked = Properties.Settings.Default.DisplayConnectOnStartup;
1.43 - checkBoxMinimizeToTray.Checked = Properties.Settings.Default.MinimizeToTray;
1.44 - checkBoxStartMinimized.Checked = Properties.Settings.Default.StartMinimized;
1.45 - iCheckBoxStartIdleClient.Checked = Properties.Settings.Default.StartIdleClient;
1.46 + //
1.47 labelStartFileName.Text = Properties.Settings.Default.StartFileName;
1.48
1.49
1.50 @@ -1269,11 +1264,9 @@
1.51 }
1.52
1.53 //Harmony settings
1.54 - iCheckBoxHarmonyEnabled.Checked = Properties.Settings.Default.HarmonyEnabled;
1.55 iTextBoxHarmonyHubAddress.Text = Properties.Settings.Default.HarmonyHubAddress;
1.56
1.57 //CEC settings
1.58 - checkBoxCecEnabled.Checked = Properties.Settings.Default.CecEnabled;
1.59 comboBoxHdmiPort.SelectedIndex = Properties.Settings.Default.CecHdmiPort - 1;
1.60
1.61 //Mini Display settings
1.62 @@ -1418,34 +1411,6 @@
1.63 CheckFontHeight();
1.64 }
1.65
1.66 - private void checkBoxConnectOnStartup_CheckedChanged(object sender, EventArgs e)
1.67 - {
1.68 - //Save our connect on startup setting
1.69 - Properties.Settings.Default.DisplayConnectOnStartup = checkBoxConnectOnStartup.Checked;
1.70 - Properties.Settings.Default.Save();
1.71 - }
1.72 -
1.73 - private void checkBoxMinimizeToTray_CheckedChanged(object sender, EventArgs e)
1.74 - {
1.75 - //Save our "Minimize to tray" setting
1.76 - Properties.Settings.Default.MinimizeToTray = checkBoxMinimizeToTray.Checked;
1.77 - Properties.Settings.Default.Save();
1.78 -
1.79 - }
1.80 -
1.81 - private void checkBoxStartMinimized_CheckedChanged(object sender, EventArgs e)
1.82 - {
1.83 - //Save our "Start minimized" setting
1.84 - Properties.Settings.Default.StartMinimized = checkBoxStartMinimized.Checked;
1.85 - Properties.Settings.Default.Save();
1.86 - }
1.87 -
1.88 - private void checkBoxStartIdleClient_CheckedChanged(object sender, EventArgs e)
1.89 - {
1.90 - Properties.Settings.Default.StartIdleClient = iCheckBoxStartIdleClient.Checked;
1.91 - Properties.Settings.Default.Save();
1.92 - }
1.93 -
1.94 private void checkBoxAutoStart_CheckedChanged(object sender, EventArgs e)
1.95 {
1.96 iStartupManager.Startup = checkBoxAutoStart.Checked;
1.97 @@ -2658,9 +2623,6 @@
1.98
1.99 private void checkBoxCecEnabled_CheckedChanged(object sender, EventArgs e)
1.100 {
1.101 - //Save CEC enabled status
1.102 - Properties.Settings.Default.CecEnabled = checkBoxCecEnabled.Checked;
1.103 - Properties.Settings.Default.Save();
1.104 //
1.105 ResetCec();
1.106 }
1.107 @@ -2840,8 +2802,7 @@
1.108 DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
1.109 if (res == DialogResult.OK)
1.110 {
1.111 - selectedEvent.Actions.Add(ea.Object);
1.112 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.113 + selectedEvent.Actions.Add(ea.Object);
1.114 Properties.Settings.Default.Save();
1.115 PopulateEventsTreeView();
1.116 }
1.117 @@ -2872,7 +2833,6 @@
1.118 //Update our action
1.119 selectedEvent.Actions[actionIndex]=ea.Object;
1.120 //Save and rebuild our event tree view
1.121 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.122 Properties.Settings.Default.Save();
1.123 PopulateEventsTreeView();
1.124 }
1.125 @@ -2893,8 +2853,7 @@
1.126 return;
1.127 }
1.128
1.129 - Ear.Manager.Current.RemoveAction(action);
1.130 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.131 + Properties.Settings.Default.EarManager.RemoveAction(action);
1.132 Properties.Settings.Default.Save();
1.133 PopulateEventsTreeView();
1.134 }
1.135 @@ -2938,7 +2897,6 @@
1.136 currentEvent.Actions[currentIndex-1] = movingUp;
1.137
1.138 //Save and populate our tree again
1.139 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.140 Properties.Settings.Default.Save();
1.141 PopulateEventsTreeView();
1.142
1.143 @@ -2968,7 +2926,6 @@
1.144 currentEvent.Actions[currentIndex + 1] = movingDown;
1.145
1.146 //Save and populate our tree again
1.147 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.148 Properties.Settings.Default.Save();
1.149 PopulateEventsTreeView();
1.150 }
1.151 @@ -3038,8 +2995,7 @@
1.152 DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
1.153 if (res == DialogResult.OK)
1.154 {
1.155 - Ear.Manager.Current.Events.Add(ea.Object);
1.156 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.157 + Properties.Settings.Default.EarManager.Events.Add(ea.Object);
1.158 Properties.Settings.Default.Save();
1.159 PopulateEventsTreeView();
1.160 SelectEvent(ea.Object);
1.161 @@ -3055,8 +3011,7 @@
1.162 return;
1.163 }
1.164
1.165 - Ear.Manager.Current.Events.Remove(currentEvent);
1.166 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.167 + Properties.Settings.Default.EarManager.Events.Remove(currentEvent);
1.168 Properties.Settings.Default.Save();
1.169 PopulateEventsTreeView();
1.170 }
1.171 @@ -3078,7 +3033,6 @@
1.172 if (res == DialogResult.OK)
1.173 {
1.174 //Save and rebuild our event tree view
1.175 - Properties.Settings.Default.Events = Ear.Manager.Current;
1.176 Properties.Settings.Default.Save();
1.177 PopulateEventsTreeView();
1.178 }
1.179 @@ -3170,12 +3124,6 @@
1.180 //treeViewConfig.ExpandAll();
1.181 }
1.182
1.183 - private void iCheckBoxHarmonyEnabled_CheckedChanged(object sender, EventArgs e)
1.184 - {
1.185 - Properties.Settings.Default.HarmonyEnabled = iCheckBoxHarmonyEnabled.Checked;
1.186 - Properties.Settings.Default.Save();
1.187 - }
1.188 -
1.189 private async void iTreeViewHarmony_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
1.190 {
1.191 //Upon function node double click we execute it