66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
using 垂直剖面动态观测系统.Common;
|
|||
|
|
using 垂直剖面动态观测系统.View;
|
|||
|
|
using 垂直剖面动态观测系统.ViewModel;
|
|||
|
|
|
|||
|
|
namespace 垂直剖面动态观测系统
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for App.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class App : Application
|
|||
|
|
{
|
|||
|
|
protected override void OnStartup(StartupEventArgs e)
|
|||
|
|
{
|
|||
|
|
base.OnStartup(e);
|
|||
|
|
|
|||
|
|
if (new LoginView().ShowDialog() == true)
|
|||
|
|
{
|
|||
|
|
//连接串口
|
|||
|
|
//new MainView().ShowDialog();
|
|||
|
|
//Application.Current.Shutdown();
|
|||
|
|
GlobalValues.Start(
|
|||
|
|
//成功的委托
|
|||
|
|
() =>
|
|||
|
|
{
|
|||
|
|
//线程回调 将主窗口线程从子线程回调至主线程
|
|||
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|||
|
|
{
|
|||
|
|
new MainView().ShowDialog();
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
//失败的委托
|
|||
|
|
(msg) =>
|
|||
|
|
{
|
|||
|
|
//线程回调 将主窗口线程从子线程回调至主线程
|
|||
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(msg, "系统启动失败");
|
|||
|
|
Application.Current.Shutdown();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
protected override void OnExit(ExitEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (MainViewModel.timer != null)
|
|||
|
|
{
|
|||
|
|
MainViewModel.timer.Stop();
|
|||
|
|
MainViewModel.timer.Dispose();
|
|||
|
|
}
|
|||
|
|
//在应用退出的时候就会销毁掉
|
|||
|
|
GlobalValues.Dispose();
|
|||
|
|
base.OnExit(e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|