Address some formatting things and update Packages

This commit is contained in:
2021-08-06 22:35:21 -05:00
parent e08ba30d91
commit 67741eccee
26 changed files with 8042 additions and 9159 deletions
@@ -1,5 +1,4 @@
using System;
namespace qController.Events
namespace qController.Events
{
public delegate void SelectedCueEditedHandler(object source, CueEditArgs args);
@@ -11,9 +11,7 @@ namespace qController.Helpers
}
public static bool IsValidAddress(string ipString){
if ((ipString.Split('.').Length - 1) != 3) return false;
IPAddress address;
return IPAddress.TryParse(ipString, out address);
return (ipString.Split('.').Length - 1) == 3 && IPAddress.TryParse(ipString, out _);
}
public static bool IsReachable(string ipString)
@@ -16,7 +16,7 @@ namespace qController.QItems
}
public bool IsReachable()
{
return qController.Helpers.IPHelper.IsReachable(address);
return Helpers.IPHelper.IsReachable(address);
}
}
}
@@ -69,7 +69,7 @@ namespace qController
}
public static void RemoveInstance(string name, string address){
foreach (var item in qInstances)
foreach (QInstance item in qInstances)
{
if(item.address == address && item.name == name){
RemoveInstance(item);
@@ -85,9 +85,11 @@ namespace qController
public static bool AddServer(string host, int port)
{
QServerInfo serverInfo = new QServerInfo();
serverInfo.host = host;
serverInfo.port = port;
QServerInfo serverInfo = new QServerInfo
{
host = host,
port = port
};
return AddServer(serverInfo);
}
@@ -109,7 +111,7 @@ namespace qController
public static void RemoveServer(string host)
{
foreach (var item in qStoredServers)
foreach (QServerInfo item in qStoredServers)
{
if (item.host == host)
{
@@ -131,7 +133,7 @@ namespace qController
}
public static bool Contains(string address){
foreach (var item in qInstances)
foreach (QInstance item in qInstances)
{
//Log.Debug("Item name: " + item.name + " Found Name: " + name);
if (item.address == address)
@@ -140,7 +142,7 @@ namespace qController
}
}
foreach (var item in qStoredServers)
foreach (QServerInfo item in qStoredServers)
{
//Log.Debug("Item name: " + item.name + " Found Name: " + name);
if (item.host == address)
@@ -59,20 +59,20 @@ namespace qController.UI.Cells
for(int i = 0; i< numberOfChannelsVisible; i++)
{
var sliderToAdd = new Slider
Slider sliderToAdd = new Slider
{
Minimum = -60,
Maximum = 12
};
var labelToAdd = new Label
Label labelToAdd = new Label
{
Text = $"{i+1}:",
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center
};
var valueLabelToAdd = new Label
Label valueLabelToAdd = new Label
{
Text = "",
VerticalTextAlignment = TextAlignment.Center,
@@ -11,15 +11,15 @@ namespace qController.UI.Dialogs
Title = "Enter IP of QLab Computer";
Message = "Enter an IP Address to save";
OkText = "Next";
OnTextChanged = args =>
{
OnTextChanged = args => {
//IPAddress ugh
args.IsValid = IPHelper.IsValidAddress(args.Value);
};
OnAction = (qAddress) =>
{
if (!qAddress.Ok)
if (!qAddress.Ok) {
return;
}
UserDialogs.Instance.Prompt(new PromptConfig
{
@@ -27,13 +27,13 @@ namespace qController.UI.Dialogs
Message = "Enter OSC port for " + qAddress.Text,
OkText = "Save",
InputType = InputType.Number,
OnTextChanged = args =>
{
OnTextChanged = args => {
args.IsValid = args.Value.Length > 0;
},
OnAction = (qPort) => {
if (!qPort.Ok)
if (!qPort.Ok) {
return;
}
QStorage.AddServer(qAddress.Text, int.Parse(qPort.Text));
App.showToast("Manual QLab Instance Added!");
@@ -14,8 +14,9 @@ namespace qController.UI.Dialogs
OkText = "Donate";
OnAction = (response) =>
{
if (response)
if (response) {
Launcher.OpenAsync(new Uri("https://linktr.ee/JoelWetzell"));
}
};
}
}
+26 -24
View File
@@ -1,8 +1,8 @@
using Xamarin.Forms;
using qController.ViewModels;
using QControlKit;
using Serilog;
using System.Linq;
using System.Collections.Generic;
namespace qController.UI
{
@@ -38,18 +38,18 @@ namespace qController.UI
//Group List "Frame" added early so other children or "on top"
if (cue.cues.Count > 0)
{
var cueFrame = new Frame
Frame cueFrame = new Frame
{
BackgroundColor = Color.Transparent,
BorderColor = Color.Black,
Margin = qCueViewModel.nestPadding
};
Children.Add(cueFrame, 1, 0);
Grid.SetRowSpan(cueFrame, cue.cues.Count + 1);
Grid.SetColumnSpan(cueFrame, ColumnDefinitions.Count - 1);
SetRowSpan(cueFrame, cue.cues.Count + 1);
SetColumnSpan(cueFrame, ColumnDefinitions.Count - 1);
}
var cueLabel = new Label
Label cueLabel = new Label
{
BindingContext = qCueViewModel,
HorizontalOptions = LayoutOptions.FillAndExpand,
@@ -61,7 +61,7 @@ namespace qController.UI
cueLabel.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor");
cueLabel.SetBinding(Label.MarginProperty, "nestPadding", BindingMode.OneWay);
var cueTypeLabel = new Label
Label cueTypeLabel = new Label
{
FontFamily = (OnPlatform<string>)Application.Current.Resources["QFontFamily"],
BindingContext = qCueViewModel,
@@ -91,7 +91,7 @@ namespace qController.UI
if (!cue.IsCueList)
{
//Section for selecting a cue by tapping the name Label
var selectCueGesture = new TapGestureRecognizer();
TapGestureRecognizer selectCueGesture = new TapGestureRecognizer();
selectCueGesture.Tapped += (sender, e) =>
{
//TODO: need to make this work regardless of the cue list a cue is in
@@ -103,13 +103,13 @@ namespace qController.UI
//Add collapse gesture to the cue type icon if it is a group cue
if (cue.IsGroup)
{
var CollapseGroupCueGesture = new TapGestureRecognizer();
TapGestureRecognizer CollapseGroupCueGesture = new TapGestureRecognizer();
CollapseGroupCueGesture.Tapped += (sender, e) =>
{
if (cue.IsGroup)
{
qCueViewModel.IsCollapsed = !qCueViewModel.IsCollapsed;
for (var i = 1; i < RowDefinitions.Count; i++)
for (int i = 1; i < RowDefinitions.Count; i++)
{
RowDefinitions[i].Height = qCueViewModel.IsCollapsed ? 0 : GridLength.Auto;
@@ -117,9 +117,9 @@ namespace qController.UI
if (Device.RuntimePlatform.Equals(Device.Android))
{
foreach (var child in Children)
foreach (View child in Children)
{
if (Grid.GetRow(child) > 0)
if (GetRow(child) > 0)
{
child.IsVisible = !qCueViewModel.IsCollapsed;
}
@@ -130,7 +130,7 @@ namespace qController.UI
cueTypeLabel.GestureRecognizers.Add(CollapseGroupCueGesture);
}
var cueBackground = new Frame
Frame cueBackground = new Frame
{
BindingContext = qCueViewModel,
Opacity = 0.50,
@@ -142,7 +142,7 @@ namespace qController.UI
cueBackground.SetBinding(BackgroundColorProperty, "color", BindingMode.OneWay);
//TODO: find a solution so the selected cue indicator is under the frame
var cueSelectedIndicator = new Frame
Frame cueSelectedIndicator = new Frame
{
BindingContext = qCueViewModel,
BackgroundColor = Color.Blue,
@@ -152,30 +152,32 @@ namespace qController.UI
cueSelectedIndicator.SetBinding(IsVisibleProperty, "IsSelected");
Children.Add(cueSelectedIndicator, 0, 0);
Grid.SetColumnSpan(cueSelectedIndicator, ColumnDefinitions.Count);
SetColumnSpan(cueSelectedIndicator, ColumnDefinitions.Count);
Children.Add(cueBackground, 0, 0);
Grid.SetColumnSpan(cueBackground, ColumnDefinitions.Count);
SetColumnSpan(cueBackground, ColumnDefinitions.Count);
Children.Add(cueTypeLabel, 0, 0);
Children.Add(cueLabel, 1, 0);
if (cue.cues.Count > 0)
{
foreach (var aCue in cue.cues)
foreach (QCue aCue in cue.cues)
{
this.RowDefinitions.Add(
RowDefinitions.Add(
new RowDefinition
{
Height = GridLength.Auto,
BindingContext = new QCueViewModel(aCue, false)
}
);
var aCueGrid = new QCueGrid(aCue);
//cueGridDict.Add(aCue.uid, aCueGrid);
aCueGrid.Margin = new Thickness(0, 0, 0, 0);
QCueGrid aCueGrid = new QCueGrid(aCue)
{
//cueGridDict.Add(aCue.uid, aCueGrid);
Margin = new Thickness(0, 0, 0, 0)
};
QCueGridListHelper.insert(aCue.uid, aCueGrid);
Children.Add(aCueGrid, 0, aCue.sortIndex + 1);
Grid.SetColumnSpan(aCueGrid, this.ColumnDefinitions.Count);
SetColumnSpan(aCueGrid, ColumnDefinitions.Count);
}
}
}
@@ -185,10 +187,10 @@ namespace qController.UI
Device.BeginInvokeOnMainThread(() =>
{
//Nuke current grid
var children = this.Children.ToList();
foreach (var child in children)
List<View> children = Children.ToList();
foreach (View child in children)
{
this.Children.Remove(child);
Children.Remove(child);
}
RowDefinitions = new RowDefinitionCollection();
@@ -33,13 +33,7 @@ namespace qController.UI
public static QCueGrid get(string cueID)
{
if (cueGridDict.ContainsKey(cueID))
{
return cueGridDict[cueID];
}
else {
return null;
}
return cueGridDict.ContainsKey(cueID) ? cueGridDict[cueID] : null;
}
}
}
+21 -15
View File
@@ -10,26 +10,28 @@ namespace qController.UI
public QNavBar()
{
this.SetDynamicResource(Grid.BackgroundColorProperty, "NavigationBarColor");
SetDynamicResource(BackgroundColorProperty, "NavigationBarColor");
CornerRadius = 0;
HasShadow = false;
Padding = 0;
Margin = 0;
Grid grid = new Grid();
grid.RowSpacing = 0;
grid.ColumnSpacing = 0;
grid.Margin = 0;
grid.Padding = 0;
grid.RowDefinitions = new RowDefinitionCollection {
new RowDefinition { Height = 50 }
};
grid.ColumnDefinitions = new ColumnDefinitionCollection
Grid grid = new Grid
{
new ColumnDefinition {Width = GridLength.Star},
new ColumnDefinition {Width = new GridLength(4,GridUnitType.Star)},
RowSpacing = 0,
ColumnSpacing = 0,
Margin = 0,
Padding = 0,
RowDefinitions = new RowDefinitionCollection {
new RowDefinition { Height = 50 }
},
ColumnDefinitions = new ColumnDefinitionCollection
{
new ColumnDefinition {Width = GridLength.Star},
new ColumnDefinition {Width = new GridLength(4,GridUnitType.Star)},
}
};
menuButton = new Label
@@ -63,7 +65,7 @@ namespace qController.UI
instanceName.SetDynamicResource(Label.TextColorProperty, "PrimaryTextColor");
var menuButtonGesture = new TapGestureRecognizer();
TapGestureRecognizer menuButtonGesture = new TapGestureRecognizer();
menuButtonGesture.Tapped += App.ShowMenu;
menuButton.GestureRecognizers.Add(menuButtonGesture);
@@ -77,6 +79,10 @@ namespace qController.UI
HeightRequest = App.HeightUnit * 6;
menuButton.FontSize = App.Height * .04;
break;
default:
HeightRequest = App.HeightUnit * 6;
menuButton.FontSize = App.Height * .04;
break;
}
grid.Children.Add(menuButton, 0, 0);
@@ -12,15 +12,15 @@ namespace qController.UI
Padding = 8;
HeightRequest = 175;
CornerRadius = 0;
this.SetBinding(Frame.BackgroundColorProperty, "color", BindingMode.OneWay);
this.SetBinding(Frame.BorderColorProperty, "color", BindingMode.OneWay);
this.SetBinding(BackgroundColorProperty, "color", BindingMode.OneWay);
this.SetBinding(BorderColorProperty, "color", BindingMode.OneWay);
Frame frameInt = new Frame
{
Padding = 0
};
frameInt.SetDynamicResource(Frame.BackgroundColorProperty, "SelectedCueCellBackgroundColor");
frameInt.SetDynamicResource(BackgroundColorProperty, "SelectedCueCellBackgroundColor");
Grid selectedCueGrid = new Grid
@@ -106,8 +106,10 @@ namespace qController.UI
//Double tap to edit name/number
var nameDoubleTap = new TapGestureRecognizer();
nameDoubleTap.NumberOfTapsRequired = 2;
TapGestureRecognizer nameDoubleTap = new TapGestureRecognizer
{
NumberOfTapsRequired = 2
};
nameDoubleTap.Tapped += (s, e) =>
{
@@ -119,30 +121,31 @@ namespace qController.UI
Text = name.Text,
OnAction = (qName) =>
{
if (!qName.Ok)
if (!qName.Ok) {
return;
((QCueViewModel)this.BindingContext).name = qName.Text;
}
((QCueViewModel)BindingContext).name = qName.Text;
}
});
};
name.GestureRecognizers.Add(nameDoubleTap);
var numberDoubleTap = new TapGestureRecognizer();
numberDoubleTap.NumberOfTapsRequired = 2;
numberDoubleTap.Tapped += (s, e) =>
TapGestureRecognizer numberDoubleTap = new TapGestureRecognizer
{
UserDialogs.Instance.Prompt(new PromptConfig
{
NumberOfTapsRequired = 2
};
numberDoubleTap.Tapped += (s, e) => {
UserDialogs.Instance.Prompt(new PromptConfig {
Title = "Update Number",
Message = "Change number to update",
OkText = "Update",
Text = number.Text,
OnAction = (qNumber) =>
{
if (!qNumber.Ok)
OnAction = (qNumber) => {
if (!qNumber.Ok) {
return;
}
//This bypasses the label .Text property because the number might not be valid (no duplicates)
((QCueViewModel)BindingContext).number = qNumber.Text;
}
@@ -152,21 +155,21 @@ namespace qController.UI
number.GestureRecognizers.Add(numberDoubleTap);
var notesDoubleTap = new TapGestureRecognizer();
notesDoubleTap.NumberOfTapsRequired = 2;
notesDoubleTap.Tapped += (s, e) =>
TapGestureRecognizer notesDoubleTap = new TapGestureRecognizer
{
UserDialogs.Instance.Prompt(new PromptConfig
{
NumberOfTapsRequired = 2
};
notesDoubleTap.Tapped += (s, e) => {
UserDialogs.Instance.Prompt(new PromptConfig {
Title = "Update Notes",
Message = "Change notes to update",
OkText = "Update",
Text = notes.Text,
OnAction = (qNotes) =>
{
if (!qNotes.Ok)
OnAction = (qNotes) => {
if (!qNotes.Ok) {
return;
}
((QCueViewModel)BindingContext).notes = qNotes.Text;
}
});