123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- using Caliburn.Micro;
- using Caliburn.Micro.Core;
- 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.Jobs;
- using System.Windows.Controls;
- using MECF.Framework.UI.Client.CenterViews.Parameter;
- namespace FurnaceUI.Views.Editors
- {
- public class AlarmErrorCommandViewModel : FurnaceUIViewModelBase
- {
- private string selectCommand;
- public string SelectCommand
- {
- get { return selectCommand; }
- set { selectCommand = value; this.NotifyOfPropertyChange(nameof(SelectCommand)); }
- }
- private AlarmErrorCommandView _view;
- public string ResultParameterStr { get; set; }
- private string _alarmStr;
- public string AlarmStr
- {
- get { return _alarmStr; }
- set
- {
- _alarmStr = value; this.NotifyOfPropertyChange(nameof(AlarmStr));
- }
- }
- private Visibility _isJumpVisibility = Visibility.Collapsed;
- public Visibility IsJumpVisibility
- {
- get { return _isJumpVisibility; }
- set { _isJumpVisibility = value; this.NotifyOfPropertyChange(nameof(IsJumpVisibility)); }
- }
- private Visibility _isAlarmVisibility = Visibility.Collapsed;
- public Visibility IsAlarmVisibility
- {
- get { return _isAlarmVisibility; }
- set { _isAlarmVisibility = value; this.NotifyOfPropertyChange(nameof(IsAlarmVisibility)); }
- }
- private Visibility _isAbortVisibility = Visibility.Collapsed;
- public Visibility IsAbortVisibility
- {
- get { return _isAbortVisibility; }
- set { _isAbortVisibility = value; this.NotifyOfPropertyChange(nameof(IsAbortVisibility)); }
- }
- private string _abortStr;
- public string AbortStr
- {
- get { return _abortStr; }
- set { _abortStr = value; this.NotifyOfPropertyChange(nameof(AbortStr)); }
- }
- private string _jumpStr;
- public string JumpStr
- {
- get { return _jumpStr; }
- set { _jumpStr = value; this.NotifyOfPropertyChange(nameof(JumpStr)); }
- }
- protected override void OnInitialize()
- {
- base.OnInitialize();
- InitControl();
- }
- /// <summary>
- /// 初始化按钮 是否被选中
- /// </summary>
- private void InitControl()
- {
- if (string.IsNullOrEmpty(selectCommand))
- return;
- _view = ((GetView() as Window).Content) as AlarmErrorCommandView;
- var key = selectCommand.Split(' ')[0];
- Dictionary<string, string> dicNames = new Dictionary<string, string>() {
- { "Call Alarm Recipe","CallAlarmRecipe"},
- { "Call Abort Recipe","CallAbortRecipe"},
- { "ABORT","CallAbortRecipe"},
- { "CALL","CallAlarmRecipe"},
- { "JUMP","JumpStep"},
- };
- string nameKey = dicNames.ContainsKey(key) ? dicNames[key] : selectCommand;
- var control = _view.FindName(nameKey);
- if (control is null)
- return;
- RadioButton radioButton = control as RadioButton;
- radioButton.IsChecked = true;
- if (key.Equals("CALL"))
- {
- AlarmStr = selectCommand.Replace("CALL ","");
- IsAlarmVisibility = Visibility.Visible;
- }
- else if (key.Equals("ABORT"))
- {
- AbortStr = selectCommand.Replace("ABORT ", "");
- IsAbortVisibility = Visibility.Visible;
- }
- else if (key.Equals("JUMP"))
- {
- JumpStr= selectCommand.Replace("JUMP ", "");
- IsJumpVisibility = Visibility.Visible;
- }
- }
- public void SetCommand(string commandContent)
- {
-
- var windowManager = IoC.Get<IWindowManager>();
- AlarmErrorCallRecipeViewModel errorCallRecipeViewModel = new AlarmErrorCallRecipeViewModel();
- if (commandContent.Equals("Call Alarm Recipe"))
- {
- errorCallRecipeViewModel.IsAlarmVisibility = Visibility.Visible;
- errorCallRecipeViewModel.ResultParameterStr = AlarmStr;
- if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(errorCallRecipeViewModel, null, "Call Alarm Recipe"))
- {
- ResultParameterStr = errorCallRecipeViewModel.ResultParameterStr;
- AlarmStr = ResultParameterStr;
- IsAlarmVisibility = Visibility.Visible;
- IsAbortVisibility = Visibility.Collapsed;
- IsJumpVisibility = Visibility.Collapsed;
- }
- else
- {
- ((Window)GetView()).DialogResult = false;
- }
- selectCommand = "CALL";
- }
- else if (commandContent.Equals("JumpStep"))
- {
- AlarmErrorJumpStepViewModel alarmErrorJumpStepView = new AlarmErrorJumpStepViewModel();
- alarmErrorJumpStepView.ResultParameterStr = JumpStr;
- if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(alarmErrorJumpStepView, null, "Jump"))
- {
- ResultParameterStr = alarmErrorJumpStepView.ResultParameterStr;
- JumpStr = ResultParameterStr;
- IsJumpVisibility = Visibility.Visible;
- IsAbortVisibility = Visibility.Collapsed;
- IsAlarmVisibility = Visibility.Collapsed;
- }
- else
- {
- ((Window)GetView()).DialogResult = false;
- }
- selectCommand = "JUMP";
- }
- else if (commandContent.Equals("Call Abort Recipe"))
- {
- errorCallRecipeViewModel = new AlarmErrorCallRecipeViewModel();
- errorCallRecipeViewModel.IsAlarmVisibility = Visibility.Hidden;
- errorCallRecipeViewModel.ResultParameterStr = AbortStr;
- if ((bool)(windowManager as WindowManager)?.ShowDialogWithTitle(errorCallRecipeViewModel, null, "Call Abort Recipe"))
- {
- ResultParameterStr = errorCallRecipeViewModel.ResultParameterStr;
- AbortStr = ResultParameterStr;
- IsAbortVisibility = Visibility.Visible;
- IsAlarmVisibility = Visibility.Collapsed;
- IsJumpVisibility = Visibility.Collapsed;
- }
- else {
- ((Window)GetView()).DialogResult = false;
- }
- selectCommand = "ABORT";
- }
- else
- {
- ResultParameterStr = null;
- selectCommand = commandContent;
- }
- }
- public void CloseCommand()
- {
- ((Window)GetView()).DialogResult = false;
- }
- public void OKCommand()
- {
- ((Window)GetView()).DialogResult = true;
- }
- }
- }
|