| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 | using Caliburn.Micro;using Caliburn.Micro.Core;using MECF.Framework.Common.OperationCenter;using MECF.Framework.UI.Client.CenterViews.Alarms;using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;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 System.Windows.Controls;using FurnaceUI.Models;using FurnaceUI.Views.Recipes;namespace FurnaceUI.Views.Editors{    public class RecipeAlarmActionViewModel : FurnaceUIViewModelBase    {             public Dictionary<int, AlarmAction> AlarmActions { get; set; } = new Dictionary<int, AlarmAction>();        public bool IsEnabled { get; set; } = true;        public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式        private void CreateTestAlarmActions()        {            for (int j = 1; j < 11; j++)            {                AlarmAction alarmAction = new AlarmAction() { PtocessingType = "Ignore Alarm", PtocessingDetails = "" };                if (!AlarmActions.ContainsKey(j))                    AlarmActions.Add(j, alarmAction);            }        }        private string _tableIndex;        public string TableIndex        {            get => _tableIndex;            set            {                _tableIndex = value;            }        }        public void AlarmStabilizeSelected(object obj)        {            if (obj is RadioButton)            {             //   TableIndex = int.Parse((string)((RadioButton)obj).Content);            }        }        private void SelectedTableShowValues()        {            Dictionary<int, AlarmAction> tempAlarm = AlarmActions;            Alarm01Action = tempAlarm[1].PtocessingType;            Alarm01Details = tempAlarm[1].PtocessingDetails;            Alarm02Action = tempAlarm[2].PtocessingType;            Alarm02Details = tempAlarm[2].PtocessingDetails;            Alarm03Action = tempAlarm[3].PtocessingType;            Alarm03Details = tempAlarm[3].PtocessingDetails;            Alarm04Action = tempAlarm[4].PtocessingType;            Alarm04Details = tempAlarm[4].PtocessingDetails;            Alarm05Action = tempAlarm[5].PtocessingType;            Alarm05Details = tempAlarm[5].PtocessingDetails;            Alarm06Action = tempAlarm[6].PtocessingType;            Alarm06Details = tempAlarm[6].PtocessingDetails;            Alarm07Action = tempAlarm[7].PtocessingType;            Alarm07Details = tempAlarm[7].PtocessingDetails;            Alarm08Action = tempAlarm[8].PtocessingType;            Alarm08Details = tempAlarm[8].PtocessingDetails;            Alarm09Action = tempAlarm[9].PtocessingType;            Alarm09Details = tempAlarm[9].PtocessingDetails;            Alarm10Action = tempAlarm[10].PtocessingType;            Alarm10Details = tempAlarm[10].PtocessingDetails;        }        private string _alarm01Action;        public string Alarm01Action        {            get => _alarm01Action;            set            {                _alarm01Action = value;                NotifyOfPropertyChange("Alarm01Action");            }        }        private string _alarm02Action;        public string Alarm02Action        {            get => _alarm02Action;            set            {                _alarm02Action = value;                NotifyOfPropertyChange("Alarm02Action");            }        }        private string _alarm03Action;        public string Alarm03Action        {            get => _alarm03Action;            set            {                _alarm03Action = value;                NotifyOfPropertyChange("Alarm03Action");            }        }        private string _alarm04Action;        public string Alarm04Action        {            get => _alarm04Action;            set            {                _alarm04Action = value;                NotifyOfPropertyChange("Alarm04Action");            }        }        private string _alarm05Action;        public string Alarm05Action        {            get => _alarm05Action;            set            {                _alarm05Action = value;                NotifyOfPropertyChange("Alarm05Action");            }        }        private string _alarm06Action;        public string Alarm06Action        {            get => _alarm06Action;            set            {                _alarm06Action = value;                NotifyOfPropertyChange("Alarm06Action");            }        }        private string _alarm07Action;        public string Alarm07Action        {            get => _alarm07Action;            set            {                _alarm07Action = value;                NotifyOfPropertyChange("Alarm07Action");            }        }        private string _alarm08Action;        public string Alarm08Action        {            get => _alarm08Action;            set            {                _alarm08Action = value;                NotifyOfPropertyChange("Alarm08Action");            }        }        private string _alarm09Action;        public string Alarm09Action        {            get => _alarm09Action;            set            {                _alarm09Action = value;                NotifyOfPropertyChange("Alarm09Action");            }        }        private string _alarm10Action;        public string Alarm10Action        {            get => _alarm10Action;            set            {                _alarm10Action = value;                NotifyOfPropertyChange("Alarm10Action");            }        }        private string _alarm01Details;        public string Alarm01Details        {            get => _alarm01Details;            set            {                _alarm01Details = value;                NotifyOfPropertyChange("Alarm01Details");            }        }        private string _alarm02Details;        public string Alarm02Details        {            get => _alarm02Details;            set            {                _alarm02Details = value;                NotifyOfPropertyChange("Alarm02Details");            }        }        private string _alarm03Details;        public string Alarm03Details        {            get => _alarm03Details;            set            {                _alarm03Details = value;                NotifyOfPropertyChange("Alarm03Details");            }        }        private string _alarm04Details;        public string Alarm04Details        {            get => _alarm04Details;            set            {                _alarm04Details = value;                NotifyOfPropertyChange("Alarm04Details");            }        }        private string _alarm05Details;        public string Alarm05Details        {            get => _alarm05Details;            set            {                _alarm05Details = value;                NotifyOfPropertyChange("Alarm05Details");            }        }        private string _alarm06Details;        public string Alarm06Details        {            get => _alarm06Details;            set            {                _alarm06Details = value;                NotifyOfPropertyChange("Alarm06Details");            }        }        private string _alarm07Details;        public string Alarm07Details        {            get => _alarm07Details;            set            {                _alarm07Details = value;                NotifyOfPropertyChange("Alarm07Details");            }        }        private string _alarm08Details;        public string Alarm08Details        {            get => _alarm08Details;            set            {                _alarm08Details = value;                NotifyOfPropertyChange("Alarm08Details");            }        }        private string _alarm09Details;        public string Alarm09Details        {            get => _alarm09Details;            set            {                _alarm09Details = value;                NotifyOfPropertyChange("Alarm09Details");            }        }        private string _alarm10Details;        public string Alarm10Details        {            get => _alarm10Details;            set            {                _alarm10Details = value;                NotifyOfPropertyChange("Alarm10Details");            }        }        public RecipeDataBase CurrentRecipe { get; set; }        public string CurrentStepName { get; set; }        protected override void OnViewLoaded(object view)        {            base.OnViewLoaded(view);                       CreateTestAlarmActions();            SelectedTableShowValues();            var winview = (RecipeAlarmActionView)(GetView() as Window).Content;            var controls = winview.WPlTempStabilize.Children;            foreach (var item in controls)            {                if ((item is RadioButton) && ((RadioButton)item).GroupName == "TempStabilize" && (string)((RadioButton)item).Content == TableIndex.ToString())                {                    ((RadioButton)item).IsChecked = true;                }            }        }        public void AlarmActionSelected(string selectIndex)        {            if (!IsEnabled) return;            var windowManager = IoC.Get<IWindowManager>();            RecipeAlarmActionSubViewModel recipeAlarmActionSubViewModel = new RecipeAlarmActionSubViewModel();            recipeAlarmActionSubViewModel.StepList = new ObservableCollection<Step>(CurrentRecipe.Steps.OrderBy(x => x.StepNo));            recipeAlarmActionSubViewModel.CurrentStepName = CurrentStepName;            recipeAlarmActionSubViewModel.AlarmType = AlarmActions[int.Parse(selectIndex)].PtocessingType;        //    recipeAlarmActionSubViewModel.AlarmTableNo = TableIndex;            recipeAlarmActionSubViewModel.AlarmGroupNo = int.Parse(selectIndex);            if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(recipeAlarmActionSubViewModel, null, "Alarm Action Sub"))            {                var alarmTableNo = recipeAlarmActionSubViewModel.AlarmTableNo;                var alarmGroupNo = recipeAlarmActionSubViewModel.AlarmGroupNo;                var alarmType = recipeAlarmActionSubViewModel.AlarmType;                var alarmDetails = recipeAlarmActionSubViewModel.AlarmDetails;                AlarmActions[alarmGroupNo].PtocessingType = alarmType;                AlarmActions[alarmGroupNo].PtocessingDetails = alarmDetails;                SelectedTableShowValues();            }        }        public void RecipeAlarmSave()        {            ((Window)GetView()).DialogResult = true;        }        public void RecipeAlarmCancel()        {            ((Window)GetView()).DialogResult = false;        }    }}
 |