| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 | using FurnaceUI.Models;using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;using OpenSEMI.ClientBase;using System.Windows;using System.Linq;using MECF.Framework.Common.Utilities;namespace FurnaceUI.Views.Recipes{    public class RecipeTableSelectDialogViewModel : FurnaceUIViewModelBase    {        private RecipeTable _copyTable;        public RecipeDataBase Recipe { get; set; }        private int _SelectedIndex;        public int SelectedIndex        {            get { return _SelectedIndex; }            set            {                _SelectedIndex = value;                this.NotifyOfPropertyChange(nameof(SelectedIndex));                this.NotifyOfPropertyChange(nameof(SelectedTable));            }        }        public RecipeTable SelectedTable => (Recipe.Tables.Count > SelectedIndex && SelectedIndex >= 0) ? Recipe.Tables[SelectedIndex] : null;        public bool IsEditEnable { get; set; } = true;        public bool IsAlarmRecipe { get; set; }        protected override void OnInitialize()        {            base.OnInitialize();            SelectedIndex = Recipe.TableIndex - 1;        }        public void Copy()        {            if (!DialogBox.Confirm("Copy this table?"))                return;            _copyTable = SelectedTable;        }        public void Paste()        {            if (!DialogBox.Confirm("Paste the copied table?"))                return;            if (_copyTable != null)            {                var table = Recipe.Tables[SelectedIndex];                table.Name = _copyTable.Name;                table.EndStatus = _copyTable.EndStatus;                table.TableData = (RecipeDataBase)CloneUtil.CloneObject(_copyTable.TableData);                int index = 1;                foreach (var item in table.TableData.Steps)                {                    item.StepNo = index;                    index++;                }            }        }        public void Clear()        {            if (!DialogBox.Confirm("Clear this table?"))                return;            // SelectedTable.Name = "";            SelectedTable.EndStatus = "";            if (SelectedTable.TableData.Steps.Count > 1)            {                while (SelectedTable.TableData.Steps.Count > 1)                {                    SelectedTable.TableData.Steps.RemoveAt(1);                }            }            else            {                SelectedTable.TableData = new RecipeDataBase();            }        }        public void NotSelect()        {            SelectedIndex = -1;        }        public void CancelCmd()        {            ((Window)GetView()).DialogResult = false;        }        public void SaveCmd()        {            if (SelectedIndex < 0)            {                Recipe.TableIndex = -1;                Recipe.Steps = null;            }            else            {                Recipe.TableIndex = SelectedTable.Index;                Recipe.Steps.Clear();                SelectedTable.TableData.Steps.ToList().ForEach(x =>                {                    var tempStep = (Step)CloneUtil.CloneObject(x);                    tempStep.StepNo = x.StepNo;                    Recipe.Steps.Add(tempStep);                });            }            ((Window)GetView()).DialogResult = true;        }    }}
 |