Split DeviceChannelSelector to per device type separate components#234
Draft
vicocz wants to merge 4 commits into
Draft
Split DeviceChannelSelector to per device type separate components#234vicocz wants to merge 4 commits into
vicocz wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the UI channel selector by splitting the previous monolithic DeviceChannelSelector XAML into per-device selector components, and introducing a shared base class plus a registry-based factory to load the appropriate selector at runtime.
Changes:
- Added per-device
*ChannelSelectorViewXAML + code-behind components underUI/Controls/Devices. - Introduced
DeviceChannelSelectorViewBase(shared bindable properties + button registration wiring) andIDeviceChannelSelectorView(static device identity). - Refactored
DeviceChannelSelectorto dynamically instantiate the correct per-device selector via a registry; updated the project file to ensure XAML compilation.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| BrickController2/BrickController2/UI/Controls/Devices/WeDo2ChannelSelectorView.xaml.cs | New WeDo2 selector view code-behind using shared base registration. |
| BrickController2/BrickController2/UI/Controls/Devices/WeDo2ChannelSelectorView.xaml | New WeDo2 selector layout extracted from the old monolithic XAML. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicMoveChannelSelectorView.xaml.cs | New Technic Move selector with device-dependent visibility logic. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicMoveChannelSelectorView.xaml | New Technic Move selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicHubChannelSelectorView.xaml.cs | New Technic Hub selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/TechnicHubChannelSelectorView.xaml | New Technic Hub selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickLightChannelSelectorView.xaml.cs | New SBrick Light selector with custom port/subchannel handling. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickLightChannelSelectorView.xaml | New SBrick Light selector layout (includes settings UI). |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickChannelSelectorView.xaml.cs | New SBrick selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/SBrickChannelSelectorView.xaml | New SBrick selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PowerFunctionsChannelSelectorView.xaml.cs | New Infrared/Power Functions selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PowerFunctionsChannelSelectorView.xaml | New Infrared/Power Functions selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PoweredUpChannelSelectorView.xaml.cs | New Powered Up selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PoweredUpChannelSelectorView.xaml | New Powered Up selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/PfxBrickChannelSelectorView.xaml.cs | New PFx Brick selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/PfxBrickChannelSelectorView.xaml | New PFx Brick selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK6ChannelSelectorView.xaml.cs | New MK6 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK6ChannelSelectorView.xaml | New MK6 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK5ChannelSelectorView.xaml.cs | New MK5 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK5ChannelSelectorView.xaml | New MK5 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK4ChannelSelectorView.xaml.cs | New MK4 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK4ChannelSelectorView.xaml | New MK4 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK3_8ChannelSelectorView.xaml.cs | New MK3_8 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/MK3_8ChannelSelectorView.xaml | New MK3_8 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/MK_DIYChannelSelectorView.xaml.cs | New MK_DIY selector view code-behind (stamps MK4 labels intentionally). |
| BrickController2/BrickController2/UI/Controls/Devices/MK_DIYChannelSelectorView.xaml | New MK_DIY selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM8ChannelSelectorView.xaml.cs | New JieStar SCM8 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM8ChannelSelectorView.xaml | New JieStar SCM8 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM4ChannelSelectorView.xaml.cs | New JieStar SCM4 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/JieStarSCM4ChannelSelectorView.xaml | New JieStar SCM4 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/DuploTrainHubChannelSelectorView.xaml.cs | New Duplo Train Hub selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/DuploTrainHubChannelSelectorView.xaml | New Duplo Train Hub selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/CircuitCubesChannelSelectorView.xaml.cs | New Circuit Cubes selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/CircuitCubesChannelSelectorView.xaml | New Circuit Cubes selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/CaDARaceCarChannelSelectorView.xaml.cs | New CaDA Race Car selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/CaDARaceCarChannelSelectorView.xaml | New CaDA Race Car selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizzChannelSelectorView.xaml.cs | New BuWizz selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizzChannelSelectorView.xaml | New BuWizz selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizz3ChannelSelectorView.xaml.cs | New BuWizz3 selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BuWizz3ChannelSelectorView.xaml | New BuWizz3 selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/BoostChannelSelectorView.xaml.cs | New Boost selector view code-behind. |
| BrickController2/BrickController2/UI/Controls/Devices/BoostChannelSelectorView.xaml | New Boost selector layout. |
| BrickController2/BrickController2/UI/Controls/Devices/IDeviceChannelSelectorView.cs | New interface providing compile-time device type identity for selector views. |
| BrickController2/BrickController2/UI/Controls/Devices/DeviceChannelSelectorViewBase.cs | New shared base class that wires up button commands and SelectedChannel propagation. |
| BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml.cs | Refactored selector to registry-driven dynamic child view instantiation. |
| BrickController2/BrickController2/UI/Controls/DeviceChannelSelector.xaml | Simplified host XAML to a content placeholder for the active selector view. |
| BrickController2/BrickController2/BrickController2.csproj | Ensures new per-device XAML views are compiled as MAUI XAML. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+66
to
+71
| private static object OnCoerceDevice(BindableObject bindable, object value) | ||
| { | ||
| if (bindable is DeviceChannelSelectorViewBase view && value is Device device) | ||
| view.OnDeviceChanged(device); | ||
| return value; | ||
| } |
Comment on lines
82
to
+86
| private static object OnCoerceDevice(BindableObject bindable, object value) | ||
| { | ||
| if (bindable is DeviceChannelSelector dcs && value is Device device) | ||
| { | ||
| // enforce update | ||
| // enforce update even when the same Device reference is re-set (e.g. TechnicMove PlayVM mode change) |
Comment on lines
+102
to
+103
| if (!_registry.TryGetValue(device.DeviceType, out var entry)) | ||
| throw new NotSupportedException($"No channel selector for device type {device.DeviceType}"); |
Comment on lines
+121
to
+125
| private static void OnSelectedChannelChanged(BindableObject bindable, object oldValue, object newValue) | ||
| { | ||
| if (bindable is DeviceChannelSelector dcs) | ||
| if (bindable is DeviceChannelSelector dcs && dcs._activeView is not null) | ||
| { | ||
| int selectedChannel = (int)newValue; | ||
| dcs.OnSelectedChannelChanged(selectedChannel); | ||
| dcs._activeView.SelectedChannel = (int)newValue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.