mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-21 06:59:17 +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 qController.ViewModels;
|
||||||
using QControlKit;
|
using QControlKit;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace qController.UI
|
namespace qController.UI
|
||||||
{
|
{
|
||||||
public class QCueGrid : Grid
|
public class QCueGrid : Grid
|
||||||
{
|
{
|
||||||
private QCueViewModel qCueViewModel;
|
private QCueViewModel qCueViewModel;
|
||||||
|
|
||||||
public QCueGrid(QCue cue)
|
public QCueGrid(QCue cue)
|
||||||
{
|
{
|
||||||
qCueViewModel = new QCueViewModel(cue, true);
|
qCueViewModel = new QCueViewModel(cue, true);
|
||||||
|
qCueViewModel.PropertyChanged += QCueViewModel_PropertyChanged;
|
||||||
RowSpacing = 0;
|
RowSpacing = 0;
|
||||||
|
|
||||||
|
BuildGrid(cue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildGrid(QCue cue)
|
||||||
|
{
|
||||||
RowDefinitions.Add(
|
RowDefinitions.Add(
|
||||||
new RowDefinition {
|
new RowDefinition
|
||||||
|
{
|
||||||
Height = new GridLength(40),
|
Height = new GridLength(40),
|
||||||
BindingContext = qCueViewModel
|
BindingContext = qCueViewModel
|
||||||
}
|
}
|
||||||
@@ -34,9 +44,9 @@ namespace qController.UI
|
|||||||
BorderColor = Color.Black,
|
BorderColor = Color.Black,
|
||||||
Margin = qCueViewModel.nestPadding
|
Margin = qCueViewModel.nestPadding
|
||||||
};
|
};
|
||||||
Children.Add(cueFrame,1,0);
|
Children.Add(cueFrame, 1, 0);
|
||||||
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
|
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
|
||||||
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count-1);
|
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cueLabel = new Label
|
var cueLabel = new Label
|
||||||
@@ -60,7 +70,7 @@ namespace qController.UI
|
|||||||
VerticalOptions = LayoutOptions.FillAndExpand,
|
VerticalOptions = LayoutOptions.FillAndExpand,
|
||||||
VerticalTextAlignment = TextAlignment.Center,
|
VerticalTextAlignment = TextAlignment.Center,
|
||||||
Padding = 0,
|
Padding = 0,
|
||||||
Margin = new Thickness(10,0,0,0),
|
Margin = new Thickness(10, 0, 0, 0),
|
||||||
//BackgroundColor = Color.Red
|
//BackgroundColor = Color.Red
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,7 +164,8 @@ namespace qController.UI
|
|||||||
foreach (var aCue in cue.cues)
|
foreach (var aCue in cue.cues)
|
||||||
{
|
{
|
||||||
this.RowDefinitions.Add(
|
this.RowDefinitions.Add(
|
||||||
new RowDefinition {
|
new RowDefinition
|
||||||
|
{
|
||||||
Height = GridLength.Auto,
|
Height = GridLength.Auto,
|
||||||
BindingContext = new QCueViewModel(aCue, false)
|
BindingContext = new QCueViewModel(aCue, false)
|
||||||
}
|
}
|
||||||
@@ -162,10 +173,40 @@ namespace qController.UI
|
|||||||
var aCueGrid = new QCueGrid(aCue);
|
var aCueGrid = new QCueGrid(aCue);
|
||||||
//cueGridDict.Add(aCue.uid, aCueGrid);
|
//cueGridDict.Add(aCue.uid, aCueGrid);
|
||||||
aCueGrid.Margin = new Thickness(0, 0, 0, 0);
|
aCueGrid.Margin = new Thickness(0, 0, 0, 0);
|
||||||
|
QCueGridListHelper.insert(aCue.uid, aCueGrid);
|
||||||
Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
|
Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
|
||||||
Grid.SetColumnSpan(aCueGrid, this.ColumnDefinitions.Count);
|
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;
|
// Allows the "storage" of links between cue ids and QCueGrids
|
||||||
namespace qController
|
// 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 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 System.Runtime.CompilerServices;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
using QControlKit;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using QControlKit;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace qController.ViewModels
|
namespace qController.ViewModels
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Xamarin.Forms;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using Acr.UserDialogs;
|
using Acr.UserDialogs;
|
||||||
|
|
||||||
using qController.Dialogs;
|
using qController.UI.Dialogs;
|
||||||
using qController.QItems;
|
using qController.QItems;
|
||||||
using qController.UI.Cells;
|
using qController.UI.Cells;
|
||||||
using qController.UI.Buttons;
|
using qController.UI.Buttons;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ using Zeroconf;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using qController.QItems;
|
using qController.QItems;
|
||||||
using qController.Dialogs;
|
using qController.UI.Dialogs;
|
||||||
using qController.UI.Cells;
|
using qController.UI.Cells;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Xamarin.Forms;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using qController.UI.Cells;
|
using qController.UI.Cells;
|
||||||
using Acr.UserDialogs;
|
using Acr.UserDialogs;
|
||||||
using qController.Dialogs;
|
using qController.UI.Dialogs;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
using System;
|
using System;
|
||||||
using qController.ViewModels;
|
using qController.ViewModels;
|
||||||
|
|||||||
@@ -19,14 +19,16 @@ namespace qController
|
|||||||
{
|
{
|
||||||
private QWorkspace connectedWorkspace;
|
private QWorkspace connectedWorkspace;
|
||||||
private string passcode;
|
private string passcode;
|
||||||
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
|
||||||
public QWorkspacePage(QWorkspace workspace, string passcode = null)
|
public QWorkspacePage(QWorkspace workspace, string passcode = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
|
||||||
connectedWorkspace = workspace;
|
connectedWorkspace = workspace;
|
||||||
this.passcode = passcode;
|
this.passcode = passcode;
|
||||||
|
|
||||||
|
QCueGridListHelper.reset();
|
||||||
|
|
||||||
SetupTopBar();
|
SetupTopBar();
|
||||||
|
|
||||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||||
@@ -90,49 +92,69 @@ namespace qController
|
|||||||
QCue selectedCue = connectedWorkspace.cueWithID(args.cueID);
|
QCue selectedCue = connectedWorkspace.cueWithID(args.cueID);
|
||||||
if(selectedCue != null)
|
if(selectedCue != null)
|
||||||
{
|
{
|
||||||
|
//update properties for selected cue to ensure latest data for cue preview
|
||||||
connectedWorkspace.fetchDefaultPropertiesForCue(selectedCue);
|
connectedWorkspace.fetchDefaultPropertiesForCue(selectedCue);
|
||||||
|
|
||||||
selectedCueFrame.BindingContext = new QCueViewModel(selectedCue, false);
|
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
|
cueListScrollView.ScrollToAsync(gridToScrollTo, ScrollToPosition.Center,true);
|
||||||
//TODO: FIX THIS
|
|
||||||
cueListScrollView.ScrollToAsync(cueGrid, 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)
|
void Workspace_WorkspaceUpdated(object source, QWorkspaceUpdatedArgs args)
|
||||||
{
|
{
|
||||||
Log.Debug("[workspacepage] Workspace Updated");
|
Log.Debug("[workspacepage] Workspace Updated");
|
||||||
|
|
||||||
|
//Workspace updated means we connected so update the recent workspace
|
||||||
App.SetRecentWorkspace(connectedWorkspace);
|
App.SetRecentWorkspace(connectedWorkspace);
|
||||||
|
|
||||||
if (connectedWorkspace.cueLists.Count > 0)
|
if (connectedWorkspace.cueLists.Count > 0)
|
||||||
{
|
{
|
||||||
List<Task> cueAddTasks = new List<Task>();
|
List<Task> cueAddTasks = new List<Task>();
|
||||||
|
|
||||||
|
|
||||||
foreach (var aCue in connectedWorkspace.cueLists)
|
foreach (var aCue in connectedWorkspace.cueLists)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(aCue.cues.Count > 0)
|
if(aCue.cues.Count > 0)
|
||||||
{
|
{
|
||||||
QCueGrid cueGrid = new QCueGrid(aCue);
|
QCueGrid mainCueGrid = new QCueGrid(aCue);
|
||||||
|
|
||||||
cueGridDict.Add(aCue.uid, cueGrid);
|
|
||||||
|
|
||||||
MainThread.InvokeOnMainThreadAsync(() =>
|
MainThread.InvokeOnMainThreadAsync(() =>
|
||||||
{
|
{
|
||||||
|
QCueGridListHelper.insert(aCue.uid, mainCueGrid);
|
||||||
cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||||
cueListsGrid.Children.Add(cueGrid, 0, aCue.sortIndex);
|
cueListsGrid.Children.Add(mainCueGrid, 0, aCue.sortIndex);
|
||||||
}).Wait();
|
}).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(() =>
|
Device.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
selectedCueFrame.IsVisible = true;
|
selectedCueFrame.IsVisible = true;
|
||||||
cueListScrollView.IsVisible = true;
|
cueListScrollView.IsVisible = true;
|
||||||
});
|
});
|
||||||
//break; //only load first cue list with cues.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +170,9 @@ namespace qController
|
|||||||
if (connectedWorkspace.connected)
|
if (connectedWorkspace.connected)
|
||||||
connectedWorkspace.disconnect(); //TODO: This might not be implemented?
|
connectedWorkspace.disconnect(); //TODO: This might not be implemented?
|
||||||
|
|
||||||
|
//purge QCueGridListHelper
|
||||||
|
QCueGridListHelper.reset();
|
||||||
|
|
||||||
//unsubscribe from events
|
//unsubscribe from events
|
||||||
App.rootPage.MenuItemSelected -= OnMenuItemSelected;
|
App.rootPage.MenuItemSelected -= OnMenuItemSelected;
|
||||||
connectedWorkspace.WorkspaceUpdated -= Workspace_WorkspaceUpdated;
|
connectedWorkspace.WorkspaceUpdated -= Workspace_WorkspaceUpdated;
|
||||||
|
|||||||
Reference in New Issue
Block a user