using System.Windows;
using System.Windows.Shapes;
using TeamsISO.App.ViewModels;
namespace TeamsISO.App;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
StateChanged += OnWindowStateChanged;
}
public MainWindow(MainViewModel viewModel) : this()
{
DataContext = viewModel;
}
/// Custom min button — chrome'd window has no system caption buttons.
private void OnMinimize(object sender, RoutedEventArgs e) =>
WindowState = WindowState.Minimized;
/// Toggles maximize/restore. Bound to the maximize button + double-click on the drag region.
private void OnMaximizeRestore(object sender, RoutedEventArgs e) =>
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
/// Custom close button.
private void OnClose(object sender, RoutedEventArgs e) => Close();
///
/// Swap the maximize-button glyph between the "single rectangle" (when normal) and the
/// "two-overlapping-rectangles" (when maximized) variants, matching the Windows 11
/// caption-button conventions.
///
private void OnWindowStateChanged(object? sender, EventArgs e)
{
if (FindName("MaximizeIcon") is not Path icon) return;
icon.Data = WindowState == WindowState.Maximized
// Two-rectangle "restore" glyph
? System.Windows.Media.Geometry.Parse("M 2,0 L 10,0 L 10,8 M 0,2 L 8,2 L 8,10 L 0,10 Z")
// Single-rectangle "maximize" glyph
: System.Windows.Media.Geometry.Parse("M 0,0 L 10,0 L 10,10 L 0,10 Z");
}
}