System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CecConfigGUI));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.Configuration = new System.Windows.Forms.TabPage();
+ this.bReloadConfig = new System.Windows.Forms.Button();
this.cbVendorOverride = new System.Windows.Forms.CheckBox();
this.cbVendorId = new System.Windows.Forms.ComboBox();
this.lPowerOff = new System.Windows.Forms.Label();
this.lAdapterConfig = new System.Windows.Forms.Label();
this.cbDeviceType = new System.Windows.Forms.ComboBox();
this.bClose = new System.Windows.Forms.Button();
- this.bSave = new System.Windows.Forms.Button();
+ this.bSaveConfig = new System.Windows.Forms.Button();
this.cbPortNumber = new System.Windows.Forms.ComboBox();
this.lConnectedPhysicalAddress = new System.Windows.Forms.Label();
this.tbPhysicalAddress = new System.Windows.Forms.TextBox();
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(600, 385);
this.tabControl1.TabIndex = 0;
+ this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
//
// Configuration
//
+ this.Configuration.Controls.Add(this.bReloadConfig);
this.Configuration.Controls.Add(this.cbVendorOverride);
this.Configuration.Controls.Add(this.cbVendorId);
this.Configuration.Controls.Add(this.lPowerOff);
this.Configuration.Controls.Add(this.lAdapterConfig);
this.Configuration.Controls.Add(this.cbDeviceType);
this.Configuration.Controls.Add(this.bClose);
- this.Configuration.Controls.Add(this.bSave);
+ this.Configuration.Controls.Add(this.bSaveConfig);
this.Configuration.Controls.Add(this.cbPortNumber);
this.Configuration.Controls.Add(this.lConnectedPhysicalAddress);
this.Configuration.Controls.Add(this.tbPhysicalAddress);
this.Configuration.Text = "Configuration";
this.Configuration.UseVisualStyleBackColor = true;
//
+ // bReloadConfig
+ //
+ this.bReloadConfig.Enabled = false;
+ this.bReloadConfig.Location = new System.Drawing.Point(358, 330);
+ this.bReloadConfig.Name = "bReloadConfig";
+ this.bReloadConfig.Size = new System.Drawing.Size(125, 23);
+ this.bReloadConfig.TabIndex = 30;
+ this.bReloadConfig.Text = "Reload configuration";
+ this.bReloadConfig.UseVisualStyleBackColor = true;
+ this.bReloadConfig.Click += new System.EventHandler(this.bReloadConfig_Click);
+ //
// cbVendorOverride
//
this.cbVendorOverride.AutoSize = true;
// bClose
//
this.bClose.Enabled = false;
- this.bClose.Location = new System.Drawing.Point(189, 330);
+ this.bClose.Location = new System.Drawing.Point(96, 330);
this.bClose.Name = "bClose";
- this.bClose.Size = new System.Drawing.Size(75, 23);
+ this.bClose.Size = new System.Drawing.Size(125, 23);
this.bClose.TabIndex = 13;
this.bClose.Text = "Close";
this.bClose.UseVisualStyleBackColor = true;
this.bClose.Click += new System.EventHandler(this.bCancel_Click);
//
- // bSave
+ // bSaveConfig
//
- this.bSave.Enabled = false;
- this.bSave.Location = new System.Drawing.Point(298, 330);
- this.bSave.Name = "bSave";
- this.bSave.Size = new System.Drawing.Size(125, 23);
- this.bSave.TabIndex = 12;
- this.bSave.Text = "Save configuration";
- this.bSave.UseVisualStyleBackColor = true;
- this.bSave.Click += new System.EventHandler(this.bSave_Click);
+ this.bSaveConfig.Enabled = false;
+ this.bSaveConfig.Location = new System.Drawing.Point(227, 330);
+ this.bSaveConfig.Name = "bSaveConfig";
+ this.bSaveConfig.Size = new System.Drawing.Size(125, 23);
+ this.bSaveConfig.TabIndex = 12;
+ this.bSaveConfig.Text = "Save configuration";
+ this.bSaveConfig.UseVisualStyleBackColor = true;
+ this.bSaveConfig.Click += new System.EventHandler(this.bSave_Click);
//
// cbPortNumber
//
private System.Windows.Forms.TextBox tbLog;
private System.Windows.Forms.ComboBox cbPortNumber;
private System.Windows.Forms.Button bClose;
- private System.Windows.Forms.Button bSave;
+ private System.Windows.Forms.Button bSaveConfig;
private System.Windows.Forms.ComboBox cbDeviceType;
private System.Windows.Forms.Label lAdapterConfig;
private System.Windows.Forms.CheckBox cbPowerOffOnStandby;
private System.Windows.Forms.CheckedListBox cbPowerOffDevices;
private System.Windows.Forms.CheckBox cbVendorOverride;
private System.Windows.Forms.ComboBox cbVendorId;
+ private System.Windows.Forms.Button bReloadConfig;
}
}
\ No newline at end of file
namespace CecConfigGui
{
+ internal enum ConfigTab
+ {
+ Configuration,
+ KeyConfiguration,
+ Tester,
+ Log
+ }
+
public partial class CecConfigGUI : AsyncForm
{
public CecConfigGUI()
}
}
+ private void SetControlsEnabled(bool val)
+ {
+ SetControlEnabled(cbPortNumber, val);
+ SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false);
+ SetControlEnabled(tbPhysicalAddress, val);
+ SetControlEnabled(cbDeviceType, false); // TODO not implemented yet
+ SetControlEnabled(cbUseTVMenuLanguage, val);
+ SetControlEnabled(cbActivateSource, val);
+ SetControlEnabled(cbPowerOffScreensaver, val);
+ SetControlEnabled(cbPowerOffOnStandby, val);
+ SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet
+ SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet
+ SetControlEnabled(cbVendorOverride, val);
+ SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
+ SetControlEnabled(bClose, val);
+ SetControlEnabled(bSaveConfig, val);
+ SetControlEnabled(bReloadConfig, val);
+
+ SetControlEnabled(bSendImageViewOn, val);
+ SetControlEnabled(bStandby, val);
+ SetControlEnabled(bActivateSource, val);
+ SetControlEnabled(bScan, val);
+
+ bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem) && val;
+ SetControlEnabled(bVolUp, enableVolumeButtons);
+ SetControlEnabled(bVolDown, enableVolumeButtons);
+ SetControlEnabled(bMute, enableVolumeButtons);
+ }
+
+ private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ switch (tabControl1.SelectedIndex)
+ {
+ case 0:
+ SelectedTab = ConfigTab.Configuration;
+ break;
+ case 1:
+ SelectedTab = ConfigTab.KeyConfiguration;
+ break;
+ case 2:
+ SelectedTab = ConfigTab.Tester;
+ break;
+ case 3:
+ SelectedTab = ConfigTab.Log;
+ UpdateLog();
+ break;
+ default:
+ SelectedTab = ConfigTab.Configuration;
+ break;
+ }
+ }
+
+ #region Actions
+ public void ReloadXMLConfiguration()
+ {
+ LoadXMLConfiguration(ref Config);
+ Lib.SetConfiguration(Config);
+ ConfigurationChanged(Config);
+ }
+
public void SetPhysicalAddress(ushort physicalAddress)
{
if (!SuppressUpdates && ActiveProcess == null)
(new Thread(new ThreadStart(ActiveProcess.Run))).Start();
}
}
-
- private void SetControlsEnabled(bool val)
- {
- SetControlEnabled(cbPortNumber, val);
- SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false);
- SetControlEnabled(tbPhysicalAddress, val);
- SetControlEnabled(cbDeviceType, false); // TODO not implemented yet
- SetControlEnabled(cbUseTVMenuLanguage, val);
- SetControlEnabled(cbActivateSource, val);
- SetControlEnabled(cbPowerOffScreensaver, val);
- SetControlEnabled(cbPowerOffOnStandby, val);
- SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet
- SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet
- SetControlEnabled(cbVendorOverride, val);
- SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked);
- SetControlEnabled(bClose, val);
- SetControlEnabled(bSave, val);
-
- SetControlEnabled(bSendImageViewOn, val);
- SetControlEnabled(bStandby, val);
- SetControlEnabled(bActivateSource, val);
- SetControlEnabled(bScan, val);
-
- bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem) && val;
- SetControlEnabled(bVolUp, enableVolumeButtons);
- SetControlEnabled(bVolDown, enableVolumeButtons);
- SetControlEnabled(bMute, enableVolumeButtons);
- }
+ #endregion
#region Configuration tab
private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
SetControlsEnabled(true);
}
+ private void bReloadConfig_Click(object sender, EventArgs e)
+ {
+ if (Lib.CanPersistConfiguration())
+ {
+ Lib.GetCurrentConfiguration(Config);
+ ConfigurationChanged(Config);
+ }
+ else
+ {
+ ReloadXMLConfiguration();
+ }
+ }
+
private void cbVendorOverride_CheckedChanged(object sender, EventArgs e)
{
if (cbVendorOverride.Checked)
#endregion
#region Log tab
- delegate void AddLogMessageCallback(CecLogMessage message);
- private void AddLogMessage(CecLogMessage message)
+ delegate void UpdateLogCallback();
+ private void UpdateLog()
{
if (tbLog.InvokeRequired)
{
- AddLogMessageCallback d = new AddLogMessageCallback(AddLogMessage);
+ UpdateLogCallback d = new UpdateLogCallback(UpdateLog);
try
{
- this.Invoke(d, new object[] { message });
+ this.Invoke(d, new object[] { });
}
catch (Exception) { }
}
else
{
- string strLevel = "";
- bool display = false;
- switch (message.Level)
- {
- case CecLogLevel.Error:
- strLevel = "ERROR: ";
- display = cbLogError.Checked;
- break;
- case CecLogLevel.Warning:
- strLevel = "WARNING: ";
- display = cbLogWarning.Checked;
- break;
- case CecLogLevel.Notice:
- strLevel = "NOTICE: ";
- display = cbLogNotice.Checked;
- break;
- case CecLogLevel.Traffic:
- strLevel = "TRAFFIC: ";
- display = cbLogTraffic.Checked;
- break;
- case CecLogLevel.Debug:
- strLevel = "DEBUG: ";
- display = cbLogDebug.Checked;
- break;
- default:
- break;
- }
+ tbLog.Text = Log;
+ tbLog.Select(tbLog.Text.Length, 0);
+ tbLog.ScrollToCaret();
+ }
+ }
- if (display)
- {
- string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message) + System.Environment.NewLine;
- tbLog.Text += strLog;
- tbLog.Select(tbLog.Text.Length, 0);
- tbLog.ScrollToCaret();
- }
+ private void AddLogMessage(CecLogMessage message)
+ {
+ string strLevel = "";
+ bool display = false;
+ switch (message.Level)
+ {
+ case CecLogLevel.Error:
+ strLevel = "ERROR: ";
+ display = cbLogError.Checked;
+ break;
+ case CecLogLevel.Warning:
+ strLevel = "WARNING: ";
+ display = cbLogWarning.Checked;
+ break;
+ case CecLogLevel.Notice:
+ strLevel = "NOTICE: ";
+ display = cbLogNotice.Checked;
+ break;
+ case CecLogLevel.Traffic:
+ strLevel = "TRAFFIC: ";
+ display = cbLogTraffic.Checked;
+ break;
+ case CecLogLevel.Debug:
+ strLevel = "DEBUG: ";
+ display = cbLogDebug.Checked;
+ break;
+ default:
+ break;
+ }
+
+ if (display)
+ {
+ string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message) + System.Environment.NewLine;
+ Log += strLog;
}
+
+ if (SelectedTab == ConfigTab.Log)
+ UpdateLog();
}
private void bClearLog_Click(object sender, EventArgs e)
private CecCallbackWrapper Callbacks;
private UpdateProcess ActiveProcess = null;
private bool SuppressUpdates = false;
+ private ConfigTab SelectedTab = ConfigTab.Configuration;
+ private string Log = string.Empty;
#endregion
}