mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-06 16:03:48 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Serilog;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Xamarin.Forms;
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using QControlKit;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using QControlKit;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace qController.ViewModels
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using Xamarin.Forms;
|
||||
using Serilog;
|
||||
using Acr.UserDialogs;
|
||||
|
||||
using qController.Dialogs;
|
||||
using qController.UI.Dialogs;
|
||||
using qController.QItems;
|
||||
using qController.UI.Cells;
|
||||
using qController.UI.Buttons;
|
||||
|
||||
@@ -5,7 +5,7 @@ using Zeroconf;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using qController.QItems;
|
||||
using qController.Dialogs;
|
||||
using qController.UI.Dialogs;
|
||||
using qController.UI.Cells;
|
||||
using Xamarin.Essentials;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using Xamarin.Forms;
|
||||
using Serilog;
|
||||
using qController.UI.Cells;
|
||||
using Acr.UserDialogs;
|
||||
using qController.Dialogs;
|
||||
using qController.UI.Dialogs;
|
||||
using Xamarin.Essentials;
|
||||
using System;
|
||||
using qController.ViewModels;
|
||||
@@ -110,5 +110,5 @@ namespace qController.Pages
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -19,14 +19,16 @@ namespace qController
|
||||
{
|
||||
private QWorkspace connectedWorkspace;
|
||||
private string passcode;
|
||||
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
||||
|
||||
public QWorkspacePage(QWorkspace workspace, string passcode = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
connectedWorkspace = workspace;
|
||||
this.passcode = passcode;
|
||||
|
||||
QCueGridListHelper.reset();
|
||||
|
||||
SetupTopBar();
|
||||
|
||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||
@@ -90,49 +92,69 @@ namespace qController
|
||||
QCue selectedCue = connectedWorkspace.cueWithID(args.cueID);
|
||||
if(selectedCue != null)
|
||||
{
|
||||
//update properties for selected cue to ensure latest data for cue preview
|
||||
connectedWorkspace.fetchDefaultPropertiesForCue(selectedCue);
|
||||
|
||||
selectedCueFrame.BindingContext = new QCueViewModel(selectedCue, false);
|
||||
if (cueGridDict.ContainsKey(args.cueID))
|
||||
|
||||
//Find cue grid for selected cue and scroll to it if it exists
|
||||
QCueGrid gridToScrollTo = QCueGridListHelper.get(args.cueID);
|
||||
if(gridToScrollTo != null)
|
||||
{
|
||||
var cueGrid = cueGridDict[args.cueID]; //element to scroll to
|
||||
//TODO: FIX THIS
|
||||
cueListScrollView.ScrollToAsync(cueGrid, ScrollToPosition.Center, true);
|
||||
cueListScrollView.ScrollToAsync(gridToScrollTo, ScrollToPosition.Center,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Setup and "empty" cue for when no cue is selected
|
||||
QCue emptyCue = new QCue();
|
||||
emptyCue.workspace = connectedWorkspace;
|
||||
emptyCue.type = "Memo";
|
||||
emptyCue.listName = "No Cue Selected";
|
||||
|
||||
selectedCueFrame.BindingContext = new QCueViewModel(emptyCue, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Workspace_WorkspaceUpdated(object source, QWorkspaceUpdatedArgs args)
|
||||
{
|
||||
Log.Debug("[workspacepage] Workspace Updated");
|
||||
|
||||
//Workspace updated means we connected so update the recent workspace
|
||||
App.SetRecentWorkspace(connectedWorkspace);
|
||||
|
||||
if (connectedWorkspace.cueLists.Count > 0)
|
||||
{
|
||||
List<Task> cueAddTasks = new List<Task>();
|
||||
|
||||
|
||||
foreach (var aCue in connectedWorkspace.cueLists)
|
||||
{
|
||||
|
||||
if(aCue.cues.Count > 0)
|
||||
{
|
||||
QCueGrid cueGrid = new QCueGrid(aCue);
|
||||
|
||||
cueGridDict.Add(aCue.uid, cueGrid);
|
||||
|
||||
QCueGrid mainCueGrid = new QCueGrid(aCue);
|
||||
MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
QCueGridListHelper.insert(aCue.uid, mainCueGrid);
|
||||
cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
cueListsGrid.Children.Add(cueGrid, 0, aCue.sortIndex);
|
||||
cueListsGrid.Children.Add(mainCueGrid, 0, aCue.sortIndex);
|
||||
}).Wait();
|
||||
}
|
||||
break; //TODO: Make the displayed cue list selectable
|
||||
}
|
||||
|
||||
connectedWorkspace.valueForKey(connectedWorkspace.firstCueList, QOSCKey.PlaybackPositionId); //fetch playback position for cueList once all cue loading is done.
|
||||
//TODO: fetch playback position for first cue list once all cue loading is done.
|
||||
connectedWorkspace.valueForKey(connectedWorkspace.firstCueList, QOSCKey.PlaybackPositionId);
|
||||
|
||||
|
||||
//Display cuelist and selected cue info
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
selectedCueFrame.IsVisible = true;
|
||||
cueListScrollView.IsVisible = true;
|
||||
});
|
||||
//break; //only load first cue list with cues.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +170,9 @@ namespace qController
|
||||
if (connectedWorkspace.connected)
|
||||
connectedWorkspace.disconnect(); //TODO: This might not be implemented?
|
||||
|
||||
//purge QCueGridListHelper
|
||||
QCueGridListHelper.reset();
|
||||
|
||||
//unsubscribe from events
|
||||
App.rootPage.MenuItemSelected -= OnMenuItemSelected;
|
||||
connectedWorkspace.WorkspaceUpdated -= Workspace_WorkspaceUpdated;
|
||||
|
||||
Reference in New Issue
Block a user