mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-03 14:37:53 +00:00
9cf241f9c8
* packages.config: * packages.config: * qController.iOS.csproj: * qController.Droid.csproj: * qController.csproj: Update Packages * App.xaml: Add some static styles * App.xaml.cs: Trying out Sharpnado Stuff * QCueGrid.cs: Move QCueGrid Recursive stuff inside class * QBrowserViewModel.cs: Hook into new ServerFound/Lost Methods * QCueViewModel.cs: Start work on cue children updating * QServerViewModel.cs: Hook into WorkspaceAdded/Removed methods * MenuPage.xaml.cs: Remove Add from side menu * QBrowserPage.xaml: Further work on front page design * QBrowserPage.xaml.cs: Add Manually add button to main page * QWorkspacePage.xaml.cs: Move recursive stuff out of Page code behind
79 lines
2.3 KiB
C#
79 lines
2.3 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using Xamarin.Forms;
|
|
|
|
using QControlKit;
|
|
using QControlKit.Events;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace qController.ViewModels
|
|
{
|
|
public class QBrowserViewModel : INotifyPropertyChanged
|
|
{
|
|
QBrowser browser;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public ObservableCollection<QServerViewModel> ServersGrouped { get; set; }
|
|
public QBrowserViewModel(QBrowser browser)
|
|
{
|
|
this.browser = browser;
|
|
ServersGrouped = new ObservableCollection<QServerViewModel>();
|
|
|
|
this.browser.ServerFound += OnServerFound;
|
|
this.browser.ServerLost += OnServerLost;
|
|
|
|
Device.StartTimer(TimeSpan.FromSeconds(4), () =>
|
|
{
|
|
Task.Run(async () =>
|
|
{
|
|
this.browser.ProbeForQLabInstances();
|
|
// do something with time...
|
|
});
|
|
return true;
|
|
});
|
|
|
|
}
|
|
|
|
private void OnServerFound(object source, QServerFoundArgs args)
|
|
{
|
|
Device.BeginInvokeOnMainThread(() =>
|
|
{
|
|
System.Console.WriteLine($"[QBrowserViewModel] adding server: {args.server.description}");
|
|
ServersGrouped.Add(new QServerViewModel(args.server));
|
|
});
|
|
}
|
|
|
|
|
|
private void OnServerLost(object source, QServerLostArgs args)
|
|
{
|
|
QServerViewModel serverToRemove = null;
|
|
|
|
foreach(var serverGroup in ServersGrouped)
|
|
{
|
|
if (serverGroup.host.Equals(args.server.host))
|
|
{
|
|
serverToRemove = serverGroup;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(serverToRemove != null)
|
|
{
|
|
Device.BeginInvokeOnMainThread(() =>
|
|
{
|
|
System.Console.WriteLine($"[QBrowserViewModel] removing server: {args.server.description}");
|
|
ServersGrouped.Remove(serverToRemove);
|
|
});
|
|
}
|
|
}
|
|
|
|
void OnPropertyChanged([CallerMemberName] string name = "")
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
}
|
|
}
|
|
}
|