# HG changeset patch
# User StephaneLenclud
# Date 1469539846 -7200
# Node ID 5770478e1fe3bc7f551e729da0bc35989421709b
# Parent e5910d7b6a815195d7de24393b7fc5acac915d81
Improved support for action enum properties.
diff -r e5910d7b6a81 -r 5770478e1fe3 Server/Actions/ActionCecDevicePowerOn.cs
--- a/Server/Actions/ActionCecDevicePowerOn.cs Tue Jul 26 15:05:57 2016 +0200
+++ b/Server/Actions/ActionCecDevicePowerOn.cs Tue Jul 26 15:30:46 2016 +0200
@@ -20,6 +20,12 @@
///
public override string Brief()
{
+ if (Device == CecLogicalAddress.Broadcast)
+ {
+ //Because of duplicated values it would display Unregistered
+ return "CEC Power On Broadcast";
+ }
+
return "CEC Power On " + Device.ToString();
}
diff -r e5910d7b6a81 -r 5770478e1fe3 Server/Actions/ActionCecDeviceStandby.cs
--- a/Server/Actions/ActionCecDeviceStandby.cs Tue Jul 26 15:05:57 2016 +0200
+++ b/Server/Actions/ActionCecDeviceStandby.cs Tue Jul 26 15:30:46 2016 +0200
@@ -20,6 +20,12 @@
///
public override string Brief()
{
+ if (Device == CecLogicalAddress.Broadcast)
+ {
+ //Because of duplicated values it would display Unregistered
+ return "CEC Standby Broadcast";
+ }
+
return "CEC Standby " + Device.ToString();
}
diff -r e5910d7b6a81 -r 5770478e1fe3 Server/FormEditAction.Designer.cs
--- a/Server/FormEditAction.Designer.cs Tue Jul 26 15:05:57 2016 +0200
+++ b/Server/FormEditAction.Designer.cs Tue Jul 26 15:30:46 2016 +0200
@@ -44,6 +44,7 @@
this.comboBoxActionType.Location = new System.Drawing.Point(55, 12);
this.comboBoxActionType.Name = "comboBoxActionType";
this.comboBoxActionType.Size = new System.Drawing.Size(333, 21);
+ this.comboBoxActionType.Sorted = true;
this.comboBoxActionType.TabIndex = 18;
this.comboBoxActionType.SelectedIndexChanged += new System.EventHandler(this.comboBoxActionType_SelectedIndexChanged);
//
diff -r e5910d7b6a81 -r 5770478e1fe3 Server/FormEditAction.cs
--- a/Server/FormEditAction.cs Tue Jul 26 15:05:57 2016 +0200
+++ b/Server/FormEditAction.cs Tue Jul 26 15:30:46 2016 +0200
@@ -102,8 +102,8 @@
// Instantiate our enum
object enumValue= Activator.CreateInstance(aInfo.PropertyType);
// Parse our enum from combo box
- //enumValue = Enum.Parse(aInfo.PropertyType,((ComboBox)aControl).SelectedValue.ToString());
- enumValue = ((ComboBox)aControl).SelectedValue;
+ enumValue = Enum.Parse(aInfo.PropertyType,((ComboBox)aControl).SelectedItem.ToString());
+ //enumValue = ((ComboBox)aControl).SelectedValue;
// Set enum value
aInfo.SetValue(aAction, enumValue);
}
@@ -131,7 +131,18 @@
//Enum properties are using combo box
ComboBox ctrl = new ComboBox();
ctrl.DropDownStyle = ComboBoxStyle.DropDownList;
- ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
+ //Data source is fine but it gives us duplicate entries for duplicated enum values
+ //ctrl.DataSource = Enum.GetValues(aInfo.PropertyType);
+
+ //Therefore we need to explicitly create our items
+ foreach (string name in aInfo.PropertyType.GetEnumNames())
+ {
+ ctrl.Items.Add(name.ToString());
+ }
+
+ //Select the first item
+ ctrl.SelectedItem=ctrl.Items[0];
+
return ctrl;
}