diff -r cadc4e4302c6 -r b2121d03f6f0 Server/Actions/ActionHarmonyCommand.cs
--- a/Server/Actions/ActionHarmonyCommand.cs Sun Aug 21 16:35:20 2016 +0200
+++ b/Server/Actions/ActionHarmonyCommand.cs Sun Aug 21 18:35:58 2016 +0200
@@ -6,6 +6,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
+using System.Windows.Forms;
namespace SharpDisplayManager
{
@@ -30,6 +31,14 @@
)]
public string FunctionName { get; set; } = "";
+ [DataMember]
+ [AttributeObjectProperty(
+ Id = "Harmony.Command.SelectCommand",
+ Name = "Select command",
+ Description = "Click to select a command."
+ )]
+ public PropertyButton SelectCommand { get; set; } = new PropertyButton { Text = "None" };
+
///
///
///
@@ -54,6 +63,18 @@
return brief;
}
+
+ protected override void DoConstruct()
+ {
+ base.DoConstruct();
+
+ if (SelectCommand == null)
+ {
+ SelectCommand = new PropertyButton { Text = "None"};
+ }
+ SelectCommand.ClickEventHandler = ClickEventHandler;
+ }
+
///
///
///
@@ -72,5 +93,52 @@
}
+
+ ///
+ ///
+ ///
+ ///
+ public override bool IsValid()
+ {
+ if (Program.HarmonyConfig != null)
+ {
+ foreach (HarmonyHub.Device d in Program.HarmonyConfig.Devices)
+ {
+ if (d.Id.Equals(DeviceId))
+ {
+ foreach (HarmonyHub.ControlGroup cg in d.ControlGroups)
+ {
+ foreach (HarmonyHub.Function f in cg.Functions)
+ {
+ if (f.Name.Equals(FunctionName))
+ {
+ //We found our device and our function
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+
+ void ClickEventHandler(object sender, EventArgs e)
+ {
+ FormSelectHarmonyCommand dlg = new FormSelectHarmonyCommand();
+ DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(dlg);
+ if (res == DialogResult.OK)
+ {
+ DeviceId = dlg.DeviceId;
+ FunctionName = dlg.FunctionName;
+ SelectCommand.Text = Brief();
+ //Tell observer the object itself changed
+ OnPropertyChanged("Brief");
+ }
+
+ }
+
}
}