using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Toolkit.Mvvm.Messaging;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using HBLConsole.Model;
using HBLConsole.Service;

namespace HBLConsole.DialogWindow.View
{
    /// <summary>
    /// DeviceManagermentSetView.xaml 的交互逻辑
    /// </summary>
    public partial class DeviceManagermentSetView : Window
    {
        public DeviceManagermentSetView()
        {
            InitializeComponent();
            this.MoveBorder.MouseLeftButtonDown += (o, e) => { this.DragMove(); };
            this.ButMin.Click += (o, e) => { this.WindowState = WindowState.Minimized; };
            this.ButMax.Click += (o, e) => { this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; };
            this.ButClose.Click += (o, e) => { this.DialogResult = false; };
            this.MaxWidth = SystemParameters.WorkArea.Width;
            this.MaxHeight = SystemParameters.WorkArea.Height;

            ActionOperate.GetInstance.Register(new Action<object>((s) =>
            {
                this.Tag = s;
                this.DialogResult = false;
                ActionOperate.GetInstance.CancelRegister("Cancel");
                this.Close();

            }), "Cancel");

            ActionOperate.GetInstance.Register(new Action<object>((s) =>
            {
                this.Tag = s;
                this.DialogResult = true;
                ActionOperate.GetInstance.CancelRegister("Confirm");
                this.Close();

            }), "Confirm");


            //DelegationNotifi.GetInstance.Cancel = new Action<DeviceManagermentResult>((s) =>
            //{
            //    this.Tag = s;
            //    this.DialogResult = false;
            //    DelegationNotifi.GetInstance.Cancel = null;
            //    this.Close();
            //});

            //DelegationNotifi.GetInstance.Confirm = new Action<DeviceManagermentResult>((s) =>
            //{
            //    this.Tag = s;
            //    this.DialogResult = true;
            //    DelegationNotifi.GetInstance.Cancel = null;
            //    this.Close();
            //});

        }


        //private void ThisDialogResult(DeviceManagermentResult s, bool result)
        //{
        //    this.Tag = s;
        //    this.DialogResult = result;
        //    //DelegationNotifi.GetInstance.Cancel = null;
        //    ActionManagerment.GetInstance.LogOut("Cancel");
        //    this.Close();
        //}
    }
}
