Ear HID event now functional.
1.1 --- a/Server/Events/EventHid.cs Sat Aug 20 21:00:35 2016 +0200
1.2 +++ b/Server/Events/EventHid.cs Sun Aug 21 16:11:40 2016 +0200
1.3 @@ -12,7 +12,7 @@
1.4 namespace SharpDisplayManager
1.5 {
1.6 [DataContract]
1.7 - [Ear.AttributeObject(Id = "Event.Hid", Name = "HID", Description = "Corresponding HID message received.")]
1.8 + [Ear.AttributeObject(Id = "Event.Hid", Name = "HID", Description = "Handle input from Keyboards and Remotes.")]
1.9 public class EventHid: Ear.Event
1.10 {
1.11 public EventHid()
1.12 @@ -62,7 +62,7 @@
1.13 public bool HasModifierWindows { get; set; } = false;
1.14
1.15 [DataMember]
1.16 - public string PersistedBrief { get; set; } = "Press a key";
1.17 + public string UsageName { get; set; } = "Press a key";
1.18
1.19
1.20
1.21 @@ -111,7 +111,7 @@
1.22 }
1.23 else if (IsGeneric)
1.24 {
1.25 - brief += PersistedBrief;
1.26 + brief += UsageName;
1.27 }
1.28
1.29 if (IsKeyUp)
1.30 @@ -133,15 +133,21 @@
1.31 /// <returns></returns>
1.32 public override bool Equals(object obj)
1.33 {
1.34 - if (obj is EventHidKeyboard)
1.35 + if (obj is EventHid)
1.36 {
1.37 - EventHidKeyboard e = (EventHidKeyboard)obj;
1.38 + EventHid e = (EventHid)obj;
1.39 return e.Key == Key
1.40 - && e.IsKeyUp == IsKeyUp
1.41 - && e.HasModifierAlt == HasModifierAlt
1.42 - && e.HasModifierControl == HasModifierControl
1.43 - && e.HasModifierShift == HasModifierShift
1.44 - && e.HasModifierWindows == HasModifierWindows;
1.45 + && e.Usage == Usage
1.46 + && e.UsagePage == UsagePage
1.47 + && e.UsageCollection == UsageCollection
1.48 + && e.IsKeyUp == IsKeyUp
1.49 + && e.IsGeneric == IsGeneric
1.50 + && e.IsKeyboard == IsKeyboard
1.51 + && e.IsMouse == IsMouse
1.52 + && e.HasModifierAlt == HasModifierAlt
1.53 + && e.HasModifierControl == HasModifierControl
1.54 + && e.HasModifierShift == HasModifierShift
1.55 + && e.HasModifierWindows == HasModifierWindows;
1.56 }
1.57
1.58 return false;
1.59 @@ -230,7 +236,7 @@
1.60 if (aHidEvent.Usages.Count > 0)
1.61 {
1.62 Usage = aHidEvent.Usages[0];
1.63 - PersistedBrief = aHidEvent.UsageName(0);
1.64 + UsageName = aHidEvent.UsageName(0);
1.65 }
1.66
1.67 Key = Keys.None;
1.68 @@ -251,6 +257,13 @@
1.69
1.70 }
1.71
1.72 -
1.73 + /// <summary>
1.74 + ///
1.75 + /// </summary>
1.76 + /// <returns></returns>
1.77 + public override bool IsValid()
1.78 + {
1.79 + return IsGeneric || IsKeyboard;
1.80 + }
1.81 }
1.82 }
2.1 --- a/Server/FormEditObject.Designer.cs Sat Aug 20 21:00:35 2016 +0200
2.2 +++ b/Server/FormEditObject.Designer.cs Sun Aug 21 16:11:40 2016 +0200
2.3 @@ -29,33 +29,35 @@
2.4 private void InitializeComponent()
2.5 {
2.6 this.components = new System.ComponentModel.Container();
2.7 - this.comboBoxActionType = new System.Windows.Forms.ComboBox();
2.8 + this.iComboBoxObjectType = new System.Windows.Forms.ComboBox();
2.9 this.labelActionType = new System.Windows.Forms.Label();
2.10 - this.buttonOk = new System.Windows.Forms.Button();
2.11 + this.iButtonOk = new System.Windows.Forms.Button();
2.12 this.buttonCancel = new System.Windows.Forms.Button();
2.13 this.iTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
2.14 this.toolTip = new System.Windows.Forms.ToolTip(this.components);
2.15 - this.buttonTest = new System.Windows.Forms.Button();
2.16 - this.labelBrief = new System.Windows.Forms.Label();
2.17 + this.iButtonTest = new System.Windows.Forms.Button();
2.18 + this.iLabelBrief = new System.Windows.Forms.Label();
2.19 + this.iLabelDescription = new System.Windows.Forms.Label();
2.20 this.SuspendLayout();
2.21 //
2.22 - // comboBoxActionType
2.23 + // iComboBoxObjectType
2.24 //
2.25 - this.comboBoxActionType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
2.26 + this.iComboBoxObjectType.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
2.27 | System.Windows.Forms.AnchorStyles.Right)));
2.28 - this.comboBoxActionType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
2.29 - this.comboBoxActionType.FormattingEnabled = true;
2.30 - this.comboBoxActionType.Location = new System.Drawing.Point(55, 12);
2.31 - this.comboBoxActionType.Name = "comboBoxActionType";
2.32 - this.comboBoxActionType.Size = new System.Drawing.Size(272, 21);
2.33 - this.comboBoxActionType.Sorted = true;
2.34 - this.comboBoxActionType.TabIndex = 18;
2.35 - this.comboBoxActionType.SelectedIndexChanged += new System.EventHandler(this.comboBoxActionType_SelectedIndexChanged);
2.36 + this.iComboBoxObjectType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
2.37 + this.iComboBoxObjectType.FormattingEnabled = true;
2.38 + this.iComboBoxObjectType.Location = new System.Drawing.Point(55, 52);
2.39 + this.iComboBoxObjectType.Name = "iComboBoxObjectType";
2.40 + this.iComboBoxObjectType.Size = new System.Drawing.Size(272, 21);
2.41 + this.iComboBoxObjectType.Sorted = true;
2.42 + this.iComboBoxObjectType.TabIndex = 18;
2.43 + this.iComboBoxObjectType.SelectedIndexChanged += new System.EventHandler(this.comboBoxActionType_SelectedIndexChanged);
2.44 + this.iComboBoxObjectType.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.iComboBoxObjectType_KeyPress);
2.45 //
2.46 // labelActionType
2.47 //
2.48 this.labelActionType.AutoSize = true;
2.49 - this.labelActionType.Location = new System.Drawing.Point(12, 15);
2.50 + this.labelActionType.Location = new System.Drawing.Point(12, 55);
2.51 this.labelActionType.Name = "labelActionType";
2.52 this.labelActionType.Size = new System.Drawing.Size(37, 13);
2.53 this.labelActionType.TabIndex = 20;
2.54 @@ -63,21 +65,21 @@
2.55 //
2.56 // buttonOk
2.57 //
2.58 - this.buttonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
2.59 - this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
2.60 - this.buttonOk.Location = new System.Drawing.Point(12, 151);
2.61 - this.buttonOk.Name = "buttonOk";
2.62 - this.buttonOk.Size = new System.Drawing.Size(75, 23);
2.63 - this.buttonOk.TabIndex = 21;
2.64 - this.buttonOk.Text = "Ok";
2.65 - this.buttonOk.UseVisualStyleBackColor = true;
2.66 - this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click);
2.67 + this.iButtonOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
2.68 + this.iButtonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
2.69 + this.iButtonOk.Location = new System.Drawing.Point(12, 157);
2.70 + this.iButtonOk.Name = "buttonOk";
2.71 + this.iButtonOk.Size = new System.Drawing.Size(75, 23);
2.72 + this.iButtonOk.TabIndex = 21;
2.73 + this.iButtonOk.Text = "Ok";
2.74 + this.iButtonOk.UseVisualStyleBackColor = true;
2.75 + this.iButtonOk.Click += new System.EventHandler(this.buttonOk_Click);
2.76 //
2.77 // buttonCancel
2.78 //
2.79 this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
2.80 this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
2.81 - this.buttonCancel.Location = new System.Drawing.Point(93, 151);
2.82 + this.buttonCancel.Location = new System.Drawing.Point(93, 157);
2.83 this.buttonCancel.Name = "buttonCancel";
2.84 this.buttonCancel.Size = new System.Drawing.Size(75, 23);
2.85 this.buttonCancel.TabIndex = 22;
2.86 @@ -94,51 +96,65 @@
2.87 this.iTableLayoutPanel.ColumnCount = 2;
2.88 this.iTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
2.89 this.iTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
2.90 - this.iTableLayoutPanel.Location = new System.Drawing.Point(15, 72);
2.91 + this.iTableLayoutPanel.Location = new System.Drawing.Point(15, 91);
2.92 this.iTableLayoutPanel.Name = "iTableLayoutPanel";
2.93 this.iTableLayoutPanel.RowCount = 2;
2.94 this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
2.95 this.iTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
2.96 - this.iTableLayoutPanel.Size = new System.Drawing.Size(312, 60);
2.97 + this.iTableLayoutPanel.Size = new System.Drawing.Size(312, 46);
2.98 this.iTableLayoutPanel.TabIndex = 23;
2.99 //
2.100 // buttonTest
2.101 //
2.102 - this.buttonTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
2.103 - this.buttonTest.Location = new System.Drawing.Point(252, 151);
2.104 - this.buttonTest.Name = "buttonTest";
2.105 - this.buttonTest.Size = new System.Drawing.Size(75, 23);
2.106 - this.buttonTest.TabIndex = 24;
2.107 - this.buttonTest.Text = "Test";
2.108 - this.buttonTest.UseVisualStyleBackColor = true;
2.109 - this.buttonTest.Click += new System.EventHandler(this.buttonTest_Click);
2.110 + this.iButtonTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
2.111 + this.iButtonTest.Location = new System.Drawing.Point(252, 157);
2.112 + this.iButtonTest.Name = "buttonTest";
2.113 + this.iButtonTest.Size = new System.Drawing.Size(75, 23);
2.114 + this.iButtonTest.TabIndex = 24;
2.115 + this.iButtonTest.Text = "Test";
2.116 + this.iButtonTest.UseVisualStyleBackColor = true;
2.117 + this.iButtonTest.Click += new System.EventHandler(this.buttonTest_Click);
2.118 //
2.119 - // labelBrief
2.120 + // iLabelBrief
2.121 //
2.122 - this.labelBrief.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
2.123 + this.iLabelBrief.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
2.124 | System.Windows.Forms.AnchorStyles.Right)));
2.125 - this.labelBrief.AutoSize = true;
2.126 - this.labelBrief.Location = new System.Drawing.Point(12, 45);
2.127 - this.labelBrief.Name = "labelBrief";
2.128 - this.labelBrief.Size = new System.Drawing.Size(28, 13);
2.129 - this.labelBrief.TabIndex = 25;
2.130 - this.labelBrief.Text = "Brief";
2.131 + this.iLabelBrief.AutoSize = true;
2.132 + this.iLabelBrief.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
2.133 + this.iLabelBrief.Location = new System.Drawing.Point(12, 9);
2.134 + this.iLabelBrief.Name = "iLabelBrief";
2.135 + this.iLabelBrief.Size = new System.Drawing.Size(33, 13);
2.136 + this.iLabelBrief.TabIndex = 25;
2.137 + this.iLabelBrief.Text = "Brief";
2.138 + //
2.139 + // iLabelDescription
2.140 + //
2.141 + this.iLabelDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
2.142 + | System.Windows.Forms.AnchorStyles.Right)));
2.143 + this.iLabelDescription.AutoSize = true;
2.144 + this.iLabelDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
2.145 + this.iLabelDescription.Location = new System.Drawing.Point(12, 31);
2.146 + this.iLabelDescription.Name = "iLabelDescription";
2.147 + this.iLabelDescription.Size = new System.Drawing.Size(60, 13);
2.148 + this.iLabelDescription.TabIndex = 26;
2.149 + this.iLabelDescription.Text = "Description";
2.150 //
2.151 // FormEditObject
2.152 //
2.153 - this.AcceptButton = this.buttonOk;
2.154 + this.AcceptButton = this.iButtonOk;
2.155 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
2.156 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
2.157 this.AutoSize = true;
2.158 this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
2.159 this.CancelButton = this.buttonCancel;
2.160 - this.ClientSize = new System.Drawing.Size(339, 186);
2.161 - this.Controls.Add(this.labelBrief);
2.162 - this.Controls.Add(this.buttonTest);
2.163 + this.ClientSize = new System.Drawing.Size(339, 192);
2.164 + this.Controls.Add(this.iLabelDescription);
2.165 + this.Controls.Add(this.iLabelBrief);
2.166 + this.Controls.Add(this.iButtonTest);
2.167 this.Controls.Add(this.buttonCancel);
2.168 - this.Controls.Add(this.buttonOk);
2.169 + this.Controls.Add(this.iButtonOk);
2.170 this.Controls.Add(this.labelActionType);
2.171 - this.Controls.Add(this.comboBoxActionType);
2.172 + this.Controls.Add(this.iComboBoxObjectType);
2.173 this.Controls.Add(this.iTableLayoutPanel);
2.174 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
2.175 this.MaximizeBox = false;
2.176 @@ -154,13 +170,14 @@
2.177
2.178 #endregion
2.179
2.180 - private System.Windows.Forms.ComboBox comboBoxActionType;
2.181 + private System.Windows.Forms.ComboBox iComboBoxObjectType;
2.182 private System.Windows.Forms.Label labelActionType;
2.183 - private System.Windows.Forms.Button buttonOk;
2.184 + private System.Windows.Forms.Button iButtonOk;
2.185 private System.Windows.Forms.Button buttonCancel;
2.186 private System.Windows.Forms.TableLayoutPanel iTableLayoutPanel;
2.187 private System.Windows.Forms.ToolTip toolTip;
2.188 - private System.Windows.Forms.Button buttonTest;
2.189 - private System.Windows.Forms.Label labelBrief;
2.190 + private System.Windows.Forms.Button iButtonTest;
2.191 + private System.Windows.Forms.Label iLabelBrief;
2.192 + private System.Windows.Forms.Label iLabelDescription;
2.193 }
2.194 }
2.195 \ No newline at end of file
3.1 --- a/Server/FormEditObject.cs Sat Aug 20 21:00:35 2016 +0200
3.2 +++ b/Server/FormEditObject.cs Sun Aug 21 16:11:40 2016 +0200
3.3 @@ -42,42 +42,53 @@
3.4 foreach (Type type in types)
3.5 {
3.6 ItemObjectType item = new ItemObjectType(type);
3.7 - comboBoxActionType.Items.Add(item);
3.8 + iComboBoxObjectType.Items.Add(item);
3.9 }
3.10
3.11 if (Object == null)
3.12 {
3.13 // Creating new issue, select our first item
3.14 - comboBoxActionType.SelectedIndex = 0;
3.15 + iComboBoxObjectType.SelectedIndex = 0;
3.16 }
3.17 else
3.18 {
3.19 // Editing existing object
3.20 // Look up our item in our object type combobox
3.21 - foreach (ItemObjectType item in comboBoxActionType.Items)
3.22 + foreach (ItemObjectType item in iComboBoxObjectType.Items)
3.23 {
3.24 if (item.Type == Object.GetType())
3.25 {
3.26 - comboBoxActionType.SelectedItem = item;
3.27 + iComboBoxObjectType.SelectedItem = item;
3.28 }
3.29 }
3.30
3.31 }
3.32 }
3.33
3.34 + /// <summary>
3.35 + ///
3.36 + /// </summary>
3.37 + /// <param name="sender"></param>
3.38 + /// <param name="e"></param>
3.39 private void buttonOk_Click(object sender, EventArgs e)
3.40 {
3.41 FetchPropertiesValue(Object);
3.42 if (!Object.IsValid())
3.43 {
3.44 - // Tell for closing event to abort
3.45 + // Tell closing event to cancel
3.46 DialogResult = DialogResult.None;
3.47 }
3.48 }
3.49
3.50
3.51 + /// <summary>
3.52 + ///
3.53 + /// </summary>
3.54 + /// <param name="sender"></param>
3.55 + /// <param name="e"></param>
3.56 private void FormEditObject_FormClosing(object sender, FormClosingEventArgs e)
3.57 {
3.58 + //Check if we need to cancel the closing of our form.
3.59 e.Cancel = DialogResult == DialogResult.None;
3.60
3.61 if (!e.Cancel)
3.62 @@ -88,21 +99,23 @@
3.63 }
3.64 }
3.65
3.66 + /// <summary>
3.67 + ///
3.68 + /// </summary>
3.69 + /// <param name="sender"></param>
3.70 + /// <param name="e"></param>
3.71 private void comboBoxActionType_SelectedIndexChanged(object sender, EventArgs e)
3.72 {
3.73 //Instantiate an action corresponding to our type
3.74 - Type actionType = ((ItemObjectType) comboBoxActionType.SelectedItem).Type;
3.75 + Type actionType = ((ItemObjectType) iComboBoxObjectType.SelectedItem).Type;
3.76 //Create another type of action only if needed
3.77 if (Object == null || Object.GetType() != actionType)
3.78 {
3.79 Object = (T)Activator.CreateInstance(actionType);
3.80 }
3.81
3.82 - //Disable ok button if our object is not valid
3.83 - buttonOk.Enabled = Object.IsValid();
3.84 -
3.85 //Create input fields
3.86 - UpdateTableLayoutPanel(Object);
3.87 + UpdateControls();
3.88 }
3.89
3.90
3.91 @@ -206,6 +219,8 @@
3.92 ctrl.Maximum = Int32.Parse(aAttribute.Maximum);
3.93 ctrl.Increment = Int32.Parse(aAttribute.Increment);
3.94 ctrl.Value = (int)aInfo.GetValue(aObject);
3.95 + // Hook-in change notification after setting the value
3.96 + ctrl.ValueChanged += ControlValueChanged;
3.97 return ctrl;
3.98 }
3.99 else if (aInfo.PropertyType.IsEnum)
3.100 @@ -238,6 +253,8 @@
3.101 enumValue = aInfo.GetValue(aObject);
3.102 //Set the current item
3.103 ctrl.SelectedItem = enumValue.ToString();
3.104 + // Hook-in change notification after setting the value
3.105 + ctrl.SelectedIndexChanged += ControlValueChanged;
3.106
3.107 return ctrl;
3.108 }
3.109 @@ -247,6 +264,8 @@
3.110 ctrl.AutoSize = true;
3.111 ctrl.Text = aAttribute.Description;
3.112 ctrl.Checked = (bool)aInfo.GetValue(aObject);
3.113 + // Hook-in change notification after setting the value
3.114 + ctrl.CheckedChanged += ControlValueChanged;
3.115 return ctrl;
3.116 }
3.117 else if (aInfo.PropertyType == typeof(string))
3.118 @@ -254,6 +273,8 @@
3.119 TextBox ctrl = new TextBox();
3.120 ctrl.AutoSize = true;
3.121 ctrl.Text = (string)aInfo.GetValue(aObject);
3.122 + // Hook-in change notification after setting the value
3.123 + ctrl.TextChanged += ControlValueChanged;
3.124 return ctrl;
3.125 }
3.126 else if (aInfo.PropertyType == typeof(PropertyFile))
3.127 @@ -263,7 +284,6 @@
3.128 Button ctrl = new Button();
3.129 ctrl.AutoSize = true;
3.130 ctrl.Text = ((PropertyFile)aInfo.GetValue(aObject)).FullPath;
3.131 -
3.132 // Add lambda expression to Click event
3.133 ctrl.Click += (sender, e) =>
3.134 {
3.135 @@ -277,11 +297,11 @@
3.136 {
3.137 // Fetch selected file name
3.138 ctrl.Text = ofd.FileName;
3.139 - //Enable Ok button then
3.140 - buttonOk.Enabled = Object.IsValid();
3.141 }
3.142 };
3.143
3.144 + // Hook-in change notification after setting the value
3.145 + ctrl.TextChanged += ControlValueChanged;
3.146 return ctrl;
3.147 }
3.148 else if (aInfo.PropertyType == typeof(PropertyComboBox))
3.149 @@ -349,8 +369,9 @@
3.150 /// Will instantiated every field control as defined by our object.
3.151 /// </summary>
3.152 /// <param name="aLayout"></param>
3.153 - private void UpdateTableLayoutPanel(T aObject)
3.154 + private void UpdateControls()
3.155 {
3.156 +
3.157 toolTip.RemoveAll();
3.158 //Debug.Print("UpdateTableLayoutPanel")
3.159 //First clean our current panel
3.160 @@ -365,20 +386,22 @@
3.161 iTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
3.162
3.163
3.164 - if (aObject == null)
3.165 + if (Object == null)
3.166 {
3.167 //Just drop it
3.168 return;
3.169 }
3.170
3.171 + UpdateStaticControls();
3.172 +
3.173 //IEnumerable<PropertyInfo> properties = aObject.GetType().GetProperties().Where(
3.174 // prop => Attribute.IsDefined(prop, typeof(AttributeObjectProperty)));
3.175
3.176 //TODO: Do this whenever a field changes
3.177 - labelBrief.Text = Object.Brief();
3.178 + iLabelBrief.Text = Object.Brief();
3.179
3.180
3.181 - foreach (PropertyInfo pi in aObject.GetType().GetProperties())
3.182 + foreach (PropertyInfo pi in Object.GetType().GetProperties())
3.183 {
3.184 AttributeObjectProperty[] attributes = ((AttributeObjectProperty[])pi.GetCustomAttributes(typeof(AttributeObjectProperty), true));
3.185 if (attributes.Length != 1)
3.186 @@ -390,7 +413,7 @@
3.187
3.188 //Before anything we need to check if that kind of property is supported by our UI
3.189 //Create the editor
3.190 - Control ctrl = CreateControlForProperty(pi, attribute, aObject);
3.191 + Control ctrl = CreateControlForProperty(pi, attribute, Object);
3.192 if (ctrl == null)
3.193 {
3.194 //Property type not supported
3.195 @@ -421,6 +444,11 @@
3.196 Object.PropertyChanged += PropertyChangedEventHandlerThreadSafe;
3.197 }
3.198
3.199 + /// <summary>
3.200 + ///
3.201 + /// </summary>
3.202 + /// <param name="sender"></param>
3.203 + /// <param name="e"></param>
3.204 void PropertyChangedEventHandlerThreadSafe(object sender, PropertyChangedEventArgs e)
3.205 {
3.206 if (this.InvokeRequired)
3.207 @@ -431,16 +459,13 @@
3.208 }
3.209 else
3.210 {
3.211 - //Disable ok button if our object is not valid
3.212 - buttonOk.Enabled = Object.IsValid();
3.213 + // We could test the name of the property that has changed as follow
3.214 + // It's currently not needed though
3.215 + //if (e.PropertyName == "Brief")
3.216
3.217 - if (e.PropertyName == "Brief")
3.218 - {
3.219 - labelBrief.Text = Object.Brief();
3.220 - }
3.221 -
3.222 - //Create input fields
3.223 - //UpdateTableLayoutPanel(Object);
3.224 + // Our object has changed behind our back.
3.225 + // That's currently only the case for HID events that are listening for inputs.
3.226 + UpdateStaticControls();
3.227 }
3.228 }
3.229
3.230 @@ -456,5 +481,60 @@
3.231 }
3.232
3.233 }
3.234 +
3.235 +
3.236 + /// <summary>
3.237 + ///
3.238 + /// </summary>
3.239 + /// <param name="sender"></param>
3.240 + /// <param name="e"></param>
3.241 + private void ControlValueChanged(object sender, EventArgs e)
3.242 + {
3.243 + UpdateObject();
3.244 + }
3.245 +
3.246 + /// <summary>
3.247 + ///
3.248 + /// </summary>
3.249 + private void UpdateObject()
3.250 + {
3.251 + // Update our object with the content of our controls
3.252 + FetchPropertiesValue(Object);
3.253 +
3.254 + UpdateStaticControls();
3.255 + //
3.256 + //PerformLayout();
3.257 + }
3.258 +
3.259 + /// <summary>
3.260 + ///
3.261 + /// </summary>
3.262 + private void UpdateStaticControls()
3.263 + {
3.264 + // Update OK and test button status
3.265 + iButtonOk.Enabled = Object.IsValid();
3.266 + iButtonTest.Enabled = iButtonOk.Enabled;
3.267 +
3.268 + // Update brief title
3.269 + iLabelBrief.Text = Object.Brief();
3.270 +
3.271 + // Update object description
3.272 + iLabelDescription.Text = Object.Description;
3.273 + }
3.274 +
3.275 + /// <summary>
3.276 + ///
3.277 + /// </summary>
3.278 + /// <param name="sender"></param>
3.279 + /// <param name="e"></param>
3.280 + private void iComboBoxObjectType_KeyPress(object sender, KeyPressEventArgs e)
3.281 + {
3.282 + //Special case for HID events
3.283 + if (Object is EventHid)
3.284 + {
3.285 + //Disable handling of key input as we are using key input for changing our event
3.286 + e.Handled = true;
3.287 + }
3.288 + }
3.289 }
3.290 }
4.1 --- a/Server/FormMain.Hid.cs Sat Aug 20 21:00:35 2016 +0200
4.2 +++ b/Server/FormMain.Hid.cs Sun Aug 21 16:11:40 2016 +0200
4.3 @@ -118,6 +118,13 @@
4.4 }
4.5 else
4.6 {
4.7 + //Trigger corresponding EAR event if any
4.8 + {
4.9 + EventHid e = new EventHid();
4.10 + e.Copy(aHidEvent);
4.11 + Properties.Settings.Default.EarManager.TriggerEvent(e);
4.12 + }
4.13 +
4.14 if (aHidEvent.IsGeneric)
4.15 {
4.16 if (aHidEvent.Usages.Count == 0)