Begin Custom Controls and Editable Cue Info

This commit is contained in:
2019-07-15 07:01:35 -05:00
parent 2f29172f2d
commit e4aadf835a
7 changed files with 253 additions and 87 deletions
+30 -6
View File
@@ -5,16 +5,40 @@ namespace qController
{
public class QButton : Button
{
public string OSCCommand
public QCommand qCommand
{
get;
set;
}
public QButton(string text, string cmd)
{
Text = text;
OSCCommand = cmd;
}
public QButton(QCommand command){
qCommand = command;
Text = qCommand.text;
TextColor = Color.Black;
if (qCommand.osc.Contains("go"))
{
BackgroundColor = Color.SeaGreen;
switch (Device.RuntimePlatform)
{
case Device.iOS:
FontSize = App.HeightUnit * 4;
FontAttributes = FontAttributes.Bold;
break;
case Device.Android:
FontSize = App.HeightUnit * 4;
FontAttributes = FontAttributes.Bold;
break;
}
}
else if (qCommand.osc.Contains("panic"))
{
BackgroundColor = Color.IndianRed;
}
else
{
BackgroundColor = Color.FromHex("D8D8D8");
}
}
}
}
@@ -0,0 +1,136 @@
using System;
using System.Collections.Generic;
using Xamarin.Forms;
namespace qController
{
public class QControlsBlock: Frame
{
Grid mainG;
QController qController;
public QControlsBlock(QController controller)
{
qController = controller;
Margin = new Thickness(10);
Padding = new Thickness(0);
IsVisible = true;
BackgroundColor = Color.FromHex("4A4A4A");
//highlight Button Grid
//BackgroundColor = Color.FromHex("FF0000");
List<QCommand> commands = new List<QCommand>();
commands.Add(QCommands.PREVIOUS);
commands.Add(QCommands.PAUSE);
commands.Add(QCommands.NEXT);
commands.Add(QCommands.PREVIEW);
commands.Add(QCommands.PANIC);
commands.Add(QCommands.RESUME);
//setCustomButtons(commands);
setDefaultButtons();
}
void setDefaultButtons(){
List<QButton> buttons = new List<QButton>();
buttons.Add(new QButton(QCommands.PREVIOUS));
buttons.Add(new QButton(QCommands.PANIC));
buttons.Add(new QButton(QCommands.NEXT));
buttons.Add(new QButton(QCommands.PREVIEW));
buttons.Add(new QButton(QCommands.PAUSE));
buttons.Add(new QButton(QCommands.RESUME));
mainG = new Grid
{
Padding = new Thickness(0),
RowDefinitions = {
new RowDefinition{Height = GridLength.Auto},
new RowDefinition{Height = GridLength.Auto},
new RowDefinition{Height = GridLength.Auto}
},
ColumnDefinitions = {
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(0)
};
int row = 0;
int column = 0;
for(int i = 0; i < buttons.Count; i++)
{
QButton b = buttons[i];
b.Clicked += sendOSC;
mainG.Children.Add(b, column, row);
row++;
if (row == 3)
{
row = 0;
column = 2;
}
}
QButton goButton = new QButton(QCommands.GO);
goButton.Clicked += sendOSC;
mainG.Children.Add(goButton, 1, 0);
Grid.SetRowSpan(goButton, 3);
Content = mainG;
}
public void setCustomButtons(List<QCommand> commands){
mainG = new Grid
{
Padding = new Thickness(0),
RowDefinitions = {
new RowDefinition{Height = GridLength.Auto},
new RowDefinition{Height = GridLength.Auto},
new RowDefinition{Height = GridLength.Auto}
},
ColumnDefinitions = {
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(0)
};
int row = 0;
int column = 0;
for(int i = 0; i < commands.Count; i++)
{
QButton b = new QButton(commands[i]);
b.Clicked += sendOSC;
mainG.Children.Add(b, column, row);
row++;
if (row == 3)
{
row = 0;
column = 2;
}
}
QButton goButton = new QButton(QCommands.GO);
goButton.Clicked += sendOSC;
mainG.Children.Add(goButton, 1, 0);
Grid.SetRowSpan(goButton, 3);
Content = mainG;
}
void sendOSC(object sender, EventArgs e)
{
if(((QButton)sender).qCommand.type == "WORKSPACE"){
string workspace_prefix = "/workspace/" + qController.qWorkspace.workspace_id;
string command = workspace_prefix + ((QButton)sender).qCommand.osc;
qController.qClient.sendStringUDP(command);
}
}
}
}
@@ -15,6 +15,7 @@ namespace qController
Padding = new Thickness(5);
CornerRadius = 20;
BackgroundColor = Color.FromHex("D8D8D8");
HeightRequest = App.HeightUnit * 25;
Grid mainG = new Grid
{
Padding = new Thickness(0),
@@ -53,8 +54,8 @@ namespace qController
Padding = new Thickness(0),
RowDefinitions =
{
new RowDefinition{Height = GridLength.Auto},
new RowDefinition{Height = GridLength.Auto}
new RowDefinition{Height = new GridLength(1,GridUnitType.Star)},
new RowDefinition{Height = new GridLength(2,GridUnitType.Star)}
},
ColumnDefinitions =
{
@@ -69,8 +70,7 @@ namespace qController
number = new Label {
Text = "",
FontAttributes = FontAttributes.Bold,
FontSize = App.HeightUnit * 5,
Margin = new Thickness(5)
FontSize = App.HeightUnit * 5
};
name = new Label {
@@ -86,16 +86,34 @@ namespace qController
FontFamily = App.QFont,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.End,
Margin = new Thickness(5),
FontSize = App.HeightUnit * 5
};
notes = new Label {
Text = "Loading Cue Lists and Playhead Position",
HorizontalTextAlignment = TextAlignment.Center
HorizontalTextAlignment = TextAlignment.Center,
Margin = new Thickness(0,0,0,10)
};
notes.HorizontalTextAlignment = TextAlignment.Center;
notes.Margin = new Thickness(0, 0, 0, 10);
notes.VerticalOptions = LayoutOptions.FillAndExpand;
notes.HorizontalOptions = LayoutOptions.FillAndExpand;
notes.BackgroundColor = Color.FromHex("FF0000");
number.BackgroundColor = Color.Red;
name.BackgroundColor = Color.Red;
type.BackgroundColor = Color.Red;
var notesDoubleTap = new TapGestureRecognizer();
notesDoubleTap.NumberOfTapsRequired = 2;
notesDoubleTap.Tapped += (s, e) =>
{
Console.WriteLine("Notes double tapped");
};
number.GestureRecognizers.Add(notesDoubleTap);
type.GestureRecognizers.Add(notesDoubleTap);
name.GestureRecognizers.Add(notesDoubleTap);
notes.GestureRecognizers.Add(notesDoubleTap);
topGrid.Children.Add(number, 0, 0);
topGrid.Children.Add(type, 4, 0);
@@ -113,6 +131,8 @@ namespace qController
mainG.Children.Add(bottomGrid, 0, 1);
Grid.SetColumnSpan(bottomGrid, 5);
topGrid.BackgroundColor = Color.FromHex("00FF00");
bottomGrid.BackgroundColor = Color.FromHex("00FF00");
Margin = new Thickness(10);
Content = mainG;
}
@@ -124,6 +144,9 @@ namespace qController
number.Text = cue.number;
type.Text = cue.getIconString();
notes.Text = cue.notes;
if(notes.Text == ""){
notes.Text = " ";
}
}
}
}
@@ -0,0 +1,18 @@
using System;
namespace qController
{
public class QCommand
{
public string osc;
public string text;
public string type;
public QCommand(string display, string cmd, string command_type)
{
text = display;
osc = cmd;
type = command_type;
}
}
}
@@ -0,0 +1,18 @@
using System;
namespace qController
{
public static class QCommands
{
public static QCommand GO = new QCommand("GO", "/go","WORKSPACE");
public static QCommand PANIC = new QCommand("Panic", "/panic","WORKSPACE");
public static QCommand PAUSE = new QCommand("Pause", "/pause","WORKSPACE");
public static QCommand PREVIEW = new QCommand("Preview", "/preview","WORKSPACE");
public static QCommand RESUME = new QCommand("Resume", "/resume","WORKSPACE");
public static QCommand PREVIOUS = new QCommand("Previous","/select/previous","WORKSPACE");
public static QCommand NEXT = new QCommand("Next", "/select/next","WORKSPACE");
public static QCommand RESET = new QCommand("Reset","/reset","WORKSPACE");
public static QCommand STOP = new QCommand("Stop","/stop","WORKSPACE");
public static QCommand HARDSTOP = new QCommand("Hard Stop", "/hardStop","WORKSPACE");
}
}