From cd6115bfbc6f9cfca5f2923cb38215f6497e3509 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sat, 17 Jul 2021 20:33:27 -0500 Subject: [PATCH] Add Network Cue class. Closes #12 --- QControlKit/Constants/QDefines.cs | 12 ++++ QControlKit/Cue/QLightCue.cs | 91 +++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 QControlKit/Cue/QLightCue.cs diff --git a/QControlKit/Constants/QDefines.cs b/QControlKit/Constants/QDefines.cs index 9d74ff7..76ed591 100644 --- a/QControlKit/Constants/QDefines.cs +++ b/QControlKit/Constants/QDefines.cs @@ -229,6 +229,18 @@ public const string OutputSize = "outputSize"; //Implement on Text Cue //Light Cue Keys + public const string AlwaysCollate = "alwaysCollate"; + public const string CollateAndStart = "collateAndStart"; + public const string LightCommandText = "lightCommandText"; + public const string Prune = "prune"; + public const string PruneCommands = "pruneCommands"; + public const string RemoveLightCommandsMatching = "removeLightCommandsMatching"; + public const string ReplaceLightCommand = "replaceLightCommand"; + public const string SafeSort = "safeSort"; + public const string SafeSortCommands = "safeSortCommands"; + public const string SetLight = "setLight"; + public const string UpdateLightCommand = "updateLightCommand"; + //Fade Cue Keys //Network Cue Keys public const string CustomString = "customString"; diff --git a/QControlKit/Cue/QLightCue.cs b/QControlKit/Cue/QLightCue.cs new file mode 100644 index 0000000..0be0d53 --- /dev/null +++ b/QControlKit/Cue/QLightCue.cs @@ -0,0 +1,91 @@ +using QControlKit.Constants; + +namespace QControlKit.Cue +{ + public class QLightCue : QCue + { + public bool alwaysCollate + { + get + { + return (bool)propertyForKey(QOSCKey.AlwaysCollate); + } + set + { + setProperty(value, QOSCKey.AlwaysCollate); + } + } + + public string lightCommandText + { + get + { + return propertyForKey(QOSCKey.LightCommandText).ToString(); + } + set + { + setProperty(value, QOSCKey.LightCommandText); + } + } + + public void collateAndStart() + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.CollateAndStart}"); + } + + public void prune() + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.Prune}"); + } + + public void pruneCommands() + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.PruneCommands}"); + } + + public void removeLightCommandsMatching(string match) + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.RemoveLightCommandsMatching}", match); + } + + public void replaceLightCommand(string oldCommand, string newCommand) + { + if(this.workspace.versionParts[0] == "4" && int.Parse(this.workspace.versionParts[1]) >= 4) + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.ReplaceLightCommand}", oldCommand, newCommand); + } + else + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.UpdateLightCommand}", oldCommand, newCommand); + } + } + + public void safeSort() + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.SafeSort}"); + } + + public void safeSortCommands() + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.SafeSortCommands}"); + } + + public void setLight(string light, object setting) + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.SetLight}", light, setting); + } + + public void updateLightCommand(string oldCommand, string newCommand) + { + if (int.Parse(this.workspace.versionParts[0]) >= 4 && int.Parse(this.workspace.versionParts[1]) >= 4) + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.ReplaceLightCommand}", oldCommand, newCommand); + } + else + { + workspace.sendMessage($"/cue_id/{this.propertyForKey(QOSCKey.UID)}/{QOSCKey.UpdateLightCommand}", oldCommand, newCommand); + } + } + + } +}