mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-07 16:33:45 +00:00
Server Listing Work and Passcode connection
This commit is contained in:
@@ -3,73 +3,120 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
|
||||
mc:Ignorable="d"
|
||||
x:Class="qController.Pages.QBrowserPage">
|
||||
<ContentPage.Content>
|
||||
|
||||
<StackLayout x:Name="sLayout">
|
||||
|
||||
<StackLayout x:Name="sLayout" Spacing="0">
|
||||
|
||||
<!--Old "Instance" listview -->
|
||||
<ListView x:Name="storageListView"
|
||||
HasUnevenRows="true"
|
||||
BackgroundColor="#4A4A4A"
|
||||
BackgroundColor="#4a4a4a"
|
||||
SeparatorVisibility="None">
|
||||
|
||||
</ListView>
|
||||
|
||||
<ListView x:Name="serverListView"
|
||||
GroupDisplayBinding="{Binding name}"
|
||||
|
||||
|
||||
<!--Beginning of new style of "server" view-->
|
||||
|
||||
<BoxView HeightRequest="10" BackgroundColor="DarkGray"/>
|
||||
|
||||
<Frame BackgroundColor="SlateGray"
|
||||
CornerRadius="0"
|
||||
HasShadow="False"
|
||||
Margin="0"
|
||||
Padding="0">
|
||||
<!--Need to try and remove the group spacing caused by ios:GroupHeaderStyle-->
|
||||
<ListView x:Name="serverListView"
|
||||
ios:ListView.GroupHeaderStyle="Grouped"
|
||||
GroupDisplayBinding="{Binding name}"
|
||||
IsGroupingEnabled="True"
|
||||
d:IsGroupingEnabled="False"
|
||||
BackgroundColor="#4A4A4A"
|
||||
BackgroundColor="Transparent"
|
||||
SeparatorVisibility="None"
|
||||
ItemsSource="{Binding ServersGrouped}">
|
||||
<ListView.GroupHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell Height="25">
|
||||
<Grid BackgroundColor="#ffffff" VerticalOptions="FillAndExpand">
|
||||
<Label Text="{Binding GroupName}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="Start"/>
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.GroupHeaderTemplate>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<Grid Margin="20,0,0,0" BackgroundColor="#D8D8D8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<Label Grid.Column="0" Text="{Binding Name}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="Start"/>
|
||||
ItemsSource="{Binding ServersGrouped}"
|
||||
Margin="0">
|
||||
<ListView.GroupHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<Frame BackgroundColor="#ffffff"
|
||||
Margin="0,0,0,0"
|
||||
Padding="10,0,10,0"
|
||||
CornerRadius="0">
|
||||
<Grid BackgroundColor="Transparent" VerticalOptions="FillAndExpand"
|
||||
RowSpacing="0"
|
||||
ColumnSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="1" Text="󱆄"
|
||||
FontFamily="{StaticResource MaterialFontFamily}"
|
||||
FontSize="Large"
|
||||
IsVisible="{Binding HasPasscode}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="End"/>
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<Label Grid.Column="0"
|
||||
Text="{Binding GroupName}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="Start"/>
|
||||
<Label Grid.Column="1"
|
||||
Text="{Binding version}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="End"/>
|
||||
</Grid>
|
||||
</Frame>
|
||||
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.GroupHeaderTemplate>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<Frame BackgroundColor="#D8D8D8"
|
||||
BorderColor="Black"
|
||||
Margin="5,0,5,0"
|
||||
Padding="10,0,10,0"
|
||||
CornerRadius="0"
|
||||
HasShadow="False">
|
||||
<Grid Margin="0"
|
||||
BackgroundColor="Transparent"
|
||||
RowSpacing="0"
|
||||
ColumnSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<Label Grid.Column="0" Text="{Binding Name}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="Start"/>
|
||||
|
||||
<Label Grid.Column="1" Text="󱆄"
|
||||
FontFamily="{StaticResource MaterialFontFamily}"
|
||||
FontSize="Large"
|
||||
IsVisible="{Binding HasPasscode}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand"
|
||||
VerticalTextAlignment="Center"
|
||||
HorizontalTextAlignment="End"/>
|
||||
</Grid>
|
||||
</Frame>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Frame>
|
||||
</StackLayout>
|
||||
|
||||
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
@@ -18,12 +18,8 @@ namespace qController.Pages
|
||||
App.rootPage.MenuItemSelected += OnMenuItemSelected;
|
||||
|
||||
serverListView.BindingContext = new QBrowserViewModel(new QBrowser());
|
||||
|
||||
|
||||
serverListView.ItemSelected += QWorkspaceSelected;
|
||||
|
||||
|
||||
|
||||
storageListView.ItemsSource = QStorage.qInstances;
|
||||
storageListView.ItemTemplate = new DataTemplate(typeof(QInstanceCell));
|
||||
storageListView.ItemTapped += (object sender, ItemTappedEventArgs e) =>
|
||||
@@ -53,10 +49,15 @@ namespace qController.Pages
|
||||
Title = "Workspace Requires Passcode",
|
||||
OkText = "Connect",
|
||||
IsCancellable = true,
|
||||
OnTextChanged = args =>
|
||||
{
|
||||
args.IsValid = args.Value != null && !args.Value.Equals("") && args.Value.Length == 4;
|
||||
},
|
||||
OnAction = async (resp) =>
|
||||
{
|
||||
if (resp.Ok)
|
||||
{
|
||||
Console.WriteLine($"Passcode is null: {resp.Value == null}");
|
||||
await Navigation.PushAsync(new WorkspacePage(selectedWorkspace, resp.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,13 @@
|
||||
x:Class="qController.WorkspacePage">
|
||||
<Grid RowSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="200"/>
|
||||
<RowDefinition Height="150"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ScrollView x:Name="cueListScrollView"
|
||||
Grid.Row="1">
|
||||
<Grid x:Name="cueListsGrid"
|
||||
RowSpacing="0"
|
||||
ColumnSpacing="0"
|
||||
BackgroundColor="#808080">
|
||||
<Grid.RowDefinitions></Grid.RowDefinitions>
|
||||
|
||||
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<Grid x:Name="selectedCueGrid"
|
||||
Grid.Row="0"
|
||||
@@ -60,5 +53,16 @@
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
FontSize="Large"/>
|
||||
</Grid>
|
||||
|
||||
<ScrollView x:Name="cueListScrollView"
|
||||
Grid.Row="1">
|
||||
<Grid x:Name="cueListsGrid"
|
||||
RowSpacing="0"
|
||||
ColumnSpacing="0"
|
||||
BackgroundColor="#808080">
|
||||
<Grid.RowDefinitions></Grid.RowDefinitions>
|
||||
|
||||
</Grid>
|
||||
</ScrollView>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
@@ -6,6 +6,7 @@ using Serilog;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
using Acr.UserDialogs;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace qController
|
||||
{
|
||||
@@ -13,29 +14,44 @@ namespace qController
|
||||
{
|
||||
private QWorkspace connectedWorkspace;
|
||||
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
||||
|
||||
public WorkspacePage(QWorkspace workspace)
|
||||
public WorkspacePage(QWorkspace workspace, string passcode = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
connectedWorkspace = workspace;
|
||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||
|
||||
connectedWorkspace.WorkspaceConnectionError += ConnectedWorkspace_WorkspaceConnectionError;
|
||||
connectedWorkspace.defaultSendUpdatesOSC = true;
|
||||
connectedWorkspace.CueListChangedPlaybackPosition += ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||
|
||||
connectedWorkspace.connect(passcode);
|
||||
}
|
||||
|
||||
public WorkspacePage(QWorkspace workspace, string passcode)
|
||||
private void ConnectedWorkspace_WorkspaceConnectionError(object source, QWorkspaceConnectionErrorArgs connectionErrorArgs)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
connectedWorkspace = workspace;
|
||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||
connectedWorkspace.connectWithPasscode(passcode);
|
||||
|
||||
|
||||
connectedWorkspace.defaultSendUpdatesOSC = true;
|
||||
connectedWorkspace.CueListChangedPlaybackPosition += ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||
System.Console.WriteLine("WorkspaceConnectionError Called");
|
||||
if (connectionErrorArgs.status.Equals("badpass"))
|
||||
{
|
||||
UserDialogs.Instance.Prompt(new PromptConfig
|
||||
{
|
||||
InputType = InputType.Number,
|
||||
MaxLength = 4,
|
||||
Title = "Incorrect Passcode!",
|
||||
OkText = "Connect",
|
||||
IsCancellable = true,
|
||||
OnTextChanged = args =>
|
||||
{
|
||||
args.IsValid = args.Value != null && !args.Value.Equals("") && args.Value.Length == 4;
|
||||
},
|
||||
OnAction = (resp) =>
|
||||
{
|
||||
if (resp.Ok)
|
||||
{
|
||||
connectedWorkspace.connect(resp.Value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectedWorkspace_CueListChangedPlaybackPosition(object source, QCueListChangedPlaybackPositionArgs args)
|
||||
@@ -84,6 +100,7 @@ namespace qController
|
||||
//unsubscribe from events
|
||||
connectedWorkspace.WorkspaceUpdated -= Workspace_WorkspaceUpdated;
|
||||
connectedWorkspace.CueListChangedPlaybackPosition -= ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||
connectedWorkspace.WorkspaceConnectionError -= ConnectedWorkspace_WorkspaceConnectionError;
|
||||
//disconnect
|
||||
connectedWorkspace.disconnect();
|
||||
|
||||
@@ -95,6 +112,20 @@ namespace qController
|
||||
QCueViewModel qCueViewModel = new QCueViewModel(cue, true);
|
||||
cueGrid.RowDefinitions = new RowDefinitionCollection();
|
||||
cueGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) });
|
||||
|
||||
|
||||
//Group List "Frame" added early so other children or "on top"
|
||||
if (cue.cues.Count > 0)
|
||||
{
|
||||
var cueFrame = new Frame
|
||||
{
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.Black
|
||||
};
|
||||
cueGrid.Children.Add(cueFrame);
|
||||
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
|
||||
}
|
||||
|
||||
var cueLabel = new Label
|
||||
{
|
||||
BindingContext = qCueViewModel,
|
||||
@@ -102,6 +133,17 @@ namespace qController
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
};
|
||||
cueLabel.SetBinding(Label.TextProperty, "name", BindingMode.OneWay);
|
||||
|
||||
//System.Console.WriteLine($"Cue has continue mode: {cue.}" );
|
||||
//Section for selecting a cue by tapping the name Label
|
||||
var selectCueGesture = new TapGestureRecognizer();
|
||||
selectCueGesture.Tapped += (sender, e) =>
|
||||
{
|
||||
connectedWorkspace.firstCueList.playbackPositionID = cue.uid;
|
||||
};
|
||||
cueLabel.GestureRecognizers.Add(selectCueGesture);
|
||||
|
||||
|
||||
var cueBackground = new Frame
|
||||
{
|
||||
BindingContext = qCueViewModel,
|
||||
@@ -110,6 +152,7 @@ namespace qController
|
||||
CornerRadius = 0,
|
||||
BorderColor = Color.Black
|
||||
};
|
||||
|
||||
cueBackground.SetBinding(BackgroundColorProperty, "color", BindingMode.OneWay);
|
||||
|
||||
var cueSelectedIndicator = new Frame
|
||||
@@ -118,13 +161,13 @@ namespace qController
|
||||
BackgroundColor = Color.Blue,
|
||||
HasShadow = false
|
||||
};
|
||||
|
||||
cueSelectedIndicator.SetBinding(IsVisibleProperty, "IsSelected");
|
||||
|
||||
cueGrid.Children.Add(cueSelectedIndicator, 0, 0);
|
||||
cueGrid.Children.Add(cueBackground, 0, 0);
|
||||
cueGrid.Children.Add(cueLabel, 0, 0);
|
||||
|
||||
int rows = 1;
|
||||
if (cue.cues.Count > 0)
|
||||
{
|
||||
foreach (var aCue in cue.cues)
|
||||
@@ -134,17 +177,9 @@ namespace qController
|
||||
cueGridDict.Add(aCue.uid, aCueGrid);
|
||||
aCueGrid.Margin = new Thickness(10, 0, 0, 0);
|
||||
cueGrid.Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
|
||||
rows++;
|
||||
}
|
||||
|
||||
var cueFrame = new Frame
|
||||
{
|
||||
BackgroundColor = Color.Transparent,
|
||||
BorderColor = Color.Black
|
||||
};
|
||||
|
||||
cueGrid.Children.Add(cueFrame);
|
||||
Grid.SetRowSpan(cueFrame, rows);
|
||||
|
||||
|
||||
}
|
||||
return cueGrid;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace qController.ViewModels
|
||||
{
|
||||
@@ -22,8 +23,11 @@ namespace qController.ViewModels
|
||||
|
||||
private void OnServerFound(object source, QServerFoundArgs args)
|
||||
{
|
||||
ServersGrouped.Add(new QServerViewModel(args.server));
|
||||
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
System.Console.WriteLine($"[QBrowserViewModel] adding server: {args.server.description}");
|
||||
ServersGrouped.Add(new QServerViewModel(args.server));
|
||||
});
|
||||
}
|
||||
|
||||
void OnPropertyChanged([CallerMemberName] string name = "")
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using QControlKit;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace qController.ViewModels
|
||||
{
|
||||
public class QServerViewModel : ObservableCollection<QWorkspaceViewModel>
|
||||
public class QServerViewModel : ObservableCollection<QWorkspaceViewModel>, INotifyPropertyChanged
|
||||
{
|
||||
QServer server;
|
||||
public new event PropertyChangedEventHandler PropertyChanged;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
@@ -26,6 +30,22 @@ namespace qController.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public string version
|
||||
{
|
||||
get
|
||||
{
|
||||
if (server.version == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"v{server.version}";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GroupName
|
||||
{
|
||||
get
|
||||
@@ -40,19 +60,35 @@ namespace qController.ViewModels
|
||||
name = this.server.name;
|
||||
foreach (var workspace in this.server.workspaces)
|
||||
{
|
||||
this.Add(new QWorkspaceViewModel(workspace));
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
this.Add(new QWorkspaceViewModel(workspace));
|
||||
});
|
||||
}
|
||||
this.server.ServerUpdated += OnServerUpdated;
|
||||
}
|
||||
|
||||
private void OnServerUpdated(object source, QServerUpdatedArgs args)
|
||||
{
|
||||
OnPropertyChanged("GroupName");
|
||||
OnPropertyChanged("version");
|
||||
|
||||
foreach (var workspace in this.server.workspaces)
|
||||
{
|
||||
QWorkspaceViewModel workspaceViewModel = new QWorkspaceViewModel(workspace);
|
||||
if (!Contains(workspaceViewModel))
|
||||
Add(workspaceViewModel);
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
Add(workspaceViewModel);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnPropertyChanged([CallerMemberName] string name = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user