Actually Fix Row Sizing and Scroll to center

This commit is contained in:
2020-06-18 22:18:11 -05:00
parent 4a0777314b
commit f6c1cdf70a
+15 -24
View File
@@ -31,14 +31,16 @@ namespace QSharpXamDemo
{ {
selectedCueGrid.BindingContext = new SelectedQCueViewModel(connectedWorkspace.cueWithID(args.cueID)); selectedCueGrid.BindingContext = new SelectedQCueViewModel(connectedWorkspace.cueWithID(args.cueID));
if(cueGridDict.ContainsKey(args.cueID)) if (cueGridDict.ContainsKey(args.cueID))
cueListScrollView.ScrollToAsync(cueGridDict[args.cueID].X, cueGridDict[args.cueID].Y, true); {
var cueGrid = cueGridDict[args.cueID]; //element to scroll to
cueListScrollView.ScrollToAsync(cueGrid, ScrollToPosition.Center, true);
}
}); });
} }
void Workspace_WorkspaceUpdated(object source, QWorkspaceUpdatedArgs args) void Workspace_WorkspaceUpdated(object source, QWorkspaceUpdatedArgs args)
{ {
Log.Debug("[demo] Workspace has been updated");
foreach (var cue in connectedWorkspace.cueLists) foreach (var cue in connectedWorkspace.cueLists)
{ {
if(cue.cues.Count > 0) if(cue.cues.Count > 0)
@@ -46,24 +48,15 @@ namespace QSharpXamDemo
List<Task> cueAddTasks = new List<Task>(); List<Task> cueAddTasks = new List<Task>();
foreach(var aCue in cue.cues) foreach(var aCue in cue.cues)
{ {
var cueAddTask = new Task(() => Grid cueGrid = cueToGrid(aCue);
cueGridDict.Add(aCue.uid, cueGrid);
MainThread.InvokeOnMainThreadAsync(() =>
{ {
Grid cueGrid = cueToGrid(aCue); cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
cueGridDict.Add(aCue.uid, cueGrid); cueListsGrid.Children.Add(cueGrid, 0, aCue.sortIndex);
MainThread.InvokeOnMainThreadAsync(() => }).Wait();
{
cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
cueListsGrid.Children.Add(cueGrid, 0, aCue.sortIndex);
}).Wait();
});
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.
{
connectedWorkspace.valueForKey(cue, QOSCKey.PlaybackPositionId); //fetch playback position for cueList once all cue loading is done.
});
break; //only load first cue list with cues. break; //only load first cue list with cues.
} }
} }
@@ -85,7 +78,7 @@ namespace QSharpXamDemo
var cueBackground = new Frame var cueBackground = new Frame
{ {
BindingContext = qCueViewModel, BindingContext = qCueViewModel,
Opacity = 0.60, Opacity = 0.50,
HasShadow = false, HasShadow = false,
CornerRadius = 0, CornerRadius = 0,
BorderColor = Color.Black BorderColor = Color.Black
@@ -112,21 +105,19 @@ namespace QSharpXamDemo
cueGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); cueGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
var aCueGrid = cueToGrid(aCue); var aCueGrid = cueToGrid(aCue);
cueGridDict.Add(aCue.uid, aCueGrid); cueGridDict.Add(aCue.uid, aCueGrid);
aCueGrid.Margin = new Thickness(10, 0, 0, 0); aCueGrid.Margin = new Thickness(10, 0, 0, 0);
cueGrid.Children.Add(aCueGrid, 0, aCue.sortIndex + 1); cueGrid.Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
rows++; rows++;
} }
//this doesn't work to outline group? var cueFrame = new Frame
/*var cueFrame = new Frame
{ {
BackgroundColor = Color.Transparent, BackgroundColor = Color.Transparent,
BorderColor = Color.Black BorderColor = Color.Black
}; };
cueGrid.Children.Add(cueFrame); cueGrid.Children.Add(cueFrame);
Grid.SetRowSpan(cueFrame, rows);*/ Grid.SetRowSpan(cueFrame, rows);
} }
return cueGrid; return cueGrid;