From f97c196c789eca722dbf729a9a821f55d40f9616 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Thu, 18 Jun 2020 20:20:08 -0500 Subject: [PATCH] Scroll to Selected Cue automatically --- QSharp/QWorkspace.cs | 1 - QSharpXamDemo/QSharpXamDemo/CueListPage.xaml | 3 ++- QSharpXamDemo/QSharpXamDemo/CueListPage.xaml.cs | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/QSharp/QWorkspace.cs b/QSharp/QWorkspace.cs index 99bcbfd..6c5f277 100644 --- a/QSharp/QWorkspace.cs +++ b/QSharp/QWorkspace.cs @@ -436,7 +436,6 @@ namespace QSharp } currentCueLists.Add(cueList); index++; - valueForKey(cueList,QOSCKey.PlaybackPositionId); } QCue activeCuesList = root.cueWithID(QIdentifiers.ActiveCues, false); if(activeCuesList != null) diff --git a/QSharpXamDemo/QSharpXamDemo/CueListPage.xaml b/QSharpXamDemo/QSharpXamDemo/CueListPage.xaml index 5646dde..2b91f7f 100644 --- a/QSharpXamDemo/QSharpXamDemo/CueListPage.xaml +++ b/QSharpXamDemo/QSharpXamDemo/CueListPage.xaml @@ -10,7 +10,8 @@ - + cueGridDict = new Dictionary(); public CueListPage(QWorkspace workspace) { InitializeComponent(); @@ -27,6 +29,9 @@ namespace QSharpXamDemo Device.BeginInvokeOnMainThread(() => { selectedCueGrid.BindingContext = new SelectedQCueViewModel(connectedWorkspace.cueWithID(args.cueID)); + + if(cueGridDict.ContainsKey(args.cueID)) + cueListScrollView.ScrollToAsync(cueGridDict[args.cueID].X, cueGridDict[args.cueID].Y, true); }); } @@ -43,6 +48,7 @@ namespace QSharpXamDemo var cueAddTask = new Task(() => { Grid cueGrid = cueToGrid(aCue); + cueGridDict.Add(aCue.uid, cueGrid); Device.BeginInvokeOnMainThread(() => { cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); @@ -53,6 +59,10 @@ namespace QSharpXamDemo cueAddTask.Start(); cueAddTasks.Add(cueAddTask); } + Task.WhenAll(cueAddTasks).ContinueWith((task) => + { + connectedWorkspace.valueForKey(cue, QOSCKey.PlaybackPositionId); //fetch playback position for cueList once all cue loading is done. + }); break; //only load first cue list with cues. } } @@ -100,6 +110,8 @@ namespace QSharpXamDemo { cueGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); var aCueGrid = cueToGrid(aCue); + cueGridDict.Add(aCue.uid, aCueGrid); + aCueGrid.Margin = new Thickness(10, 0, 0, 0); cueGrid.Children.Add(aCueGrid, 0, aCue.sortIndex + 1); rows++;