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();
//
// cbPowerOffDevices
//
+ this.cbPowerOffDevices.Enabled = false;
this.cbPowerOffDevices.FormattingEnabled = true;
this.cbPowerOffDevices.Items.AddRange(new object[] {
"0: TV",
//
// cbWakeDevices
//
+ this.cbWakeDevices.Enabled = false;
this.cbWakeDevices.FormattingEnabled = true;
this.cbWakeDevices.Items.AddRange(new object[] {
"0: TV",
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
//
//
// 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);
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;
//
// 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);
//
// 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);
//
// 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);
//
// 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);
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";
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
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;
}
}
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);
SetControlEnabled(bClose, val);
SetControlEnabled(bSaveConfig, val);
SetControlEnabled(bReloadConfig, val);
+ SetControlEnabled(bRescanDevices, val);
SetControlEnabled(bSendImageViewOn, val);
SetControlEnabled(bStandby, val);
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<UpdateEvent>(ProcessEventHandler);
+ (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+ }
+ }
+
public void SetPhysicalAddress(ushort physicalAddress)
{
if (!SuppressUpdates && ActiveProcess == null)
}
}
+ public void UpdateConfigurationAsync()
+ {
+ if (!SuppressUpdates && ActiveProcess == null)
+ {
+ SetControlsEnabled(false);
+ ActiveProcess = new UpdateConfiguration(ref Lib, Config);
+ ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+ (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+ }
+ }
+
public void SendImageViewOn(CecLogicalAddress address)
{
if (!SuppressUpdates && ActiveProcess == null)
output.AppendLine("<setting id=\"port\" value=\"\" />");
// only supported by 1.5.0+ clients
+ output.AppendLine("<!-- the following lines are only supported by v1.5.0+ clients -->");
output.AppendLine("<setting id=\"physical_address\" value=\"" + string.Format("{0,4:X}", Config.PhysicalAddress) + "\" />");
output.AppendLine("<setting id=\"device_type\" value=\"" + (int)Config.DeviceTypes.Types[0] + "\" />");
output.AppendLine("<setting id=\"tv_vendor\" value=\"" + string.Format("{0,6:X}", (int)Config.TvVendor) + "\" />");
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
#endregion
#region CEC Tester tab
+ public void CheckActiveDevices()
+ {
+ CecLogicalAddresses activeDevices = Lib.GetActiveDevices();
+ List<string> deviceList = new List<string>();
+ 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()
{
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)
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<UpdateEvent>(ProcessEventHandler);
+ (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+ }
+ }
#endregion
#region Log tab
private void bClearLog_Click(object sender, EventArgs e)
{
- tbLog.Text = string.Empty;
+ Log = string.Empty;
+ UpdateLog();
}
private void bSaveLog_Click(object sender, EventArgs e)
else
{
StreamWriter writer = new StreamWriter(fs);
- writer.Write(tbLog.Text);
+ writer.Write(Log);
writer.Close();
fs.Close();
fs.Dispose();
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
private bool SuppressUpdates = true;
private ConfigTab SelectedTab = ConfigTab.Configuration;
private string Log = string.Empty;
+ private DeviceInformation UpdatingInfoPanel = null;
+ private bool DeviceChangeWarningDisplayed = false;
#endregion
}
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
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);
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
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)
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;
}
}
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);
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.");
}
--- /dev/null
+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.");
+ }
+ }
+}
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;
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);
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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;
+ }
+}
HasAVRDevice,
AVRVendorId,
Configuration,
- MenuLanguage
+ MenuLanguage,
+ PollDevices
}
public class UpdateEvent : EventArgs
{
+ public UpdateEvent(UpdateEventType type)
+ {
+ Type = type;
+ }
+
public UpdateEvent(UpdateEventType type, bool value)
{
Type = type;
{
}
+ public void SendEvent(UpdateEventType type)
+ {
+ EventHandler<UpdateEvent> temp = EventHandler;
+ if (temp != null)
+ temp(this, new UpdateEvent(type));
+ }
+
public void SendEvent(UpdateEventType type, bool value)
{
EventHandler<UpdateEvent> temp = EventHandler;
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="actions\UpdateConfiguration.cs" />
<Compile Include="actions\ConnectToDevice.cs" />
+ <Compile Include="actions\RescanDevices.cs" />
<Compile Include="actions\SendActivateSource.cs" />
<Compile Include="actions\SendImageViewOn.cs" />
<Compile Include="actions\SendStandby.cs" />
<Compile Include="actions\ShowDeviceInfo.cs" />
<Compile Include="actions\UpdateConnectedDevice.cs" />
+ <Compile Include="actions\UpdateDeviceInfo.cs" />
<Compile Include="actions\UpdatePhysicalAddress.cs" />
<Compile Include="AsyncForm.cs">
<SubType>Form</SubType>