Skip to content

Commit 4d2b7b3

Browse files
committed
fix: Various UI fixes
1 parent 0982a1d commit 4d2b7b3

2 files changed

Lines changed: 62 additions & 64 deletions

File tree

src/BambiHeavy/Converters/Converters.cs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -151,44 +151,31 @@ public class BoolToEyeIconConverter : IValueConverter
151151
}
152152
}
153153

154-
public class StyleToBorderBrushConverter : IValueConverter
154+
public class ActiveStyleToBorderBrushConverter : IMultiValueConverter
155155
{
156-
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
157-
{
158-
return value is bool b && b
159-
? new SolidColorBrush(Colors.SteelBlue)
160-
: new SolidColorBrush(Color.Parse("#E0E0E0"));
161-
}
162-
163-
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
164-
{
165-
throw new NotImplementedException();
166-
}
167-
}
168-
169-
public class StyleToBackgroundConverter : IValueConverter
170-
{
171-
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
156+
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
172157
{
173-
return value is bool b && b ? new SolidColorBrush(Color.Parse("#E8F0FE")) : Brushes.Transparent;
174-
}
175-
176-
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
177-
{
178-
throw new NotImplementedException();
158+
if (values.Count == 2 && values[0] is BambiStyle current && values[1] is BambiStyle active)
159+
{
160+
return current == active
161+
? new SolidColorBrush(Colors.SteelBlue)
162+
: new SolidColorBrush(Color.Parse("#E0E0E0"));
163+
}
164+
return new SolidColorBrush(Color.Parse("#E0E0E0"));
179165
}
180166
}
181167

182-
public class IsActiveStyleConverter : IValueConverter
168+
public class ActiveStyleToBackgroundConverter : IMultiValueConverter
183169
{
184-
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
185-
{
186-
return value is BambiStyle style && parameter is BambiStyle active && style == active;
187-
}
188-
189-
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
190-
{
191-
throw new NotImplementedException();
170+
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
171+
{
172+
if (values.Count == 2 && values[0] is BambiStyle current && values[1] is BambiStyle active)
173+
{
174+
return current == active
175+
? new SolidColorBrush(Color.Parse("#E8F0FE"))
176+
: Brushes.Transparent;
177+
}
178+
return Brushes.Transparent;
192179
}
193180
}
194181

src/BambiHeavy/Views/SettingsWindow.axaml

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
<converters:MqttStatusTextConverter x:Key="MqttStatusText" />
2121
<converters:BoolToEyeIconConverter x:Key="BoolToEyeIcon" />
2222
<converters:StringToVisibilityConverter x:Key="StringToVisibility" />
23-
<converters:StyleToBorderBrushConverter x:Key="StyleToBorderBrush" />
24-
<converters:StyleToBackgroundConverter x:Key="StyleToBackground" />
2523
<converters:InvertedBoolConverter x:Key="InvertedBool" />
26-
<converters:IsActiveStyleConverter x:Key="IsActiveStyle" />
24+
<converters:ActiveStyleToBorderBrushConverter x:Key="ActiveStyleToBorderBrush" />
25+
<converters:ActiveStyleToBackgroundConverter x:Key="ActiveStyleToBackground" />
2726
<converters:StyleDescriptionConverter x:Key="StyleDescription" />
2827
</Window.Resources>
2928

@@ -79,31 +78,30 @@
7978
<StackPanel Spacing="10">
8079
<TextBlock FontWeight="SemiBold" FontSize="13">MQTT Broker</TextBlock>
8180

82-
<StackPanel Orientation="Horizontal" Spacing="8">
83-
<TextBlock Text="Host:" Width="72" VerticalAlignment="Center" />
84-
<TextBox Text="{Binding MqttBrokerUrl}"
81+
<Grid ColumnDefinitions="80, *">
82+
<TextBlock Text="Host:" VerticalAlignment="Center" />
83+
<TextBox Grid.Column="1" Text="{Binding MqttBrokerUrl}"
8584
PlaceholderText="e.g. 192.168.1.100"
86-
HorizontalAlignment="Stretch"
87-
MinWidth="200" />
88-
</StackPanel>
85+
HorizontalAlignment="Stretch" />
86+
</Grid>
8987

90-
<StackPanel Orientation="Horizontal" Spacing="8">
91-
<TextBlock Text="Port:" Width="72" VerticalAlignment="Center" />
92-
<TextBox Text="{Binding MqttBrokerPort}"
88+
<Grid ColumnDefinitions="80, *, Auto">
89+
<TextBlock Text="Port:" VerticalAlignment="Center" />
90+
<TextBox Grid.Column="1" Text="{Binding MqttBrokerPort}"
9391
PlaceholderText="1883"
9492
HorizontalAlignment="Stretch" />
95-
<CheckBox Content="Use TLS/SSL"
93+
<CheckBox Grid.Column="2" Content="Use TLS/SSL"
9694
IsChecked="{Binding MqttUseTls}"
9795
Margin="12,0,0,0"
9896
VerticalAlignment="Center" />
99-
</StackPanel>
97+
</Grid>
10098

101-
<StackPanel Orientation="Horizontal" Spacing="8">
102-
<TextBlock Text="Client ID:" Width="72" VerticalAlignment="Center" />
103-
<TextBox Text="{Binding MqttClientId}"
99+
<Grid ColumnDefinitions="80, *">
100+
<TextBlock Text="Client ID:" VerticalAlignment="Center" />
101+
<TextBox Grid.Column="1" Text="{Binding MqttClientId}"
104102
PlaceholderText="leave empty for auto-generated"
105103
HorizontalAlignment="Stretch" />
106-
</StackPanel>
104+
</Grid>
107105
</StackPanel>
108106
</Border>
109107

@@ -118,24 +116,27 @@
118116
<StackPanel Spacing="8"
119117
Margin="24,0,0,0"
120118
IsVisible="{Binding UseAuthentication, Converter={StaticResource BoolToIsVisible}}">
121-
<StackPanel Orientation="Horizontal" Spacing="8">
122-
<TextBlock Text="Username:" Width="72" VerticalAlignment="Center" />
123-
<TextBox Text="{Binding MqttUsername}"
119+
<Grid ColumnDefinitions="80, *">
120+
<TextBlock Text="Username:" VerticalAlignment="Center" />
121+
<TextBox Grid.Column="1" Text="{Binding MqttUsername}"
124122
PlaceholderText="MQTT username"
125123
HorizontalAlignment="Stretch" />
126-
</StackPanel>
124+
</Grid>
127125

128-
<StackPanel Orientation="Horizontal" Spacing="8">
129-
<TextBlock Text="Password:" Width="72" VerticalAlignment="Center" />
130-
<TextBox Text="{Binding MqttPassword}"
126+
<Grid ColumnDefinitions="80, *, Auto">
127+
<TextBlock Text="Password:" VerticalAlignment="Center" />
128+
<TextBox Grid.Column="1" Text="{Binding MqttPassword}"
129+
PasswordChar="*"
130+
RevealPassword="{Binding ShowPassword}"
131131
PlaceholderText="MQTT password"
132132
HorizontalAlignment="Stretch" />
133-
<Button
133+
<Button Grid.Column="2"
134134
Content="{Binding ShowPassword, Converter={StaticResource BoolToEyeIcon}}"
135135
Width="56"
136+
Margin="8,0,0,0"
136137
Command="{Binding ToggleShowPasswordCommand}"
137138
HorizontalContentAlignment="Center" />
138-
</StackPanel>
139+
</Grid>
139140
</StackPanel>
140141
</StackPanel>
141142
</Border>
@@ -433,17 +434,27 @@
433434
<ItemsControl.ItemTemplate>
434435
<DataTemplate>
435436
<Border Padding="8" CornerRadius="4" Transitions="{}"
436-
BorderThickness="1"
437-
BorderBrush="{Binding Converter={StaticResource IsActiveStyle}, ConverterParameter={Binding $parent[Window].DataContext.ActiveStyle}, Converter={StaticResource StyleToBorderBrush}}"
438-
Background="{Binding Converter={StaticResource IsActiveStyle}, ConverterParameter={Binding $parent[Window].DataContext.ActiveStyle}, Converter={StaticResource StyleToBackground}}">
437+
BorderThickness="1">
438+
<Border.BorderBrush>
439+
<MultiBinding Converter="{StaticResource ActiveStyleToBorderBrush}">
440+
<Binding />
441+
<Binding Path="$parent[Window].DataContext.ActiveStyle" />
442+
</MultiBinding>
443+
</Border.BorderBrush>
444+
<Border.Background>
445+
<MultiBinding Converter="{StaticResource ActiveStyleToBackground}">
446+
<Binding />
447+
<Binding Path="$parent[Window].DataContext.ActiveStyle" />
448+
</MultiBinding>
449+
</Border.Background>
439450
<Button Padding="8" Background="Transparent" BorderThickness="0"
440451
HorizontalAlignment="Stretch" HorizontalContentAlignment="Left"
441452
Transitions="{}"
442453
Command="{Binding $parent[Window].DataContext.SelectStyleCommand}"
443454
CommandParameter="{Binding}">
444455
<StackPanel>
445456
<TextBlock FontWeight="SemiBold" FontSize="13"
446-
Text="{Binding ToString}" />
457+
Text="{Binding}" />
447458
<TextBlock FontSize="12" Foreground="Gray"
448459
Text="{Binding Converter={StaticResource StyleDescription}}" />
449460
</StackPanel>
@@ -594,7 +605,7 @@
594605
<TextBlock DockPanel.Dock="Right" FontSize="11" Width="36"
595606
TextAlignment="Right" VerticalAlignment="Center">
596607
<TextBlock.Text>
597-
<Binding Path="BypassCoefficient" />
608+
<Binding Path="BypassCoefficient" StringFormat="{}{0}" />
598609
</TextBlock.Text>
599610
</TextBlock>
600611
<TextBlock DockPanel.Dock="Left" Text="Bypass Speed (frames):"

0 commit comments

Comments
 (0)