mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-11 10:23:50 +00:00
Rest of rename to QControlKit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Application xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
x:Class="QControlKitXamDemo.App">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,26 @@
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace QControlKitXamDemo
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
public App()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
MainPage = new NavigationPage(new MainPage());
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnSleep()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
x:Class="QControlKitXamDemo.CueListPage">
|
||||
<Grid RowSpacing="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="200"/>
|
||||
<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"
|
||||
RowSpacing="0"
|
||||
BackgroundColor="#D8D8D8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Frame Grid.RowSpan="3" Grid.ColumnSpan="5" BorderColor="Black" BackgroundColor="Transparent"/>
|
||||
<ActivityIndicator x:Name="workspaceLoadingIndicator" Grid.Row="1" HeightRequest="20"/>
|
||||
|
||||
<Label Grid.Row ="0"
|
||||
Grid.Column="0"
|
||||
Text="{Binding number}"
|
||||
d:Text="100"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
FontSize="Medium"/>
|
||||
|
||||
<Label Grid.Row ="1"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="5"
|
||||
Text="{Binding name}"
|
||||
d:Text="Cue 1"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
FontSize="Large"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using QControlKit;
|
||||
using QControlKitXamDemo.ViewModels;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace QControlKitXamDemo
|
||||
{
|
||||
public partial class CueListPage : ContentPage
|
||||
{
|
||||
private QWorkspace connectedWorkspace;
|
||||
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
||||
public CueListPage(QWorkspace workspace)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
connectedWorkspace = workspace;
|
||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||
connectedWorkspace.connectWithPasscode("1234");
|
||||
connectedWorkspace.defaultSendUpdatesOSC = true;
|
||||
connectedWorkspace.CueListChangedPlaybackPosition += ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||
}
|
||||
|
||||
void ConnectedWorkspace_CueListChangedPlaybackPosition(object source, QCueListChangedPlaybackPositionArgs args)
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
selectedCueGrid.BindingContext = new QCueViewModel(connectedWorkspace.cueWithID(args.cueID), false);
|
||||
|
||||
if (cueGridDict.ContainsKey(args.cueID))
|
||||
{
|
||||
var cueGrid = cueGridDict[args.cueID]; //element to scroll to
|
||||
cueListScrollView.ScrollToAsync(cueGrid, ScrollToPosition.Center, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Workspace_WorkspaceUpdated(object source, QWorkspaceUpdatedArgs args)
|
||||
{
|
||||
foreach (var cue in connectedWorkspace.cueLists)
|
||||
{
|
||||
if(cue.cues.Count > 0)
|
||||
{
|
||||
List<Task> cueAddTasks = new List<Task>();
|
||||
foreach(var aCue in cue.cues)
|
||||
{
|
||||
Grid cueGrid = cueToGrid(aCue);
|
||||
cueGridDict.Add(aCue.uid, cueGrid);
|
||||
MainThread.InvokeOnMainThreadAsync(() =>
|
||||
{
|
||||
cueListsGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
cueListsGrid.Children.Add(cueGrid, 0, aCue.sortIndex);
|
||||
}).Wait();
|
||||
}
|
||||
connectedWorkspace.valueForKey(cue, QOSCKey.PlaybackPositionId); //fetch playback position for cueList once all cue loading is done.
|
||||
break; //only load first cue list with cues.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Grid cueToGrid(QCue cue)
|
||||
{
|
||||
Grid cueGrid = new Grid { RowSpacing = 0 };
|
||||
QCueViewModel qCueViewModel = new QCueViewModel(cue, true);
|
||||
cueGrid.RowDefinitions = new RowDefinitionCollection();
|
||||
cueGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(40) });
|
||||
var cueLabel = new Label
|
||||
{
|
||||
BindingContext = qCueViewModel,
|
||||
HorizontalOptions = LayoutOptions.StartAndExpand,
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
};
|
||||
cueLabel.SetBinding(Label.TextProperty, "name", BindingMode.OneWay);
|
||||
var cueBackground = new Frame
|
||||
{
|
||||
BindingContext = qCueViewModel,
|
||||
Opacity = 0.50,
|
||||
HasShadow = false,
|
||||
CornerRadius = 0,
|
||||
BorderColor = Color.Black
|
||||
};
|
||||
cueBackground.SetBinding(BackgroundColorProperty, "color",BindingMode.OneWay);
|
||||
|
||||
var cueSelectedIndicator = new Frame
|
||||
{
|
||||
BindingContext = qCueViewModel,
|
||||
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)
|
||||
{
|
||||
cueGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
var aCueGrid = cueToGrid(aCue);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
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"
|
||||
x:Class="QControlKitXamDemo.MainPage">
|
||||
|
||||
<ListView x:Name="serverListView" GroupDisplayBinding="{Binding name}" IsGroupingEnabled="True">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextCell Text="{Binding name}"/>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
|
||||
</ContentPage>
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Xamarin.Forms;
|
||||
using QControlKit;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QControlKitXamDemo
|
||||
{
|
||||
// Learn more about making custom code visible in the Xamarin.Forms previewer
|
||||
// by visiting https://aka.ms/xamarinforms-previewer
|
||||
[DesignTimeVisible(false)]
|
||||
public partial class MainPage : ContentPage
|
||||
{
|
||||
public ObservableCollection<ServerGroup> servers = new ObservableCollection<ServerGroup>();
|
||||
public MainPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
serverListView.ItemsSource = servers;
|
||||
QBrowser browser = new QBrowser();
|
||||
browser.ServerUpdatedWorkspaces += Browser_ServerUpdatedWorkspaces;
|
||||
serverListView.ItemSelected += ServerListView_ItemSelected;
|
||||
|
||||
}
|
||||
|
||||
async void ServerListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||
{
|
||||
QWorkspace selectedWorkspace = e.SelectedItem as QWorkspace;
|
||||
Console.WriteLine($"[demo] workspace: {selectedWorkspace.nameWithoutPathExtension} has been selected");
|
||||
await Navigation.PushAsync(new CueListPage(selectedWorkspace));
|
||||
}
|
||||
|
||||
private void Browser_ServerUpdatedWorkspaces(object source, QServerUpdatedArgs args)
|
||||
{
|
||||
Console.WriteLine(args.server.name);
|
||||
|
||||
ServerGroup serverGroup = new ServerGroup(args.server.name);
|
||||
serverGroup.AddRange(args.server.workspaces);
|
||||
|
||||
Device.BeginInvokeOnMainThread(() =>
|
||||
{
|
||||
servers.Add(serverGroup);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class ServerGroup : List<QWorkspace>{
|
||||
public string name { get; set; }
|
||||
|
||||
public ServerGroup(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebugType>portable</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.9.0" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="4.7.0.968" />
|
||||
<PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Views\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="CueListPage.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\QControlKit\QControlKit.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,96 @@
|
||||
using QControlKit;
|
||||
using Serilog;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Xamarin.Forms;
|
||||
namespace QControlKitXamDemo.ViewModels
|
||||
{
|
||||
public class QCueViewModel : INotifyPropertyChanged
|
||||
{
|
||||
QCue cue;
|
||||
bool isSelected = false;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public QCueViewModel(QCue cue, bool checkPlayback)
|
||||
{
|
||||
this.cue = cue;
|
||||
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 = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
private void Workspace_CueListChangedPlaybackPosition(object source, QCueListChangedPlaybackPositionArgs args)
|
||||
{
|
||||
IsSelected = args.cueID == cue.uid;
|
||||
}
|
||||
|
||||
public string name {
|
||||
get
|
||||
{
|
||||
return cue.displayName;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSelected {
|
||||
get
|
||||
{
|
||||
return isSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user