mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-22 15:39:19 +00:00
Work on Workspace loading
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Xamarin.Forms;
|
using Acr.UserDialogs;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace qController
|
namespace qController
|
||||||
{
|
{
|
||||||
@@ -63,5 +64,13 @@ namespace qController
|
|||||||
{
|
{
|
||||||
// Handle when your app resumes
|
// Handle when your app resumes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showToast(string message)
|
||||||
|
{
|
||||||
|
var toastConfig = new ToastConfig(message);
|
||||||
|
toastConfig.SetDuration(3000);
|
||||||
|
toastConfig.SetPosition(ToastPosition.Bottom);
|
||||||
|
UserDialogs.Instance.Toast(toastConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
using SharpOSC;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace qController
|
namespace qController
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace qController
|
|||||||
Label number;
|
Label number;
|
||||||
Label type;
|
Label type;
|
||||||
Label notes;
|
Label notes;
|
||||||
|
public QCue activeCue;
|
||||||
public QSelectedCueCell()
|
public QSelectedCueCell()
|
||||||
{
|
{
|
||||||
Padding = new Thickness(5);
|
Padding = new Thickness(5);
|
||||||
@@ -115,6 +116,7 @@ namespace qController
|
|||||||
|
|
||||||
public void UpdateSelectedCue(QCue cue)
|
public void UpdateSelectedCue(QCue cue)
|
||||||
{
|
{
|
||||||
|
activeCue = cue;
|
||||||
name.Text = cue.listName;
|
name.Text = cue.listName;
|
||||||
number.Text = cue.number;
|
number.Text = cue.number;
|
||||||
type.Text = cue.getIconString();
|
type.Text = cue.getIconString();
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ namespace qController
|
|||||||
int Port;
|
int Port;
|
||||||
|
|
||||||
|
|
||||||
public delegate void WorkspaceDisconnectHandler(object source, EventArgs args);
|
|
||||||
public event WorkspaceDisconnectHandler WorkspaceDisconnect;
|
|
||||||
|
|
||||||
public QClient(string address, int port)
|
public QClient(string address, int port)
|
||||||
{
|
{
|
||||||
@@ -77,7 +76,7 @@ namespace qController
|
|||||||
{
|
{
|
||||||
if (msg.Address.Contains("disconnect"))
|
if (msg.Address.Contains("disconnect"))
|
||||||
{
|
{
|
||||||
OnWorkspaceDisconnect();
|
qParser.ParseMessage(msg);
|
||||||
}
|
}
|
||||||
else if (msg.Address.Contains("cue_id"))
|
else if (msg.Address.Contains("cue_id"))
|
||||||
{
|
{
|
||||||
@@ -118,11 +117,6 @@ namespace qController
|
|||||||
Console.WriteLine("Workspace needs to be updated: " + ws_id);
|
Console.WriteLine("Workspace needs to be updated: " + ws_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnWorkspaceDisconnect()
|
|
||||||
{
|
|
||||||
if (WorkspaceDisconnect != null)
|
|
||||||
WorkspaceDisconnect(this, new EventArgs());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ namespace qController
|
|||||||
public delegate void PlaybackPositionUpdatedHandler(object source, PlaybackPositionArgs args);
|
public delegate void PlaybackPositionUpdatedHandler(object source, PlaybackPositionArgs args);
|
||||||
public delegate void ConnectionStatusHandler(object source, ConnectEventArgs args);
|
public delegate void ConnectionStatusHandler(object source, ConnectEventArgs args);
|
||||||
public delegate void ChildrenUpdateHandler(object source, ChildrenEventArgs args);
|
public delegate void ChildrenUpdateHandler(object source, ChildrenEventArgs args);
|
||||||
|
public delegate void WorkspaceDisconnectHandler(object source, EventArgs args);
|
||||||
|
public event WorkspaceDisconnectHandler WorkspaceDisconnect;
|
||||||
public event ChildrenUpdateHandler ChildrenUpdated;
|
public event ChildrenUpdateHandler ChildrenUpdated;
|
||||||
public event ConnectionStatusHandler ConnectionStatusChanged;
|
public event ConnectionStatusHandler ConnectionStatusChanged;
|
||||||
public event SelectedCueUpdatedHandler SelectedCueUpdated;
|
public event SelectedCueUpdatedHandler SelectedCueUpdated;
|
||||||
@@ -96,6 +98,10 @@ namespace qController
|
|||||||
ParseConnectInfo(msg);
|
ParseConnectInfo(msg);
|
||||||
else if (msg.Address.Contains("children"))
|
else if (msg.Address.Contains("children"))
|
||||||
ParseChildrenInfo(msg);
|
ParseChildrenInfo(msg);
|
||||||
|
else if (msg.Address.Contains("workspaces"))
|
||||||
|
ParseInstanceInfo(msg);
|
||||||
|
else if (msg.Address.Contains("disconnect"))
|
||||||
|
OnWorkspaceDisconnect();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Unknown message type");
|
Console.WriteLine("Unknown message type");
|
||||||
@@ -125,7 +131,6 @@ namespace qController
|
|||||||
public void ParseCueUpdateInfo(OscMessage msg)
|
public void ParseCueUpdateInfo(OscMessage msg)
|
||||||
{
|
{
|
||||||
JToken cueUpdate = OSC2JSON(msg);
|
JToken cueUpdate = OSC2JSON(msg);
|
||||||
Console.WriteLine(OSC2JSON(msg).ToString());
|
|
||||||
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
QCue cue = JsonConvert.DeserializeObject<QCue>(cueUpdate.ToString());
|
||||||
OnCueInfoUpdated(cue);
|
OnCueInfoUpdated(cue);
|
||||||
}
|
}
|
||||||
@@ -136,8 +141,15 @@ namespace qController
|
|||||||
OnSelectedCueUpdated(cue);
|
OnSelectedCueUpdated(cue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ParseInstanceInfo(OscMessage msg)
|
||||||
|
{
|
||||||
|
//Console.WriteLine(OSC2JSON(msg));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public void ParseNoteInfo(OscMessage msg){
|
public void ParseNoteInfo(OscMessage msg){
|
||||||
//JToken cueInfo = OSC2JSON(msg);
|
//JToken cueInfo = OSC2JSON(msg);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ParseWorkspaceInfo(OscMessage msg)
|
public void ParseWorkspaceInfo(OscMessage msg)
|
||||||
@@ -197,6 +209,11 @@ namespace qController
|
|||||||
if (ChildrenUpdated != null)
|
if (ChildrenUpdated != null)
|
||||||
ChildrenUpdated(this, new ChildrenEventArgs() { cue_id = id, children = cues });
|
ChildrenUpdated(this, new ChildrenEventArgs() { cue_id = id, children = cues });
|
||||||
}
|
}
|
||||||
|
protected virtual void OnWorkspaceDisconnect()
|
||||||
|
{
|
||||||
|
if (WorkspaceDisconnect != null)
|
||||||
|
WorkspaceDisconnect(this, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace qController
|
|||||||
private void OnChildrenUpdated(object source, ChildrenEventArgs args)
|
private void OnChildrenUpdated(object source, ChildrenEventArgs args)
|
||||||
{
|
{
|
||||||
qController.qWorkspace.UpdateChildren(args.cue_id, args.children);
|
qController.qWorkspace.UpdateChildren(args.cue_id, args.children);
|
||||||
|
Console.WriteLine("Populated: " + qController.qWorkspace.IsPopulated);
|
||||||
if (!qController.qWorkspace.IsPopulated)
|
if (!qController.qWorkspace.IsPopulated)
|
||||||
{
|
{
|
||||||
QCue cue = qController.qWorkspace.GetEmptyGroup();
|
QCue cue = qController.qWorkspace.GetEmptyGroup();
|
||||||
@@ -56,13 +56,20 @@ namespace qController
|
|||||||
qController.qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
qController.qClient.sendStringUDP("/cue_id/" + cue.uniqueID + "/children");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qController.qClient.UpdateSelectedCue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnWorkspaceUpdated(object source, WorkspaceEventArgs args)
|
public void OnWorkspaceUpdated(object source, WorkspaceEventArgs args)
|
||||||
{
|
{
|
||||||
qController.qWorkspace = args.UpdatedWorkspace;
|
qController.qWorkspace = args.UpdatedWorkspace;
|
||||||
qController.playbackPosition = null;
|
qController.playbackPosition = null;
|
||||||
qController.qClient.UpdateSelectedCue();
|
qController.qWorkspace.CheckPopulated();
|
||||||
|
RefreshGroupCues();
|
||||||
|
//qController.qClient.UpdateSelectedCue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
||||||
@@ -72,8 +79,14 @@ namespace qController
|
|||||||
|
|
||||||
public void RefreshGroupCues()
|
public void RefreshGroupCues()
|
||||||
{
|
{
|
||||||
if (qController.qWorkspace.ChildrenPopulated())
|
if (qController.qWorkspace.IsPopulated)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Workspace group cues are already populated");
|
||||||
|
App.showToast("Workspace cues have been loaded....");
|
||||||
|
qController.qClient.UpdateSelectedCue();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
Console.WriteLine("Workspace group cues are not populated");
|
||||||
foreach (var cueList in qController.qWorkspace.data)
|
foreach (var cueList in qController.qWorkspace.data)
|
||||||
{
|
{
|
||||||
foreach (var cue in cueList.cues)
|
foreach (var cue in cueList.cues)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ namespace SharpOSC
|
|||||||
NetworkStream netStream = client.GetStream();
|
NetworkStream netStream = client.GetStream();
|
||||||
netStream.Write(slipData.ToArray(), 0, slipData.ToArray().Length);
|
netStream.Write(slipData.ToArray(), 0, slipData.ToArray().Length);
|
||||||
netStream.Close();
|
netStream.Close();
|
||||||
client.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Receive()
|
public async void Receive()
|
||||||
@@ -80,7 +79,7 @@ namespace SharpOSC
|
|||||||
//Console.WriteLine( "Thread " + num + ": Bytes read: " + bytesRead + " - " + Encoding.ASCII.GetString(buffer));
|
//Console.WriteLine( "Thread " + num + ": Bytes read: " + bytesRead + " - " + Encoding.ASCII.GetString(buffer));
|
||||||
} while (netStream.DataAvailable);
|
} while (netStream.DataAvailable);
|
||||||
|
|
||||||
Console.WriteLine("Raw TCP In: " + System.Text.Encoding.ASCII.GetString(responseData.ToArray()));
|
//Console.WriteLine("Raw TCP In: " + System.Text.Encoding.ASCII.GetString(responseData.ToArray()));
|
||||||
response = (OscMessage)OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
response = (OscMessage)OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
||||||
}
|
}
|
||||||
} catch(Exception e)
|
} catch(Exception e)
|
||||||
@@ -88,7 +87,6 @@ namespace SharpOSC
|
|||||||
Console.WriteLine(e.ToString());
|
Console.WriteLine(e.ToString());
|
||||||
}
|
}
|
||||||
netStream.Close();
|
netStream.Close();
|
||||||
client.Close();
|
|
||||||
OnMessageReceived(response);
|
OnMessageReceived(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace qController
|
|||||||
if(data[i].cues[j].type == "Group")
|
if(data[i].cues[j].type == "Group")
|
||||||
{
|
{
|
||||||
data[i].cues[j].cues = children;
|
data[i].cues[j].cues = children;
|
||||||
|
CheckPopulated();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +76,7 @@ namespace qController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ChildrenPopulated()
|
public bool CheckPopulated()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < data.Count; i++)
|
for (int i = 0; i < data.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ namespace qController
|
|||||||
new ColumnDefinition{Width = new GridLength(1,GridUnitType.Star)},
|
new ColumnDefinition{Width = new GridLength(1,GridUnitType.Star)},
|
||||||
new ColumnDefinition{Width = new GridLength(1,GridUnitType.Star)}
|
new ColumnDefinition{Width = new GridLength(1,GridUnitType.Star)}
|
||||||
},
|
},
|
||||||
Margin = new Thickness(10)
|
Margin = new Thickness(10),
|
||||||
|
IsVisible = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -143,10 +144,21 @@ namespace qController
|
|||||||
{
|
{
|
||||||
if(e.UpdatedWorkspace.data.Count > 0)
|
if(e.UpdatedWorkspace.data.Count > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
App.rootPage.MenuPage.ChangeToWorkspace(e.UpdatedWorkspace);
|
App.rootPage.MenuPage.ChangeToWorkspace(e.UpdatedWorkspace);
|
||||||
qController.qWorkspace = e.UpdatedWorkspace;
|
qController.qWorkspace = e.UpdatedWorkspace;
|
||||||
//qController.RefreshGroupCues();
|
qController.qWorkspace.CheckPopulated();
|
||||||
|
if (qController.qWorkspace.IsPopulated)
|
||||||
|
{
|
||||||
|
if (qCell.activeCue == null)
|
||||||
|
{
|
||||||
|
QCue noSelect = new QCue();
|
||||||
|
noSelect.listName = "No Cue Selected";
|
||||||
|
noSelect.type = "";
|
||||||
|
noSelect.notes = "Workspace has loaded but no cue is selected";
|
||||||
|
noSelect.number = "!";
|
||||||
|
qCell.UpdateSelectedCue(noSelect);
|
||||||
|
}
|
||||||
|
}
|
||||||
Console.WriteLine("Workspace updated in ControlPage: " + qController.qWorkspace.workspace_id);
|
Console.WriteLine("Workspace updated in ControlPage: " + qController.qWorkspace.workspace_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,6 +194,8 @@ namespace qController
|
|||||||
else
|
else
|
||||||
sLayout.Children.Remove(qSelectedCueOptions);
|
sLayout.Children.Remove(qSelectedCueOptions);
|
||||||
qCell.UpdateSelectedCue(args.Cue);
|
qCell.UpdateSelectedCue(args.Cue);
|
||||||
|
if (!mainG.IsVisible)
|
||||||
|
mainG.IsVisible = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,15 +204,13 @@ namespace qController
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Children Updated in ControlPage: " + args.cue_id);
|
Console.WriteLine("Children Updated in ControlPage: " + args.cue_id);
|
||||||
qController.qWorkspace.UpdateChildren(args.cue_id, args.children);
|
qController.qWorkspace.UpdateChildren(args.cue_id, args.children);
|
||||||
if (qController.qWorkspace.ChildrenPopulated())
|
if (qController.qWorkspace.IsPopulated)
|
||||||
{
|
{
|
||||||
Device.BeginInvokeOnMainThread(() =>
|
Device.BeginInvokeOnMainThread(() =>
|
||||||
{
|
{
|
||||||
if (App.MenuIsPresented)
|
if (App.MenuIsPresented)
|
||||||
{
|
{
|
||||||
//App.MenuIsPresented = false;
|
|
||||||
App.rootPage.MenuPage.ChangeToWorkspace(qController.qWorkspace);
|
App.rootPage.MenuPage.ChangeToWorkspace(qController.qWorkspace);
|
||||||
//App.MenuIsPresented = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -207,6 +219,7 @@ namespace qController
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
qController.qClient.UpdateSelectedCue();
|
qController.qClient.UpdateSelectedCue();
|
||||||
|
App.showToast("Workspace cues loaded...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Acr.UserDialogs;
|
|||||||
using Acr.Settings;
|
using Acr.Settings;
|
||||||
using Zeroconf;
|
using Zeroconf;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
namespace qController
|
namespace qController
|
||||||
{
|
{
|
||||||
@@ -38,7 +39,6 @@ namespace qController
|
|||||||
NavigationPage.SetHasNavigationBar(this, false);
|
NavigationPage.SetHasNavigationBar(this, false);
|
||||||
lstView.ItemsSource = QStorage.qInstances;
|
lstView.ItemsSource = QStorage.qInstances;
|
||||||
|
|
||||||
|
|
||||||
lstView.ItemTemplate = new DataTemplate(typeof(QInstanceCell));
|
lstView.ItemTemplate = new DataTemplate(typeof(QInstanceCell));
|
||||||
lstView.SeparatorVisibility = SeparatorVisibility.None;
|
lstView.SeparatorVisibility = SeparatorVisibility.None;
|
||||||
lstView.ItemTapped += (object sender, ItemTappedEventArgs e) =>
|
lstView.ItemTapped += (object sender, ItemTappedEventArgs e) =>
|
||||||
@@ -98,7 +98,7 @@ namespace qController
|
|||||||
if (!qName.Ok)
|
if (!qName.Ok)
|
||||||
return;
|
return;
|
||||||
QStorage.AddInstance(qName.Text,qAddress.Text);
|
QStorage.AddInstance(qName.Text,qAddress.Text);
|
||||||
showToast("Manual Workspace Added!");
|
App.showToast("Manual Workspace Added!");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -109,7 +109,7 @@ namespace qController
|
|||||||
|
|
||||||
async void Scan(){
|
async void Scan(){
|
||||||
bool workspacesFound = false;
|
bool workspacesFound = false;
|
||||||
showToast("Scanning for Workspaces...");
|
App.showToast("Scanning for Workspaces...");
|
||||||
Console.WriteLine("Begin Scanning");
|
Console.WriteLine("Begin Scanning");
|
||||||
|
|
||||||
IReadOnlyList<IZeroconfHost> results = await ZeroconfResolver.ResolveAsync("_qlab._udp.local.",TimeSpan.FromSeconds(3));
|
IReadOnlyList<IZeroconfHost> results = await ZeroconfResolver.ResolveAsync("_qlab._udp.local.",TimeSpan.FromSeconds(3));
|
||||||
@@ -118,7 +118,8 @@ namespace qController
|
|||||||
{
|
{
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
QStorage.AddInstance(result.DisplayName, result.IPAddress);
|
QInstance instance = new QInstance(result.DisplayName, result.IPAddress);
|
||||||
|
QStorage.AddInstance(instance);
|
||||||
Console.WriteLine(result.DisplayName + " @ " + result.IPAddress + " added");
|
Console.WriteLine(result.DisplayName + " @ " + result.IPAddress + " added");
|
||||||
workspacesFound = true;
|
workspacesFound = true;
|
||||||
}
|
}
|
||||||
@@ -126,9 +127,9 @@ namespace qController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(workspacesFound){
|
if(workspacesFound){
|
||||||
showToast("Workspace Found and Added!");
|
App.showToast("Workspace Found and Added!");
|
||||||
}else{
|
}else{
|
||||||
showToast("No Workspaces Found!");
|
App.showToast("No Workspaces Found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user