@@ -98,6 +98,7 @@ public HubWindow()
9898 InitializeComponent ( ) ;
9999 Title = AppIdentity . DisplayName ;
100100 RefreshDiagnosticsNavVisibility ( ) ;
101+ ApplyHighContrastFallbackIfNeeded ( ) ;
101102 ExtendsContentIntoTitleBar = true ;
102103 SetTitleBar ( AppTitleBar ) ;
103104 Closed += ( s , e ) =>
@@ -1393,11 +1394,90 @@ private void ExecuteCommand(CommandItem cmd)
13931394 }
13941395 }
13951396
1397+ #region High Contrast icon fallback
1398+
1399+ // Fixed-color SVGs provide the normal Hub presentation. In High Contrast,
1400+ // App.xaml resolves this path to system-foreground Fluent glyphs without
1401+ // constructing or subscribing to the legacy WinRT accessibility API.
1402+ private static readonly Dictionary < string , string > s_highContrastGlyphFallback = new ( )
1403+ {
1404+ { "chat" , "\uE8BD " } ,
1405+ { "connection" , "\uE839 " } ,
1406+ { "sessions" , "\uE8F2 " } ,
1407+ { "skills" , "\uE945 " } ,
1408+ { "channels" , "\uEC05 " } ,
1409+ { "instances" , "\uE977 " } ,
1410+ { "agentevents" , "\uE943 " } ,
1411+ { "bindings" , "\uE8AD " } ,
1412+ { "config" , "\uE90F " } ,
1413+ { "usage" , "\uE9D9 " } ,
1414+ { "cron" , "\uE787 " } ,
1415+ { "voice" , "\uE720 " } ,
1416+ { "settings" , "\uE713 " } ,
1417+ { "permissions" , "\uEA18 " } ,
1418+ { "sandbox" , "\uE72E " } ,
1419+ { "activity" , "\uEA95 " } ,
1420+ { "notifications" , "\uE7F4 " } ,
1421+ { "debug" , "\uEBE8 " } ,
1422+ } ;
1423+
1424+ private const string AdvancedGroupGlyph = "\uE950 " ;
1425+ private const string AgentsGroupGlyph = "\uE99A " ;
1426+ private bool _isHighContrast ;
1427+
1428+ private void ApplyHighContrastFallbackIfNeeded ( )
1429+ {
1430+ const string resourceKey = "HubNavigationUseHighContrastIcons" ;
1431+ _isHighContrast = Application . Current . Resources . ContainsKey ( resourceKey )
1432+ && Application . Current . Resources [ resourceKey ] is true ;
1433+ if ( ! _isHighContrast )
1434+ return ;
1435+
1436+ SwapToFontIcons ( NavView . MenuItems ) ;
1437+ SwapToFontIcons ( NavView . FooterMenuItems ) ;
1438+ }
1439+
1440+ private void SwapToFontIcons ( IList < object > items )
1441+ {
1442+ foreach ( var value in items )
1443+ {
1444+ if ( value is not NavigationViewItem item )
1445+ continue ;
1446+
1447+ item . Icon = ResolveHighContrastIcon ( item ) ;
1448+ if ( item . MenuItems . Count > 0 )
1449+ SwapToFontIcons ( item . MenuItems ) ;
1450+ }
1451+ }
1452+
1453+ private IconElement ResolveHighContrastIcon ( NavigationViewItem item )
1454+ {
1455+ if ( item . Tag is string tag )
1456+ {
1457+ if ( s_highContrastGlyphFallback . TryGetValue ( tag , out var glyph ) )
1458+ return FluentIconCatalog . Build ( glyph , 20 ) ;
1459+ if ( tag . StartsWith ( "agent:" , StringComparison . Ordinal ) )
1460+ return FluentIconCatalog . Build ( AgentsGroupGlyph , 20 ) ;
1461+ }
1462+
1463+ if ( item == AgentsNavItem )
1464+ return FluentIconCatalog . Build ( AgentsGroupGlyph , 20 ) ;
1465+ if ( item == NavAdvanced )
1466+ return FluentIconCatalog . Build ( AdvancedGroupGlyph , 20 ) ;
1467+
1468+ return FluentIconCatalog . Build ( "\uE700 " , 20 ) ;
1469+ }
1470+
13961471 private IconElement BuildAgentItemIcon ( )
13971472 {
1473+ if ( _isHighContrast )
1474+ return FluentIconCatalog . Build ( AgentsGroupGlyph , 20 ) ;
1475+
13981476 return new ImageIcon
13991477 {
14001478 Source = ( ImageSource ) NavView . Resources [ "Agents_Icon" ]
14011479 } ;
14021480 }
1481+
1482+ #endregion
14031483}
0 commit comments