using MECF.Framework.Common.Aitex.Core.RT.EMS;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MECF.Framework.UI.Client.CenterViews.Maintain.ViewModels
{
    public class MaintainConfirmViewModel : DialogViewModel<ResultYesNo>
    {
        #region Properties
        private string _record=string.Empty;

        public string Record
        {
            get { return _record; }
            set { _record = value; NotifyOfPropertyChange(nameof(Record)); }
        }

        private MaintainerItemInfo _iteminfo;

        public MaintainerItemInfo ItemInfo
        {
            get { return _iteminfo; }
            set { _iteminfo = value; NotifyOfPropertyChange(nameof(ItemInfo)); }
        }

        private MaintainerInfo _maintainerInfo;

        public MaintainerInfo MaInfo
        {
            get { return _maintainerInfo; }
            set { _maintainerInfo = value; NotifyOfPropertyChange(nameof(MaInfo)); }
        }


        #endregion

        #region Constructors
        public MaintainConfirmViewModel()
        {
            this.DisplayName = "Confirm";
            this.DialogResult = ResultYesNo.NO;
        }

        public MaintainConfirmViewModel(MaintainerItemInfo info,MaintainerInfo minfo)
        {
            ItemInfo = info;
            MaInfo = minfo;
            Record = info.Config.DefaultRecord;
            this.DisplayName = "Confirm";
            this.DialogResult = ResultYesNo.NO;
        }
        #endregion

        #region Functions

        public void OKExit()
        {
            this.DialogResult = ResultYesNo.YES;
            this.TryClose();
        }

        public void NGExit()
        {
            this.DialogResult = ResultYesNo.NO;
            this.TryClose();
        }

        public void FileOpen(string name)
        {
            InvokeClient.Instance.Service.DoOperation("MaintainManager.OpenFile", name);
        }

        #endregion
    }
}
