# HG changeset patch # User StephaneLenclud # Date 1469294576 -7200 # Node ID 96f8b4dc430063bddf52886b5fcba3f99bf39a55 # Parent 83dd86e7344875b8509f76862ed48290014ba4e7 Adding Events tab. diff -r 83dd86e73448 -r 96f8b4dc4300 Server/FormEditAction.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/FormEditAction.Designer.cs Sat Jul 23 19:22:56 2016 +0200 @@ -0,0 +1,104 @@ +namespace SharpDisplayManager +{ + partial class FormEditAction + { + /// + /// 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.comboBoxActionType = new System.Windows.Forms.ComboBox(); + this.labelActionType = new System.Windows.Forms.Label(); + this.buttonOk = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // comboBoxActionType + // + this.comboBoxActionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxActionType.FormattingEnabled = true; + this.comboBoxActionType.Location = new System.Drawing.Point(55, 12); + this.comboBoxActionType.Name = "comboBoxActionType"; + this.comboBoxActionType.Size = new System.Drawing.Size(333, 21); + this.comboBoxActionType.TabIndex = 18; + // + // labelActionType + // + this.labelActionType.AutoSize = true; + this.labelActionType.Location = new System.Drawing.Point(12, 15); + this.labelActionType.Name = "labelActionType"; + this.labelActionType.Size = new System.Drawing.Size(37, 13); + this.labelActionType.TabIndex = 20; + this.labelActionType.Text = "Type :"; + // + // buttonOk + // + this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.buttonOk.Location = new System.Drawing.Point(12, 55); + this.buttonOk.Name = "buttonOk"; + this.buttonOk.Size = new System.Drawing.Size(75, 23); + this.buttonOk.TabIndex = 21; + this.buttonOk.Text = "Ok"; + this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); + // + // buttonCancel + // + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(93, 55); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(75, 23); + this.buttonCancel.TabIndex = 22; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + // + // FormEditAction + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(400, 86); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOk); + this.Controls.Add(this.labelActionType); + this.Controls.Add(this.comboBoxActionType); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FormEditAction"; + this.Text = "Edit action"; + this.Load += new System.EventHandler(this.FormEditAction_Load); + this.Validating += new System.ComponentModel.CancelEventHandler(this.FormEditAction_Validating); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ComboBox comboBoxActionType; + private System.Windows.Forms.Label labelActionType; + private System.Windows.Forms.Button buttonOk; + private System.Windows.Forms.Button buttonCancel; + } +} \ No newline at end of file diff -r 83dd86e73448 -r 96f8b4dc4300 Server/FormEditAction.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/FormEditAction.cs Sat Jul 23 19:22:56 2016 +0200 @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using SharpLib.Ear; + +namespace SharpDisplayManager +{ + public partial class FormEditAction : Form + { + public SharpLib.Ear.Action Action = null; + + public FormEditAction() + { + InitializeComponent(); + } + + private void FormEditAction_Load(object sender, EventArgs e) + { + //Populate registered actions + foreach (string key in EventActionManager.Current.ActionTypes.Keys) + { + Type t = EventActionManager.Current.ActionTypes[key]; + comboBoxActionType.Items.Add(t); + } + + comboBoxActionType.SelectedIndex = 0; + } + + private void buttonOk_Click(object sender, EventArgs e) + { + Action = (SharpLib.Ear.Action)Activator.CreateInstance((Type)comboBoxActionType.SelectedItem); + } + + private void FormEditAction_Validating(object sender, CancelEventArgs e) + { + + } + } +} diff -r 83dd86e73448 -r 96f8b4dc4300 Server/FormEditAction.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Server/FormEditAction.resx Sat Jul 23 19:22:56 2016 +0200 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r 83dd86e73448 -r 96f8b4dc4300 Server/MainForm.Designer.cs --- a/Server/MainForm.Designer.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/Server/MainForm.Designer.cs Sat Jul 23 19:22:56 2016 +0200 @@ -112,6 +112,10 @@ this.checkBoxCecEnabled = new System.Windows.Forms.CheckBox(); this.labelHdmiPort = new System.Windows.Forms.Label(); this.comboBoxHdmiPort = new System.Windows.Forms.ComboBox(); + this.tabPageEvent = new System.Windows.Forms.TabPage(); + this.buttonDeleteAction = new System.Windows.Forms.Button(); + this.buttonAddAction = new System.Windows.Forms.Button(); + this.iTreeViewEvents = new System.Windows.Forms.TreeView(); this.tabPageApp = new System.Windows.Forms.TabPage(); this.checkBoxStartMinimized = new System.Windows.Forms.CheckBox(); this.checkBoxMinimizeToTray = new System.Windows.Forms.CheckBox(); @@ -138,6 +142,7 @@ ((System.ComponentModel.ISupportInitialize)(this.pictureBoxGreenStart)).BeginInit(); this.tabPageCec.SuspendLayout(); this.groupBoxCecLogOptions.SuspendLayout(); + this.tabPageEvent.SuspendLayout(); this.tabPageApp.SuspendLayout(); this.tabPageLogs.SuspendLayout(); this.SuspendLayout(); @@ -566,6 +571,7 @@ this.tabControl.Controls.Add(this.tabPageAudio); this.tabControl.Controls.Add(this.tabPageInput); this.tabControl.Controls.Add(this.tabPageCec); + this.tabControl.Controls.Add(this.tabPageEvent); this.tabControl.Controls.Add(this.tabPageApp); this.tabControl.Controls.Add(this.tabPageLogs); this.tabControl.Location = new System.Drawing.Point(12, 125); @@ -1000,6 +1006,48 @@ this.comboBoxHdmiPort.TabIndex = 19; this.comboBoxHdmiPort.SelectedIndexChanged += new System.EventHandler(this.comboBoxHdmiPort_SelectedIndexChanged); // + // tabPageEvent + // + this.tabPageEvent.Controls.Add(this.buttonDeleteAction); + this.tabPageEvent.Controls.Add(this.buttonAddAction); + this.tabPageEvent.Controls.Add(this.iTreeViewEvents); + this.tabPageEvent.Location = new System.Drawing.Point(4, 22); + this.tabPageEvent.Name = "tabPageEvent"; + this.tabPageEvent.Padding = new System.Windows.Forms.Padding(3); + this.tabPageEvent.Size = new System.Drawing.Size(752, 385); + this.tabPageEvent.TabIndex = 9; + this.tabPageEvent.Text = "Events"; + this.tabPageEvent.UseVisualStyleBackColor = true; + // + // buttonDeleteAction + // + this.buttonDeleteAction.Location = new System.Drawing.Point(6, 35); + this.buttonDeleteAction.Name = "buttonDeleteAction"; + this.buttonDeleteAction.Size = new System.Drawing.Size(96, 23); + this.buttonDeleteAction.TabIndex = 21; + this.buttonDeleteAction.Text = "Delete Action"; + this.buttonDeleteAction.UseVisualStyleBackColor = true; + // + // buttonAddAction + // + this.buttonAddAction.Location = new System.Drawing.Point(6, 6); + this.buttonAddAction.Name = "buttonAddAction"; + this.buttonAddAction.Size = new System.Drawing.Size(96, 23); + this.buttonAddAction.TabIndex = 20; + this.buttonAddAction.Text = "Add Action"; + this.buttonAddAction.UseVisualStyleBackColor = true; + this.buttonAddAction.Click += new System.EventHandler(this.buttonAddAction_Click); + // + // iTreeViewEvents + // + this.iTreeViewEvents.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.iTreeViewEvents.Location = new System.Drawing.Point(111, 3); + this.iTreeViewEvents.Name = "iTreeViewEvents"; + this.iTreeViewEvents.Size = new System.Drawing.Size(638, 376); + this.iTreeViewEvents.TabIndex = 1; + // // tabPageApp // this.tabPageApp.Controls.Add(this.checkBoxStartMinimized); @@ -1163,6 +1211,7 @@ this.tabPageCec.PerformLayout(); this.groupBoxCecLogOptions.ResumeLayout(false); this.groupBoxCecLogOptions.PerformLayout(); + this.tabPageEvent.ResumeLayout(false); this.tabPageApp.ResumeLayout(false); this.tabPageApp.PerformLayout(); this.tabPageLogs.ResumeLayout(false); @@ -1258,6 +1307,10 @@ private System.Windows.Forms.CheckBox checkBoxCecLogNotice; private System.Windows.Forms.CheckBox checkBoxCecLogTraffic; private System.Windows.Forms.CheckBox checkBoxCecLogNoPoll; + private System.Windows.Forms.TabPage tabPageEvent; + private System.Windows.Forms.TreeView iTreeViewEvents; + private System.Windows.Forms.Button buttonDeleteAction; + private System.Windows.Forms.Button buttonAddAction; } } diff -r 83dd86e73448 -r 96f8b4dc4300 Server/MainForm.cs --- a/Server/MainForm.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/Server/MainForm.cs Sat Jul 23 19:22:56 2016 +0200 @@ -210,6 +210,8 @@ OnWndProc += iCecManager.OnWndProc; ResetCec(); + //Setup Events + SetupEvents(); //Setup notification icon SetupTrayIcon(); @@ -285,6 +287,30 @@ } + /// + /// + /// + private void SetupEvents() + { + //Reset our tree + iTreeViewEvents.Nodes.Clear(); + //Populate registered events + foreach (string key in EventActionManager.Current.Events.Keys) + { + Event e = EventActionManager.Current.Events[key]; + TreeNode eventNode = iTreeViewEvents.Nodes.Add(key,e.Name); + eventNode.Tag = e; + eventNode.Nodes.Add(key + ".Description", e.Description); + TreeNode actionsNodes = eventNode.Nodes.Add(key + ".Actions", "Actions"); + + foreach (SharpLib.Ear.Action a in e.Actions) + { + actionsNodes.Nodes.Add(a.Name); + } + } + + } + /// /// Called when our display is closed. /// @@ -2625,5 +2651,23 @@ { SetupCecLogLevel(); } + + private void buttonAddAction_Click(object sender, EventArgs e) + { + Event ear = (Event)iTreeViewEvents.SelectedNode.Tag; + if (ear == null) + { + //Must select event node + return; + } + + FormEditAction ea = new FormEditAction(); + DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea); + if (res == DialogResult.OK) + { + ear.Actions.Add(ea.Action); + SetupEvents(); + } + } } } diff -r 83dd86e73448 -r 96f8b4dc4300 Server/MainForm.resx --- a/Server/MainForm.resx Sat Jul 23 16:00:04 2016 +0200 +++ b/Server/MainForm.resx Sat Jul 23 19:22:56 2016 +0200 @@ -185,9 +185,6 @@ WSC3/b/CbwiR/gNzbuWksIMBOAAAAABJRU5ErkJggg== - - 315, 17 - 405, 17 diff -r 83dd86e73448 -r 96f8b4dc4300 Server/SharpDisplayManager.csproj --- a/Server/SharpDisplayManager.csproj Sat Jul 23 16:00:04 2016 +0200 +++ b/Server/SharpDisplayManager.csproj Sat Jul 23 19:22:56 2016 +0200 @@ -157,6 +157,12 @@ + + Form + + + FormEditAction.cs + UserControl @@ -193,6 +199,9 @@ + + FormEditAction.cs + FxControl.cs diff -r 83dd86e73448 -r 96f8b4dc4300 SharpLibEar/Action.cs --- a/SharpLibEar/Action.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/SharpLibEar/Action.cs Sat Jul 23 19:22:56 2016 +0200 @@ -12,6 +12,12 @@ { public abstract void Execute(); + public string Name { + //Get the name of this object action attribute + get { return Utils.Reflection.GetAttribute(GetType()).Name; } + private set { } + } + public int CompareTo(object obj) { //Sort by action name diff -r 83dd86e73448 -r 96f8b4dc4300 SharpLibEar/EventActionManager.cs --- a/SharpLibEar/EventActionManager.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/SharpLibEar/EventActionManager.cs Sat Jul 23 19:22:56 2016 +0200 @@ -14,7 +14,7 @@ { public static EventActionManager Current = null; public IDictionary ActionTypes; - private IDictionary Events; + public readonly IDictionary Events; public EventActionManager() { diff -r 83dd86e73448 -r 96f8b4dc4300 SharpLibEar/EventMonitorPowerOff.cs --- a/SharpLibEar/EventMonitorPowerOff.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/SharpLibEar/EventMonitorPowerOff.cs Sat Jul 23 19:22:56 2016 +0200 @@ -11,7 +11,7 @@ public EventMonitorPowerOff() { Name = "Monitor Power Off"; - Description = ""; + Description = "Windows is powering off your monitor."; } } diff -r 83dd86e73448 -r 96f8b4dc4300 SharpLibEar/EventMonitorPowerOn.cs --- a/SharpLibEar/EventMonitorPowerOn.cs Sat Jul 23 16:00:04 2016 +0200 +++ b/SharpLibEar/EventMonitorPowerOn.cs Sat Jul 23 19:22:56 2016 +0200 @@ -11,7 +11,7 @@ public EventMonitorPowerOn() { Name = "Monitor Power On"; - Description = ""; + Description = "Windows is powering on your monitor."; } }