cec-config-gui: open the connection in the background thread
[deb_libcec.git] / src / cec-config-gui / CecConfigGUI.cs
CommitLineData
006b76b9
LOK
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using System.Threading;
9using CecSharp;
10using CecConfigGui.actions;
11using System.Globalization;
12using System.IO;
4555ed72 13using System.Xml;
006b76b9
LOK
14
15namespace CecConfigGui
16{
5de1dde4
LOK
17 internal enum ConfigTab
18 {
19 Configuration,
20 KeyConfiguration,
21 Tester,
22 Log
23 }
24
75af24f1 25 public partial class CecConfigGUI : AsyncForm
006b76b9
LOK
26 {
27 public CecConfigGUI()
28 {
29 Config = new LibCECConfiguration();
30 Config.DeviceTypes.Types[0] = CecDeviceType.RecordingDevice;
31 Config.DeviceName = "CEC Config";
32 Config.GetSettingsFromROM = true;
33 Config.ClientVersion = CecClientVersion.Version1_5_0;
34 Callbacks = new CecCallbackWrapper(this);
35 Config.SetCallbacks(Callbacks);
4555ed72 36 LoadXMLConfiguration(ref Config);
006b76b9
LOK
37 Lib = new LibCecSharp(Config);
38
4555ed72 39 InitializeComponent();
8674df6a
LOK
40 LoadButtonConfiguration();
41
4555ed72 42 ActiveProcess = new ConnectToDevice(ref Lib, Config);
006b76b9
LOK
43 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
44 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
45 }
46
4555ed72
LOK
47 private bool LoadXMLConfiguration(ref LibCECConfiguration config)
48 {
49 bool gotConfig = false;
50 string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
51 string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
52 string file = defaultDir + @"\usb_2548_1001.xml";
53 if (File.Exists(xbmcDir + @"\usb_2548_1001.xml"))
54 file = xbmcDir + @"\usb_2548_1001.xml";
55
56 if (File.Exists(file))
57 {
58 XmlTextReader reader = new XmlTextReader(file);
59 while (reader.Read())
60 {
61 gotConfig = true;
62 switch (reader.NodeType)
63 {
64 case XmlNodeType.Element:
65 if (reader.Name.ToLower() == "setting")
66 {
67 string name = string.Empty;
68 string value = string.Empty;
69
70 while (reader.MoveToNextAttribute())
71 {
72 if (reader.Name.ToLower().Equals("id"))
73 name = reader.Value.ToLower();
74 if (reader.Name.ToLower().Equals("value"))
75 value = reader.Value;
76 }
77
78 switch (name)
79 {
80 case "cec_hdmi_port":
81 {
82 byte iPort;
83 if (byte.TryParse(value, out iPort))
84 config.HDMIPort = iPort;
85 }
86 break;
87 case "connected_device":
88 {
89 ushort iDevice;
90 if (ushort.TryParse(value, out iDevice))
91 config.BaseDevice = (CecLogicalAddress)iDevice;
92 }
93 break;
75af24f1
LOK
94 case "cec_power_on_startup":
95 if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
96 {
97 config.ActivateSource = true;
98 config.WakeDevices.Set(CecLogicalAddress.Tv);
99 }
100 break;
101 case "cec_power_off_shutdown":
102 if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
103 config.PowerOffDevices.Set(CecLogicalAddress.Broadcast);
104 break;
105 case "cec_standby_screensaver":
106 config.PowerOffScreensaver = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
107 break;
108 case "standby_pc_on_tv_standby":
109 config.PowerOffOnStandby = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
110 break;
111 case "use_tv_menu_language":
112 config.UseTVMenuLanguage = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
113 break;
114 // 1.5.0+ settings
4555ed72
LOK
115 case "physical_address":
116 {
117 ushort physicalAddress = 0;
118 if (ushort.TryParse(value, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
119 config.PhysicalAddress = physicalAddress;
120 }
121 break;
122 case "device_type":
123 {
124 ushort iType;
125 if (ushort.TryParse(value, out iType))
126 config.DeviceTypes.Types[0] = (CecDeviceType)iType;
127 }
128 break;
75af24f1
LOK
129 case "tv_vendor":
130 {
131 UInt64 iVendor;
132 if (UInt64.TryParse(value, out iVendor))
133 config.TvVendor = (CecVendorId)iVendor;
134 }
4555ed72 135 break;
75af24f1
LOK
136 case "wake_devices":
137 {
138 config.WakeDevices.Clear();
139 string[] split = value.Split(new char[] { ' ' });
140 foreach (string dev in split)
141 {
142 byte iLogicalAddress;
143 if (byte.TryParse(dev, out iLogicalAddress))
144 config.WakeDevices.Set((CecLogicalAddress)iLogicalAddress);
145 }
146 }
4555ed72 147 break;
75af24f1
LOK
148 case "standby_devices":
149 {
150 config.PowerOffDevices.Clear();
151 string[] split = value.Split(new char[] { ' ' });
152 foreach (string dev in split)
153 {
154 byte iLogicalAddress;
155 if (byte.TryParse(dev, out iLogicalAddress))
156 config.PowerOffDevices.Set((CecLogicalAddress)iLogicalAddress);
157 }
158 }
4555ed72
LOK
159 break;
160 case "enabled":
161 break;
162 case "port":
163 //TODO
164 break;
165 default:
166 break;
167 }
168 }
169 break;
170 default:
171 break;
172 }
173 }
174 }
175 return gotConfig;
176 }
177
8674df6a
LOK
178 private void LoadButtonConfiguration()
179 {
180 //TODO load the real configuration
181 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select", (new CecSharp.CecKeypress() { Keycode = 0x00 }), string.Empty));
182 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Up", (new CecSharp.CecKeypress() { Keycode = 0x01 }), string.Empty));
183 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Down", (new CecSharp.CecKeypress() { Keycode = 0x02 }), string.Empty));
184 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left", (new CecSharp.CecKeypress() { Keycode = 0x03 }), string.Empty));
185 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right", (new CecSharp.CecKeypress() { Keycode = 0x04 }), string.Empty));
186 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Up", (new CecSharp.CecKeypress() { Keycode = 0x05 }), string.Empty));
187 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Down", (new CecSharp.CecKeypress() { Keycode = 0x06 }), string.Empty));
188 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Up", (new CecSharp.CecKeypress() { Keycode = 0x07 }), string.Empty));
189 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Down", (new CecSharp.CecKeypress() { Keycode = 0x08 }), string.Empty));
190 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Root menu", (new CecSharp.CecKeypress() { Keycode = 0x09 }), string.Empty));
191 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Setup menu", (new CecSharp.CecKeypress() { Keycode = 0x0A }), string.Empty));
192 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Contents menu", (new CecSharp.CecKeypress() { Keycode = 0x0B }), string.Empty));
193 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Favourite menu", (new CecSharp.CecKeypress() { Keycode = 0x0C }), string.Empty));
194 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Exit", (new CecSharp.CecKeypress() { Keycode = 0x0D }), string.Empty));
195 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("0", (new CecSharp.CecKeypress() { Keycode = 0x20 }), string.Empty));
196 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("1", (new CecSharp.CecKeypress() { Keycode = 0x21 }), string.Empty));
197 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("2", (new CecSharp.CecKeypress() { Keycode = 0x22 }), string.Empty));
198 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("3", (new CecSharp.CecKeypress() { Keycode = 0x23 }), string.Empty));
199 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("4", (new CecSharp.CecKeypress() { Keycode = 0x24 }), string.Empty));
200 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("5", (new CecSharp.CecKeypress() { Keycode = 0x25 }), string.Empty));
201 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("6", (new CecSharp.CecKeypress() { Keycode = 0x26 }), string.Empty));
202 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("7", (new CecSharp.CecKeypress() { Keycode = 0x27 }), string.Empty));
203 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("8", (new CecSharp.CecKeypress() { Keycode = 0x28 }), string.Empty));
204 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("9", (new CecSharp.CecKeypress() { Keycode = 0x29 }), string.Empty));
205 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem(".", (new CecSharp.CecKeypress() { Keycode = 0x2A }), string.Empty));
206 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Enter", (new CecSharp.CecKeypress() { Keycode = 0x2B }), string.Empty));
207 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Clear", (new CecSharp.CecKeypress() { Keycode = 0x2C }), string.Empty));
208 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Next favourite", (new CecSharp.CecKeypress() { Keycode = 0x2F }), string.Empty));
209 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel up", (new CecSharp.CecKeypress() { Keycode = 0x30 }), string.Empty));
210 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel down", (new CecSharp.CecKeypress() { Keycode = 0x31 }), string.Empty));
211 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Previous channel", (new CecSharp.CecKeypress() { Keycode = 0x32 }), string.Empty));
212 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sound select", (new CecSharp.CecKeypress() { Keycode = 0x33 }), string.Empty));
213 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Input select", (new CecSharp.CecKeypress() { Keycode = 0x34 }), string.Empty));
214 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Display information", (new CecSharp.CecKeypress() { Keycode = 0x35 }), string.Empty));
215 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Help", (new CecSharp.CecKeypress() { Keycode = 0x36 }), string.Empty));
216 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page up", (new CecSharp.CecKeypress() { Keycode = 0x37 }), string.Empty));
217 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page down", (new CecSharp.CecKeypress() { Keycode = 0x38 }), string.Empty));
218 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power", (new CecSharp.CecKeypress() { Keycode = 0x40 }), string.Empty));
219 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume up", (new CecSharp.CecKeypress() { Keycode = 0x41 }), string.Empty));
220 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume down", (new CecSharp.CecKeypress() { Keycode = 0x42 }), string.Empty));
221 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute", (new CecSharp.CecKeypress() { Keycode = 0x43 }), string.Empty));
222 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play", (new CecSharp.CecKeypress() { Keycode = 0x44 }), string.Empty));
223 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop", (new CecSharp.CecKeypress() { Keycode = 0x45 }), string.Empty));
224 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause", (new CecSharp.CecKeypress() { Keycode = 0x46 }), string.Empty));
225 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record", (new CecSharp.CecKeypress() { Keycode = 0x47 }), string.Empty));
226 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Rewind", (new CecSharp.CecKeypress() { Keycode = 0x48 }), string.Empty));
227 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Fast forward", (new CecSharp.CecKeypress() { Keycode = 0x49 }), string.Empty));
228 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Eject", (new CecSharp.CecKeypress() { Keycode = 0x4A }), string.Empty));
229 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Forward", (new CecSharp.CecKeypress() { Keycode = 0x4B }), string.Empty));
230 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Backward", (new CecSharp.CecKeypress() { Keycode = 0x4C }), string.Empty));
231 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop record", (new CecSharp.CecKeypress() { Keycode = 0x4D }), string.Empty));
232 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record", (new CecSharp.CecKeypress() { Keycode = 0x4E }), string.Empty));
233 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Angle", (new CecSharp.CecKeypress() { Keycode = 0x50 }), string.Empty));
234 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sub picture", (new CecSharp.CecKeypress() { Keycode = 0x51 }), string.Empty));
235 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Video on demand", (new CecSharp.CecKeypress() { Keycode = 0x52 }), string.Empty));
236 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Electronic program guide", (new CecSharp.CecKeypress() { Keycode = 0x53 }), string.Empty));
237 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Timer programming", (new CecSharp.CecKeypress() { Keycode = 0x54 }), string.Empty));
238 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Initial configuration", (new CecSharp.CecKeypress() { Keycode = 0x55 }), string.Empty));
239 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play (function)", (new CecSharp.CecKeypress() { Keycode = 0x60 }), string.Empty));
240 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause play (function)", (new CecSharp.CecKeypress() { Keycode = 0x61 }), string.Empty));
241 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record (function)", (new CecSharp.CecKeypress() { Keycode = 0x62 }), string.Empty));
242 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record (function)", (new CecSharp.CecKeypress() { Keycode = 0x63 }), string.Empty));
243 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop (function)", (new CecSharp.CecKeypress() { Keycode = 0x64 }), string.Empty));
244 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute (function)", (new CecSharp.CecKeypress() { Keycode = 0x65 }), string.Empty));
245 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Restore volume", (new CecSharp.CecKeypress() { Keycode = 0x66 }), string.Empty));
246 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Tune", (new CecSharp.CecKeypress() { Keycode = 0x67 }), string.Empty));
247 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select media", (new CecSharp.CecKeypress() { Keycode = 0x68 }), string.Empty));
248 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select AV input", (new CecSharp.CecKeypress() { Keycode = 0x69 }), string.Empty));
249 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select audio input", (new CecSharp.CecKeypress() { Keycode = 0x6A }), string.Empty));
250 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power toggle", (new CecSharp.CecKeypress() { Keycode = 0x6B }), string.Empty));
251 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power off", (new CecSharp.CecKeypress() { Keycode = 0x6C }), string.Empty));
252 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power on", (new CecSharp.CecKeypress() { Keycode = 0x6D }), string.Empty));
253 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F1 (blue)", (new CecSharp.CecKeypress() { Keycode = 0x71 }), string.Empty));
254 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F2 (red)", (new CecSharp.CecKeypress() { Keycode = 0x72 }), string.Empty));
255 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F3 (green)", (new CecSharp.CecKeypress() { Keycode = 0x73 }), string.Empty));
256 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F4 (yellow)", (new CecSharp.CecKeypress() { Keycode = 0x74 }), string.Empty));
257 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F5", (new CecSharp.CecKeypress() { Keycode = 0x75 }), string.Empty));
258 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Data", (new CecSharp.CecKeypress() { Keycode = 0x76 }), string.Empty));
259 this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecSharp.CecKeypress() { Keycode = 0x91 }), string.Empty));
260 }
261
75af24f1 262 private void ProcessEventHandler(object src, UpdateEvent updateEvent)
8674df6a 263 {
75af24f1 264 switch (updateEvent.Type)
8674df6a 265 {
75af24f1
LOK
266 case UpdateEventType.StatusText:
267 SetControlText(lStatus, updateEvent.StringValue);
268 break;
269 case UpdateEventType.PhysicalAddress:
270 Config.PhysicalAddress = (ushort)updateEvent.IntValue;
271 SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", updateEvent.IntValue));
272 break;
273 case UpdateEventType.ProgressBar:
274 SetProgressValue(pProgress, updateEvent.IntValue);
275 break;
276 case UpdateEventType.TVVendorId:
277 TVVendor = (CecVendorId)updateEvent.IntValue;
278 UpdateSelectedDevice();
279 break;
280 case UpdateEventType.BaseDevicePhysicalAddress:
281 SetControlText(lConnectedPhysicalAddress, string.Format("Address: {0,4:X}", updateEvent.IntValue));
282 break;
283 case UpdateEventType.BaseDevice:
284 Config.BaseDevice = (CecLogicalAddress)updateEvent.IntValue;
285 break;
286 case UpdateEventType.HDMIPort:
287 Config.HDMIPort = (byte)updateEvent.IntValue;
288 break;
289 case UpdateEventType.MenuLanguage:
290 SetControlText(cbUseTVMenuLanguage, "Use the TV's language setting" + (updateEvent.StringValue.Length > 0 ? " (" + updateEvent.StringValue + ")" : ""));
291 break;
292 case UpdateEventType.HasAVRDevice:
293 if (HasAVRDevice != updateEvent.BoolValue)
8674df6a 294 {
75af24f1
LOK
295 HasAVRDevice = updateEvent.BoolValue;
296 UpdateSelectedDevice();
8674df6a 297 }
75af24f1
LOK
298 break;
299 case UpdateEventType.AVRVendorId:
300 AVRVendor = (CecVendorId)updateEvent.IntValue;
301 UpdateSelectedDevice();
302 break;
303 case UpdateEventType.Configuration:
304 SuppressUpdates = true;
305 ConfigurationChanged(updateEvent.ConfigValue);
306 SuppressUpdates = false;
307 break;
308 case UpdateEventType.ProcessCompleted:
309 ActiveProcess = null;
310 SetControlsEnabled(true);
311 break;
8674df6a
LOK
312 }
313 }
314
5de1dde4
LOK
315 private void SetControlsEnabled(bool val)
316 {
317 SetControlEnabled(cbPortNumber, val);
318 SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false);
319 SetControlEnabled(tbPhysicalAddress, val);
320 SetControlEnabled(cbDeviceType, false); // TODO not implemented yet
321 SetControlEnabled(cbUseTVMenuLanguage, val);
322 SetControlEnabled(cbActivateSource, val);
323 SetControlEnabled(cbPowerOffScreensaver, val);
324 SetControlEnabled(cbPowerOffOnStandby, val);
325 SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet
326 SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet
327 SetControlEnabled(cbVendorOverride, val);
328 SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
329 SetControlEnabled(bClose, val);
330 SetControlEnabled(bSaveConfig, val);
331 SetControlEnabled(bReloadConfig, val);
332
333 SetControlEnabled(bSendImageViewOn, val);
334 SetControlEnabled(bStandby, val);
335 SetControlEnabled(bActivateSource, val);
336 SetControlEnabled(bScan, val);
337
338 bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem) && val;
339 SetControlEnabled(bVolUp, enableVolumeButtons);
340 SetControlEnabled(bVolDown, enableVolumeButtons);
341 SetControlEnabled(bMute, enableVolumeButtons);
342 }
343
344 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
345 {
346 switch (tabControl1.SelectedIndex)
347 {
348 case 0:
349 SelectedTab = ConfigTab.Configuration;
350 break;
351 case 1:
352 SelectedTab = ConfigTab.KeyConfiguration;
353 break;
354 case 2:
355 SelectedTab = ConfigTab.Tester;
356 break;
357 case 3:
358 SelectedTab = ConfigTab.Log;
359 UpdateLog();
360 break;
361 default:
362 SelectedTab = ConfigTab.Configuration;
363 break;
364 }
365 }
366
367 #region Actions
368 public void ReloadXMLConfiguration()
369 {
370 LoadXMLConfiguration(ref Config);
371 Lib.SetConfiguration(Config);
372 ConfigurationChanged(Config);
373 }
374
75af24f1 375 public void SetPhysicalAddress(ushort physicalAddress)
006b76b9 376 {
75af24f1 377 if (!SuppressUpdates && ActiveProcess == null)
006b76b9 378 {
75af24f1
LOK
379 SetControlsEnabled(false);
380 SetControlText(cbPortNumber, string.Empty);
381 SetControlText(cbConnectedDevice, string.Empty);
382 ActiveProcess = new UpdatePhysicalAddress(ref Lib, physicalAddress);
383 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
384 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
006b76b9 385 }
75af24f1 386 }
6b92c1c4 387
75af24f1
LOK
388 public void SendImageViewOn(CecLogicalAddress address)
389 {
390 if (!SuppressUpdates && ActiveProcess == null)
391 {
392 SetControlsEnabled(false);
393 ActiveProcess = new SendImageViewOn(ref Lib, address);
394 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
395 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
006b76b9
LOK
396 }
397 }
398
75af24f1 399 public void ActivateSource(CecLogicalAddress address)
006b76b9 400 {
75af24f1
LOK
401 if (!SuppressUpdates && ActiveProcess == null)
402 {
403 SetControlsEnabled(false);
404 ActiveProcess = new SendActivateSource(ref Lib, address);
405 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
406 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
407 }
006b76b9
LOK
408 }
409
75af24f1 410 public void SendStandby(CecLogicalAddress address)
006b76b9 411 {
75af24f1 412 if (!SuppressUpdates && ActiveProcess == null)
006b76b9 413 {
75af24f1
LOK
414 SetControlsEnabled(false);
415 ActiveProcess = new SendStandby(ref Lib, address);
416 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
417 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
006b76b9 418 }
75af24f1
LOK
419 }
420
421 public void ShowDeviceInfo(CecLogicalAddress address)
422 {
423 if (!SuppressUpdates && ActiveProcess == null)
006b76b9 424 {
75af24f1
LOK
425 SetControlsEnabled(false);
426 ActiveProcess = new ShowDeviceInfo(this, ref Lib, address);
427 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
428 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
006b76b9
LOK
429 }
430 }
5de1dde4 431 #endregion
006b76b9 432
75af24f1
LOK
433 #region Configuration tab
434 private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
006b76b9 435 {
75af24f1
LOK
436 if (tbPhysicalAddress.Text.Length != 4)
437 return;
438 ushort physicalAddress = 0;
439 if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
440 return;
441
442 SetPhysicalAddress(physicalAddress);
006b76b9
LOK
443 }
444
75af24f1 445 private void UpdateSelectedDevice()
006b76b9 446 {
75af24f1
LOK
447 if (HasAVRDevice)
448 SetComboBoxItems(this.cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString, new object[] { TVVendorString, AVRVendorString });
006b76b9 449 else
75af24f1 450 SetComboBoxItems(this.cbConnectedDevice, TVVendorString, new object[] { TVVendorString });
006b76b9
LOK
451 }
452
75af24f1 453 public void SetConnectedDevice(CecLogicalAddress address, int portnumber)
006b76b9 454 {
75af24f1 455 if (!SuppressUpdates && ActiveProcess == null)
006b76b9 456 {
75af24f1
LOK
457 SetControlsEnabled(false);
458 ActiveProcess = new UpdateConnectedDevice(ref Lib, address, portnumber);
459 ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
460 (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
006b76b9
LOK
461 }
462 }
463
75af24f1 464 private void connectedDevice_SelectedIndexChanged(object sender, EventArgs e)
006b76b9 465 {
75af24f1 466 SetConnectedDevice(SelectedConnectedDevice, SelectedPortNumber);
ece1582e
LOK
467 }
468
006b76b9
LOK
469 private void bCancel_Click(object sender, EventArgs e)
470 {
471 this.Dispose();
472 }
473
474 private void bSave_Click(object sender, EventArgs e)
475 {
476 SetControlsEnabled(false);
477
478 Config.UseTVMenuLanguage = cbUseTVMenuLanguage.Checked;
75af24f1 479 Config.ActivateSource = cbActivateSource.Checked;
006b76b9
LOK
480 Config.PowerOffScreensaver = cbPowerOffScreensaver.Checked;
481 Config.PowerOffOnStandby = cbPowerOffOnStandby.Checked;
482
483 if (!Lib.CanPersistConfiguration())
484 {
485 if (ActiveProcess == null)
486 {
487 SetControlsEnabled(false);
488 string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
489 string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
490
491 SaveFileDialog dialog = new SaveFileDialog()
492 {
493 Title = "Where do you want to store the settings?",
494 InitialDirectory = Directory.Exists(xbmcDir) ? xbmcDir : defaultDir,
495 FileName = "usb_2548_1001.xml",
496 Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*",
497 FilterIndex = 1
498 };
499
500 if (dialog.ShowDialog() == DialogResult.OK)
501 {
de90f347
LOK
502 FileStream fs = null;
503 string error = string.Empty;
504 try
505 {
506 fs = (FileStream)dialog.OpenFile();
507 }
508 catch (Exception ex)
509 {
510 error = ex.Message;
511 }
006b76b9
LOK
512 if (fs == null)
513 {
de90f347 514 MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing" + (error.Length > 0 ? ": " + error : string.Empty ), "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
006b76b9
LOK
515 }
516 else
517 {
518 StreamWriter writer = new StreamWriter(fs);
519 StringBuilder output = new StringBuilder();
520 output.AppendLine("<settings>");
521 output.AppendLine("<setting id=\"cec_hdmi_port\" value=\"" + Config.HDMIPort + "\" />");
522 output.AppendLine("<setting id=\"connected_device\" value=\"" + (Config.BaseDevice == CecLogicalAddress.AudioSystem ? 5 : 1) + "\" />");
75af24f1
LOK
523 output.AppendLine("<setting id=\"cec_power_on_startup\" value=\"" + (Config.ActivateSource ? 1 : 0) + "\" />");
524 output.AppendLine("<setting id=\"cec_power_off_shutdown\" value=\"" + (Config.PowerOffDevices.IsSet(CecLogicalAddress.Broadcast) ? 1 : 0) + "\" />");
006b76b9
LOK
525 output.AppendLine("<setting id=\"cec_standby_screensaver\" value=\"" + (Config.PowerOffScreensaver ? 1 : 0) + "\" />");
526 output.AppendLine("<setting id=\"standby_pc_on_tv_standby\" value=\"" + (Config.PowerOffOnStandby ? 1 : 0) + "\" />");
527 output.AppendLine("<setting id=\"use_tv_menu_language\" value=\"" + (Config.UseTVMenuLanguage ? 1 : 0) + "\" />");
528 output.AppendLine("<setting id=\"enabled\" value=\"1\" />");
529 output.AppendLine("<setting id=\"port\" value=\"\" />");
75af24f1
LOK
530
531 // only supported by 1.5.0+ clients
532 output.AppendLine("<setting id=\"physical_address\" value=\"" + string.Format("{0,4:X}", Config.PhysicalAddress) + "\" />");
533 output.AppendLine("<setting id=\"device_type\" value=\"" + (int)Config.DeviceTypes.Types[0] + "\" />");
534 output.AppendLine("<setting id=\"tv_vendor\" value=\"" + string.Format("{0,6:X}", (int)Config.TvVendor) + "\" />");
535
536 output.Append("<setting id=\"wake_devices\" value=\"");
537 foreach (CecLogicalAddress addr in Config.WakeDevices.Addresses)
538 if (addr != CecLogicalAddress.Unregistered)
539 output.Append(" " + addr);
540 output.AppendLine("\" />");
541
542 output.Append("<setting id=\"standby_devices\" value=\"");
543 foreach (CecLogicalAddress addr in Config.PowerOffDevices.Addresses)
544 if (addr != CecLogicalAddress.Unregistered)
545 output.Append(" " + addr);
546 output.AppendLine("\" />");
547
006b76b9
LOK
548 output.AppendLine("</settings>");
549 writer.Write(output.ToString());
550 writer.Close();
551 fs.Close();
552 fs.Dispose();
553 MessageBox.Show("Settings are stored.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
554 }
555 }
556 SetControlsEnabled(true);
557 }
558 }
559 else
560 {
561 if (!Lib.PersistConfiguration(Config))
562 MessageBox.Show("Could not persist the new settings.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
563 else
564 MessageBox.Show("Settings are stored.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
565 }
566 SetControlsEnabled(true);
567 }
de90f347 568
5de1dde4
LOK
569 private void bReloadConfig_Click(object sender, EventArgs e)
570 {
571 if (Lib.CanPersistConfiguration())
572 {
573 Lib.GetCurrentConfiguration(Config);
574 ConfigurationChanged(Config);
575 }
576 else
577 {
578 ReloadXMLConfiguration();
579 }
580 }
581
de90f347
LOK
582 private void cbVendorOverride_CheckedChanged(object sender, EventArgs e)
583 {
584 if (cbVendorOverride.Checked)
585 {
586 cbVendorId.Enabled = true;
587 switch (cbVendorId.Text)
588 {
589 case "LG":
590 Config.TvVendor = CecVendorId.LG;
591 break;
592 case "Onkyo":
593 Config.TvVendor = CecVendorId.Onkyo;
594 break;
595 case "Panasonic":
596 Config.TvVendor = CecVendorId.Panasonic;
597 break;
598 case "Philips":
599 Config.TvVendor = CecVendorId.Philips;
600 break;
601 case "Pioneer":
602 Config.TvVendor = CecVendorId.Pioneer;
603 break;
604 case "Samsung":
605 Config.TvVendor = CecVendorId.Samsung;
606 break;
607 case "Sony":
608 Config.TvVendor = CecVendorId.Sony;
609 break;
610 case "Yamaha":
611 Config.TvVendor = CecVendorId.Yamaha;
612 break;
613 default:
614 Config.TvVendor = CecVendorId.Unknown;
615 break;
616 }
617 }
618 else
619 {
620 cbVendorId.Enabled = false;
621 Config.TvVendor = CecVendorId.Unknown;
622 }
623 }
75af24f1 624 #endregion
006b76b9 625
75af24f1
LOK
626 #region Key configuration tab
627 delegate void SelectKeypressRowCallback(CecKeypress key);
628 private void SelectKeypressRow(CecKeypress key)
6b92c1c4 629 {
75af24f1 630 if (dgButtons.InvokeRequired)
6b92c1c4 631 {
75af24f1
LOK
632 SelectKeypressRowCallback d = new SelectKeypressRowCallback(SelectKeypressRow);
633 try
6b92c1c4 634 {
75af24f1 635 this.Invoke(d, new object[] { key });
6b92c1c4 636 }
75af24f1
LOK
637 catch (Exception) { }
638 }
639 else
640 {
641 int rowIndex = -1;
642 foreach (DataGridViewRow row in dgButtons.Rows)
6b92c1c4 643 {
75af24f1
LOK
644 CecButtonConfigItem item = row.DataBoundItem as CecButtonConfigItem;
645 if (item != null && item.Key.Keycode == key.Keycode)
646 {
647 rowIndex = row.Index;
648 row.Selected = true;
649 item.Enabled = true;
650 }
651 else
652 {
653 row.Selected = false;
654 }
6b92c1c4 655 }
75af24f1
LOK
656 if (rowIndex > -1)
657 dgButtons.FirstDisplayedScrollingRowIndex = rowIndex;
6b92c1c4
LOK
658 }
659 }
8674df6a
LOK
660
661 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
662 {
663 DataGridView grid = sender as DataGridView;
664 CecButtonConfigItem data = grid.Rows[e.RowIndex].DataBoundItem as CecButtonConfigItem;
665 if (data == null || !data.Enabled)
666 e.CellStyle.ForeColor = Color.Gray;
667 }
75af24f1 668 #endregion
96fa7764 669
75af24f1 670 #region CEC Tester tab
ece1582e 671 delegate CecLogicalAddress GetTargetDeviceCallback();
96fa7764
LOK
672 private CecLogicalAddress GetTargetDevice()
673 {
ece1582e
LOK
674 if (this.cbCommandDestination.InvokeRequired)
675 {
676 GetTargetDeviceCallback d = new GetTargetDeviceCallback(GetTargetDevice);
677 CecLogicalAddress retval = CecLogicalAddress.Unknown;
678 try
679 {
680 retval = (CecLogicalAddress)this.Invoke(d, new object[] { });
681 }
682 catch (Exception) { }
683 return retval;
684 }
685
96fa7764
LOK
686 switch (this.cbCommandDestination.Text.Substring(0, 1).ToLower())
687 {
688 case "0":
689 return CecLogicalAddress.Tv;
690 case "1":
691 return CecLogicalAddress.RecordingDevice1;
692 case "2":
693 return CecLogicalAddress.RecordingDevice2;
694 case "3":
695 return CecLogicalAddress.Tuner1;
696 case "4":
697 return CecLogicalAddress.PlaybackDevice1;
698 case "5":
699 return CecLogicalAddress.AudioSystem;
700 case "6":
701 return CecLogicalAddress.Tuner2;
702 case "7":
703 return CecLogicalAddress.Tuner3;
704 case "8":
705 return CecLogicalAddress.PlaybackDevice2;
706 case "9":
707 return CecLogicalAddress.RecordingDevice3;
708 case "a":
709 return CecLogicalAddress.Tuner4;
710 case "b":
711 return CecLogicalAddress.PlaybackDevice3;
712 case "c":
713 return CecLogicalAddress.Reserved1;
714 case "d":
715 return CecLogicalAddress.Reserved2;
716 case "e":
717 return CecLogicalAddress.FreeUse;
718 case "f":
719 return CecLogicalAddress.Broadcast;
720 default:
721 return CecLogicalAddress.Unknown;
722 }
723 }
724
ece1582e
LOK
725 private void bSendImageViewOn_Click(object sender, EventArgs e)
726 {
727 SendImageViewOn(GetTargetDevice());
728 }
729
ece1582e
LOK
730 private void bStandby_Click(object sender, EventArgs e)
731 {
732 SendStandby(GetTargetDevice());
733 }
734
ece1582e
LOK
735 private void bScan_Click(object sender, EventArgs e)
736 {
737 ShowDeviceInfo(GetTargetDevice());
738 }
739
ece1582e
LOK
740 private void bActivateSource_Click(object sender, EventArgs e)
741 {
742 ActivateSource(GetTargetDevice());
743 }
744
745 private void cbCommandDestination_SelectedIndexChanged(object sender, EventArgs e)
746 {
747 bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem);
748 this.bVolUp.Enabled = enableVolumeButtons;
749 this.bVolDown.Enabled = enableVolumeButtons;
750 this.bMute.Enabled = enableVolumeButtons;
751 }
752
753 private void bVolUp_Click(object sender, EventArgs e)
754 {
755 SetControlsEnabled(false);
756 Lib.VolumeUp(true);
757 SetControlsEnabled(true);
758 }
759
760 private void bVolDown_Click(object sender, EventArgs e)
761 {
762 SetControlsEnabled(false);
763 Lib.VolumeDown(true);
764 SetControlsEnabled(true);
765 }
766
767 private void bMute_Click(object sender, EventArgs e)
768 {
769 SetControlsEnabled(false);
770 Lib.MuteAudio(true);
771 SetControlsEnabled(true);
772 }
75af24f1
LOK
773 #endregion
774
775 #region Log tab
5de1dde4
LOK
776 delegate void UpdateLogCallback();
777 private void UpdateLog()
75af24f1
LOK
778 {
779 if (tbLog.InvokeRequired)
780 {
5de1dde4 781 UpdateLogCallback d = new UpdateLogCallback(UpdateLog);
75af24f1
LOK
782 try
783 {
5de1dde4 784 this.Invoke(d, new object[] { });
75af24f1
LOK
785 }
786 catch (Exception) { }
787 }
788 else
789 {
5de1dde4
LOK
790 tbLog.Text = Log;
791 tbLog.Select(tbLog.Text.Length, 0);
792 tbLog.ScrollToCaret();
793 }
794 }
75af24f1 795
5de1dde4
LOK
796 private void AddLogMessage(CecLogMessage message)
797 {
798 string strLevel = "";
799 bool display = false;
800 switch (message.Level)
801 {
802 case CecLogLevel.Error:
803 strLevel = "ERROR: ";
804 display = cbLogError.Checked;
805 break;
806 case CecLogLevel.Warning:
807 strLevel = "WARNING: ";
808 display = cbLogWarning.Checked;
809 break;
810 case CecLogLevel.Notice:
811 strLevel = "NOTICE: ";
812 display = cbLogNotice.Checked;
813 break;
814 case CecLogLevel.Traffic:
815 strLevel = "TRAFFIC: ";
816 display = cbLogTraffic.Checked;
817 break;
818 case CecLogLevel.Debug:
819 strLevel = "DEBUG: ";
820 display = cbLogDebug.Checked;
821 break;
822 default:
823 break;
824 }
825
826 if (display)
827 {
828 string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message) + System.Environment.NewLine;
829 Log += strLog;
75af24f1 830 }
5de1dde4
LOK
831
832 if (SelectedTab == ConfigTab.Log)
833 UpdateLog();
75af24f1
LOK
834 }
835
836 private void bClearLog_Click(object sender, EventArgs e)
837 {
838 tbLog.Text = string.Empty;
839 }
840
841 private void bSaveLog_Click(object sender, EventArgs e)
842 {
843 SaveFileDialog dialog = new SaveFileDialog()
844 {
845 Title = "Where do you want to store the log file?",
846 InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
847 FileName = "cec-log.txt",
848 Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
849 FilterIndex = 1
850 };
851
852 if (dialog.ShowDialog() == DialogResult.OK)
853 {
854 FileStream fs = (FileStream)dialog.OpenFile();
855 if (fs == null)
856 {
857 MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
858 }
859 else
860 {
861 StreamWriter writer = new StreamWriter(fs);
862 writer.Write(tbLog.Text);
863 writer.Close();
864 fs.Close();
865 fs.Dispose();
866 MessageBox.Show("The log file was stored as '" + dialog.FileName + "'.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
867 }
868 }
869 }
870 #endregion
871
872 #region LibCecSharp callbacks
873 public int ConfigurationChanged(LibCECConfiguration config)
874 {
875 Config = config;
876 SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", Config.PhysicalAddress));
877 SetControlText(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString);
878 SetControlText(cbPortNumber, Config.HDMIPort.ToString());
de90f347
LOK
879 switch (config.DeviceTypes.Types[0])
880 {
881 case CecDeviceType.RecordingDevice:
882 SetControlText(cbDeviceType, "Recorder");
883 break;
884 case CecDeviceType.PlaybackDevice:
885 SetControlText(cbDeviceType, "Player");
886 break;
887 case CecDeviceType.Tuner:
888 SetControlText(cbDeviceType, "Tuner");
889 break;
890 default:
891 SetControlText(cbDeviceType, "Recorder");
892 break;
893 }
894 if (config.TvVendor != CecVendorId.Unknown)
895 {
896 SetCheckboxChecked(cbVendorOverride, true);
897 SetControlText(cbVendorId, Lib.ToString(config.TvVendor));
898 }
899 else
900 {
901 SetCheckboxChecked(cbVendorOverride, false);
902 SetControlText(cbVendorId, Lib.ToString(TVVendor));
903 }
904
75af24f1
LOK
905 SetCheckboxChecked(cbUseTVMenuLanguage, Config.UseTVMenuLanguage);
906 SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
907 SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
908 SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
909 UpdateSelectedDevice();
910 return 1;
911 }
912
913 public int ReceiveCommand(CecCommand command)
914 {
915 return 1;
916 }
917
918 public int ReceiveKeypress(CecKeypress key)
919 {
920 SelectKeypressRow(key);
921 return 1;
922 }
923
924 public int ReceiveLogMessage(CecLogMessage message)
925 {
926 AddLogMessage(message);
927 return 1;
928 }
929 #endregion
930
931 #region Class members
932 public bool HasAVRDevice { get; private set; }
933 #region TV Vendor
934 private CecVendorId _tvVendor = CecVendorId.Unknown;
935 public CecVendorId TVVendor
936 {
937 get { return _tvVendor;}
938 private set { _tvVendor = value; }
939 }
940 public string TVVendorString
941 {
942 get
943 {
944 return TVVendor != CecVendorId.Unknown ?
945 "Television (" + Lib.ToString(TVVendor) + ")" :
946 "Television";
947 }
948 }
949 #endregion
950 #region AVR Vendor
951 private CecVendorId _avrVendor = CecVendorId.Unknown;
952 public CecVendorId AVRVendor
953 {
954 get { return _avrVendor; }
955 private set { _avrVendor = value; }
956 }
957 public string AVRVendorString
958 {
959 get
960 {
961 return AVRVendor != CecVendorId.Unknown ?
962 "AVR (" + Lib.ToString(AVRVendor) + ")" :
963 "AVR";
964 }
965 }
966 #endregion
967 public CecLogicalAddress SelectedConnectedDevice
968 {
969 get
970 {
971 return (cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
972 }
973 }
974 public int SelectedPortNumber
975 {
976 get
977 {
978 int iPortNumber = 0;
979 if (!int.TryParse(cbPortNumber.Text, out iPortNumber))
980 iPortNumber = 1;
981 return iPortNumber;
982 }
983 }
984 protected LibCECConfiguration Config;
985 protected LibCecSharp Lib;
986 private CecCallbackWrapper Callbacks;
987 private UpdateProcess ActiveProcess = null;
5b8c2761 988 private bool SuppressUpdates = true;
5de1dde4
LOK
989 private ConfigTab SelectedTab = ConfigTab.Configuration;
990 private string Log = string.Empty;
75af24f1 991 #endregion
006b76b9
LOK
992 }
993
75af24f1
LOK
994 /// <summary>
995 /// A little wrapper that is needed because we already inherit form
996 /// </summary>
006b76b9
LOK
997 internal class CecCallbackWrapper : CecCallbackMethods
998 {
999 public CecCallbackWrapper(CecConfigGUI gui)
1000 {
1001 Gui = gui;
1002 }
1003
1004 public override int ReceiveCommand(CecCommand command)
1005 {
1006 return Gui.ReceiveCommand(command);
1007 }
1008
1009 public override int ReceiveKeypress(CecKeypress key)
1010 {
1011 return Gui.ReceiveKeypress(key);
1012 }
1013
1014 public override int ReceiveLogMessage(CecLogMessage message)
1015 {
1016 return Gui.ReceiveLogMessage(message);
1017 }
1018
32403cc3
LOK
1019 public override int ConfigurationChanged(LibCECConfiguration config)
1020 {
1021 return Gui.ConfigurationChanged(config);
1022 }
1023
006b76b9
LOK
1024 private CecConfigGUI Gui;
1025 }
1026}