mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-13 19:33:52 +00:00
* QCueGrid.cs: Rebuild cue grid when children cue change
* QCueGridListHelper.cs: Helper class for linking cue id with cue grid * QCueViewModel.cs: Revoe unused import * QBrowserPage.xaml.cs: * ControlPage.xaml.cs: * QWorkspaceViewModel.cs: * qConnectionPage.xaml.cs: Remove unused import * QWorkspacePage.xaml.cs: Fix scrolling to select cue and handle no selected cue
This commit is contained in:
@@ -2,19 +2,29 @@
|
||||
using qController.ViewModels;
|
||||
using QControlKit;
|
||||
using Serilog;
|
||||
using System.Linq;
|
||||
|
||||
namespace qController.UI
|
||||
{
|
||||
public class QCueGrid : Grid
|
||||
{
|
||||
private QCueViewModel qCueViewModel;
|
||||
|
||||
public QCueGrid(QCue cue)
|
||||
{
|
||||
qCueViewModel = new QCueViewModel(cue, true);
|
||||
|
||||
qCueViewModel.PropertyChanged += QCueViewModel_PropertyChanged;
|
||||
RowSpacing = 0;
|
||||
|
||||
BuildGrid(cue);
|
||||
|
||||
}
|
||||
|
||||
private void BuildGrid(QCue cue)
|
||||
{
|
||||
RowDefinitions.Add(
|
||||
new RowDefinition {
|
||||
new RowDefinition
|
||||
{
|
||||
Height = new GridLength(40),
|
||||
BindingContext = qCueViewModel
|
||||
}
|
||||
@@ -34,9 +44,9 @@ namespace qController.UI
|
||||
BorderColor = Color.Black,
|
||||
Margin = qCueViewModel.nestPadding
|
||||
};
|
||||
Children.Add(cueFrame,1,0);
|
||||
Children.Add(cueFrame, 1, 0);
|
||||
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
|
||||
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count-1);
|
||||
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count - 1);
|
||||
}
|
||||
|
||||
var cueLabel = new Label
|
||||
@@ -60,7 +70,7 @@ namespace qController.UI
|
||||
VerticalOptions = LayoutOptions.FillAndExpand,
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
Padding = 0,
|
||||
Margin = new Thickness(10,0,0,0),
|
||||
Margin = new Thickness(10, 0, 0, 0),
|
||||
//BackgroundColor = Color.Red
|
||||
};
|
||||
|
||||
@@ -77,7 +87,7 @@ namespace qController.UI
|
||||
cueTypeLabel.SetBinding(Label.TextProperty, "type", BindingMode.OneWay);
|
||||
cueTypeLabel.SetDynamicResource(Label.TextColorProperty, "IconTextColor");
|
||||
|
||||
|
||||
|
||||
if (!cue.IsCueList)
|
||||
{
|
||||
//Section for selecting a cue by tapping the name Label
|
||||
@@ -102,7 +112,7 @@ namespace qController.UI
|
||||
for (var i = 1; i < RowDefinitions.Count; i++)
|
||||
{
|
||||
RowDefinitions[i].Height = qCueViewModel.IsCollapsed ? 0 : GridLength.Auto;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (Device.RuntimePlatform.Equals(Device.Android))
|
||||
@@ -154,7 +164,8 @@ namespace qController.UI
|
||||
foreach (var aCue in cue.cues)
|
||||
{
|
||||
this.RowDefinitions.Add(
|
||||
new RowDefinition {
|
||||
new RowDefinition
|
||||
{
|
||||
Height = GridLength.Auto,
|
||||
BindingContext = new QCueViewModel(aCue, false)
|
||||
}
|
||||
@@ -162,10 +173,40 @@ namespace qController.UI
|
||||
var aCueGrid = new QCueGrid(aCue);
|
||||
//cueGridDict.Add(aCue.uid, aCueGrid);
|
||||
aCueGrid.Margin = new Thickness(0, 0, 0, 0);
|
||||
QCueGridListHelper.insert(aCue.uid, aCueGrid);
|
||||
Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
|
||||
Grid.SetColumnSpan(aCueGrid, this.ColumnDefinitions.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReloadGrid()
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
//Nuke current grid
|
||||
var children = this.Children.ToList();
|
||||
foreach (var child in children)
|
||||
{
|
||||
this.Children.Remove(child);
|
||||
}
|
||||
|
||||
RowDefinitions = new RowDefinitionCollection();
|
||||
|
||||
//rebuild
|
||||
BuildGrid(qCueViewModel.cue);
|
||||
|
||||
//TODO: check if this is working
|
||||
qCueViewModel.cue.workspace.fetchPlaybackPositionForCue(qCueViewModel.cue);
|
||||
});
|
||||
}
|
||||
|
||||
private void QCueViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName.Equals("cues"))
|
||||
{
|
||||
ReloadGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,45 @@
|
||||
using System;
|
||||
namespace qController
|
||||
// Allows the "storage" of links between cue ids and QCueGrids
|
||||
// a little hacky but works with the recursive nature of QCueGrids
|
||||
// used mainly for scrolling to the appropriate QCueGrid when selected cue changes
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace qController.UI
|
||||
{
|
||||
public class QCueGridListHelper
|
||||
{
|
||||
public QCueGridListHelper()
|
||||
private static Dictionary<string, QCueGrid> cueGridDict;
|
||||
static QCueGridListHelper()
|
||||
{
|
||||
cueGridDict = new Dictionary<string, QCueGrid>();
|
||||
}
|
||||
|
||||
public static void reset()
|
||||
{
|
||||
cueGridDict.Clear();
|
||||
}
|
||||
|
||||
public static void insert(string cueID, QCueGrid cueGrid)
|
||||
{
|
||||
if (cueGridDict.ContainsKey(cueID))
|
||||
{
|
||||
cueGridDict[cueID] = cueGrid;
|
||||
}
|
||||
else
|
||||
{
|
||||
cueGridDict.Add(cueID, cueGrid);
|
||||
}
|
||||
}
|
||||
|
||||
public static QCueGrid get(string cueID)
|
||||
{
|
||||
if (cueGridDict.ContainsKey(cueID))
|
||||
{
|
||||
return cueGridDict[cueID];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user