diff --git a/BrickController2/BrickController2/BrickController2.csproj b/BrickController2/BrickController2/BrickController2.csproj
index 41f61ff8..1ba594d0 100644
--- a/BrickController2/BrickController2/BrickController2.csproj
+++ b/BrickController2/BrickController2/BrickController2.csproj
@@ -3,6 +3,7 @@
net10.0
BrickController2
+ true
diff --git a/BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml b/BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml
index e54ccfbc..0adbb20f 100644
--- a/BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml
+++ b/BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml
@@ -5,7 +5,9 @@
xmlns:converters="clr-namespace:BrickController2.UI.Converters"
xmlns:controls="clr-namespace:BrickController2.UI.Controls"
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
- x:Class="BrickController2.UI.Controls.DeviceChannelSelector">
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ x:Class="BrickController2.UI.Controls.DeviceChannelSelector"
+ x:DataType="viewModels:ControllerActionPageViewModel">
diff --git a/BrickController2/BrickController2/UI/Controls/Dialogs.xaml b/BrickController2/BrickController2/UI/Controls/Dialogs.xaml
index 8a44190c..75866ea1 100644
--- a/BrickController2/BrickController2/UI/Controls/Dialogs.xaml
+++ b/BrickController2/BrickController2/UI/Controls/Dialogs.xaml
@@ -70,7 +70,7 @@
MinimumHeightRequest="40"
MaximumHeightRequest="200">
-
+
diff --git a/BrickController2/BrickController2/UI/Controls/SettingsControl.xaml b/BrickController2/BrickController2/UI/Controls/SettingsControl.xaml
index fec16fc3..e7b8fd63 100644
--- a/BrickController2/BrickController2/UI/Controls/SettingsControl.xaml
+++ b/BrickController2/BrickController2/UI/Controls/SettingsControl.xaml
@@ -6,7 +6,9 @@
xmlns:converters="clr-namespace:BrickController2.UI.Converters"
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:t="clr-namespace:BrickController2.UI.Templates"
+ xmlns:settingsVm="clr-namespace:BrickController2.UI.ViewModels.Settings"
x:Class="BrickController2.UI.Controls.SettingsControl"
+ x:DataType="settingsVm:SettingsPageViewModelBase"
x:Name="Control"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -31,7 +33,7 @@
-
+
@@ -52,7 +54,7 @@
-
+
@@ -69,7 +71,7 @@
-
+
@@ -90,7 +92,7 @@
-
+
@@ -126,7 +128,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/AboutPage.xaml b/BrickController2/BrickController2/UI/Pages/AboutPage.xaml
index aadbb30f..2bf32d17 100644
--- a/BrickController2/BrickController2/UI/Pages/AboutPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/AboutPage.xaml
@@ -6,7 +6,9 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.AboutPage"
+ x:DataType="viewModels:AboutPageViewModel"
Title="{extensions:Translate About}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/ChannelSetupPage.xaml b/BrickController2/BrickController2/UI/Pages/ChannelSetupPage.xaml
index 9ff51ec5..2afc507d 100644
--- a/BrickController2/BrickController2/UI/Pages/ChannelSetupPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/ChannelSetupPage.xaml
@@ -7,7 +7,9 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.ChannelSetupPage"
+ x:DataType="viewModels:ChannelSetupPageViewModel"
Title="{extensions:Translate ChannelSetup}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/ControllerActionPage.xaml b/BrickController2/BrickController2/UI/Pages/ControllerActionPage.xaml
index 2d80a2ec..9f3dcf41 100644
--- a/BrickController2/BrickController2/UI/Pages/ControllerActionPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/ControllerActionPage.xaml
@@ -9,7 +9,9 @@
xmlns:gameController="clr-namespace:BrickController2.PlatformServices.InputDevice"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.ControllerActionPage"
+ x:DataType="viewModels:ControllerActionPageViewModel"
Title="{extensions:Translate ControllerAction}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/ControllerProfilePage.xaml b/BrickController2/BrickController2/UI/Pages/ControllerProfilePage.xaml
index 47118299..effb0cfd 100644
--- a/BrickController2/BrickController2/UI/Pages/ControllerProfilePage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/ControllerProfilePage.xaml
@@ -7,8 +7,10 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.ControllerProfilePage"
x:Name="Page"
+ x:DataType="viewModels:ControllerProfilePageViewModel"
Title="{extensions:Translate ControllerProfile}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -49,7 +51,7 @@
-
+
@@ -79,7 +81,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/CreationListPage.xaml b/BrickController2/BrickController2/UI/Pages/CreationListPage.xaml
index 0efc8653..39ac4e12 100644
--- a/BrickController2/BrickController2/UI/Pages/CreationListPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/CreationListPage.xaml
@@ -7,8 +7,11 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ xmlns:models="clr-namespace:BrickController2.CreationManagement"
x:Class="BrickController2.UI.Pages.CreationListPage"
x:Name="Page"
+ x:DataType="viewModels:CreationListPageViewModel"
Title="{extensions:Translate Creations}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -39,7 +42,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/CreationPage.xaml b/BrickController2/BrickController2/UI/Pages/CreationPage.xaml
index 5cf82571..d01a6225 100644
--- a/BrickController2/BrickController2/UI/Pages/CreationPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/CreationPage.xaml
@@ -6,8 +6,11 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ xmlns:models="clr-namespace:BrickController2.CreationManagement"
x:Class="BrickController2.UI.Pages.CreationPage"
x:Name="Page"
+ x:DataType="viewModels:CreationPageViewModel"
Title="{extensions:Translate Creation}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -42,7 +45,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/CreationSharePage.xaml b/BrickController2/BrickController2/UI/Pages/CreationSharePage.xaml
index db3ec5a6..911c2d1e 100644
--- a/BrickController2/BrickController2/UI/Pages/CreationSharePage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/CreationSharePage.xaml
@@ -5,9 +5,11 @@
xmlns:controls="clr-namespace:BrickController2.UI.Controls"
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
- xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
- x:Class="BrickController2.UI.Pages.CreationSharePage"
+ x:Class="BrickController2.UI.Pages.CreationSharePage"
+ x:DataType="viewModels:CreationSharePageViewModel"
Title="{extensions:Translate Share}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/DeviceListPage.xaml b/BrickController2/BrickController2/UI/Pages/DeviceListPage.xaml
index 5e249380..1dc88db7 100644
--- a/BrickController2/BrickController2/UI/Pages/DeviceListPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/DeviceListPage.xaml
@@ -7,8 +7,11 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ xmlns:deviceManagement="clr-namespace:BrickController2.DeviceManagement"
x:Class="BrickController2.UI.Pages.DeviceListPage"
x:Name="Page"
+ x:DataType="viewModels:DeviceListPageViewModel"
Title="{extensions:Translate Devices}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -26,7 +29,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/DevicePage.xaml b/BrickController2/BrickController2/UI/Pages/DevicePage.xaml
index a65f72db..c05ae103 100644
--- a/BrickController2/BrickController2/UI/Pages/DevicePage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/DevicePage.xaml
@@ -7,7 +7,9 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.DevicePage"
+ x:DataType="viewModels:DevicePageViewModel"
Title="{extensions:Translate Device}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -114,7 +116,7 @@
-
+
@@ -125,7 +127,7 @@
+ IsVisible="{Binding IsServoOrStepperSupported}"/>
diff --git a/BrickController2/BrickController2/UI/Pages/DeviceSettingsPage.xaml b/BrickController2/BrickController2/UI/Pages/DeviceSettingsPage.xaml
index a251de5b..797b203e 100644
--- a/BrickController2/BrickController2/UI/Pages/DeviceSettingsPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/DeviceSettingsPage.xaml
@@ -10,6 +10,7 @@
xmlns:vm="clr-namespace:BrickController2.UI.ViewModels"
xmlns:t="clr-namespace:BrickController2.UI.Templates"
x:Class="BrickController2.UI.Pages.DeviceSettingsPage"
+ x:DataType="vm:DeviceSettingsPageViewModel"
Title="{extensions:Translate DeviceSettings}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/InputDeviceTesterPage.xaml b/BrickController2/BrickController2/UI/Pages/InputDeviceTesterPage.xaml
index 295667b9..13cf4ae2 100644
--- a/BrickController2/BrickController2/UI/Pages/InputDeviceTesterPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/InputDeviceTesterPage.xaml
@@ -8,6 +8,7 @@
xmlns:local="clr-namespace:BrickController2.UI.Pages"
xmlns:vm="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.InputDeviceTesterPage"
+ x:DataType="vm:InputDeviceTesterPageViewModel"
Title="{extensions:Translate InputDeviceTester}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -33,7 +34,7 @@
-
+
@@ -48,7 +49,7 @@
-
+
@@ -30,7 +32,7 @@
-
+
@@ -44,12 +46,12 @@
-
+
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/PlayerPage.xaml b/BrickController2/BrickController2/UI/Pages/PlayerPage.xaml
index 8f687e2c..725feacf 100644
--- a/BrickController2/BrickController2/UI/Pages/PlayerPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/PlayerPage.xaml
@@ -6,7 +6,9 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.PlayerPage"
+ x:DataType="viewModels:PlayerPageViewModel"
Title="{extensions:Translate Play}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -56,7 +58,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/ScannerPageBase.xaml b/BrickController2/BrickController2/UI/Pages/ScannerPageBase.xaml
index 7e336be1..1cb3bba8 100644
--- a/BrickController2/BrickController2/UI/Pages/ScannerPageBase.xaml
+++ b/BrickController2/BrickController2/UI/Pages/ScannerPageBase.xaml
@@ -5,9 +5,11 @@
xmlns:controls="clr-namespace:BrickController2.UI.Controls"
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
- xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
- x:Class="BrickController2.UI.Pages.ScannerPageBase"
+ x:Class="BrickController2.UI.Pages.ScannerPageBase"
+ x:DataType="viewModels:ScannerPageViewModelBase"
Title="{extensions:Translate ScanQr}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/SequenceEditorPage.xaml b/BrickController2/BrickController2/UI/Pages/SequenceEditorPage.xaml
index e4a5a222..32e7bcf3 100644
--- a/BrickController2/BrickController2/UI/Pages/SequenceEditorPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/SequenceEditorPage.xaml
@@ -7,8 +7,11 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ xmlns:models="clr-namespace:BrickController2.CreationManagement"
x:Class="BrickController2.UI.Pages.SequenceEditorPage"
x:Name="Page"
+ x:DataType="viewModels:SequenceEditorPageViewModel"
Title="{extensions:Translate Sequence}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -81,7 +84,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/SequenceListPage.xaml b/BrickController2/BrickController2/UI/Pages/SequenceListPage.xaml
index 31a57fc2..353cef60 100644
--- a/BrickController2/BrickController2/UI/Pages/SequenceListPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/SequenceListPage.xaml
@@ -7,8 +7,11 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
+ xmlns:models="clr-namespace:BrickController2.CreationManagement"
x:Class="BrickController2.UI.Pages.SequenceListPage"
x:Name="Page"
+ x:DataType="viewModels:SequenceListPageViewModel"
Title="{extensions:Translate Sequences}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
@@ -34,7 +37,7 @@
-
+
diff --git a/BrickController2/BrickController2/UI/Pages/SequenceSharePage.xaml b/BrickController2/BrickController2/UI/Pages/SequenceSharePage.xaml
index c7e56bca..2bd0cbca 100644
--- a/BrickController2/BrickController2/UI/Pages/SequenceSharePage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/SequenceSharePage.xaml
@@ -5,9 +5,11 @@
xmlns:controls="clr-namespace:BrickController2.UI.Controls"
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
- xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
- x:Class="BrickController2.UI.Pages.SequenceSharePage"
+ x:Class="BrickController2.UI.Pages.SequenceSharePage"
+ x:DataType="viewModels:SequenceSharePageViewModel"
Title="{extensions:Translate Share}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/Pages/SettingsPage.xaml b/BrickController2/BrickController2/UI/Pages/SettingsPage.xaml
index fa6441e2..cf8fd570 100644
--- a/BrickController2/BrickController2/UI/Pages/SettingsPage.xaml
+++ b/BrickController2/BrickController2/UI/Pages/SettingsPage.xaml
@@ -7,7 +7,9 @@
xmlns:extensions="clr-namespace:BrickController2.UI.MarkupExtensions"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
xmlns:local="clr-namespace:BrickController2.UI.Pages"
+ xmlns:viewModels="clr-namespace:BrickController2.UI.ViewModels"
x:Class="BrickController2.UI.Pages.SettingsPage"
+ x:DataType="viewModels:SettingsPageViewModel"
Title="{extensions:Translate Settings}"
ios:Page.UseSafeArea="True"
BackgroundColor="{DynamicResource PageBackgroundColor}">
diff --git a/BrickController2/BrickController2/UI/ViewModels/ControllerProfilePageViewModel.cs b/BrickController2/BrickController2/UI/ViewModels/ControllerProfilePageViewModel.cs
index d1b32e5d..c21995ee 100644
--- a/BrickController2/BrickController2/UI/ViewModels/ControllerProfilePageViewModel.cs
+++ b/BrickController2/BrickController2/UI/ViewModels/ControllerProfilePageViewModel.cs
@@ -404,55 +404,56 @@ private bool ValidateControllerActionChannelSetup(object? cmdParam)
device.IsOutputTypeSupported(controllerAction.Channel, controllerAction.ChannelOutputType);
}
- public class ControllerActionViewModel
- {
- private readonly Device? _device;
+ }
- public ControllerActionViewModel(
- ControllerAction controllerAction,
- IDeviceManager deviceManager,
- IPlayLogic playLogic,
- ITranslationService translationService)
- {
- ControllerAction = controllerAction;
- _device = deviceManager.GetDeviceById(controllerAction.DeviceId);
-
- ControllerActionValid = playLogic.ValidateControllerAction(controllerAction);
- DeviceName = _device != null ? _device.Name : translationService.Translate("Missing");
- // primary take type from existing device or try to parse DeviceId
- DeviceType = _device != null ? _device.DeviceType :
- (DeviceId.TryParse(controllerAction.DeviceId, out var deviceType, out var _) ? deviceType : DeviceType.Unknown);
- Channel = controllerAction.Channel;
- InvertName = controllerAction.IsInvert ? translationService.Translate("Inv") : string.Empty;
- }
+ public class ControllerActionViewModel
+ {
+ private readonly Device? _device;
- public ControllerAction ControllerAction { get; }
- public bool ControllerActionValid { get; }
- public string DeviceName { get; }
- public DeviceType DeviceType { get; }
- public int Channel { get; }
- public string InvertName { get; }
-
- public bool IsChannelSetupSupported =>
- _device is not null &&
- ControllerAction.ChannelOutputType.IsChannelSetupSupported() &&
- _device.IsOutputTypeSupported(Channel, ControllerAction.ChannelOutputType);
+ public ControllerActionViewModel(
+ ControllerAction controllerAction,
+ IDeviceManager deviceManager,
+ IPlayLogic playLogic,
+ ITranslationService translationService)
+ {
+ ControllerAction = controllerAction;
+ _device = deviceManager.GetDeviceById(controllerAction.DeviceId);
+
+ ControllerActionValid = playLogic.ValidateControllerAction(controllerAction);
+ DeviceName = _device != null ? _device.Name : translationService.Translate("Missing");
+ // primary take type from existing device or try to parse DeviceId
+ DeviceType = _device != null ? _device.DeviceType :
+ (DeviceId.TryParse(controllerAction.DeviceId, out var deviceType, out var _) ? deviceType : DeviceType.Unknown);
+ Channel = controllerAction.Channel;
+ InvertName = controllerAction.IsInvert ? translationService.Translate("Inv") : string.Empty;
}
- public class ControllerEventViewModel : List
- {
- public ControllerEventViewModel(
- ControllerEvent controllerEvent,
- IDeviceManager deviceManager,
- IPlayLogic playLogic,
- ITranslationService translationService)
- {
- ControllerEvent = controllerEvent;
+ public ControllerAction ControllerAction { get; }
+ public bool ControllerActionValid { get; }
+ public string DeviceName { get; }
+ public DeviceType DeviceType { get; }
+ public int Channel { get; }
+ public string InvertName { get; }
+
+ public bool IsChannelSetupSupported =>
+ _device is not null &&
+ ControllerAction.ChannelOutputType.IsChannelSetupSupported() &&
+ _device.IsOutputTypeSupported(Channel, ControllerAction.ChannelOutputType);
+ }
- AddRange(controllerEvent.ControllerActions.Select(ca => new ControllerActionViewModel(ca, deviceManager, playLogic, translationService)));
- }
+ public class ControllerEventViewModel : List
+ {
+ public ControllerEventViewModel(
+ ControllerEvent controllerEvent,
+ IDeviceManager deviceManager,
+ IPlayLogic playLogic,
+ ITranslationService translationService)
+ {
+ ControllerEvent = controllerEvent;
- public ControllerEvent ControllerEvent { get; }
+ AddRange(controllerEvent.ControllerActions.Select(ca => new ControllerActionViewModel(ca, deviceManager, playLogic, translationService)));
}
+
+ public ControllerEvent ControllerEvent { get; }
}
}
diff --git a/BrickController2/BrickController2/UI/ViewModels/DeviceEntry.cs b/BrickController2/BrickController2/UI/ViewModels/DeviceEntry.cs
new file mode 100644
index 00000000..fdf50603
--- /dev/null
+++ b/BrickController2/BrickController2/UI/ViewModels/DeviceEntry.cs
@@ -0,0 +1,19 @@
+using BrickController2.DeviceManagement;
+using Device = BrickController2.DeviceManagement.Device;
+
+namespace BrickController2.UI.ViewModels
+{
+ public class DeviceEntry
+ {
+ public IDeviceFactoryData DeviceFactoryData { get; }
+ public Device? ExistingDevice { get; }
+ public bool Selected { get; set; }
+
+ public DeviceEntry(IDeviceFactoryData deviceFactoryData, Device? instace)
+ {
+ DeviceFactoryData = deviceFactoryData;
+ ExistingDevice = instace;
+ Selected = instace != null;
+ }
+ }
+}
diff --git a/BrickController2/BrickController2/UI/ViewModels/DeviceGroup.cs b/BrickController2/BrickController2/UI/ViewModels/DeviceGroup.cs
new file mode 100644
index 00000000..7fcf8e33
--- /dev/null
+++ b/BrickController2/BrickController2/UI/ViewModels/DeviceGroup.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+using BrickController2.DeviceManagement;
+
+namespace BrickController2.UI.ViewModels
+{
+ public class DeviceGroup : List
+ {
+ public DeviceType DeviceType { get; }
+
+ public string GroupName { get; }
+
+ public DeviceGroup(DeviceType deviceType, string groupName, List deviceEntries) : base(deviceEntries)
+ {
+ GroupName = groupName;
+ DeviceType = deviceType;
+ }
+ }
+}
diff --git a/BrickController2/BrickController2/UI/ViewModels/DevicePageViewModel.cs b/BrickController2/BrickController2/UI/ViewModels/DevicePageViewModel.cs
index 710220d3..a5ea36f1 100644
--- a/BrickController2/BrickController2/UI/ViewModels/DevicePageViewModel.cs
+++ b/BrickController2/BrickController2/UI/ViewModels/DevicePageViewModel.cs
@@ -43,7 +43,7 @@ public DevicePageViewModel(
BuWizz2OutputLevel = Device.DefaultOutputLevel;
DeviceOutputs = Enumerable
.Range(0, Device.NumberOfChannels)
- .Select(channel => new DeviceOutputViewModel(this, Device, channel))
+ .Select(channel => new DeviceOutputViewModel(this, NavigationService, Device, channel))
.ToArray();
RenameCommand = new SafeCommand(async () => await RenameDeviceAsync());
@@ -115,7 +115,7 @@ public override async void OnDisappearing()
await DisconnectAsync();
}
- private async Task DisconnectAsync()
+ internal async Task DisconnectAsync()
{
if (_connectionTokenSource is not null && _connectionTask is not null)
{
@@ -364,67 +364,70 @@ private void SetBuWizzOutputLevel(int level)
Device.SetOutputLevel(level);
}
- public class DeviceOutputViewModel : NotifyPropertyChangedSource
- {
- private readonly DevicePageViewModel _pageViewModel;
- private int _output;
+ }
- public DeviceOutputViewModel(DevicePageViewModel pageViewModel, Device device, int channel)
- {
- _pageViewModel = pageViewModel;
- Device = device;
- Channel = channel;
- Output = 0;
+ public class DeviceOutputViewModel : NotifyPropertyChangedSource
+ {
+ private readonly DevicePageViewModel _pageViewModel;
+ private readonly INavigationService _navigationService;
+ private int _output;
- TouchUpCommand = new Command(() => Output = 0);
- TestServoStepperCommand = new SafeCommand(OpenChannelSetupAsync, () => IsServoOrStepperSupported);
- }
+ public DeviceOutputViewModel(DevicePageViewModel pageViewModel, INavigationService navigationService, Device device, int channel)
+ {
+ _pageViewModel = pageViewModel;
+ _navigationService = navigationService;
+ Device = device;
+ Channel = channel;
+ Output = 0;
+
+ TouchUpCommand = new Command(() => Output = 0);
+ TestServoStepperCommand = new SafeCommand(OpenChannelSetupAsync, () => IsServoOrStepperSupported);
+ }
- public Device Device { get; }
- public int Channel { get; }
+ public Device Device { get; }
+ public int Channel { get; }
- public int MinValue => -100;
- public int MaxValue => 100;
+ public int MinValue => -100;
+ public int MaxValue => 100;
- public int Output
+ public int Output
+ {
+ get { return _output; }
+ set
{
- get { return _output; }
- set
- {
- _output = value;
- Device.SetOutput(Channel, (float)value / MaxValue);
- RaisePropertyChanged();
- }
+ _output = value;
+ Device.SetOutput(Channel, (float)value / MaxValue);
+ RaisePropertyChanged();
}
+ }
- public bool IsServoOrStepperSupported =>
- Device.IsOutputTypeSupported(Channel, ChannelOutputType.ServoMotor) ||
- Device.IsOutputTypeSupported(Channel, ChannelOutputType.StepperMotor);
+ public bool IsServoOrStepperSupported =>
+ Device.IsOutputTypeSupported(Channel, ChannelOutputType.ServoMotor) ||
+ Device.IsOutputTypeSupported(Channel, ChannelOutputType.StepperMotor);
- public ICommand TouchUpCommand { get; }
- public ICommand TestServoStepperCommand { get; }
+ public ICommand TouchUpCommand { get; }
+ public ICommand TestServoStepperCommand { get; }
- private async Task OpenChannelSetupAsync()
- {
- // enforce disconnection before navigating to channel setup to avoid connection conflicts
- await _pageViewModel.DisconnectAsync();
+ private async Task OpenChannelSetupAsync()
+ {
+ // enforce disconnection before navigating to channel setup to avoid connection conflicts
+ await _pageViewModel.DisconnectAsync();
- var action = new ControllerAction
- {
- DeviceId = Device.Id,
- Channel = Channel,
- MaxServoAngle = DEFAULT_MAX_SERVO_ANGLE,
- ServoBaseAngle = DEFAULT_SERVO_BASE_ANGLE,
- StepperAngle = DEFAULT_STEPPER_ANGLE,
- // choose first supported output type
- ChannelOutputType = Device.IsOutputTypeSupported(Channel, ChannelOutputType.ServoMotor)
- ? ChannelOutputType.ServoMotor
- : ChannelOutputType.StepperMotor,
- };
- await _pageViewModel.NavigationService.NavigateToAsync(new NavigationParameters(("device", Device),
- ("controlleraction", action),
- ("ischanneltest", true)));
- }
+ var action = new ControllerAction
+ {
+ DeviceId = Device.Id,
+ Channel = Channel,
+ MaxServoAngle = DEFAULT_MAX_SERVO_ANGLE,
+ ServoBaseAngle = DEFAULT_SERVO_BASE_ANGLE,
+ StepperAngle = DEFAULT_STEPPER_ANGLE,
+ // choose first supported output type
+ ChannelOutputType = Device.IsOutputTypeSupported(Channel, ChannelOutputType.ServoMotor)
+ ? ChannelOutputType.ServoMotor
+ : ChannelOutputType.StepperMotor,
+ };
+ await _navigationService.NavigateToAsync(new NavigationParameters(("device", Device),
+ ("controlleraction", action),
+ ("ischanneltest", true)));
}
}
}
diff --git a/BrickController2/BrickController2/UI/ViewModels/ManualDeviceListPageViewModel.cs b/BrickController2/BrickController2/UI/ViewModels/ManualDeviceListPageViewModel.cs
index ddf253ca..450054dd 100644
--- a/BrickController2/BrickController2/UI/ViewModels/ManualDeviceListPageViewModel.cs
+++ b/BrickController2/BrickController2/UI/ViewModels/ManualDeviceListPageViewModel.cs
@@ -14,32 +14,6 @@ namespace BrickController2.UI.ViewModels
{
public class ManualDeviceListPageViewModel : PageViewModelBase
{
- public class DeviceEntry
- {
- public IDeviceFactoryData DeviceFactoryData { get; }
- public Device? ExistingDevice { get; }
- public bool Selected { get; set; }
-
- public DeviceEntry(IDeviceFactoryData deviceFactoryData, Device? instace)
- {
- DeviceFactoryData = deviceFactoryData;
- ExistingDevice = instace;
- Selected = instace != null;
- }
- }
- public class DeviceGroup : List
- {
- public DeviceType DeviceType { get; }
-
- public string GroupName { get; }
-
- public DeviceGroup(DeviceType deviceType, string groupName, List deviceEntries) : base(deviceEntries)
- {
- GroupName = groupName;
- DeviceType = deviceType;
- }
- }
-
private readonly IDeviceManager _deviceManager;
private readonly IDialogService _dialogService;