80 lines
2.6 KiB
C#
80 lines
2.6 KiB
C#
using System.Windows;
|
||
using System.Windows.Input;
|
||
using WPFWCSDemo.Utilities;
|
||
using WPFWCSDemo.ViewModels;
|
||
using WPFWCSDemo.Views;
|
||
|
||
namespace WPFWCSDemo
|
||
{
|
||
/// <summary>
|
||
/// Interaction logic for MainWindow.xaml
|
||
/// </summary>
|
||
public partial class MainWindow : Window
|
||
{
|
||
public MainWindow()
|
||
{
|
||
InitializeComponent();
|
||
DataContext = new MainViewModel(mainFrame);
|
||
|
||
DevicesNavigationView.GetMainFrame(mainFrame);
|
||
|
||
//初始页面
|
||
//mainFrame.Navigate(new MonitorView());
|
||
//this.NavigationService.Navigate(new Uri("MonitorView.xaml"));
|
||
mainFrame.NavigationService.Navigate(new DataInfoView());
|
||
|
||
#region 窗口拖动/大小化
|
||
//最小化
|
||
btnMin.Click += (s, e) => { this.WindowState = WindowState.Minimized; };
|
||
//最大化
|
||
btnMax.Click += (s, e) => { WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal; };
|
||
//双击最大化 / 最小化
|
||
colorZone.MouseDoubleClick += (s, e) =>
|
||
{
|
||
if (e.Source == s && !colorZone.IsMouseCaptureWithin)
|
||
{
|
||
WindowState = WindowState == WindowState.Normal ? WindowState.Maximized : WindowState.Normal;
|
||
}
|
||
};
|
||
//关闭
|
||
btnClose.Click += (s, e) =>
|
||
{
|
||
MessageDialog dialog = new MessageDialog();
|
||
dialog.Title = "弹窗提示";
|
||
// 显示弹窗窗口
|
||
dialog.ShowDialog();
|
||
|
||
|
||
//if (MessageBox.Show("关闭该系统可能导致执行中的任务中断,是否确认要退出程序?", "提示", )
|
||
//{
|
||
// //Environment.Exit(exitCode:1);
|
||
// Application.Current.Shutdown();
|
||
//}
|
||
//else
|
||
//{
|
||
// //关闭通道操作在这执行
|
||
|
||
//}
|
||
|
||
};
|
||
//设备控制器
|
||
//btnController.Click += (s, e) =>
|
||
//{
|
||
// ControllerView controllerView = new ControllerView();
|
||
// controllerView.Show();
|
||
//};
|
||
|
||
//拖动
|
||
colorZone.MouseMove += (s, e) =>
|
||
{
|
||
if (e.LeftButton == MouseButtonState.Pressed) DragMove();
|
||
};
|
||
|
||
//添加事件:选择后将左侧导航栏隐藏1
|
||
menuBar.SelectionChanged += (s, e) => { drawerHost.IsLeftDrawerOpen = false; };
|
||
#endregion
|
||
|
||
}
|
||
}
|
||
}
|