Files
6098/Cowain.Bake.Main/Views/MainWindow.xaml.cs

77 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AvalonDock.Layout;
using AvalonDock.Themes;
using Cowain.Bake.BLL;
using Cowain.Bake.Common;
using Cowain.Bake.Common.Enums;
using Cowain.Bake.Communication.Interface;
using Cowain.Bake.Model;
using System.Collections.Generic;
using System.Threading;
using System.Windows;
using Unity;
namespace Cowain.Bake.Main.Views
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public static LayoutDocument mainShowWindow; //为了设置Title直接Binding无效
IUnityContainer _unityContainer = null;
List<Theme> _theme = new List<Theme>();
//public static MainWindowViewModel mainWindowModel = null;
public MainWindow(IUnityContainer unityContainer)
{
InitializeComponent();
_unityContainer = unityContainer;
mainShowWindow = showWindow;
_theme.Add(new MetroTheme()); //GenericTheme
_theme.Add(new AeroTheme());
_theme.Add(new Vs2013BlueTheme());
_theme.Add(new Vs2013DarkTheme());
_theme.Add(new Vs2013LightTheme());
_theme.Add(new ExpressionDarkTheme());
}
public void ChangeSkin(int i)
{
dockingManager.Theme = _theme[i]; //MetroTheme
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
void CloseAllHandle()
{
System.Collections.Generic.List<TDeviceConfig> plcList = _unityContainer.Resolve<DeviceConfigService>().GetConfig(EDeviceType.PLC);
foreach (var item in plcList)
{
IPLCDevice plc = _unityContainer.Resolve<IPLCDevice>(item.Name); //几个PLC就实例化几个
if (null != plc && plc.IsConnect)
{
plc.Close();
}
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// 执行窗体的 Closing 事件的逻辑
if (MessageBoxResult.OK == HandyControl.Controls.MessageBox.Ask("是否退出自动真空烘烤系统?", "退出"))
{
Global.AppExit = true;
CloseAllHandle();
//Thread.Sleep(3000);
//await Task.Delay(10000); async
e.Cancel = false;
}
else
{
e.Cancel = true;
}
}
}
}