From 96adbadbd7146814518e2ce76a077429a81e9001 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sun, 20 Jun 2021 18:50:39 -0500 Subject: [PATCH] * QCue.cs: Add child cue sorting * QControlKit.csproj: Update Versions * QMessage.cs: * QWorkspace.cs: * CueListPage.xaml.cs: Cleanup TODO's and Logging --- QControlKit/QControlKit.csproj | 4 ++-- QControlKit/QCue.cs | 7 +++---- QControlKit/QMessage.cs | 13 ++++--------- QControlKit/QWorkspace.cs | 19 +++++-------------- .../QControlKitXamDemo/CueListPage.xaml.cs | 13 ++++++++----- 5 files changed, 22 insertions(+), 34 deletions(-) diff --git a/QControlKit/QControlKit.csproj b/QControlKit/QControlKit.csproj index a71cead..b981e94 100644 --- a/QControlKit/QControlKit.csproj +++ b/QControlKit/QControlKit.csproj @@ -6,7 +6,7 @@ Joel Wetzell 1.0.0-devel true - 0.0.17 + 0.0.18 QControlKit MIT Unofficial C# port of Figure53's QLabKit.objc @@ -17,7 +17,7 @@ - + diff --git a/QControlKit/QCue.cs b/QControlKit/QCue.cs index 9d08d9a..74f0b0a 100644 --- a/QControlKit/QCue.cs +++ b/QControlKit/QCue.cs @@ -186,7 +186,7 @@ namespace QControlKit childCues.Add(cue); childCuesUIDMap.Add(uid, cue); //some sorting of the childCues needs to be done? //TODO - //reset sorting index + //reset sorting index? } public void removeChildCue(QCue cue) { @@ -730,7 +730,8 @@ namespace QControlKit if (needsSortChildCues) { - //something about cues needing to be sorted? + childCues.Sort((q1, q2)=> q1.sortIndex.CompareTo(q2.sortIndex)); + needsSortChildCues = false; } return needsNotifyCueUpdated; @@ -873,8 +874,6 @@ namespace QControlKit else cueData.Remove(key); - //TODO: Cuelistchangedplaybackpositionid? - } else { diff --git a/QControlKit/QMessage.cs b/QControlKit/QMessage.cs index dff95eb..7b7c09d 100644 --- a/QControlKit/QMessage.cs +++ b/QControlKit/QMessage.cs @@ -129,19 +129,14 @@ namespace QControlKit { get { - if (IsCueUpdate) - { + if (IsCueUpdate) { return AddressParts[4]; - }else if (IsPlaybackPositionUpdate) - { + } else if (IsPlaybackPositionUpdate) { //TODO: check string cast return arguments.Count > 0 ? (string)arguments[0] : null; - }else if (IsReplyFromCue) - { + } else if (IsReplyFromCue) { return AddressParts[2]; - } - else - { + } else { return null; } } diff --git a/QControlKit/QWorkspace.cs b/QControlKit/QWorkspace.cs index d3bccc2..52b0aa8 100644 --- a/QControlKit/QWorkspace.cs +++ b/QControlKit/QWorkspace.cs @@ -1,5 +1,4 @@ -//TODO: workspace connection error handlers -using Newtonsoft.Json; +using Newtonsoft.Json; using Serilog; using System; using System.Collections.Generic; @@ -160,7 +159,7 @@ namespace QControlKit public List cueLists { get { return root.cues; } } public string fullNameWithCueList(QCue cueList) { return ""; } - //TODO other convenience methods + public string[] versionParts { get { return version.Split('.'); } } public bool connectedToQLab3 { get { return versionParts[0] == "3"; } } @@ -193,10 +192,9 @@ namespace QControlKit private void finishConnection() { - //TODO connected = true; startReceivingUpdates(); - //fetchQLabVersion(); + //fetchQLabVersion(); //this is not needed since the version is loaded from the workspace info call fetchCueLists(); } @@ -210,7 +208,6 @@ namespace QControlKit else connect(); - //todo } public void disconnect() @@ -225,9 +222,6 @@ namespace QControlKit connected = false; client.disconnect(); - - //TODO - //root.removeAllChildCues(); } @@ -256,8 +250,8 @@ namespace QControlKit public void stopReceivingUpdates() { client.sendMessage($"{workspacePrefix}/updates", 0); } public void enableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 1); } public void disableAlwaysReply() { client.sendMessage($"{workspacePrefix}/alwaysReply", 0); } - public void fetchQLabVersion() { client.sendMessage($"{workspacePrefix}/version"); } //TODO: EventHandler for this? Is this still needed? - public void fetchCueLists() { client.sendMessage($"{workspacePrefix}/cueLists"); } //TODO: EventHandler for CueListUpdated + public void fetchQLabVersion() { client.sendMessage($"{workspacePrefix}/version"); } + public void fetchCueLists() { client.sendMessage($"{workspacePrefix}/cueLists"); } public void fetchPlaybackPositionForCue(QCue cue) { client.sendMessage(addressForCue(cue, QOSCKey.PlaybackPositionId)); } //EventHandler for this? can I use the CueListPlaybackPosition one? public void go() { client.sendMessage($"{workspacePrefix}/go"); } public void save() { client.sendMessage($"{workspacePrefix}/save"); } @@ -356,8 +350,6 @@ namespace QControlKit #endregion #region Property Fetching - //TODO - public void fetchDefaultPropertiesForCue(QCue cue) { @@ -536,7 +528,6 @@ namespace QControlKit cueList.setProperty(args.cueID, QOSCKey.PlaybackPositionId, false); } - //TODO: need to implement when playbackposition is "none" Log.Debug($"[workspace] cue list <{args.cueListID}> playback position changed to <{args.cueID}>"); CueListChangedPlaybackPosition?.Invoke(this, new QCueListChangedPlaybackPositionArgs { cueListID = args.cueListID, cueID = args.cueID }); diff --git a/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs b/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs index f0b9399..7b3e377 100644 --- a/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs +++ b/QControlKitXamDemo/QControlKitXamDemo/CueListPage.xaml.cs @@ -51,12 +51,15 @@ namespace QControlKitXamDemo Device.BeginInvokeOnMainThread(() => { QCue selectedCue = connectedWorkspace.cueWithID(args.cueID); - connectedWorkspace.fetchDefaultPropertiesForCue(selectedCue); - selectedCueGrid.BindingContext = new QCueViewModel(selectedCue, false); - if (cueGridDict.ContainsKey(args.cueID)) + if(selectedCue != null) //TODO: I think this being null is the result of a race condition? { - var cueGrid = cueGridDict[args.cueID]; //element to scroll to - cueListScrollView.ScrollToAsync(cueGrid, ScrollToPosition.Center, true); + connectedWorkspace.fetchDefaultPropertiesForCue(selectedCue); + selectedCueGrid.BindingContext = new QCueViewModel(selectedCue, false); + if (cueGridDict.ContainsKey(args.cueID)) + { + var cueGrid = cueGridDict[args.cueID]; //element to scroll to + cueListScrollView.ScrollToAsync(cueGrid, ScrollToPosition.Center, true); + } } }); }