using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.Dialog;
using Aitex.Core.UI.MVVM;
using Aitex.Core.Utilities;
using Caliburn.Micro.Core;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.RecipeCenter;
using CyberX8_Core;
using CyberX8_MainPages.PMs;
using CyberX8_Themes.UserControls;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace CyberX8_MainPages.ViewModels
{
    public class SrdRecipeViewModel : BindableBase
    {
        #region 常量
        private const string ENGINEERING = "Engineering";
        private const string SRD = "srd";
        #endregion
        #region 内部变量
        /// 
        /// Recipe节点字典
        /// 
        private Dictionary _recipeNodeDic = new Dictionary();
        /// 
        /// 属性检验结果字典
        /// 
        private Dictionary _propertyValidResultDic = new Dictionary();
        /// 
        /// Recipe节点集合
        /// 
        private ObservableCollection _recipeNodes;
        /// 
        /// uiRecipeManager
        /// 
        private UiRecipeManager _uiRecipeManager = new UiRecipeManager();
        /// 
        /// recipe
        /// 
        private SrdRecipe _recipe;
        /// 
        /// 编辑可用性
        /// 
        private bool _editEnable;
        /// 
        /// 创建可用性
        /// 
        private bool _createEnable;
        /// 
        /// 当前节点
        /// 
        private RecipeNode _currentNode;
        /// 
        /// 是否可用
        /// 
        private bool _enable = false;
        /// 
        /// 是否为编辑(true-Edit,false-add)
        /// 
        private bool _isEdit = false;
        #endregion
        #region 属性
        public ObservableCollection RecipeNodes
        {
            get { return _recipeNodes; }
            set { SetProperty(ref _recipeNodes, value); }
        }
        /// 
        /// Recipe
        /// 
        public SrdRecipe Recipe
        {
            get { return _recipe; }
            set { SetProperty(ref _recipe, value); }
        }
        /// 
        /// 创建可用性
        /// 
        public bool CreateEnable
        {
            get { return _createEnable; }
            set { SetProperty(ref _createEnable, value);}
        }
        /// 
        /// 编辑可用性
        /// 
        public bool EditEnable
        {
            get { return _editEnable; }
            set { SetProperty(ref _editEnable, value);}
        }
        /// 
        /// 当前节点
        /// 
        public RecipeNode CurrentNode
        {
            get { return _currentNode; }
            set { SetProperty(ref _currentNode, value);}
        }
        /// 
        /// 可用性
        /// 
        public bool Enable
        {
            get { return _enable; }
            set { SetProperty(ref _enable, value); }
        }
        /// 
        /// 属性数据检验结果
        /// 
        public Dictionary PropertyValidResultDic
        {
            get { return _propertyValidResultDic; }
            set { SetProperty(ref _propertyValidResultDic, value); }
        }
        #endregion
        #region 指令
        [IgnorePropertyChange]
        public ICommand OperationCommand
        {
            get;
            private set;
        }
        [IgnorePropertyChange]
        public ICommand CreateCommand { get; private set; }
        [IgnorePropertyChange]
        public ICommand EditCommand {  get; private set; }
        [IgnorePropertyChange]
        public ICommand SaveRecipeCommand { get; private set; }
        [IgnorePropertyChange]
        public ICommand SaveAsRecipeCommand { get; private set; }
        #endregion
        /// 
        /// 构造函数
        /// 
        public SrdRecipeViewModel()
        {
            OperationCommand = new DelegateCommand