Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System;
using System.Globalization;
using BrickController2.CreationManagement;
using Microsoft.Maui.Controls;
using Device = BrickController2.DeviceManagement.Device;

namespace BrickController2.UI.Converters
{
internal class DeviceAndChannelToMaxServoAngleVisibleConverter : IMultiValueConverter
internal class DeviceAndChannelOutputTypeToMaxServoAngleVisibleConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0] is Device device)
{
return values[1] is int channel && device.CanChangeMaxServoAngle(channel);
return values[1] is ChannelOutputType outputType && outputType == ChannelOutputType.ServoMotor &&
values[2] is int channel && device.CanChangeMaxServoAngle(channel);
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<local:PageBase.Resources>
<ResourceDictionary>
<converters:DeviceAndChannelToChannelOutputTypeVisibleConverter x:Key="DeviceAndChannelToChannelOutputTypeVisible"/>
<converters:DeviceAndChannelToMaxServoAngleVisibleConverter x:Key="DeviceAndChannelToMaxServoAngleVisible"/>
<converters:DeviceAndChannelOutputTypeToMaxServoAngleVisibleConverter x:Key="DeviceAndChannelOutputTypeToMaxServoAngleVisible"/>
</ResourceDictionary>
</local:PageBase.Resources>

<NavigationPage.TitleView>
<NavigationPage.TitleView>
<Grid HorizontalOptions="FillAndExpand">
<Label Text="{extensions:Translate ControllerAction}" TextColor="{DynamicResource NavigationBarItemColor}" FontSize="Medium" FontAttributes="Bold" HorizontalOptions="Start" VerticalOptions="Center"/>
<controls:ImageButton ImageSource="{extensions:ImageResource Source=ic_checkmark.png}" Command="{Binding SaveControllerActionCommand}" Style="{StaticResource NavigationBarImageButtonStyle}" HorizontalOptions="End" Margin="12,0"/>
Expand Down Expand Up @@ -106,8 +106,9 @@
<!-- Max servo angle setting -->
<Grid ColumnSpacing="6" Margin="0,10">
<Grid.IsVisible>
<MultiBinding Converter="{StaticResource DeviceAndChannelToMaxServoAngleVisible}">
<MultiBinding Converter="{StaticResource DeviceAndChannelOutputTypeToMaxServoAngleVisible}">
<Binding Path="SelectedDevice" />
<Binding Path="Action.ChannelOutputType" />
<Binding Path="Action.Channel" />
</MultiBinding>
</Grid.IsVisible>
Expand All @@ -125,7 +126,7 @@
</Grid>

<!-- Stepper angle setting -->
<VerticalStackLayout IsVisible="False">
<VerticalStackLayout IsVisible="False" Margin="0,10">
<VerticalStackLayout.Triggers>
<DataTrigger TargetType="VerticalStackLayout" Binding="{Binding Action.ChannelOutputType}" Value="{x:Static creationManagement:ChannelOutputType.StepperMotor}">
<Setter Property="IsVisible" Value="True"/>
Expand Down