Skip to content

Commit

Permalink
improve IController userIndex display
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Nov 23, 2023
1 parent 2b13caa commit a7aeb6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
20 changes: 14 additions & 6 deletions HandheldCompanion/Controllers/IController.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@
FontSize="30"
Glyph="␼" />

<ui:SimpleStackPanel Margin="12,0,0,0" VerticalAlignment="Center">
<ui:SimpleStackPanel Margin="12,0,0,0" VerticalAlignment="Center" Spacing="2">
<TextBlock Name="ControllerName" Style="{StaticResource BodyTextBlockStyle}" />
<TextBlock
Name="ControllerIndex"
Foreground="{DynamicResource SystemControlForegroundBaseMediumBrush}"
Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="Wrap" />

<ui:SimpleStackPanel Spacing="2" HorizontalAlignment="Left" Orientation="Horizontal" Name="UserIndexPanel">
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
<Border CornerRadius="2" Background="{DynamicResource SystemControlForegroundBaseLowBrush}" Width="12" Height="12"></Border>
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</DockPanel>

Expand Down
18 changes: 15 additions & 3 deletions HandheldCompanion/Controllers/IController.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,25 @@ protected byte UserIndex
}
set
{
_UserIndex = value;

// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
ControllerIndex.Text = string.Format(Properties.Resources.IController_ControllerIndex, (UserIndex)value);
foreach(FrameworkElement frameworkElement in UserIndexPanel.Children)
{
if (frameworkElement is not Border)
continue;

Border border = (Border)frameworkElement;
int idx = UserIndexPanel.Children.IndexOf(border);

if (idx == value)
border.SetResourceReference(BackgroundProperty, "AccentAAFillColorDefaultBrush");
else
border.SetResourceReference(BackgroundProperty, "SystemControlForegroundBaseLowBrush");
}
});

_UserIndex = value;
}
}

Expand Down

0 comments on commit a7aeb6d

Please sign in to comment.