From 96fa7764c1af5034afaba2646831df0a74419249 Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Tue, 14 Feb 2012 20:06:04 +0100 Subject: [PATCH] cec-config-gui: added some basic test commands and device information --- src/cec-config-gui/CecConfigGUI.Designer.cs | 162 +++++++-- src/cec-config-gui/CecConfigGUI.cs | 85 +++++ .../DeviceInformation.Designer.cs | 308 ++++++++++++++++++ src/cec-config-gui/DeviceInformation.cs | 31 ++ src/cec-config-gui/DeviceInformation.resx | 120 +++++++ .../actions/SendActivateSource.cs | 29 ++ src/cec-config-gui/actions/SendImageViewOn.cs | 29 ++ src/cec-config-gui/actions/SendStandby.cs | 29 ++ src/cec-config-gui/actions/ShowDeviceInfo.cs | 74 +++++ src/cec-config-gui/cec-config-gui.csproj | 14 + 10 files changed, 855 insertions(+), 26 deletions(-) create mode 100644 src/cec-config-gui/DeviceInformation.Designer.cs create mode 100644 src/cec-config-gui/DeviceInformation.cs create mode 100644 src/cec-config-gui/DeviceInformation.resx create mode 100644 src/cec-config-gui/actions/SendActivateSource.cs create mode 100644 src/cec-config-gui/actions/SendImageViewOn.cs create mode 100644 src/cec-config-gui/actions/SendStandby.cs create mode 100644 src/cec-config-gui/actions/ShowDeviceInfo.cs diff --git a/src/cec-config-gui/CecConfigGUI.Designer.cs b/src/cec-config-gui/CecConfigGUI.Designer.cs index 4b5eabb..d390753 100644 --- a/src/cec-config-gui/CecConfigGUI.Designer.cs +++ b/src/cec-config-gui/CecConfigGUI.Designer.cs @@ -51,6 +51,16 @@ this.lPortNumber = new System.Windows.Forms.Label(); this.tbButtons = new System.Windows.Forms.TabPage(); this.dgButtons = new System.Windows.Forms.DataGridView(); + this.CecButtonName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.tbTestCommands = new System.Windows.Forms.TabPage(); + this.bActivateSource = new System.Windows.Forms.Button(); + this.bScan = new System.Windows.Forms.Button(); + this.bStandby = new System.Windows.Forms.Button(); + this.bSendImageViewOn = new System.Windows.Forms.Button(); + this.lDestination = new System.Windows.Forms.Label(); + this.cbCommandDestination = new System.Windows.Forms.ComboBox(); this.LogOutput = new System.Windows.Forms.TabPage(); this.bSaveLog = new System.Windows.Forms.Button(); this.bClearLog = new System.Windows.Forms.Button(); @@ -66,21 +76,20 @@ this.helpConnectedHDMIDevice = new System.Windows.Forms.ToolTip(this.components); this.helpPhysicalAddress = new System.Windows.Forms.ToolTip(this.components); this.helpDeviceType = new System.Windows.Forms.ToolTip(this.components); - this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.CecButtonName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tabControl1.SuspendLayout(); this.Configuration.SuspendLayout(); this.tbButtons.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgButtons)).BeginInit(); - this.LogOutput.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).BeginInit(); + this.tbTestCommands.SuspendLayout(); + this.LogOutput.SuspendLayout(); this.SuspendLayout(); // // tabControl1 // this.tabControl1.Controls.Add(this.Configuration); this.tabControl1.Controls.Add(this.tbButtons); + this.tabControl1.Controls.Add(this.tbTestCommands); this.tabControl1.Controls.Add(this.LogOutput); this.tabControl1.Location = new System.Drawing.Point(12, 12); this.tabControl1.Name = "tabControl1"; @@ -346,6 +355,119 @@ this.dgButtons.TabIndex = 0; this.dgButtons.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting); // + // CecButtonName + // + this.CecButtonName.DataPropertyName = "CecButtonName"; + this.CecButtonName.FillWeight = 260F; + this.CecButtonName.HeaderText = "Button"; + this.CecButtonName.Name = "CecButtonName"; + this.CecButtonName.ReadOnly = true; + this.CecButtonName.Width = 260; + // + // playerButtonDataGridViewTextBoxColumn + // + this.playerButtonDataGridViewTextBoxColumn.DataPropertyName = "PlayerButton"; + this.playerButtonDataGridViewTextBoxColumn.FillWeight = 260F; + this.playerButtonDataGridViewTextBoxColumn.HeaderText = "Mapped to"; + this.playerButtonDataGridViewTextBoxColumn.Name = "playerButtonDataGridViewTextBoxColumn"; + this.playerButtonDataGridViewTextBoxColumn.Width = 260; + // + // cecButtonConfigBindingSource + // + this.cecButtonConfigBindingSource.DataSource = typeof(CecConfigGui.CecButtonConfig); + // + // tbTestCommands + // + this.tbTestCommands.Controls.Add(this.bActivateSource); + this.tbTestCommands.Controls.Add(this.bScan); + this.tbTestCommands.Controls.Add(this.bStandby); + this.tbTestCommands.Controls.Add(this.bSendImageViewOn); + this.tbTestCommands.Controls.Add(this.lDestination); + this.tbTestCommands.Controls.Add(this.cbCommandDestination); + this.tbTestCommands.Location = new System.Drawing.Point(4, 22); + this.tbTestCommands.Name = "tbTestCommands"; + this.tbTestCommands.Padding = new System.Windows.Forms.Padding(3); + this.tbTestCommands.Size = new System.Drawing.Size(592, 359); + this.tbTestCommands.TabIndex = 3; + this.tbTestCommands.Text = "CEC tester"; + this.tbTestCommands.UseVisualStyleBackColor = true; + // + // bActivateSource + // + this.bActivateSource.Location = new System.Drawing.Point(7, 90); + this.bActivateSource.Name = "bActivateSource"; + this.bActivateSource.Size = new System.Drawing.Size(150, 23); + this.bActivateSource.TabIndex = 5; + this.bActivateSource.Text = "Activate source"; + this.bActivateSource.UseVisualStyleBackColor = true; + this.bActivateSource.Click += new System.EventHandler(this.bActivateSource_Click); + // + // bScan + // + this.bScan.Location = new System.Drawing.Point(7, 61); + this.bScan.Name = "bScan"; + this.bScan.Size = new System.Drawing.Size(150, 23); + this.bScan.TabIndex = 4; + this.bScan.Text = "Device information"; + this.bScan.UseVisualStyleBackColor = true; + this.bScan.Click += new System.EventHandler(this.bScan_Click); + // + // bStandby + // + this.bStandby.Location = new System.Drawing.Point(7, 32); + this.bStandby.Name = "bStandby"; + this.bStandby.Size = new System.Drawing.Size(150, 23); + this.bStandby.TabIndex = 3; + this.bStandby.Text = "Standby"; + this.bStandby.UseVisualStyleBackColor = true; + this.bStandby.Click += new System.EventHandler(this.bStandby_Click); + // + // bSendImageViewOn + // + this.bSendImageViewOn.Location = new System.Drawing.Point(7, 3); + this.bSendImageViewOn.Name = "bSendImageViewOn"; + this.bSendImageViewOn.Size = new System.Drawing.Size(150, 23); + this.bSendImageViewOn.TabIndex = 2; + this.bSendImageViewOn.Text = "Image view on"; + this.bSendImageViewOn.UseVisualStyleBackColor = true; + this.bSendImageViewOn.Click += new System.EventHandler(this.bSendImageViewOn_Click); + // + // lDestination + // + this.lDestination.AutoSize = true; + this.lDestination.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lDestination.Location = new System.Drawing.Point(420, 3); + this.lDestination.Name = "lDestination"; + this.lDestination.Size = new System.Drawing.Size(138, 24); + this.lDestination.TabIndex = 1; + this.lDestination.Text = "Target device"; + // + // cbCommandDestination + // + 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"; + this.cbCommandDestination.Size = new System.Drawing.Size(121, 21); + this.cbCommandDestination.TabIndex = 0; + this.cbCommandDestination.Text = "0: TV"; + // // LogOutput // this.LogOutput.Controls.Add(this.bSaveLog); @@ -465,27 +587,6 @@ this.lStatus.TabIndex = 2; this.lStatus.Text = "Initialising..."; // - // cecButtonConfigBindingSource - // - this.cecButtonConfigBindingSource.DataSource = typeof(CecConfigGui.CecButtonConfig); - // - // CecButtonName - // - this.CecButtonName.DataPropertyName = "CecButtonName"; - this.CecButtonName.FillWeight = 260F; - this.CecButtonName.HeaderText = "Button"; - this.CecButtonName.Name = "CecButtonName"; - this.CecButtonName.ReadOnly = true; - this.CecButtonName.Width = 260; - // - // playerButtonDataGridViewTextBoxColumn - // - this.playerButtonDataGridViewTextBoxColumn.DataPropertyName = "PlayerButton"; - this.playerButtonDataGridViewTextBoxColumn.FillWeight = 260F; - this.playerButtonDataGridViewTextBoxColumn.HeaderText = "Mapped to"; - this.playerButtonDataGridViewTextBoxColumn.Name = "playerButtonDataGridViewTextBoxColumn"; - this.playerButtonDataGridViewTextBoxColumn.Width = 260; - // // CecConfigGUI // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -501,9 +602,11 @@ this.Configuration.PerformLayout(); this.tbButtons.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgButtons)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).EndInit(); + this.tbTestCommands.ResumeLayout(false); + this.tbTestCommands.PerformLayout(); this.LogOutput.ResumeLayout(false); this.LogOutput.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -551,5 +654,12 @@ private System.Windows.Forms.BindingSource cecButtonConfigBindingSource; private System.Windows.Forms.DataGridViewTextBoxColumn CecButtonName; private System.Windows.Forms.DataGridViewTextBoxColumn playerButtonDataGridViewTextBoxColumn; + private System.Windows.Forms.TabPage tbTestCommands; + private System.Windows.Forms.ComboBox cbCommandDestination; + private System.Windows.Forms.Button bStandby; + private System.Windows.Forms.Button bSendImageViewOn; + private System.Windows.Forms.Label lDestination; + private System.Windows.Forms.Button bActivateSource; + private System.Windows.Forms.Button bScan; } } \ No newline at end of file diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index 031c7e8..a75f6c4 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -681,6 +681,91 @@ namespace CecConfigGui if (data == null || !data.Enabled) e.CellStyle.ForeColor = Color.Gray; } + + private CecLogicalAddress GetTargetDevice() + { + switch (this.cbCommandDestination.Text.Substring(0, 1).ToLower()) + { + case "0": + return CecLogicalAddress.Tv; + case "1": + return CecLogicalAddress.RecordingDevice1; + case "2": + return CecLogicalAddress.RecordingDevice2; + case "3": + return CecLogicalAddress.Tuner1; + case "4": + return CecLogicalAddress.PlaybackDevice1; + case "5": + return CecLogicalAddress.AudioSystem; + case "6": + return CecLogicalAddress.Tuner2; + case "7": + return CecLogicalAddress.Tuner3; + case "8": + return CecLogicalAddress.PlaybackDevice2; + case "9": + return CecLogicalAddress.RecordingDevice3; + case "a": + return CecLogicalAddress.Tuner4; + case "b": + return CecLogicalAddress.PlaybackDevice3; + case "c": + return CecLogicalAddress.Reserved1; + case "d": + return CecLogicalAddress.Reserved2; + case "e": + return CecLogicalAddress.FreeUse; + case "f": + return CecLogicalAddress.Broadcast; + default: + return CecLogicalAddress.Unknown; + } + } + + private void bSendImageViewOn_Click(object sender, EventArgs e) + { + if (ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new SendImageViewOn(ref Lib, GetTargetDevice()); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } + + private void bStandby_Click(object sender, EventArgs e) + { + if (ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new SendStandby(ref Lib, GetTargetDevice()); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } + + private void bScan_Click(object sender, EventArgs e) + { + if (ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new ShowDeviceInfo(ref Lib, GetTargetDevice()); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } + + private void bActivateSource_Click(object sender, EventArgs e) + { + if (ActiveProcess == null) + { + SetControlsEnabled(false); + ActiveProcess = new SendActivateSource(ref Lib, GetTargetDevice()); + ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); + (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); + } + } } internal class CecCallbackWrapper : CecCallbackMethods diff --git a/src/cec-config-gui/DeviceInformation.Designer.cs b/src/cec-config-gui/DeviceInformation.Designer.cs new file mode 100644 index 0000000..5372431 --- /dev/null +++ b/src/cec-config-gui/DeviceInformation.Designer.cs @@ -0,0 +1,308 @@ +namespace CecConfigGui +{ + partial class DeviceInformation + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.lMenuLanguage = new System.Windows.Forms.Label(); + this.lOsdName = new System.Windows.Forms.Label(); + this.lPowerStatus = new System.Windows.Forms.Label(); + this.lCecVersion = new System.Windows.Forms.Label(); + this.lVendor = new System.Windows.Forms.Label(); + this.lActiveSource = new System.Windows.Forms.Label(); + this.lDevicePresent = new System.Windows.Forms.Label(); + this.lPhysicalAddress = new System.Windows.Forms.Label(); + this.lLogicalAddress = new System.Windows.Forms.Label(); + this.lDevice = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(12, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(47, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Device"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(12, 29); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(96, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Logical address"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(12, 49); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(102, 13); + this.label3.TabIndex = 2; + this.label3.Text = "Physical address"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(12, 69); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(93, 13); + this.label4.TabIndex = 3; + this.label4.Text = "Device present"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(12, 89); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(85, 13); + this.label5.TabIndex = 4; + this.label5.Text = "Active source"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(12, 109); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(47, 13); + this.label6.TabIndex = 5; + this.label6.Text = "Vendor"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(12, 129); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(76, 13); + this.label7.TabIndex = 6; + this.label7.Text = "CEC version"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.Location = new System.Drawing.Point(12, 149); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(80, 13); + this.label8.TabIndex = 7; + this.label8.Text = "Power status"; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.Location = new System.Drawing.Point(12, 169); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(67, 13); + this.label9.TabIndex = 8; + this.label9.Text = "OSD name"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.Location = new System.Drawing.Point(12, 189); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(94, 13); + this.label10.TabIndex = 9; + this.label10.Text = "Menu language"; + // + // lMenuLanguage + // + this.lMenuLanguage.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lMenuLanguage.Location = new System.Drawing.Point(122, 189); + this.lMenuLanguage.Name = "lMenuLanguage"; + this.lMenuLanguage.Size = new System.Drawing.Size(150, 13); + this.lMenuLanguage.TabIndex = 19; + this.lMenuLanguage.Text = "unknown"; + this.lMenuLanguage.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lOsdName + // + this.lOsdName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lOsdName.Location = new System.Drawing.Point(122, 169); + this.lOsdName.Name = "lOsdName"; + this.lOsdName.Size = new System.Drawing.Size(150, 13); + this.lOsdName.TabIndex = 20; + this.lOsdName.Text = "unknown"; + this.lOsdName.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lPowerStatus + // + this.lPowerStatus.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lPowerStatus.Location = new System.Drawing.Point(122, 149); + this.lPowerStatus.Name = "lPowerStatus"; + this.lPowerStatus.Size = new System.Drawing.Size(150, 13); + this.lPowerStatus.TabIndex = 21; + this.lPowerStatus.Text = "unknown"; + this.lPowerStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lCecVersion + // + this.lCecVersion.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lCecVersion.Location = new System.Drawing.Point(122, 129); + this.lCecVersion.Name = "lCecVersion"; + this.lCecVersion.Size = new System.Drawing.Size(150, 13); + this.lCecVersion.TabIndex = 22; + this.lCecVersion.Text = "unknown"; + this.lCecVersion.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lVendor + // + this.lVendor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lVendor.Location = new System.Drawing.Point(122, 109); + this.lVendor.Name = "lVendor"; + this.lVendor.Size = new System.Drawing.Size(150, 13); + this.lVendor.TabIndex = 23; + this.lVendor.Text = "unknown"; + this.lVendor.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lActiveSource + // + this.lActiveSource.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lActiveSource.Location = new System.Drawing.Point(122, 89); + this.lActiveSource.Name = "lActiveSource"; + this.lActiveSource.Size = new System.Drawing.Size(150, 13); + this.lActiveSource.TabIndex = 24; + this.lActiveSource.Text = "unknown"; + this.lActiveSource.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lDevicePresent + // + this.lDevicePresent.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lDevicePresent.Location = new System.Drawing.Point(122, 69); + this.lDevicePresent.Name = "lDevicePresent"; + this.lDevicePresent.Size = new System.Drawing.Size(150, 13); + this.lDevicePresent.TabIndex = 25; + this.lDevicePresent.Text = "unknown"; + this.lDevicePresent.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lPhysicalAddress + // + this.lPhysicalAddress.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lPhysicalAddress.Location = new System.Drawing.Point(122, 49); + this.lPhysicalAddress.Name = "lPhysicalAddress"; + this.lPhysicalAddress.Size = new System.Drawing.Size(150, 13); + this.lPhysicalAddress.TabIndex = 26; + this.lPhysicalAddress.Text = "unknown"; + this.lPhysicalAddress.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lLogicalAddress + // + this.lLogicalAddress.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lLogicalAddress.Location = new System.Drawing.Point(122, 29); + this.lLogicalAddress.Name = "lLogicalAddress"; + this.lLogicalAddress.Size = new System.Drawing.Size(150, 13); + this.lLogicalAddress.TabIndex = 27; + this.lLogicalAddress.Text = "unknown"; + this.lLogicalAddress.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // lDevice + // + this.lDevice.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lDevice.Location = new System.Drawing.Point(122, 9); + this.lDevice.Name = "lDevice"; + this.lDevice.Size = new System.Drawing.Size(150, 13); + this.lDevice.TabIndex = 28; + this.lDevice.Text = "unknown"; + this.lDevice.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // 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.Controls.Add(this.lDevice); + this.Controls.Add(this.lLogicalAddress); + this.Controls.Add(this.lPhysicalAddress); + this.Controls.Add(this.lDevicePresent); + this.Controls.Add(this.lActiveSource); + this.Controls.Add(this.lVendor); + this.Controls.Add(this.lCecVersion); + this.Controls.Add(this.lPowerStatus); + this.Controls.Add(this.lOsdName); + this.Controls.Add(this.lMenuLanguage); + this.Controls.Add(this.label10); + this.Controls.Add(this.label9); + this.Controls.Add(this.label8); + this.Controls.Add(this.label7); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.label2); + this.Controls.Add(this.label1); + this.Name = "DeviceInformation"; + this.Text = "Device: [unknown]"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label lMenuLanguage; + private System.Windows.Forms.Label lOsdName; + private System.Windows.Forms.Label lPowerStatus; + private System.Windows.Forms.Label lCecVersion; + private System.Windows.Forms.Label lVendor; + private System.Windows.Forms.Label lActiveSource; + private System.Windows.Forms.Label lDevicePresent; + private System.Windows.Forms.Label lPhysicalAddress; + private System.Windows.Forms.Label lLogicalAddress; + private System.Windows.Forms.Label lDevice; + } +} \ No newline at end of file diff --git a/src/cec-config-gui/DeviceInformation.cs b/src/cec-config-gui/DeviceInformation.cs new file mode 100644 index 0000000..9d9b983 --- /dev/null +++ b/src/cec-config-gui/DeviceInformation.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using CecSharp; + +namespace CecConfigGui +{ + public partial class DeviceInformation : Form + { + public DeviceInformation(CecLogicalAddress address, ref LibCecSharp lib, + bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) + { + InitializeComponent(); + this.lDevice.Text = lib.ToString(address); + this.lLogicalAddress.Text = "#" + (int)address; + this.lPhysicalAddress.Text = physicalAddress.ToString(); + this.lDevicePresent.Text = devicePresent ? "yes" : "no"; + this.lActiveSource.Text = isActiveSource ? "yes" : "no"; + this.lVendor.Text = lib.ToString(vendor) + " (" + (UInt64)vendor +")"; + this.lCecVersion.Text = lib.ToString(version); + this.lPowerStatus.Text = lib.ToString(power); + this.lOsdName.Text = osdName; + this.lMenuLanguage.Text = menuLanguage; + } + } +} diff --git a/src/cec-config-gui/DeviceInformation.resx b/src/cec-config-gui/DeviceInformation.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/src/cec-config-gui/DeviceInformation.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/cec-config-gui/actions/SendActivateSource.cs b/src/cec-config-gui/actions/SendActivateSource.cs new file mode 100644 index 0000000..e60c0a5 --- /dev/null +++ b/src/cec-config-gui/actions/SendActivateSource.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class SendActivateSource : UpdateProcess + { + public SendActivateSource(ref LibCecSharp lib, CecLogicalAddress address) + { + Lib = lib; + Address = address; + } + + public override void Process() + { + SendEvent(UpdateEventType.StatusText, "Sending the 'activate source' command to " + Lib.ToString(Address) + "..."); + SendEvent(UpdateEventType.ProgressBar, 50); + + bool bResult = Lib.SetStreamPath(Address); + SendEvent(UpdateEventType.StatusText, bResult ? "Command sent successfully." : "The device could not be powered on."); + SendEvent(UpdateEventType.ProgressBar, 100); + } + + private LibCecSharp Lib; + private CecLogicalAddress Address; + } +} diff --git a/src/cec-config-gui/actions/SendImageViewOn.cs b/src/cec-config-gui/actions/SendImageViewOn.cs new file mode 100644 index 0000000..26d9534 --- /dev/null +++ b/src/cec-config-gui/actions/SendImageViewOn.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class SendImageViewOn : UpdateProcess + { + public SendImageViewOn(ref LibCecSharp lib, CecLogicalAddress address) + { + Lib = lib; + Address = address; + } + + public override void Process() + { + SendEvent(UpdateEventType.StatusText, "Sending the 'power on' command to " + Lib.ToString(Address) + "..."); + SendEvent(UpdateEventType.ProgressBar, 50); + + bool bResult = Lib.PowerOnDevices(Address); + SendEvent(UpdateEventType.StatusText, bResult ? "Command sent successfully." : "The device could not be powered on."); + SendEvent(UpdateEventType.ProgressBar, 100); + } + + private LibCecSharp Lib; + private CecLogicalAddress Address; + } +} diff --git a/src/cec-config-gui/actions/SendStandby.cs b/src/cec-config-gui/actions/SendStandby.cs new file mode 100644 index 0000000..9eb8afb --- /dev/null +++ b/src/cec-config-gui/actions/SendStandby.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class SendStandby : UpdateProcess + { + public SendStandby(ref LibCecSharp lib, CecLogicalAddress address) + { + Lib = lib; + Address = address; + } + + public override void Process() + { + SendEvent(UpdateEventType.StatusText, "Sending the 'standby' command to " + Lib.ToString(Address) + "..."); + SendEvent(UpdateEventType.ProgressBar, 50); + + bool bResult = Lib.StandbyDevices(Address); + SendEvent(UpdateEventType.StatusText, bResult ? "Command sent successfully." : "The device could not be powered on."); + SendEvent(UpdateEventType.ProgressBar, 100); + } + + private LibCecSharp Lib; + private CecLogicalAddress Address; + } +} diff --git a/src/cec-config-gui/actions/ShowDeviceInfo.cs b/src/cec-config-gui/actions/ShowDeviceInfo.cs new file mode 100644 index 0000000..61dd35f --- /dev/null +++ b/src/cec-config-gui/actions/ShowDeviceInfo.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; +using CecSharp; + +namespace CecConfigGui.actions +{ + class ShowDeviceInfo : UpdateProcess + { + public ShowDeviceInfo(ref LibCecSharp lib, CecLogicalAddress address) + { + Lib = lib; + Address = address; + } + + public override void Process() + { + CecVendorId vendor = CecVendorId.Unknown; + bool isActiveSource = false; + ushort physicalAddress = 0xFFFF; + CecVersion version = CecVersion.Unknown; + CecPowerStatus power = CecPowerStatus.Unknown; + string osdName = "unknown"; + string menuLanguage = "unknown"; + + SendEvent(UpdateEventType.StatusText, "Checking device presense..."); + SendEvent(UpdateEventType.ProgressBar, 10); + + bool devicePresent = Lib.IsActiveDevice(Address); + if (devicePresent) + { + SendEvent(UpdateEventType.StatusText, "Requesting the vendor ID..."); + SendEvent(UpdateEventType.ProgressBar, 20); + vendor = Lib.GetDeviceVendorId(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting active source state..."); + SendEvent(UpdateEventType.ProgressBar, 30); + isActiveSource = Lib.IsActiveSource(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting physical address..."); + SendEvent(UpdateEventType.ProgressBar, 40); + physicalAddress = Lib.GetDevicePhysicalAddress(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting CEC version..."); + SendEvent(UpdateEventType.ProgressBar, 50); + version = Lib.GetDeviceCecVersion(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting power status..."); + SendEvent(UpdateEventType.ProgressBar, 60); + power = Lib.GetDevicePowerStatus(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting OSD name..."); + SendEvent(UpdateEventType.ProgressBar, 70); + osdName = Lib.GetDeviceOSDName(Address); + + SendEvent(UpdateEventType.StatusText, "Requesting menu language..."); + SendEvent(UpdateEventType.ProgressBar, 80); + menuLanguage = Lib.GetDeviceMenuLanguage(Address); + } + + SendEvent(UpdateEventType.StatusText, "Showing device information"); + SendEvent(UpdateEventType.ProgressBar, 90); + + DeviceInformation di = new DeviceInformation(Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); + di.ShowDialog(); + + SendEvent(UpdateEventType.StatusText, "Ready."); + SendEvent(UpdateEventType.ProgressBar, 100); + } + + private LibCecSharp Lib; + private CecLogicalAddress Address; + } +} diff --git a/src/cec-config-gui/cec-config-gui.csproj b/src/cec-config-gui/cec-config-gui.csproj index 2923747..4b83aaa 100644 --- a/src/cec-config-gui/cec-config-gui.csproj +++ b/src/cec-config-gui/cec-config-gui.csproj @@ -55,6 +55,10 @@ + + + + @@ -64,12 +68,22 @@ CecConfigGUI.cs + + Form + + + DeviceInformation.cs + CecConfigGUI.cs Designer + + DeviceInformation.cs + Designer + ResXFileCodeGenerator Resources.Designer.cs -- 2.34.1