using System.Windows.Input;

namespace EEMSCenterUI.Views;

/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        this.Closing += MainWindow_Closing;
        this.StateChanged += MainWindow_StateChanged;
    }

    private void MainWindow_StateChanged(object? sender, EventArgs e)
    {
        switch (this.WindowState)
        {
            case WindowState.Minimized:
                WindowHelper.HideWindow();
                break;
            case WindowState.Normal:
            case WindowState.Maximized:
            default:
                break;
        }
    }

    private void MainWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
    {
        MessageBoxResult result = MessageBox.Show("确认退出EEMS Server?", "退出确认", MessageBoxButton.YesNo);
        if (result == MessageBoxResult.No)
            e.Cancel = true;
    }


    private void Hide_Click(object sender, RoutedEventArgs e)
    {
        WindowHelper.HideWindow();
    }

    private void Exit_Click(object sender, RoutedEventArgs e)
    {
        WindowHelper.ExitWindow();
    }
}