Stop the recorder from hiding text with a null foreground

Setting Foreground to null is a local value of no brush, so the Record
button, connected devices in the list and the status line had no text
colour. Clear the value instead. The bitrate step is now 4 kbps.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 03:55:20 +00:00
co-authored by Claude Sonnet 5.5
parent b8007355e4
commit 75fc6c02d2
3 changed files with 33 additions and 5 deletions
+16 -2
View File
@@ -34,7 +34,14 @@ internal sealed class ChannelRow : Grid
Margin = new Thickness(0, 2); Margin = new Thickness(0, 2);
sources.ItemTemplate = new FuncDataTemplate<SourceChoice>((choice, _) => sources.ItemTemplate = new FuncDataTemplate<SourceChoice>((choice, _) =>
new TextBlock { Text = choice?.Label, Foreground = choice?.Brush }); {
TextBlock text = new() { Text = choice?.Label };
if (choice?.Brush is { } brush)
{
text.Foreground = brush;
}
return text;
});
sources.SelectionChanged += (_, _) => OnSourcePicked(); sources.SelectionChanged += (_, _) => OnSourcePicked();
monitor.Content = new PathIcon { Data = Geometry.Parse(HeadphonesPath), Width = 16, Height = 16 }; monitor.Content = new PathIcon { Data = Geometry.Parse(HeadphonesPath), Width = 16, Height = 16 };
@@ -90,7 +97,14 @@ internal sealed class ChannelRow : Grid
double peak = Math.Sqrt(Math.Min(1.0, Channel.TakePeak())); double peak = Math.Sqrt(Math.Min(1.0, Channel.TakePeak()));
shown = Math.Max(peak, shown * 0.85); shown = Math.Max(peak, shown * 0.85);
level.Value = shown; level.Value = shown;
sources.Foreground = Channel.IsAvailable ? null : new SolidColorBrush(Color.Parse("#D93025")); if (Channel.IsAvailable)
{
sources.ClearValue(TemplatedControl.ForegroundProperty);
}
else
{
sources.Foreground = new SolidColorBrush(Color.Parse("#D93025"));
}
ToolTip.SetTip(sources, Channel.IsAvailable ? null : Channel.Problem); ToolTip.SetTip(sources, Channel.IsAvailable ? null : Channel.Problem);
} }
+1 -1
View File
@@ -13,7 +13,7 @@
<Button Name="AddButton" Content="Add channel" /> <Button Name="AddButton" Content="Add channel" />
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="6" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="6" HorizontalAlignment="Right">
<TextBlock Text="Bitrate per channel" VerticalAlignment="Center" /> <TextBlock Text="Bitrate per channel" VerticalAlignment="Center" />
<NumericUpDown Name="BitrateBox" Minimum="6" Maximum="256" Increment="2" Value="32" Width="150" FormatString="0 &quot;kbps&quot;" /> <NumericUpDown Name="BitrateBox" Minimum="6" Maximum="256" Increment="4" Value="32" Width="150" FormatString="0 &quot;kbps&quot;" />
</StackPanel> </StackPanel>
<Grid Grid.Row="1" Grid.ColumnSpan="2" ColumnDefinitions="Auto,*,Auto" ColumnSpacing="8"> <Grid Grid.Row="1" Grid.ColumnSpan="2" ColumnDefinitions="Auto,*,Auto" ColumnSpacing="8">
<TextBlock Text="Save in" VerticalAlignment="Center" /> <TextBlock Text="Save in" VerticalAlignment="Center" />
+16 -2
View File
@@ -166,7 +166,14 @@ public partial class MainWindow : Window
private void ShowRecordState(bool isRecording) private void ShowRecordState(bool isRecording)
{ {
RecordButton.Content = isRecording ? "■ Stop" : "● Record"; RecordButton.Content = isRecording ? "■ Stop" : "● Record";
RecordButton.Foreground = isRecording ? null : new SolidColorBrush(Color.Parse("#D93025")); if (isRecording)
{
RecordButton.ClearValue(ForegroundProperty);
}
else
{
RecordButton.Foreground = new SolidColorBrush(Color.Parse("#D93025"));
}
PauseButton.IsEnabled = isRecording; PauseButton.IsEnabled = isRecording;
PauseButton.Content = "Pause"; PauseButton.Content = "Pause";
AddButton.IsEnabled = !isRecording && engine is not null; AddButton.IsEnabled = !isRecording && engine is not null;
@@ -229,6 +236,13 @@ public partial class MainWindow : Window
private void Say(string text, bool isProblem) private void Say(string text, bool isProblem)
{ {
StatusText.Text = text; StatusText.Text = text;
StatusText.Foreground = isProblem ? new SolidColorBrush(Color.Parse("#D93025")) : null; if (isProblem)
{
StatusText.Foreground = new SolidColorBrush(Color.Parse("#D93025"));
}
else
{
StatusText.ClearValue(ForegroundProperty);
}
} }
} }