Skip to content

Split DeviceChannelSelector to per device type separate components#234

Draft
vicocz wants to merge 4 commits into
defaultfrom
local/ui-split-components-per-devicetype
Draft

Split DeviceChannelSelector to per device type separate components#234
vicocz wants to merge 4 commits into
defaultfrom
local/ui-split-components-per-devicetype

Conversation

@vicocz

@vicocz vicocz commented Jul 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

@vicocz vicocz added this to the 2026.2 milestone Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 *ChannelSelectorView XAML + code-behind components under UI/Controls/Devices.
  • Introduced DeviceChannelSelectorViewBase (shared bindable properties + button registration wiring) and IDeviceChannelSelectorView (static device identity).
  • Refactored DeviceChannelSelector to 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;
Copilot finished work on behalf of vicocz July 3, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants