| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 | using Aitex.Core.RT.SCCore;using Caliburn.Micro;using Caliburn.Micro.Core;using MECF.Framework.Common.DataCenter;using MECF.Framework.Common.RecipeCenter;using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using FurnaceUI.Models;using FurnaceUI.Views.Parameter;using FurnaceUI.Views.Recipes;using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;using SciChart.Charting2D.Interop;using RecipeEditorLib.RecipeModel.Params;using OpenSEMI.ClientBase;using MECF.Framework.UI.Client.ClientBase;namespace FurnaceUI.Views.Editors{    public class RecipeTempModeViewModel : FurnaceUIViewModelBase    {        private bool _isProfileSelected = false;        public bool IsProfileSelected        {            get => _isProfileSelected;            set            {                _isProfileSelected = value;                NotifyOfPropertyChange(nameof(IsProfileSelected));            }        }        private string _selectProfileTable = "";        public string SelectProfileTable        {            get => _selectProfileTable;            set            {                _selectProfileTable = value;                NotifyOfPropertyChange(nameof(SelectProfileTable));            }        }        private bool _modelLeftVisibility;        public bool ModelLeftVisibility        {            get => _modelLeftVisibility;            set            {                _modelLeftVisibility = value;                NotifyOfPropertyChange(nameof(ModelLeftVisibility));            }        }        private RecipeDataBase _CurrentRecipe;        public RecipeDataBase CurrentRecipe        {            get { return _CurrentRecipe; }            set { _CurrentRecipe = value; this.NotifyOfPropertyChange(nameof(CurrentRecipe)); }        }        private bool _heaterControlIsChecked;        public bool HeaterControlIsChecked        {            get { return _heaterControlIsChecked; }            set { _heaterControlIsChecked = value; this.NotifyOfPropertyChange(nameof(HeaterControlIsChecked)); }        }        private bool _furnaceControlIsChecked;        public bool FurnaceControlIsChecked        {            get { return _furnaceControlIsChecked; }            set { _furnaceControlIsChecked = value; this.NotifyOfPropertyChange(nameof(FurnaceControlIsChecked)); }        }        private bool _furnaceDirectControlIsChecked;        public bool FurnaceDirectControlIsChecked        {            get { return _furnaceDirectControlIsChecked; }            set { _furnaceDirectControlIsChecked = value; this.NotifyOfPropertyChange(nameof(FurnaceDirectControlIsChecked)); }        }        private bool _profileControlIsChecked;        public bool ProfileControlIsChecked        {            get { return _profileControlIsChecked; }            set { _profileControlIsChecked = value; this.NotifyOfPropertyChange(nameof(ProfileControlIsChecked)); }        }        public bool IsSave { get; set; }        public bool IsManualSet { get; set; }        private string _selectBtnName;        public string SelectBtnName        {            get { return _selectBtnName; }            set { _selectBtnName = value; this.NotifyOfPropertyChange(nameof(SelectBtnName)); }        }        public RecipeTempModeViewModel()        {        }        private bool _isEnable;        public bool IsEnable        {            get { return _isEnable; }            set { _isEnable = value; this.NotifyOfPropertyChange(nameof(IsEnable)); }        }        public string ResultString { get; set; }        public string RecipeType { get; set; }        protected override void OnViewLoaded(object view)        {            base.OnViewLoaded(view);            LoadData();            InitModelLeftVisibility();            IsEnable = IsManualSet == true ? IsManualSet : CGlobal.RecipeProcessEditViewEnable;        }        private void LoadData()        {            if (!string.IsNullOrEmpty(SelectProfileTable))            {                SelectProfileTable = SelectProfileTable.TrimEnd(')');            }            else            {                SelectProfileTable = "Heater";            }            InitControlBtn();        }        private const string FURNACE = "Furnace";        private const string DIRECT = "Furnace Direct";        private const string HEATER = "Heater";        private const string PROFILE = "Profile";        private void InitControlBtn()        {            if (string.IsNullOrEmpty(SelectBtnName))            {                if (!string.IsNullOrEmpty(SelectProfileTable))                {                    if (SelectProfileTable.StartsWith(PROFILE))                        SelectBtnName = PROFILE;                    else if (SelectProfileTable.StartsWith(HEATER))                        SelectBtnName = HEATER;                    else if (SelectProfileTable.StartsWith(DIRECT))                        SelectBtnName = DIRECT;                    else                        SelectBtnName = FURNACE;                }                else                    SelectBtnName = HEATER;            }            if (PROFILE.Equals(SelectBtnName))            {                FurnaceDirectControlIsChecked = false;                FurnaceControlIsChecked = false;                HeaterControlIsChecked = false;                ProfileControlIsChecked = true;                IsProfileSelected = true;            }            if (FURNACE.Equals(SelectBtnName))            {                FurnaceDirectControlIsChecked = false;                FurnaceControlIsChecked = true;                HeaterControlIsChecked = false;                ProfileControlIsChecked = false;            }            if (HEATER.Equals(SelectBtnName))            {                FurnaceDirectControlIsChecked = false;                FurnaceControlIsChecked = false;                HeaterControlIsChecked = true;                ProfileControlIsChecked = false;            }            if (DIRECT.Equals(SelectBtnName))            {                FurnaceDirectControlIsChecked = true;                FurnaceControlIsChecked = false;                HeaterControlIsChecked = false;                ProfileControlIsChecked = false;            }        }        /// <summary>        /// Profile Control按钮 手动且Heater不展示  Recipe展示        /// </summary>        private void InitModelLeftVisibility()        {            ModelLeftVisibility = true;            //if (null == CurrentRecipe)            //{                if (!string.IsNullOrEmpty(SelectBtnName) && SelectBtnName.ToUpper().Equals(HEATER))                {                    ModelLeftVisibility = false;                }            //}        }        public void ProfileClick()        {            ShowProfileTable();        }        public void RdoChecked(string cmd)        {            SelectBtnName = cmd;            switch (cmd)            {                case "Heater":                    ResultString = "Heater";                    IsProfileSelected = false;                    ProfileControlIsChecked = false;                    InitModelLeftVisibility();                    break;                case "Furnace":                    ResultString = "Furnace";                    IsProfileSelected = false;                    ProfileControlIsChecked = false;                    ModelLeftVisibility = true;                    break;                case "Direct":                    SelectBtnName = "Furnace Direct";                    ResultString = "Furnace Direct";                    ProfileControlIsChecked = false;                    IsProfileSelected = false;                    ModelLeftVisibility = true;                    break;                case "Profile":                    ResultString = "Profile";                    IsProfileSelected = true;                    ShowProfileTable();                    break;                default:                    break;            }        }        public void ShowProfileTable()        {            var windowManager = IoC.Get<IWindowManager>();//"Combination.ProfileCondition"            StringParam profile = CurrentRecipe?.ConfigItems.FirstOrDefault(x => x.Name == "Combination.ProfileCondition") as StringParam;            if (profile == null)            {                DialogBox.ShowDialog(DialogButton.Cancel, DialogType.INFO, "Please set the combinatin file first");                return;            }            TempProfileEditViewModel tempProfileEditViewModel;            tempProfileEditViewModel = new TempProfileEditViewModel();            tempProfileEditViewModel.CurrentRecipe = CurrentRecipe;            tempProfileEditViewModel.IsEditEnabled = false;            tempProfileEditViewModel.ProfileTable1.IsChecked = false;            tempProfileEditViewModel.ProfileTable2.IsChecked = false;            tempProfileEditViewModel.ProfileTable3.IsChecked = false;            string test = SelectProfileTable;            if (SelectProfileTable != null && SelectProfileTable != "Heater" && SelectProfileTable != "Furnace Direct" && SelectProfileTable != "Furnace" && SelectProfileTable != "")            {                if (CurrentRecipe == null && SelectProfileTable.Contains(":"))                {                    if (SelectProfileTable.Split(':')[0] == "1")                    {                        tempProfileEditViewModel.Table1CheckinRecipe = true;                    }                    if (SelectProfileTable.Split(':')[0] == "2")                    {                        tempProfileEditViewModel.Table2CheckinRecipe = true;                    }                    if (SelectProfileTable.Split(':')[0] == "3")                    {                        tempProfileEditViewModel.Table3CheckinRecipe = true;                    }                }                else                {                    if (SelectProfileTable.Split(',')[1] == "1")                    {                        tempProfileEditViewModel.Table1CheckinRecipe = true;                    }                    if (SelectProfileTable.Split(',')[1] == "2")                    {                        tempProfileEditViewModel.Table2CheckinRecipe = true;                    }                    if (SelectProfileTable.Split(',')[1] == "3")                    {                        tempProfileEditViewModel.Table3CheckinRecipe = true;                    }                }            }            if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(tempProfileEditViewModel,this, null, "TempProfileEdit"))            {                SelectProfileTable = tempProfileEditViewModel.ResultString;                ResultString = $"Profile({tempProfileEditViewModel.ResultString})";            }            else            {                if (string.IsNullOrEmpty(tempProfileEditViewModel.ResultString))                {                    if (!string.IsNullOrEmpty(ResultString) && !ResultString.Contains(","))                    {                        ResultString = "";                        SelectProfileTable = "";                    }                }            }        }        public void TempSetSave()        {            if (string.IsNullOrEmpty(ResultString) && !string.IsNullOrEmpty(SelectProfileTable))            {                ResultString = SelectProfileTable.Contains("Profile") ? $"{SelectProfileTable})" : SelectProfileTable;            }            IsSave = true;            ((Window)GetView()).DialogResult = true;        }        public void TempSetCancel()        {            IsSave = false;            ((Window)GetView()).DialogResult = false;        }    }}
 |