| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851 | using Aitex.Core.UI.MVVM;using Aitex.Core.Utilities;using MECF.Framework.Common.RecipeCenter;using MECF.Framework.Common.Utilities;using Prism.Mvvm;using PunkHPX8_Core;using PunkHPX8_MainPages.PMs;using PunkHPX8_Themes.UserControls;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Input;namespace PunkHPX8_MainPages.ViewModels{    public class VpwRecipeViewModel : BindableBase    {        private const string ENGINEERING = "Engineering";        #region 内部变量        private Dictionary<string, RecipeNode> _recipeNodeDic = new Dictionary<string, RecipeNode>();        private ObservableCollection<RecipeNode> _recipeNodes;        private UiRecipeManager _uiRecipeManager = new UiRecipeManager();        private Dictionary<string, bool> _propertyValidResultDic = new Dictionary<string, bool>();        private VpwRecipe _recipe;        private bool _editEnable;        private bool _createEnable;        private RecipeNode _currentNode;        private bool _enable = false;        private bool _isEdit = false;        private string _recipeErrorReason;        private bool _isVacuumPrewetRinseAddInable = true;        private bool _isVentPrewetRinseAddInable = true;        private bool _isExtendCleanRinseAddInable = true;        /// <summary>        /// Wafer尺寸集合        /// </summary>        private List<int> _waferSizeLst = null;        /// <summary>        /// Vacuum Prewet step选择索引        /// </summary>        private int _selectedVacuumPrewetIndex = -1;        /// <summary>        /// Extend Clean step选择索引        /// </summary>        private int _selectedExtendCleanIndex = -1;        /// <summary>        /// Vent Prewet step选择索引        /// </summary>        private int _selectedVentPrewetIndex = -1;        #endregion        #region 属性        public ObservableCollection<RecipeNode> RecipeNodes        {            get { return _recipeNodes; }            set { SetProperty(ref _recipeNodes, value); }        }        public Dictionary<string, bool> PropertyValidResultDic        {            get { return _propertyValidResultDic; }            set { SetProperty(ref _propertyValidResultDic, value); }        }        public RecipeNode CurrentNode        {            get { return _currentNode; }            set { SetProperty(ref _currentNode, value); }        }        public bool Enable        {            get { return _enable; }            set { SetProperty(ref _enable, value); }        }        public bool EditEnable        {            get { return _editEnable; }            set { SetProperty(ref _editEnable, value); }        }        public bool CreateEnable        {            get { return _createEnable; }            set { SetProperty(ref _createEnable, value); }        }        public VpwRecipe Recipe        {            get { return _recipe; }            set { SetProperty(ref _recipe, value); }        }        /// <summary>        /// Wafer 尺寸集合        /// </summary>        public List<int> WaferSizeLst        {            get { return _waferSizeLst; }            set { SetProperty(ref _waferSizeLst, value); }        }        /// <summary>        /// Vacuum Prewet step选择索引        /// </summary>        public int SelectedVacuumPrewetIndex        {            get { return _selectedVacuumPrewetIndex; }            set { SetProperty(ref _selectedVacuumPrewetIndex, value); }        }        /// <summary>        /// SelectedExtendCleanIndex选择索引        /// </summary>        public int SelectedExtendCleanIndex        {            get { return _selectedExtendCleanIndex; }            set { SetProperty(ref _selectedExtendCleanIndex, value); }        }        /// <summary>        /// SelectedVentPrewetIndex选择索引        /// </summary>        public int SelectedVentPrewetIndex        {            get { return _selectedVentPrewetIndex; }            set { SetProperty(ref _selectedVentPrewetIndex, value); }        }        #region 指令        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; }        [IgnorePropertyChange]        public ICommand IsSprayBarRetractFalseCommand { get; private set; }        [IgnorePropertyChange]        public ICommand AddBelowCommand { get; private set; }        [IgnorePropertyChange]        public ICommand AddAboveCommand { get; private set; }        [IgnorePropertyChange]        public ICommand MoveUpCommand { get; private set; }        [IgnorePropertyChange]        public ICommand MoveDownCommand { get; private set; }        [IgnorePropertyChange]        public ICommand DeleteCommand { get; private set; }        public ICommand VentPrewetAddBelowCommand { get; private set; }        [IgnorePropertyChange]        public ICommand VentPrewetAddAboveCommand { get; private set; }        [IgnorePropertyChange]        public ICommand VentPrewetMoveUpCommand { get; private set; }        [IgnorePropertyChange]        public ICommand VentPrewetMoveDownCommand { get; private set; }        [IgnorePropertyChange]        public ICommand VentPrewetDeleteCommand { get; private set; }        public ICommand ExtendCleanAddBelowCommand { get; private set; }        [IgnorePropertyChange]        public ICommand ExtendCleanAddAboveCommand { get; private set; }        [IgnorePropertyChange]        public ICommand ExtendCleanMoveUpCommand { get; private set; }        [IgnorePropertyChange]        public ICommand ExtendCleanMoveDownCommand { get; private set; }        [IgnorePropertyChange]        public ICommand ExtendCleanDeleteCommand { get; private set; }        #endregion        public VpwRecipeViewModel()        {            OperationCommand = new DelegateCommand<object>(SelectionChangedAction);            CreateCommand = new DelegateCommand<object>(CreateAction);            EditCommand = new DelegateCommand<object>(EditAction);            SaveRecipeCommand = new DelegateCommand<object>(SaveAction);            SaveAsRecipeCommand = new DelegateCommand<object>(SaveAsAction);            IsSprayBarRetractFalseCommand = new DelegateCommand<object>(IsSprayBarRetractFalseAction);            AddBelowCommand = new DelegateCommand<object>(AddBelowAction);            AddAboveCommand = new DelegateCommand<object>(AddAboveAction);            MoveUpCommand = new DelegateCommand<object>(MoveUpAction);            MoveDownCommand = new DelegateCommand<object>(MoveDownAction);            DeleteCommand = new DelegateCommand<object>(DeleteAction);            VentPrewetAddBelowCommand = new DelegateCommand<object>(VentPrewetAddBelowAction);            VentPrewetAddAboveCommand = new DelegateCommand<object>(VentPrewetAddAboveAction);            VentPrewetMoveUpCommand = new DelegateCommand<object>(VentPrewetMoveUpAction);            VentPrewetMoveDownCommand = new DelegateCommand<object>(VentPrewetMoveDownAction);            VentPrewetDeleteCommand = new DelegateCommand<object>(VentPrewetDeleteAction);            ExtendCleanAddBelowCommand = new DelegateCommand<object>(ExtendCleanAddBelowAction);            ExtendCleanAddAboveCommand = new DelegateCommand<object>(ExtendCleanAddAboveAction);            ExtendCleanMoveUpCommand = new DelegateCommand<object>(ExtendCleanMoveUpAction);            ExtendCleanMoveDownCommand = new DelegateCommand<object>(ExtendCleanMoveDownAction);            ExtendCleanDeleteCommand = new DelegateCommand<object>(ExtendCleanDeleteAction);            //Wafer尺寸集合            WaferSizeLst = new List<int>();            WaferSizeLst.Add(100);            WaferSizeLst.Add(150);            WaferSizeLst.Add(200);            WaferSizeLst.Add(300);            InitializeProprtyValidResultDictionary();        }        #endregion        private void InitializeProprtyValidResultDictionary()        {            //需要检验的参数            PropertyValidResultDic["VacuumTarget"] = false;            PropertyValidResultDic["DryHoldTime"] = false;            PropertyValidResultDic["DiwLoopDoSet"] = false;            PropertyValidResultDic["SpinSpeed"] = false;            PropertyValidResultDic["SpinTime"] = false;            PropertyValidResultDic["VacuumPrewetFlowSetPoint"] = false;            PropertyValidResultDic["VacuumPrewetFlowWarningPercent"] = false;            PropertyValidResultDic["VacuumPrewetFlowErrorPercent"] = false;            PropertyValidResultDic["VentPrewetFlowSetPoint"] = false;            PropertyValidResultDic["VentPrewetFlowWarningPercent"] = false;            PropertyValidResultDic["VentPrewetFlowErrorPercent"] = false;            PropertyValidResultDic["ExtendCleanFlowSetPoint"] = false;            PropertyValidResultDic["ExtendCleanFlowWarningPercent"] = false;            PropertyValidResultDic["ExtendCleanFlowErrorPercent"] = false;        }        public void LoadRecipeData()        {            RecipeNodes = _uiRecipeManager.GetRecipesByType("vpw");            _recipeNodeDic.Clear();            InitializeDictionary(RecipeNodes);        }        private void InitializeDictionary(ObservableCollection<RecipeNode> nodes)        {            if (nodes != null)            {                foreach (var node in nodes)                {                    if (node.NodeType == RecipeNodeType.File)                    {                        _recipeNodeDic[node.Name] = node;                    }                    InitializeDictionary(node.Children);                }            }        }        private void SelectionChangedAction(object param)        {            if (_recipeNodeDic.ContainsKey(param.ToString()))            {                CurrentNode = _recipeNodeDic[param.ToString()];                if (CurrentNode.NodeType == RecipeNodeType.File)                {                    if (CurrentNode.RecipeLocation == ENGINEERING)                    {                        EditEnable = true;                        CreateEnable = true;                    }                    else                    {                        EditEnable = false;                        CreateEnable = false;                    }                }                Recipe = _uiRecipeManager.LoadRecipe<VpwRecipe>(CurrentNode.RecipeFullFileName);                if (Recipe == null)                {                    MessageBox.Show("Invalid Recipe", "Load Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                    EditEnable = false;                    CreateEnable = false;                }                Enable = false;            }            else            {                if (param.ToString() == ENGINEERING)                {                    CreateEnable = true;                }                else                {                    CreateEnable = false;                }                CurrentNode = null;                Recipe = null;                EditEnable = false;                Enable = false;            }        }        private void CreateAction(object param)        {            RecipeNameDialog recipeNameDialog = new RecipeNameDialog();            if (recipeNameDialog.ShowDialog().Value)            {                if (!CheckNameExist(recipeNameDialog.RecipeName))                {                    Recipe = new VpwRecipe();                    Recipe.CreateDate = DateTime.Now;                    Recipe.Ppid = recipeNameDialog.RecipeName;                    Recipe.Description = recipeNameDialog.RecipeDescription;                    Recipe.VacuumRinseStep = new ObservableCollection<VpwRinseStep>();                    Recipe.VentRinseStep = new ObservableCollection<VpwRinseStep>();                    Recipe.ExtendCleanRinseStep = new ObservableCollection<VpwRinseStep>();                    Enable = true;                    _isEdit = false;                }            }        }        private void EditAction(object param)        {            Enable = true;            _isEdit = false;        }        private bool CheckVpwRecipeRinseStepValueValid(VpwRecipe vpwRecipe,out string errorReason)        {            errorReason = "";            foreach (var item in vpwRecipe.VacuumRinseStep)            {                if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)                {                    errorReason = "VacuumPrewet Rinse Step Time value is not in 0~200";                    return false;                }                if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)                {                    errorReason = "VacuumPrewet Rinse Step Speed value is not in 0~800";                    return false;                }            }            foreach (var item in vpwRecipe.VentRinseStep)            {                if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)                {                    errorReason = "VentPrewet Rinse Step Rinse Step Time value is not in 0~200";                    return false;                }                if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)                {                    errorReason = "VentPrewet Rinse Step Speed value is not in 0~800";                    return false;                }            }            foreach (var item in vpwRecipe.ExtendCleanRinseStep)            {                if (item.DurationSeconds <= 0 || item.DurationSeconds > 200)                {                    errorReason = "ExtendClean Rinse Step Rinse Step Time value is not in 0~200";                    return false;                }                if (item.RotationSpeed <= 0 || item.RotationSpeed > 800)                {                    errorReason = "ExtendClean Rinse Step Rinse Step Speed value is not in 0~800";                    return false;                }            }            return true;        }        private void SaveAction(object param)        {            if (CheckValid(_isEdit))            {                if (!CheckVpwRecipeRinseStepValueValid(Recipe, out _recipeErrorReason))                {                    MessageBox.Show($"{_recipeErrorReason}", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                    return;                }                Recipe.SaveDate = DateTime.Now;                try                {                    _uiRecipeManager.SaveRecipe<VpwRecipe>(ENGINEERING, Recipe.Ppid, "vpw", Recipe);                    LoadRecipeData();                    MessageBox.Show("Save Recipe Success", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Information);                    Enable = false;                }                catch (Exception ex)                {                    MessageBox.Show(ex.Message, "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                }            }        }        /// <summary>        /// 另存为        /// </summary>        /// <param name="param"></param>        private void SaveAsAction(object param)        {            if (Recipe == null)            {                MessageBox.Show("Select a Recipe first", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            VpwRecipe recipe = new VpwRecipe();            if (CheckValid(_isEdit))            {                RecipeNameDialog recipeNameDialog = new RecipeNameDialog();                if (recipeNameDialog.ShowDialog().Value)                {                    if (!CheckNameExist(recipeNameDialog.RecipeName))                    {                        recipe = new VpwRecipe();                        recipe = (VpwRecipe)PropertyUtil.Clone(Recipe);                        recipe.CreateDate = DateTime.Now;                        recipe.Ppid = recipeNameDialog.RecipeName;                        recipe.Description = recipeNameDialog.RecipeDescription;                    }                    else if (recipeNameDialog.RecipeName != null)                    {                        MessageBox.Show("Name can not be Null", "Create Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                        return;                    }                    else                    {                        return;                    }                }                try                {                    _uiRecipeManager.SaveRecipe<VpwRecipe>(ENGINEERING, recipe.Ppid, "vpw", recipe);                    LoadRecipeData();                    MessageBox.Show("Save As Recipe Success", "SaveAs Recipe", MessageBoxButton.OK, MessageBoxImage.Information);                    Enable = false;                }                catch (Exception ex)                {                    MessageBox.Show(ex.Message, "Save As Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                }            }        }        private bool CheckNameExist(string name)        {            foreach (string item in _recipeNodeDic.Keys)            {                if (item == name)                {                    MessageBox.Show($"{name} is exsit", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                    return true;                }            }            return false;        }        private bool CheckValid(bool editType)        {            foreach (string key in _propertyValidResultDic.Keys)            {                          bool valid = _propertyValidResultDic[key];                if (!valid)                {                    MessageBox.Show($"{key} data invalid", "Save Recipe", MessageBoxButton.OK, MessageBoxImage.Error);                    return false;                }            }            return true;        }        private void IsSprayBarRetractFalseAction(object param)        {            Recipe.IsSprayBarRetract = false;        }        #region Vacuum prewet按钮        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void AddBelowAction(object param)        {            if (Recipe!=null && Recipe.VacuumRinseStep.Count >= 5)            {                MessageBox.Show($"Vacuum Prewet Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                                currentRinseSteps.Index = SelectedVacuumPrewetIndex + 1;                for(int i = currentRinseSteps.Index; i<=Recipe.VacuumRinseStep.Count-1; i++)                {                    Recipe.VacuumRinseStep[i].Index++;                }                Recipe.VacuumRinseStep.Insert(SelectedVacuumPrewetIndex + 1, currentRinseSteps);                SelectedVacuumPrewetIndex++;            }        }        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void AddAboveAction(object param)        {            if (Recipe != null && Recipe.VacuumRinseStep.Count >= 5)            {                MessageBox.Show($"Vacuum Prewet Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                if (SelectedVacuumPrewetIndex == -1)                {                    Recipe.VacuumRinseStep.Add(currentRinseSteps);                    SelectedVacuumPrewetIndex = 0;                }                else                {                    currentRinseSteps.Index = SelectedVacuumPrewetIndex;                    for (int i = currentRinseSteps.Index; i <= Recipe.VacuumRinseStep.Count-1; i++)                    {                        Recipe.VacuumRinseStep[i].Index++;                    }                    Recipe.VacuumRinseStep.Insert(SelectedVacuumPrewetIndex, currentRinseSteps);                    SelectedVacuumPrewetIndex--;                }            }                    }        /// <summary>        /// 上移        /// </summary>        /// <param name="param"></param>        private void MoveUpAction(object param)        {            if (Recipe != null)            {                if (SelectedVacuumPrewetIndex > 0)                {                    int currentIndex = SelectedVacuumPrewetIndex;                    VpwRinseStep currentRinseSteps = Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex];                                        currentRinseSteps.Index -= 1;                    Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex-1].Index += 1;                                        Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);                    Recipe.VacuumRinseStep.Insert(currentIndex - 1, currentRinseSteps);                    SelectedVacuumPrewetIndex = currentIndex - 1;                }            }        }        /// <summary>        /// 下移        /// </summary>        /// <param name="param"></param>        private void MoveDownAction(object param)        {            if (Recipe != null)            {                if (SelectedVacuumPrewetIndex >= 0 && SelectedVacuumPrewetIndex < Recipe.VacuumRinseStep.Count - 1 && Recipe.VacuumRinseStep.Count > 1)                {                    int currentIndex = SelectedVacuumPrewetIndex;                    VpwRinseStep currentRinseSteps = Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex];                                        currentRinseSteps.Index += 1;                    Recipe.VacuumRinseStep[SelectedVacuumPrewetIndex + 1].Index -= 1;                                        Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);                    Recipe.VacuumRinseStep.Insert(currentIndex + 1, currentRinseSteps);                    SelectedVacuumPrewetIndex = currentIndex + 1;                }            }        }        /// <summary>        /// 删除        /// </summary>        /// <param name="param"></param>        private void DeleteAction(object param)        {            if (SelectedVacuumPrewetIndex != -1)            {                if (Recipe != null && Recipe.VacuumRinseStep.Count > SelectedVacuumPrewetIndex)                {                    for (int i = SelectedVacuumPrewetIndex + 1; i <= Recipe.VacuumRinseStep.Count - 1; i++)                    {                        Recipe.VacuumRinseStep[i].Index -= 1;                    }                    Recipe.VacuumRinseStep.RemoveAt(SelectedVacuumPrewetIndex);                }            }        }        #endregion        #region Vent prewet按钮        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void VentPrewetAddBelowAction(object param)        {            if (Recipe != null && Recipe.VentRinseStep.Count >= 5)            {                MessageBox.Show($"Vent Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                currentRinseSteps.Index = SelectedVentPrewetIndex + 1;                for (int i = currentRinseSteps.Index; i <= Recipe.VentRinseStep.Count - 1; i++)                {                    Recipe.VentRinseStep[i].Index++;                }                                Recipe.VentRinseStep.Insert(SelectedVentPrewetIndex + 1, currentRinseSteps);                SelectedVentPrewetIndex++;            }        }        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void VentPrewetAddAboveAction(object param)        {            if (Recipe != null && Recipe.VentRinseStep.Count >= 5)            {                MessageBox.Show($"Vent Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                if (SelectedVentPrewetIndex == -1)                {                    Recipe.VentRinseStep.Add(currentRinseSteps);                    SelectedVentPrewetIndex = 0;                }                else                {                    currentRinseSteps.Index = SelectedVentPrewetIndex;                    for (int i = currentRinseSteps.Index; i <= Recipe.VentRinseStep.Count - 1; i++)                    {                        Recipe.VentRinseStep[i].Index++;                    }                                        Recipe.VentRinseStep.Insert(SelectedVentPrewetIndex, currentRinseSteps);                    SelectedVentPrewetIndex--;                }            }                   }        /// <summary>        /// 上移        /// </summary>        /// <param name="param"></param>        private void VentPrewetMoveUpAction(object param)        {            if (Recipe != null)            {                if (SelectedVentPrewetIndex > 0)                {                    int currentIndex = SelectedVentPrewetIndex;                    VpwRinseStep currentRinseSteps = Recipe.VentRinseStep[SelectedVentPrewetIndex];                    currentRinseSteps.Index -= 1;                    Recipe.VentRinseStep[SelectedVentPrewetIndex - 1].Index += 1;                    Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);                    Recipe.VentRinseStep.Insert(currentIndex - 1, currentRinseSteps);                    SelectedVentPrewetIndex = currentIndex - 1;                }            }        }        /// <summary>        /// 下移        /// </summary>        /// <param name="param"></param>        private void VentPrewetMoveDownAction(object param)        {            if (Recipe != null)            {                if (SelectedVentPrewetIndex >= 0 && SelectedVentPrewetIndex < Recipe.VentRinseStep.Count - 1 && Recipe.VentRinseStep.Count > 1)                {                    int currentIndex = SelectedVentPrewetIndex;                    VpwRinseStep currentRinseSteps = Recipe.VentRinseStep[SelectedVentPrewetIndex];                    currentRinseSteps.Index += 1;                    Recipe.VentRinseStep[SelectedVentPrewetIndex + 1].Index -= 1;                    Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);                    Recipe.VentRinseStep.Insert(currentIndex + 1, currentRinseSteps);                    SelectedVentPrewetIndex = currentIndex + 1;                }            }        }        /// <summary>        /// 删除        /// </summary>        /// <param name="param"></param>        private void VentPrewetDeleteAction(object param)        {            if (SelectedVentPrewetIndex != -1)            {                if (Recipe != null && Recipe.VentRinseStep.Count > SelectedVentPrewetIndex)                {                    for (int i = SelectedVentPrewetIndex + 1; i <= Recipe.VentRinseStep.Count - 1; i++)                    {                        Recipe.VentRinseStep[i].Index -= 1;                    }                    Recipe.VentRinseStep.RemoveAt(SelectedVentPrewetIndex);                }            }                   }        #endregion        #region Extend Clean按钮        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void ExtendCleanAddBelowAction(object param)        {            if (Recipe != null && Recipe.ExtendCleanRinseStep.Count >= 5)            {                MessageBox.Show($"Extend Clean Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                currentRinseSteps.Index = SelectedExtendCleanIndex + 1;                for (int i = currentRinseSteps.Index; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)                {                    Recipe.ExtendCleanRinseStep[i].Index++;                }                Recipe.ExtendCleanRinseStep.Insert(SelectedExtendCleanIndex + 1, currentRinseSteps);                SelectedExtendCleanIndex++;            }        }        /// <summary>        /// 增加        /// </summary>        /// <param name="param"></param>        private void ExtendCleanAddAboveAction(object param)        {            if (Recipe != null && Recipe.ExtendCleanRinseStep.Count >= 5)            {                MessageBox.Show($"Extend Clean Rinse Step is already with 5 step,can not add", "Add Rinse Step", MessageBoxButton.OK, MessageBoxImage.Error);                return;            }            if (Recipe != null)            {                VpwRinseStep currentRinseSteps = new VpwRinseStep();                if (SelectedExtendCleanIndex == -1)                {                    Recipe.ExtendCleanRinseStep.Add(currentRinseSteps);                    SelectedExtendCleanIndex = 0;                }                else                {                    currentRinseSteps.Index = SelectedExtendCleanIndex;                    for (int i = currentRinseSteps.Index; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)                    {                        Recipe.ExtendCleanRinseStep[i].Index++;                    }                    Recipe.ExtendCleanRinseStep.Insert(SelectedExtendCleanIndex, currentRinseSteps);                    SelectedExtendCleanIndex--;                }            }        }        /// <summary>        /// 上移        /// </summary>        /// <param name="param"></param>        private void ExtendCleanMoveUpAction(object param)        {            if (Recipe != null)            {                if (SelectedExtendCleanIndex > 0)                {                    int currentIndex = SelectedExtendCleanIndex;                    VpwRinseStep currentRinseSteps = Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex];                    currentRinseSteps.Index -= 1;                    Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex - 1].Index += 1;                    Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);                    Recipe.ExtendCleanRinseStep.Insert(currentIndex - 1, currentRinseSteps);                    SelectedExtendCleanIndex = currentIndex - 1;                }            }        }        /// <summary>        /// 下移        /// </summary>        /// <param name="param"></param>        private void ExtendCleanMoveDownAction(object param)        {            if (Recipe != null)            {                if (SelectedExtendCleanIndex >= 0 && SelectedExtendCleanIndex < Recipe.ExtendCleanRinseStep.Count - 1 && Recipe.ExtendCleanRinseStep.Count > 1)                {                    int currentIndex = SelectedExtendCleanIndex;                    VpwRinseStep currentRinseSteps = Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex];                    currentRinseSteps.Index += 1;                    Recipe.ExtendCleanRinseStep[SelectedExtendCleanIndex + 1].Index -= 1;                    Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);                    Recipe.ExtendCleanRinseStep.Insert(currentIndex + 1, currentRinseSteps);                    SelectedExtendCleanIndex = currentIndex + 1;                }            }        }        /// <summary>        /// 删除        /// </summary>        /// <param name="param"></param>        private void ExtendCleanDeleteAction(object param)        {            if (SelectedExtendCleanIndex != -1)            {                if (Recipe != null && Recipe.ExtendCleanRinseStep.Count > SelectedExtendCleanIndex)                {                    for (int i = SelectedExtendCleanIndex + 1; i <= Recipe.ExtendCleanRinseStep.Count - 1; i++)                    {                        Recipe.ExtendCleanRinseStep[i].Index -= 1;                    }                    Recipe.ExtendCleanRinseStep.RemoveAt(SelectedExtendCleanIndex);                }            }        }        #endregion    }}
 |