WinMain.xaml.cs 2.15 KB
using HHECS.Model.Entities;
using HHECS.WinCommon.Win;
using System;
using System.Windows;
using System.Windows.Controls;

namespace HHECS.WinClient.View.Main
{
    /// <summary>
    /// WinMain.xaml 的交互逻辑
    /// </summary>
    public partial class WinMain : BaseWindow
    {
        public MainVM MainVM { get; set; } = new MainVM();

        public WinMain()
        {
            InitializeComponent();
            this.DataContext = MainVM;
            MainVM.Owner = this;
        }

        private void BaseWindow_Closed(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void MenuMain_Click(object sender, RoutedEventArgs e)
        {
            MainVM.MenuClick((Permission)((MenuItem)e.OriginalSource).Header);
        }

        private void BtnLicenseUpdate_Click(object sender, RoutedEventArgs e)
        {
            MainVM.LicensesClick();
        }

        private void Btn_BeginExcute_Click(object sender, RoutedEventArgs e)
        {
            MainVM.BeginExecute();
        }

        private void Btn_EndExecute_Click(object sender, RoutedEventArgs e)
        {
            MainVM.EndExecute();
        }

        private void BaseWindow_ContentRendered(object sender, EventArgs e)
        {
            MainVM.Init(App.LineCode);
        }

        private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (MainVM.EquipmentExecutor.IsExecuting)
            {
                MessageBox.Show($"请先停止处理然后再推出本程序");
                e.Cancel = true;
            }
        }

        private void Btn_send_Click(object sender, RoutedEventArgs e)
        {
            MainVM.Btn_send_Click();
        }

        private void Btn_reply_Click(object sender, RoutedEventArgs e)
        {
            MainVM.Btn_reply_Click();
        }

        private void Btn_Derusting_Click(object sender, RoutedEventArgs e)
        {
            MainVM.Btn_Derusting_Click();
        }
        private void Btn_DerustingStop_Click(object sender, RoutedEventArgs e)
        {
            MainVM.Btn_DerustingStop_Click();
        }
        
    }
}