Implement Cue Properties Updating

This commit is contained in:
Joel Wetzell
2020-06-19 19:02:05 -05:00
parent f6c1cdf70a
commit 60e43e4193
11 changed files with 49 additions and 90 deletions
+5
View File
@@ -61,6 +61,11 @@ namespace QSharp
public JToken data { get; set; }
}
public class QCuePropertiesUpdatedArgs : EventArgs
{
public List<string> properties { get; set; }
}
public class QCueListsUpdatedArgs : EventArgs
{
public JToken data { get; set; }
+2 -2
View File
@@ -1,5 +1,4 @@
namespace QSharp
namespace QSharp
{
public delegate void QServerFoundHandler(object source, QServerFoundArgs args);
public delegate void QServerUpdatedHandler(object source, QServerUpdatedArgs args);
@@ -16,6 +15,7 @@ namespace QSharp
public delegate void QCueUpdatedHandler(object source, QCueUpdatedArgs args);
public delegate void QCuePropertiesUpdatedHandler(object source, QCuePropertiesUpdatedArgs args);
public delegate void QCueListsUpdatesHandler(object source, QCueListsUpdatedArgs args);
public delegate void QCueNeedsUpdatedHandler(object source, QCueNeedsUpdatedArgs args);
public delegate void QCueListChangedPlaybackPositionHandler(object source, QCueListChangedPlaybackPositionArgs args);
-1
View File
@@ -1,5 +1,4 @@
using Zeroconf;
using System;
using System.Collections.ObjectModel;
using Serilog;
+1 -4
View File
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SharpOSC;
using Serilog;
using System.Collections.Concurrent;
using System.ComponentModel;
namespace QSharp
{
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Security.Cryptography.X509Certificates;
using System.Text;
namespace QSharp
namespace QSharp
{
public class QColor
{
+17 -3
View File
@@ -22,6 +22,8 @@ namespace QSharp
public bool ignoreUpdates;
public event QCuePropertiesUpdatedHandler CuePropertiesUpdated;
public QCue()
{
init();
@@ -540,6 +542,7 @@ namespace QSharp
//TODO
JObject dictObj = (JObject)dict;
List<string> propertiesUpdated = new List<string>();
foreach (var obj in dictObj)
{
JToken value = obj.Value;
@@ -553,16 +556,17 @@ namespace QSharp
{
bool didSetProptery = setProperty(value, obj.Key, false);
if (didSetProptery)
{
cueUpdated = true;
propertiesUpdated.Add(obj.Key);
}
}
}
if (!cueUpdated)
return false;
Log.Debug($"[cue] <{nonEmptyName}> has been updated.");
//something about notifying cueUpdated ? OnCueUpdated event handler maybe?
OnCuePropertiesUpdated(propertiesUpdated);
return true;
}
@@ -820,6 +824,16 @@ namespace QSharp
#endregion
#region Event Handling
void OnCuePropertiesUpdated(List<string> properties)
{
Log.Debug($"[cue] <{nonEmptyName}> properties have been updated.");
CuePropertiesUpdated?.Invoke(this, new QCuePropertiesUpdatedArgs { properties = properties });
}
#endregion
#region Printing
public void Print()
{
+1 -5
View File
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace QSharp
namespace QSharp
{
static class QBonjour
{
-4
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using Newtonsoft.Json.Linq;
using SharpOSC;
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Security;
using System.Threading.Tasks;
using QSharp;
using QSharpXamDemo.ViewModels;
@@ -29,7 +28,7 @@ namespace QSharpXamDemo
{
Device.BeginInvokeOnMainThread(() =>
{
selectedCueGrid.BindingContext = new SelectedQCueViewModel(connectedWorkspace.cueWithID(args.cueID));
selectedCueGrid.BindingContext = new QCueViewModel(connectedWorkspace.cueWithID(args.cueID), false);
if (cueGridDict.ContainsKey(args.cueID))
{
@@ -65,7 +64,7 @@ namespace QSharpXamDemo
Grid cueToGrid(QCue cue)
{
Grid cueGrid = new Grid { RowSpacing = 0 };
QCueViewModel qCueViewModel = new QCueViewModel(cue);
QCueViewModel qCueViewModel = new QCueViewModel(cue, true);
cueGrid.RowDefinitions = new RowDefinitionCollection();
cueGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) });
var cueLabel = new Label
@@ -1,4 +1,5 @@
using QSharp;
using Serilog;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
@@ -10,10 +11,27 @@ namespace QSharpXamDemo.ViewModels
bool isSelected = false;
public event PropertyChangedEventHandler PropertyChanged;
public QCueViewModel(QCue cue)
public QCueViewModel(QCue cue, bool checkPlayback)
{
this.cue = cue;
this.cue.workspace.CueListChangedPlaybackPosition += Workspace_CueListChangedPlaybackPosition;
if(checkPlayback)
this.cue.workspace.CueListChangedPlaybackPosition += Workspace_CueListChangedPlaybackPosition;
this.cue.CuePropertiesUpdated += OnCuePropertiesUpdated;
}
private void OnCuePropertiesUpdated(object source, QCuePropertiesUpdatedArgs args)
{
foreach(var property in args.properties)
{
Log.Debug($"[cueviewmodel] property <{property}> has been updated.");
if (property.Equals(QOSCKey.Name))
{
OnPropertyChanged("name");
}else if (property.Equals(QOSCKey.ColorName))
{
OnPropertyChanged("color");
}
}
}
void OnPropertyChanged([CallerMemberName] string name = "")
@@ -1,59 +0,0 @@
using QSharp;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
namespace QSharpXamDemo.ViewModels
{
public class SelectedQCueViewModel : INotifyPropertyChanged
{
QCue cue;
public event PropertyChangedEventHandler PropertyChanged;
public SelectedQCueViewModel(QCue cue)
{
this.cue = cue;
}
void OnPropertyChanged([CallerMemberName] string name = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
public string name {
get
{
return cue.nonEmptyName;
}
set
{
cue.name = value;
}
}
public string number
{
get
{
return cue.number;
}
set
{
cue.number = value;
}
}
public Color color
{
get
{
return Color.FromHex(cue.color.Hex);
}
set
{
cue.color = new QColor("none");
}
}
}
}