59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using CapMachine.Wpf.Services;
|
||
using System.Windows;
|
||
|
||
namespace CapMachine.Wpf.Views
|
||
{
|
||
/// <summary>
|
||
/// Interaction logic for MainWindow.xaml
|
||
/// </summary>
|
||
public partial class MainView : Window
|
||
{
|
||
public MainView(ILogService logService)
|
||
{
|
||
InitializeComponent();
|
||
LogService = logService;
|
||
}
|
||
|
||
public ILogService LogService { get; }
|
||
|
||
/// <summary>
|
||
/// Windows状态
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Window_StateChanged(object sender, EventArgs e)
|
||
{
|
||
LogService.Info($"Windows状态:{this.WindowState}-Visibility: {this.Visibility}");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主界面正要关闭
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||
{
|
||
// 弹窗提示是否确定要退出
|
||
MessageBoxResult result = MessageBox.Show("您确定要退出程序吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
|
||
//System.Console.WriteLine(result);
|
||
if (result == MessageBoxResult.Cancel)
|
||
{
|
||
e.Cancel = true; // 中断点击事件
|
||
}
|
||
else
|
||
{
|
||
LogService.Info("Windows关闭");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 主界面完成关闭
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Window_Closed(object sender, EventArgs e)
|
||
{
|
||
Environment.Exit(0); // 强制结束
|
||
}
|
||
}
|
||
} |