From 6d866874c4acb7620caea7a4415357bbf56f1a62 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Wed, 15 Feb 2012 22:19:55 +0100 Subject: [PATCH] cec-config-gui: added an update button on the device info window --- src/cec-config-gui/CecConfigGUI.Designer.cs | 35 +++--- src/cec-config-gui/CecConfigGUI.cs | 119 +++++++++++++++++- .../DeviceInformation.Designer.cs | 15 ++- src/cec-config-gui/DeviceInformation.cs | 39 ++++-- src/cec-config-gui/actions/ConnectToDevice.cs | 16 ++- src/cec-config-gui/actions/RescanDevices.cs | 18 +++ src/cec-config-gui/actions/ShowDeviceInfo.cs | 11 +- .../actions/UpdateConfiguration.cs | 30 +++++ .../actions/UpdateDeviceInfo.cs | 25 ++++ src/cec-config-gui/actions/UpdateEvent.cs | 15 ++- src/cec-config-gui/cec-config-gui.csproj | 3 + 11 files changed, 287 insertions(+), 39 deletions(-) create mode 100644 src/cec-config-gui/actions/RescanDevices.cs create mode 100644 src/cec-config-gui/actions/UpdateConfiguration.cs create mode 100644 src/cec-config-gui/actions/UpdateDeviceInfo.cs diff --git a/src/cec-config-gui/CecConfigGUI.Designer.cs b/src/cec-config-gui/CecConfigGUI.Designer.cs index 2489cf2..2c0f909 100644 --- a/src/cec-config-gui/CecConfigGUI.Designer.cs +++ b/src/cec-config-gui/CecConfigGUI.Designer.cs @@ -63,6 +63,7 @@ this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components); this.tbTestCommands = new System.Windows.Forms.TabPage(); + this.bRescanDevices = new System.Windows.Forms.Button(); this.bMute = new System.Windows.Forms.Button(); this.bVolDown = new System.Windows.Forms.Button(); this.bVolUp = new System.Windows.Forms.Button(); @@ -197,6 +198,7 @@ // // cbPowerOffDevices // + this.cbPowerOffDevices.Enabled = false; this.cbPowerOffDevices.FormattingEnabled = true; this.cbPowerOffDevices.Items.AddRange(new object[] { "0: TV", @@ -231,6 +233,7 @@ // // cbWakeDevices // + this.cbWakeDevices.Enabled = false; this.cbWakeDevices.FormattingEnabled = true; this.cbWakeDevices.Items.AddRange(new object[] { "0: TV", @@ -332,6 +335,7 @@ this.cbDeviceType.TabIndex = 14; this.cbDeviceType.Text = "Recorder"; this.helpDeviceType.SetToolTip(this.cbDeviceType, "Set this to \'Player\' when your TV is having problems with \'Recorder\'"); + this.cbDeviceType.SelectedIndexChanged += new System.EventHandler(this.cbDeviceType_SelectedIndexChanged); // // bClose // @@ -508,6 +512,7 @@ // // tbTestCommands // + this.tbTestCommands.Controls.Add(this.bRescanDevices); this.tbTestCommands.Controls.Add(this.bMute); this.tbTestCommands.Controls.Add(this.bVolDown); this.tbTestCommands.Controls.Add(this.bVolUp); @@ -525,6 +530,17 @@ this.tbTestCommands.Text = "CEC tester"; this.tbTestCommands.UseVisualStyleBackColor = true; // + // bRescanDevices + // + this.bRescanDevices.Enabled = false; + this.bRescanDevices.Location = new System.Drawing.Point(424, 65); + this.bRescanDevices.Name = "bRescanDevices"; + this.bRescanDevices.Size = new System.Drawing.Size(150, 23); + this.bRescanDevices.TabIndex = 9; + this.bRescanDevices.Text = "Re-scan devices"; + this.bRescanDevices.UseVisualStyleBackColor = true; + this.bRescanDevices.Click += new System.EventHandler(this.bRescanDevices_Click); + // // bMute // this.bMute.Enabled = false; @@ -560,6 +576,7 @@ // // bActivateSource // + this.bActivateSource.Enabled = false; this.bActivateSource.Location = new System.Drawing.Point(8, 65); this.bActivateSource.Name = "bActivateSource"; this.bActivateSource.Size = new System.Drawing.Size(150, 23); @@ -570,6 +587,7 @@ // // bScan // + this.bScan.Enabled = false; this.bScan.Location = new System.Drawing.Point(8, 94); this.bScan.Name = "bScan"; this.bScan.Size = new System.Drawing.Size(150, 23); @@ -580,6 +598,7 @@ // // bStandby // + this.bStandby.Enabled = false; this.bStandby.Location = new System.Drawing.Point(8, 36); this.bStandby.Name = "bStandby"; this.bStandby.Size = new System.Drawing.Size(150, 23); @@ -590,6 +609,7 @@ // // bSendImageViewOn // + this.bSendImageViewOn.Enabled = false; this.bSendImageViewOn.Location = new System.Drawing.Point(8, 7); this.bSendImageViewOn.Name = "bSendImageViewOn"; this.bSendImageViewOn.Size = new System.Drawing.Size(150, 23); @@ -613,20 +633,6 @@ this.cbCommandDestination.FormattingEnabled = true; this.cbCommandDestination.Items.AddRange(new object[] { "0: TV", - "1: Recorder 1", - "2: Recorder 2", - "3: Tuner 1", - "4: Playback 1", - "5: Audio system", - "6: Tuner 2", - "7: Tuner 3", - "8: Playback 2", - "9: Recorder 3", - "A: Tuner 4", - "B: Playback 3", - "C: Reserved 1", - "D: Reserved 2", - "E: Free use", "F: Broadcast"}); this.cbCommandDestination.Location = new System.Drawing.Point(437, 30); this.cbCommandDestination.Name = "cbCommandDestination"; @@ -842,5 +848,6 @@ private System.Windows.Forms.CheckBox cbVendorOverride; private System.Windows.Forms.ComboBox cbVendorId; private System.Windows.Forms.Button bReloadConfig; + private System.Windows.Forms.Button bRescanDevices; } } \ No newline at end of file diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index b2b6c55..2bafae8 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -305,9 +305,17 @@ namespace CecConfigGui ConfigurationChanged(updateEvent.ConfigValue); SuppressUpdates = false; break; + case UpdateEventType.PollDevices: + CheckActiveDevices(); + break; case UpdateEventType.ProcessCompleted: ActiveProcess = null; SetControlsEnabled(true); + if (UpdatingInfoPanel != null) + { + UpdatingInfoPanel.SetControlEnabled(UpdatingInfoPanel.bUpdate, true); + UpdatingInfoPanel = null; + } break; } } @@ -317,7 +325,7 @@ namespace CecConfigGui SetControlEnabled(cbPortNumber, val); SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false); SetControlEnabled(tbPhysicalAddress, val); - SetControlEnabled(cbDeviceType, false); // TODO not implemented yet + SetControlEnabled(cbDeviceType, val); SetControlEnabled(cbUseTVMenuLanguage, val); SetControlEnabled(cbActivateSource, val); SetControlEnabled(cbPowerOffScreensaver, val); @@ -329,6 +337,7 @@ namespace CecConfigGui SetControlEnabled(bClose, val); SetControlEnabled(bSaveConfig, val); SetControlEnabled(bReloadConfig, val); + SetControlEnabled(bRescanDevices, val); SetControlEnabled(bSendImageViewOn, val); SetControlEnabled(bStandby, val); @@ -372,6 +381,19 @@ namespace CecConfigGui ConfigurationChanged(Config); } + public void UpdateInfoPanel(DeviceInformation panel) + { + if (!SuppressUpdates && ActiveProcess == null) + { + SetControlsEnabled(false); + UpdatingInfoPanel = panel; + panel.SetControlEnabled(panel.bUpdate, false); + ActiveProcess = new UpdateDeviceInfo(this, ref Lib, panel); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } + public void SetPhysicalAddress(ushort physicalAddress) { if (!SuppressUpdates && ActiveProcess == null) @@ -385,6 +407,17 @@ namespace CecConfigGui } } + public void UpdateConfigurationAsync() + { + if (!SuppressUpdates && ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new UpdateConfiguration(ref Lib, Config); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } + public void SendImageViewOn(CecLogicalAddress address) { if (!SuppressUpdates && ActiveProcess == null) @@ -529,6 +562,7 @@ namespace CecConfigGui output.AppendLine(""); // only supported by 1.5.0+ clients + output.AppendLine(""); output.AppendLine(""); output.AppendLine(""); output.AppendLine(""); @@ -621,6 +655,20 @@ namespace CecConfigGui Config.TvVendor = CecVendorId.Unknown; } } + + private void cbDeviceType_SelectedIndexChanged(object sender, EventArgs e) + { + CecDeviceType type = SelectedDeviceType; + if (type != Config.DeviceTypes.Types[0]) + { + Config.DeviceTypes.Types[0] = type; + if (!DeviceChangeWarningDisplayed) + { + DeviceChangeWarningDisplayed = true; + MessageBox.Show("You have changed the device type. Save the configuration, and restart the application to use the new setting.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + } + } #endregion #region Key configuration tab @@ -668,6 +716,40 @@ namespace CecConfigGui #endregion #region CEC Tester tab + public void CheckActiveDevices() + { + CecLogicalAddresses activeDevices = Lib.GetActiveDevices(); + List deviceList = new List(); + foreach (CecLogicalAddress activeDevice in activeDevices.Addresses) + { + if (activeDevice != CecLogicalAddress.Unregistered) + deviceList.Add(string.Format("{0,1:X} : {1}", (int)activeDevice, Lib.ToString(activeDevice))); + } + deviceList.Add(string.Format("{0,1:X} : {1}", (int)CecLogicalAddress.Broadcast, Lib.ToString(CecLogicalAddress.Broadcast))); + + SetActiveDevices(deviceList.ToArray()); + } + + delegate void SetActiveDevicesCallback(string[] activeDevices); + private void SetActiveDevices(string[] activeDevices) + { + if (this.cbCommandDestination.InvokeRequired) + { + SetActiveDevicesCallback d = new SetActiveDevicesCallback(SetActiveDevices); + try + { + this.Invoke(d, new object[] { activeDevices }); + } + catch (Exception) { } + } + else + { + this.cbCommandDestination.Items.Clear(); + foreach (string item in activeDevices) + this.cbCommandDestination.Items.Add(item); + } + } + delegate CecLogicalAddress GetTargetDeviceCallback(); private CecLogicalAddress GetTargetDevice() { @@ -748,6 +830,8 @@ namespace CecConfigGui this.bVolUp.Enabled = enableVolumeButtons; this.bVolDown.Enabled = enableVolumeButtons; this.bMute.Enabled = enableVolumeButtons; + this.bActivateSource.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast); + this.bScan.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast); } private void bVolUp_Click(object sender, EventArgs e) @@ -770,6 +854,17 @@ namespace CecConfigGui Lib.MuteAudio(true); SetControlsEnabled(true); } + + private void bRescanDevices_Click(object sender, EventArgs e) + { + if (!SuppressUpdates && ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new RescanDevices(); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } #endregion #region Log tab @@ -835,7 +930,8 @@ namespace CecConfigGui private void bClearLog_Click(object sender, EventArgs e) { - tbLog.Text = string.Empty; + Log = string.Empty; + UpdateLog(); } private void bSaveLog_Click(object sender, EventArgs e) @@ -859,7 +955,7 @@ namespace CecConfigGui else { StreamWriter writer = new StreamWriter(fs); - writer.Write(tbLog.Text); + writer.Write(Log); writer.Close(); fs.Close(); fs.Dispose(); @@ -971,6 +1067,21 @@ namespace CecConfigGui return (cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv; } } + public CecDeviceType SelectedDeviceType + { + get + { + switch (cbDeviceType.Text.ToLower()) + { + case "player": + return CecDeviceType.PlaybackDevice; + case "tuner": + return CecDeviceType.Tuner; + default: + return CecDeviceType.RecordingDevice; + } + } + } public int SelectedPortNumber { get @@ -988,6 +1099,8 @@ namespace CecConfigGui private bool SuppressUpdates = true; private ConfigTab SelectedTab = ConfigTab.Configuration; private string Log = string.Empty; + private DeviceInformation UpdatingInfoPanel = null; + private bool DeviceChangeWarningDisplayed = false; #endregion } diff --git a/src/cec-config-gui/DeviceInformation.Designer.cs b/src/cec-config-gui/DeviceInformation.Designer.cs index 4a16c7d..c2ea74f 100644 --- a/src/cec-config-gui/DeviceInformation.Designer.cs +++ b/src/cec-config-gui/DeviceInformation.Designer.cs @@ -50,6 +50,7 @@ this.lDevice = new System.Windows.Forms.Label(); this.lInactiveSource = new System.Windows.Forms.LinkLabel(); this.lPowerStatus = new System.Windows.Forms.LinkLabel(); + this.bUpdate = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -265,11 +266,22 @@ this.lPowerStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.lPowerStatus.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lStandby_LinkClicked); // + // bUpdate + // + this.bUpdate.Location = new System.Drawing.Point(102, 207); + this.bUpdate.Name = "bUpdate"; + this.bUpdate.Size = new System.Drawing.Size(75, 23); + this.bUpdate.TabIndex = 31; + this.bUpdate.Text = "Refresh"; + this.bUpdate.UseVisualStyleBackColor = true; + this.bUpdate.Click += new System.EventHandler(this.button1_Click); + // // DeviceInformation // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(284, 218); + this.ClientSize = new System.Drawing.Size(284, 239); + this.Controls.Add(this.bUpdate); this.Controls.Add(this.lPowerStatus); this.Controls.Add(this.lInactiveSource); this.Controls.Add(this.lDevice); @@ -327,5 +339,6 @@ private System.Windows.Forms.Label lDevice; private System.Windows.Forms.LinkLabel lInactiveSource; private System.Windows.Forms.LinkLabel lPowerStatus; + public System.Windows.Forms.Button bUpdate; } } \ No newline at end of file diff --git a/src/cec-config-gui/DeviceInformation.cs b/src/cec-config-gui/DeviceInformation.cs index 2900ab3..0743e9e 100644 --- a/src/cec-config-gui/DeviceInformation.cs +++ b/src/cec-config-gui/DeviceInformation.cs @@ -21,17 +21,22 @@ namespace CecConfigGui InitializeComponent(); this.lDevice.Text = lib.ToString(address); this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address); - this.lPhysicalAddress.Text = String.Format("{0,4:X}", physicalAddress); - this.lDevicePresent.Text = devicePresent ? "yes" : "no"; - this.lActiveSource.Visible = isActiveSource; - this.lInactiveSource.Visible = !isActiveSource; - this.lVendor.Text = vendor != CecVendorId.Unknown ? lib.ToString(vendor) : "unknown"; - this.lCecVersion.Text = lib.ToString(version); - this.lPowerStatus.Text = lib.ToString(power); - bool isPoweredOn = (power == CecPowerStatus.On || power == CecPowerStatus.InTransitionStandbyToOn); - this.lOsdName.Text = osdName; - this.lMenuLanguage.Text = menuLanguage; - this.Text = "Device: " + osdName; + Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); + } + + public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) + { + SetControlText(lPhysicalAddress, String.Format("{0,4:X}", physicalAddress)); + SetControlText(lDevicePresent, devicePresent ? "yes" : "no"); + SetControlVisible(lActiveSource, isActiveSource); + SetControlVisible(lInactiveSource, !isActiveSource); + SetControlText(lVendor, vendor != CecVendorId.Unknown ? Lib.ToString(vendor) : "unknown"); + SetControlText(lCecVersion, Lib.ToString(version)); + SetControlText(lPowerStatus, Lib.ToString(power)); + SetControlText(lOsdName, osdName); + SetControlText(lMenuLanguage, menuLanguage); + SetControlText(this, "Device: " + osdName); } private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -54,7 +59,17 @@ namespace CecConfigGui Gui.SendStandby(Address); } - private CecLogicalAddress Address; + + private void button1_Click(object sender, EventArgs e) + { + Gui.UpdateInfoPanel(this); + } + + public CecLogicalAddress Address + { + private set; + get; + } private CecConfigGUI Gui; private LibCecSharp Lib; } diff --git a/src/cec-config-gui/actions/ConnectToDevice.cs b/src/cec-config-gui/actions/ConnectToDevice.cs index a1e1ef6..43d786e 100644 --- a/src/cec-config-gui/actions/ConnectToDevice.cs +++ b/src/cec-config-gui/actions/ConnectToDevice.cs @@ -25,14 +25,14 @@ namespace CecConfigGui.actions } SendEvent(UpdateEventType.StatusText, "Detecting TV vendor..."); - SendEvent(UpdateEventType.ProgressBar, 25); + SendEvent(UpdateEventType.ProgressBar, 20); SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv)); SendEvent(UpdateEventType.StatusText, "Detecting menu language..."); - SendEvent(UpdateEventType.ProgressBar, 40); + SendEvent(UpdateEventType.ProgressBar, 30); SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv)); - SendEvent(UpdateEventType.ProgressBar, 50); + SendEvent(UpdateEventType.ProgressBar, 40); SendEvent(UpdateEventType.StatusText, "Detecting AVR devices..."); bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem); @@ -40,24 +40,28 @@ namespace CecConfigGui.actions if (hasAVRDevice) { - SendEvent(UpdateEventType.ProgressBar, 75); + SendEvent(UpdateEventType.ProgressBar, 50); SendEvent(UpdateEventType.StatusText, "Detecting AVR vendor..."); SendEvent(UpdateEventType.AVRVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem)); } if (!Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On)) { - SendEvent(UpdateEventType.ProgressBar, 80); + SendEvent(UpdateEventType.ProgressBar, 60); SendEvent(UpdateEventType.StatusText, "Activating the source..."); Lib.SetActiveSource(CecDeviceType.Reserved); } - SendEvent(UpdateEventType.ProgressBar, 90); + SendEvent(UpdateEventType.ProgressBar, 70); SendEvent(UpdateEventType.StatusText, "Reading device configuration..."); Lib.GetCurrentConfiguration(Config); SendEvent(Config); + SendEvent(UpdateEventType.ProgressBar, 80); + SendEvent(UpdateEventType.StatusText, "Polling active devices"); + SendEvent(UpdateEventType.PollDevices); + SendEvent(UpdateEventType.ProgressBar, 100); SendEvent(UpdateEventType.StatusText, "Ready."); } diff --git a/src/cec-config-gui/actions/RescanDevices.cs b/src/cec-config-gui/actions/RescanDevices.cs new file mode 100644 index 0000000..0e110a8 --- /dev/null +++ b/src/cec-config-gui/actions/RescanDevices.cs @@ -0,0 +1,18 @@ +using CecSharp; +using System.Windows.Forms; + +namespace CecConfigGui.actions +{ + class RescanDevices : UpdateProcess + { + public override void Process() + { + SendEvent(UpdateEventType.ProgressBar, 10); + SendEvent(UpdateEventType.StatusText, "Polling active devices"); + SendEvent(UpdateEventType.PollDevices); + + SendEvent(UpdateEventType.ProgressBar, 100); + SendEvent(UpdateEventType.StatusText, "Ready."); + } + } +} diff --git a/src/cec-config-gui/actions/ShowDeviceInfo.cs b/src/cec-config-gui/actions/ShowDeviceInfo.cs index df8b4d1..628d4a9 100644 --- a/src/cec-config-gui/actions/ShowDeviceInfo.cs +++ b/src/cec-config-gui/actions/ShowDeviceInfo.cs @@ -14,6 +14,14 @@ namespace CecConfigGui.actions Address = address; } + public virtual void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib, + bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) + { + DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); + Gui.DisplayDialog(di, false); + } + public override void Process() { CecVendorId vendor = CecVendorId.Unknown; @@ -63,8 +71,7 @@ namespace CecConfigGui.actions SendEvent(UpdateEventType.ProgressBar, 90); SendEvent(UpdateEventType.ProcessCompleted, true); - DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); - Gui.DisplayDialog(di, false); + ShowDialog(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); SendEvent(UpdateEventType.StatusText, "Ready."); SendEvent(UpdateEventType.ProgressBar, 100); diff --git a/src/cec-config-gui/actions/UpdateConfiguration.cs b/src/cec-config-gui/actions/UpdateConfiguration.cs new file mode 100644 index 0000000..af41205 --- /dev/null +++ b/src/cec-config-gui/actions/UpdateConfiguration.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class UpdateConfiguration : UpdateProcess + { + public UpdateConfiguration(ref LibCecSharp lib, LibCECConfiguration config) + { + Lib = lib; + Config = config; + } + + public override void Process() + { + SendEvent(UpdateEventType.ProgressBar, 10); + SendEvent(UpdateEventType.StatusText, "Setting the new configuration"); + + Lib.SetConfiguration(Config); + + SendEvent(UpdateEventType.ProgressBar, 100); + SendEvent(UpdateEventType.StatusText, "Ready."); + } + + private LibCecSharp Lib; + private LibCECConfiguration Config; + } +} diff --git a/src/cec-config-gui/actions/UpdateDeviceInfo.cs b/src/cec-config-gui/actions/UpdateDeviceInfo.cs new file mode 100644 index 0000000..3cbde24 --- /dev/null +++ b/src/cec-config-gui/actions/UpdateDeviceInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class UpdateDeviceInfo : ShowDeviceInfo + { + public UpdateDeviceInfo(CecConfigGUI gui, ref LibCecSharp lib, DeviceInformation dialog) : + base(gui, ref lib, dialog.Address) + { + Dialog = dialog; + } + + public override void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib, + bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) + { + Dialog.Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); + } + + private DeviceInformation Dialog; + } +} diff --git a/src/cec-config-gui/actions/UpdateEvent.cs b/src/cec-config-gui/actions/UpdateEvent.cs index 6d19757..dae21bf 100644 --- a/src/cec-config-gui/actions/UpdateEvent.cs +++ b/src/cec-config-gui/actions/UpdateEvent.cs @@ -18,11 +18,17 @@ namespace CecConfigGui HasAVRDevice, AVRVendorId, Configuration, - MenuLanguage + MenuLanguage, + PollDevices } public class UpdateEvent : EventArgs { + public UpdateEvent(UpdateEventType type) + { + Type = type; + } + public UpdateEvent(UpdateEventType type, bool value) { Type = type; @@ -60,6 +66,13 @@ namespace CecConfigGui { } + public void SendEvent(UpdateEventType type) + { + EventHandler temp = EventHandler; + if (temp != null) + temp(this, new UpdateEvent(type)); + } + public void SendEvent(UpdateEventType type, bool value) { EventHandler temp = EventHandler; diff --git a/src/cec-config-gui/cec-config-gui.csproj b/src/cec-config-gui/cec-config-gui.csproj index 3594a16..4422144 100644 --- a/src/cec-config-gui/cec-config-gui.csproj +++ b/src/cec-config-gui/cec-config-gui.csproj @@ -54,12 +54,15 @@ + + + Form -- 2.34.1