using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using TeamsISO.App.WinUI.Models; using TeamsISO.App.WinUI.Services; using Windows.Graphics; using Windows.UI; namespace TeamsISO.App.WinUI.Views; public sealed partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Title = "TeamsISO"; // ── Custom title bar wiring ─────────────────────────────────────── // ExtendsContentIntoTitleBar=true tells WindowsAppSDK to draw the // window chrome over our content instead of reserving a Windows-default // caption strip. SetTitleBar marks AppTitleBar as the drag region — // clicks on it route to the system drag handler, everything else stays // hit-testable as a normal XAML element. The system min/max/close // buttons render on top of the right edge regardless; we just provide // their colors so they match our palette. ExtendsContentIntoTitleBar = true; SetTitleBar(AppTitleBar); AppWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; AppWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; AppWindow.TitleBar.ButtonHoverForegroundColor = Colors.White; // ── Initial size & position ─────────────────────────────────────── // 1280x780 matches the WPF host's default — fits comfortably on a // 14-inch laptop while giving the participants table 600+ pixels // of vertical breathing room. AppWindow.Resize(new SizeInt32(1280, 780)); // Participants stub is now declarative in MainWindow.xaml; no // runtime population needed until the view-model wires up. // ── Theme system ────────────────────────────────────────────────── // Subscribe to ThemeManager so picker changes from anywhere // (settings drawer, title-bar toggle, system color change) reach // the title-bar buttons and the visual tree consistently. Apply // once at construction so the initial state matches the preference // before the first frame. ThemeManager.Current.Themed += (_, theme) => ApplyResolvedTheme(theme); ApplyResolvedTheme(ThemeManager.Current.ResolveTheme()); } /// /// Cycle the active theme between Dark and Light from the title-bar /// toggle. The actual swap lives in ; this /// handler just calls Toggle() and lets the subscription propagate. /// private void OnThemeToggleClick(object sender, RoutedEventArgs e) { ThemeManager.Current.Toggle(); } /// /// Settings drawer toggle. Currently a no-op because the drawer host /// can't be inlined in MainWindow.xaml without crashing the XAML parser; /// see the comment in MainWindow.xaml at the drawer placeholder. /// private void OnSettingsClick(object sender, RoutedEventArgs e) { // No-op until SettingsDrawer.xaml is simplified for WinUI 3 1.8. } /// /// Push a resolved theme to the visual tree and to the AppWindow /// title-bar buttons. Called on every /// event and once at construction. /// private void ApplyResolvedTheme(ElementTheme theme) { if (Content is FrameworkElement root) { root.RequestedTheme = theme; } AppWindow.TitleBar.ButtonForegroundColor = ThemeManager.TitleBarForegroundFor(theme); AppWindow.TitleBar.ButtonHoverBackgroundColor = ThemeManager.TitleBarHoverBgFor(theme); AppWindow.TitleBar.ButtonPressedBackgroundColor = ThemeManager.TitleBarHoverBgFor(theme); // Glyph cue: sun () means current is Light, click moves to Dark; // moon () means current is Dark, click moves to Light. ThemeToggleIcon.Glyph = theme == ElementTheme.Light ? "" : ""; } }