this.lConnectedDevice = new System.Windows.Forms.Label();
this.lPortNumber = new System.Windows.Forms.Label();
this.tbButtons = new System.Windows.Forms.TabPage();
+ this.dgButtons = new System.Windows.Forms.DataGridView();
this.LogOutput = new System.Windows.Forms.TabPage();
+ this.bSaveLog = new System.Windows.Forms.Button();
this.bClearLog = new System.Windows.Forms.Button();
this.cbLogDebug = new System.Windows.Forms.CheckBox();
this.cbLogTraffic = new System.Windows.Forms.CheckBox();
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.bSaveLog = new System.Windows.Forms.Button();
+ 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.SuspendLayout();
//
// tabControl1
//
// tbButtons
//
+ this.tbButtons.Controls.Add(this.dgButtons);
this.tbButtons.Location = new System.Drawing.Point(4, 22);
this.tbButtons.Name = "tbButtons";
this.tbButtons.Padding = new System.Windows.Forms.Padding(3);
this.tbButtons.Text = "Button Configuration";
this.tbButtons.UseVisualStyleBackColor = true;
//
+ // dgButtons
+ //
+ this.dgButtons.AllowUserToAddRows = false;
+ this.dgButtons.AllowUserToDeleteRows = false;
+ this.dgButtons.AllowUserToResizeColumns = false;
+ this.dgButtons.AllowUserToResizeRows = false;
+ this.dgButtons.AutoGenerateColumns = false;
+ this.dgButtons.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+ this.dgButtons.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.CecButtonName,
+ this.playerButtonDataGridViewTextBoxColumn});
+ this.dgButtons.DataSource = this.cecButtonConfigBindingSource;
+ this.dgButtons.Location = new System.Drawing.Point(7, 7);
+ this.dgButtons.Name = "dgButtons";
+ this.dgButtons.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+ this.dgButtons.Size = new System.Drawing.Size(579, 346);
+ this.dgButtons.TabIndex = 0;
+ this.dgButtons.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.dataGridView1_CellFormatting);
+ //
// LogOutput
//
this.LogOutput.Controls.Add(this.bSaveLog);
this.LogOutput.Text = "Log Output";
this.LogOutput.UseVisualStyleBackColor = true;
//
+ // bSaveLog
+ //
+ this.bSaveLog.Location = new System.Drawing.Point(430, 330);
+ this.bSaveLog.Name = "bSaveLog";
+ this.bSaveLog.Size = new System.Drawing.Size(75, 23);
+ this.bSaveLog.TabIndex = 7;
+ this.bSaveLog.Text = "Save";
+ this.bSaveLog.UseVisualStyleBackColor = true;
+ this.bSaveLog.Click += new System.EventHandler(this.bSaveLog_Click);
+ //
// bClearLog
//
this.bClearLog.Location = new System.Drawing.Point(511, 330);
this.lStatus.TabIndex = 2;
this.lStatus.Text = "Initialising...";
//
- // bSaveLog
+ // cecButtonConfigBindingSource
//
- this.bSaveLog.Location = new System.Drawing.Point(430, 330);
- this.bSaveLog.Name = "bSaveLog";
- this.bSaveLog.Size = new System.Drawing.Size(75, 23);
- this.bSaveLog.TabIndex = 7;
- this.bSaveLog.Text = "Save";
- this.bSaveLog.UseVisualStyleBackColor = true;
- this.bSaveLog.Click += new System.EventHandler(this.bSaveLog_Click);
+ 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.tabControl1.ResumeLayout(false);
this.Configuration.ResumeLayout(false);
this.Configuration.PerformLayout();
+ this.tbButtons.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.dgButtons)).EndInit();
this.LogOutput.ResumeLayout(false);
this.LogOutput.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
private System.Windows.Forms.CheckBox cbLogError;
private System.Windows.Forms.Button bClearLog;
private System.Windows.Forms.Button bSaveLog;
+ private System.Windows.Forms.DataGridView dgButtons;
+ private System.Windows.Forms.BindingSource cecButtonConfigBindingSource;
+ private System.Windows.Forms.DataGridViewTextBoxColumn CecButtonName;
+ private System.Windows.Forms.DataGridViewTextBoxColumn playerButtonDataGridViewTextBoxColumn;
}
}
\ No newline at end of file
InitializeComponent();
Lib = new LibCecSharp(Config);
+ LoadButtonConfiguration();
+
ActiveProcess = new ConnectToDevice(ref Lib);
ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
(new Thread(new ThreadStart(ActiveProcess.Run))).Start();
}
+ private void LoadButtonConfiguration()
+ {
+ //TODO load the real configuration
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select", (new CecSharp.CecKeypress() { Keycode = 0x00 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Up", (new CecSharp.CecKeypress() { Keycode = 0x01 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Down", (new CecSharp.CecKeypress() { Keycode = 0x02 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left", (new CecSharp.CecKeypress() { Keycode = 0x03 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right", (new CecSharp.CecKeypress() { Keycode = 0x04 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Up", (new CecSharp.CecKeypress() { Keycode = 0x05 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Right+Down", (new CecSharp.CecKeypress() { Keycode = 0x06 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Up", (new CecSharp.CecKeypress() { Keycode = 0x07 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Left+Down", (new CecSharp.CecKeypress() { Keycode = 0x08 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Root menu", (new CecSharp.CecKeypress() { Keycode = 0x09 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Setup menu", (new CecSharp.CecKeypress() { Keycode = 0x0A }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Contents menu", (new CecSharp.CecKeypress() { Keycode = 0x0B }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Favourite menu", (new CecSharp.CecKeypress() { Keycode = 0x0C }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Exit", (new CecSharp.CecKeypress() { Keycode = 0x0D }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("0", (new CecSharp.CecKeypress() { Keycode = 0x20 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("1", (new CecSharp.CecKeypress() { Keycode = 0x21 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("2", (new CecSharp.CecKeypress() { Keycode = 0x22 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("3", (new CecSharp.CecKeypress() { Keycode = 0x23 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("4", (new CecSharp.CecKeypress() { Keycode = 0x24 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("5", (new CecSharp.CecKeypress() { Keycode = 0x25 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("6", (new CecSharp.CecKeypress() { Keycode = 0x26 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("7", (new CecSharp.CecKeypress() { Keycode = 0x27 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("8", (new CecSharp.CecKeypress() { Keycode = 0x28 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("9", (new CecSharp.CecKeypress() { Keycode = 0x29 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem(".", (new CecSharp.CecKeypress() { Keycode = 0x2A }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Enter", (new CecSharp.CecKeypress() { Keycode = 0x2B }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Clear", (new CecSharp.CecKeypress() { Keycode = 0x2C }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Next favourite", (new CecSharp.CecKeypress() { Keycode = 0x2F }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel up", (new CecSharp.CecKeypress() { Keycode = 0x30 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Channel down", (new CecSharp.CecKeypress() { Keycode = 0x31 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Previous channel", (new CecSharp.CecKeypress() { Keycode = 0x32 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sound select", (new CecSharp.CecKeypress() { Keycode = 0x33 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Input select", (new CecSharp.CecKeypress() { Keycode = 0x34 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Display information", (new CecSharp.CecKeypress() { Keycode = 0x35 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Help", (new CecSharp.CecKeypress() { Keycode = 0x36 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page up", (new CecSharp.CecKeypress() { Keycode = 0x37 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Page down", (new CecSharp.CecKeypress() { Keycode = 0x38 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power", (new CecSharp.CecKeypress() { Keycode = 0x40 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume up", (new CecSharp.CecKeypress() { Keycode = 0x41 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Volume down", (new CecSharp.CecKeypress() { Keycode = 0x42 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute", (new CecSharp.CecKeypress() { Keycode = 0x43 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play", (new CecSharp.CecKeypress() { Keycode = 0x44 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop", (new CecSharp.CecKeypress() { Keycode = 0x45 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause", (new CecSharp.CecKeypress() { Keycode = 0x46 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record", (new CecSharp.CecKeypress() { Keycode = 0x47 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Rewind", (new CecSharp.CecKeypress() { Keycode = 0x48 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Fast forward", (new CecSharp.CecKeypress() { Keycode = 0x49 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Eject", (new CecSharp.CecKeypress() { Keycode = 0x4A }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Forward", (new CecSharp.CecKeypress() { Keycode = 0x4B }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Backward", (new CecSharp.CecKeypress() { Keycode = 0x4C }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop record", (new CecSharp.CecKeypress() { Keycode = 0x4D }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record", (new CecSharp.CecKeypress() { Keycode = 0x4E }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Angle", (new CecSharp.CecKeypress() { Keycode = 0x50 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Sub picture", (new CecSharp.CecKeypress() { Keycode = 0x51 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Video on demand", (new CecSharp.CecKeypress() { Keycode = 0x52 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Electronic program guide", (new CecSharp.CecKeypress() { Keycode = 0x53 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Timer programming", (new CecSharp.CecKeypress() { Keycode = 0x54 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Initial configuration", (new CecSharp.CecKeypress() { Keycode = 0x55 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Play (function)", (new CecSharp.CecKeypress() { Keycode = 0x60 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause play (function)", (new CecSharp.CecKeypress() { Keycode = 0x61 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Record (function)", (new CecSharp.CecKeypress() { Keycode = 0x62 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Pause record (function)", (new CecSharp.CecKeypress() { Keycode = 0x63 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Stop (function)", (new CecSharp.CecKeypress() { Keycode = 0x64 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Mute (function)", (new CecSharp.CecKeypress() { Keycode = 0x65 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Restore volume", (new CecSharp.CecKeypress() { Keycode = 0x66 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Tune", (new CecSharp.CecKeypress() { Keycode = 0x67 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select media", (new CecSharp.CecKeypress() { Keycode = 0x68 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select AV input", (new CecSharp.CecKeypress() { Keycode = 0x69 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Select audio input", (new CecSharp.CecKeypress() { Keycode = 0x6A }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power toggle", (new CecSharp.CecKeypress() { Keycode = 0x6B }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power off", (new CecSharp.CecKeypress() { Keycode = 0x6C }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Power on", (new CecSharp.CecKeypress() { Keycode = 0x6D }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F1 (blue)", (new CecSharp.CecKeypress() { Keycode = 0x71 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F2 (red)", (new CecSharp.CecKeypress() { Keycode = 0x72 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F3 (green)", (new CecSharp.CecKeypress() { Keycode = 0x73 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F4 (yellow)", (new CecSharp.CecKeypress() { Keycode = 0x74 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("F5", (new CecSharp.CecKeypress() { Keycode = 0x75 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("Data", (new CecSharp.CecKeypress() { Keycode = 0x76 }), string.Empty));
+ this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecSharp.CecKeypress() { Keycode = 0x91 }), string.Empty));
+ }
+
public int ReceiveCommand(CecCommand command)
{
return 1;
public int ReceiveKeypress(CecKeypress key)
{
+ SelectKeypressRow(key);
return 1;
}
+ delegate void SelectKeypressRowCallback(CecKeypress key);
+ private void SelectKeypressRow(CecKeypress key)
+ {
+ if (dgButtons.InvokeRequired)
+ {
+ SelectKeypressRowCallback d = new SelectKeypressRowCallback(SelectKeypressRow);
+ try
+ {
+ this.Invoke(d, new object[] { key });
+ }
+ catch (Exception) { }
+ }
+ else
+ {
+ int rowIndex = -1;
+ foreach (DataGridViewRow row in dgButtons.Rows)
+ {
+ CecButtonConfigItem item = row.DataBoundItem as CecButtonConfigItem;
+ if (item != null && item.Key.Keycode == key.Keycode)
+ {
+ rowIndex = row.Index;
+ row.Selected = true;
+ item.Enabled = true;
+ }
+ else
+ {
+ row.Selected = false;
+ }
+ }
+ if (rowIndex > -1)
+ dgButtons.FirstDisplayedScrollingRowIndex = rowIndex;
+ }
+ }
+
delegate void AddLogMessageCallback(CecLogMessage message);
private void AddLogMessage(CecLogMessage message)
{
}
}
}
+
+ private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
+ {
+ DataGridView grid = sender as DataGridView;
+ CecButtonConfigItem data = grid.Rows[e.RowIndex].DataBoundItem as CecButtonConfigItem;
+ if (data == null || !data.Enabled)
+ e.CellStyle.ForeColor = Color.Gray;
+ }
}
internal class CecCallbackWrapper : CecCallbackMethods