using Microsoft.UI; using Microsoft.UI.Windowing; using Microsoft.UI.Xaml; using TeamsISO.App.WinUI.Models; 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.ButtonHoverBackgroundColor = Color.FromArgb(0xFF, 0x33, 0x34, 0x3A); AppWindow.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(0xFF, 0x3F, 0x3F, 0x47); AppWindow.TitleBar.ButtonForegroundColor = Color.FromArgb(0xFF, 0xF4, 0xF4, 0xF6); 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)); // ── Mock data wiring (interim) ──────────────────────────────────── // Until ParticipantViewModel binds in the engine wiring commit, the // table is populated from a static sample list so the visual design // can be validated end-to-end against representative data. ParticipantsRepeater.ItemsSource = MockParticipant.Sample(); } /// /// Cycle the active theme between Dark and Light. The actual swap target /// is the window's root visual element — RequestedTheme on that element /// propagates the {ThemeResource} swap across the whole tree, with no /// flicker. The system title-bar buttons aren't part of the visual tree, /// so their colors are recomputed inline. /// /// Persistence to UIPreferences.Theme happens in the view-model wiring /// commit (the WinUI host doesn't yet share UIPreferences with the WPF /// host; both will once the WinUI host owns the .NET startup). /// private void OnThemeToggleClick(object sender, RoutedEventArgs e) { if (Content is FrameworkElement root) { var next = root.ActualTheme == ElementTheme.Dark ? ElementTheme.Light : ElementTheme.Dark; root.RequestedTheme = next; // Title-bar system buttons read from AppWindow.TitleBar directly, // not from the XAML resource dictionary, so we set them inline // for both themes. Dark-mode chrome lands on near-white glyphs; // light-mode chrome lands on near-black glyphs. if (next == ElementTheme.Dark) { AppWindow.TitleBar.ButtonForegroundColor = Color.FromArgb(0xFF, 0xF4, 0xF4, 0xF6); AppWindow.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(0xFF, 0x33, 0x34, 0x3A); AppWindow.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(0xFF, 0x3F, 0x3F, 0x47); ThemeToggleIcon.Glyph = ""; // sun } else { AppWindow.TitleBar.ButtonForegroundColor = Color.FromArgb(0xFF, 0x0A, 0x0A, 0x0A); AppWindow.TitleBar.ButtonHoverBackgroundColor = Color.FromArgb(0xFF, 0xEC, 0xEE, 0xF1); AppWindow.TitleBar.ButtonPressedBackgroundColor = Color.FromArgb(0xFF, 0xE0, 0xE3, 0xE7); ThemeToggleIcon.Glyph = ""; // moon } } } }