Improved support for action enum properties.
1.1 --- a/Server/Actions/ActionCecDevicePowerOn.cs Tue Jul 26 15:05:57 2016 +0200
1.2 +++ b/Server/Actions/ActionCecDevicePowerOn.cs Tue Jul 26 15:30:46 2016 +0200
1.3 @@ -20,6 +20,12 @@
1.4 /// <returns></returns>
1.5 public override string Brief()
1.6 {
1.7 + if (Device == CecLogicalAddress.Broadcast)
1.8 + {
1.9 + //Because of duplicated values it would display Unregistered
1.10 + return "CEC Power On Broadcast";
1.11 + }
1.12 +
1.13 return "CEC Power On " + Device.ToString();
1.14 }
1.15
2.1 --- a/Server/Actions/ActionCecDeviceStandby.cs Tue Jul 26 15:05:57 2016 +0200
2.2 +++ b/Server/Actions/ActionCecDeviceStandby.cs Tue Jul 26 15:30:46 2016 +0200
2.3 @@ -20,6 +20,12 @@
2.4 /// <returns></returns>
2.5 public override string Brief()
2.6 {
2.7 + if (Device == CecLogicalAddress.Broadcast)
2.8 + {
2.9 + //Because of duplicated values it would display Unregistered
2.10 + return "CEC Standby Broadcast";
2.11 + }
2.12 +
2.13 return "CEC Standby " + Device.ToString();
2.14 }
2.15
3.1 --- a/Server/FormEditAction.Designer.cs Tue Jul 26 15:05:57 2016 +0200
3.2 +++ b/Server/FormEditAction.Designer.cs Tue Jul 26 15:30:46 2016 +0200
3.3 @@ -44,6 +44,7 @@
3.4 this.comboBoxActionType.Location = new System.Drawing.Point(55, 12);
3.5 this.comboBoxActionType.Name = "comboBoxActionType";
3.6 this.comboBoxActionType.Size = new System.Drawing.Size(333, 21);
3.7 + this.comboBoxActionType.Sorted = true;
3.8 this.comboBoxActionType.TabIndex = 18;
3.9 this.comboBoxActionType.SelectedIndexChanged += new System.EventHandler(this.comboBoxActionType_SelectedIndexChanged);
3.10 //
4.1 --- a/Server/FormEditAction.cs Tue Jul 26 15:05:57 2016 +0200
4.2 +++ b/Server/FormEditAction.cs Tue Jul 26 15:30:46 2016 +0200
4.3 @@ -102,8 +102,8 @@
4.4 // Instantiate our enum
4.5 object enumValue= Activator.CreateInstance(aInfo.PropertyType);
4.6 // Parse our enum from combo box
4.7 - //enumValue = Enum.Parse(aInfo.PropertyType,((ComboBox)aControl).SelectedValue.ToString());
4.8 - enumValue = ((ComboBox)aControl).SelectedValue;
4.9 + enumValue = Enum.Parse(aInfo.PropertyType,((ComboBox)aControl).SelectedItem.ToString());
4.10 + //enumValue = ((ComboBox)aControl).SelectedValue;
4.11 // Set enum value
4.12 aInfo.SetValue(aAction, enumValue);
4.13 }
4.14 @@ -131,7 +131,18 @@
4.15 //Enum properties are using combo box
4.16 ComboBox ctrl = new ComboBox();
4.17 ctrl.DropDownStyle = ComboBoxStyle.DropDownList;
4.18 - ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
4.19 + //Data source is fine but it gives us duplicate entries for duplicated enum values
4.20 + //ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
4.21 +
4.22 + //Therefore we need to explicitly create our items
4.23 + foreach (string name in aInfo.PropertyType.GetEnumNames())
4.24 + {
4.25 + ctrl.Items.Add(name.ToString());
4.26 + }
4.27 +
4.28 + //Select the first item
4.29 + ctrl.SelectedItem=ctrl.Items[0];
4.30 +
4.31 return ctrl;
4.32 }
4.33