Improve active tab indicator with modern accent rail

This commit is contained in:
Meik
2026-03-05 10:39:35 +01:00
parent 6e40a6833f
commit 9180d88a44
2 changed files with 67 additions and 60 deletions

View File

@@ -438,16 +438,16 @@
BorderBrush="{DynamicResource navigationRailBorderColor}" BorderBrush="{DynamicResource navigationRailBorderColor}"
BorderThickness="1" BorderThickness="1"
CornerRadius="14" /> CornerRadius="14" />
<Canvas Panel.ZIndex="1000" <Border Visibility="Hidden"
Height="62" Tag="ActiveIndicator"
Width="72" Panel.ZIndex="1001"
Margin="62,0,0,0"> Width="4"
<Polygon Visibility="Hidden" Height="34"
x:Name="poly_main1" HorizontalAlignment="Right"
Panel.ZIndex="900" VerticalAlignment="Center"
Points="0,0 8,0 8,62 0,62" Margin="0,0,-7,0"
Fill="{Binding Background, ElementName=BtnAnnouncements}" /> CornerRadius="2"
</Canvas> Background="{DynamicResource accentColor}" />
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Grid> </Grid>
@@ -498,16 +498,16 @@
BorderBrush="{DynamicResource navigationRailBorderColor}" BorderBrush="{DynamicResource navigationRailBorderColor}"
BorderThickness="1" BorderThickness="1"
CornerRadius="14" /> CornerRadius="14" />
<Canvas Panel.ZIndex="1000" <Border Visibility="Hidden"
Height="62" Tag="ActiveIndicator"
Width="72" Panel.ZIndex="1001"
Margin="62,0,0,0"> Width="4"
<Polygon Visibility="Hidden" Height="34"
x:Name="poly_main2" HorizontalAlignment="Right"
Panel.ZIndex="1000" VerticalAlignment="Center"
Points="0,0 8,0 8,62 0,62" Margin="0,0,-7,0"
Fill="{Binding Background, ElementName=BtnIncident}" /> CornerRadius="2"
</Canvas> Background="{DynamicResource accentColor}" />
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Grid> </Grid>
@@ -554,16 +554,16 @@
BorderBrush="{DynamicResource navigationRailBorderColor}" BorderBrush="{DynamicResource navigationRailBorderColor}"
BorderThickness="1" BorderThickness="1"
CornerRadius="14" /> CornerRadius="14" />
<Canvas Panel.ZIndex="1000" <Border Visibility="Hidden"
Height="62" Tag="ActiveIndicator"
Width="72" Panel.ZIndex="1001"
Margin="62,0,0,0"> Width="4"
<Polygon Visibility="Hidden" Height="34"
x:Name="poly_main3" HorizontalAlignment="Right"
Panel.ZIndex="1000" VerticalAlignment="Center"
Points="0,0 8,0 8,62 0,62" Margin="0,0,-7,0"
Fill="{Binding Background, ElementName=BtnSsp}" /> CornerRadius="2"
</Canvas> Background="{DynamicResource accentColor}" />
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Grid> </Grid>
@@ -610,16 +610,16 @@
BorderBrush="{DynamicResource navigationRailBorderColor}" BorderBrush="{DynamicResource navigationRailBorderColor}"
BorderThickness="1" BorderThickness="1"
CornerRadius="14" /> CornerRadius="14" />
<Canvas Panel.ZIndex="1000" <Border Visibility="Hidden"
Height="62" Tag="ActiveIndicator"
Width="72" Panel.ZIndex="1001"
Margin="62,0,0,0"> Width="4"
<Polygon Visibility="Hidden" Height="34"
x:Name="poly_main4" HorizontalAlignment="Right"
Panel.ZIndex="90" VerticalAlignment="Center"
Points="0,0 8,0 8,62 0,62" Margin="0,0,-7,0"
Fill="{Binding Background, ElementName=BtnCustomLink}" /> CornerRadius="2"
</Canvas> Background="{DynamicResource accentColor}" />
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Grid> </Grid>
@@ -666,16 +666,16 @@
BorderBrush="{DynamicResource navigationRailBorderColor}" BorderBrush="{DynamicResource navigationRailBorderColor}"
BorderThickness="1" BorderThickness="1"
CornerRadius="14" /> CornerRadius="14" />
<Canvas Panel.ZIndex="1000" <Border Visibility="Hidden"
Height="62" Tag="ActiveIndicator"
Width="72" Panel.ZIndex="1001"
Margin="62,0,0,0"> Width="4"
<Polygon Visibility="Hidden" Height="34"
x:Name="poly_main4" HorizontalAlignment="Right"
Panel.ZIndex="90" VerticalAlignment="Center"
Points="0,0 8,0 8,62 0,62" Margin="0,0,-7,0"
Fill="{Binding Background, ElementName=BtnInfo}" /> CornerRadius="2"
</Canvas> Background="{DynamicResource accentColor}" />
<ContentPresenter HorizontalAlignment="Center" <ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
</Grid> </Grid>

View File

@@ -900,6 +900,13 @@ namespace C4IT_CustomerPanel
} }
} }
private FrameworkElement GetActiveTabIndicator(Button button)
{
return button == null
? null
: visualHelper.FindVisualChild<FrameworkElement>(button, "ActiveIndicator");
}
public void SetMenuAktivInaktiv(object sender, bool force, bool Silent = false) public void SetMenuAktivInaktiv(object sender, bool force, bool Silent = false)
{ {
Button clickedButton = (Button)sender; Button clickedButton = (Button)sender;
@@ -912,17 +919,17 @@ namespace C4IT_CustomerPanel
{ {
clickedButton.Background = btnColor1; clickedButton.Background = btnColor1;
System.Windows.Shapes.Polygon polyActiveButton = visualHelper.FindVisualChild<System.Windows.Shapes.Polygon>(clickedButton); FrameworkElement activeIndicator = GetActiveTabIndicator(clickedButton);
if (polyActiveButton != null) if (activeIndicator != null)
polyActiveButton.Visibility = Visibility.Visible; activeIndicator.Visibility = Visibility.Visible;
} }
SolidColorBrush btnColor2 = this.ConfigSettings.GetInactiveButtonColor(); SolidColorBrush btnColor2 = this.ConfigSettings.GetInactiveButtonColor();
if (btnColor2 != null && ActiveButton != null) if (btnColor2 != null && ActiveButton != null)
{ {
ActiveButton.Background = btnColor2; ActiveButton.Background = btnColor2;
System.Windows.Shapes.Polygon polyInActiveButton = visualHelper.FindVisualChild<System.Windows.Shapes.Polygon>(ActiveButton); FrameworkElement inactiveIndicator = GetActiveTabIndicator(ActiveButton);
if (polyInActiveButton != null) if (inactiveIndicator != null)
polyInActiveButton.Visibility = Visibility.Hidden; inactiveIndicator.Visibility = Visibility.Hidden;
} }
ActiveButton = clickedButton; ActiveButton = clickedButton;
} }
@@ -1720,13 +1727,13 @@ namespace C4IT_CustomerPanel
Img.Visibility = Visibility.Visible; Img.Visibility = Visibility.Visible;
} }
// check, if active button -> show advanced polygon // check, if active button -> show active tab indicator
if (bu != ActiveButton) if (bu != ActiveButton)
return; return;
System.Windows.Shapes.Polygon polyActiveButton = visualHelper.FindVisualChild<System.Windows.Shapes.Polygon>(bu); FrameworkElement activeIndicator = GetActiveTabIndicator(bu);
if (polyActiveButton != null) if (activeIndicator != null)
polyActiveButton.Visibility = Visibility.Visible; activeIndicator.Visibility = Visibility.Visible;
} }
catch (Exception E) catch (Exception E)
{ {