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 System.Windows.Controls; namespace FurnaceUI.Views.Editors { public class RecipeSkipWaitCommandViewModel : FurnaceUIViewModelBase { private bool _isStepSkipIsChecked = false; public bool IsStepSkipIsChecked { get => _isStepSkipIsChecked; set { _isStepSkipIsChecked = value; NotifyOfPropertyChange("IsStepSkipIsChecked"); } } private bool _isStepWaitIsChecked = false; public bool IsStepWaitIsChecked { get => _isStepWaitIsChecked; set { _isStepWaitIsChecked = value; NotifyOfPropertyChange("IsStepWaitIsChecked"); } } public string SkipWait { get; set; } private Visibility _isStepSkipVisibility = Visibility.Visible; public Visibility IsStepSkipVisibility { get => _isStepSkipVisibility; set { _isStepSkipVisibility = value; NotifyOfPropertyChange("IsStepSkipVisibility"); } } private Visibility _isStepWaitVisibility = Visibility.Visible; public Visibility IsStepWaitVisibility { get => _isStepWaitVisibility; set { _isStepWaitVisibility = value; NotifyOfPropertyChange("IsStepWaitVisibility"); } } private int _stepSkipValue=0; public int StepSkipValue { get => _stepSkipValue; set { _stepSkipValue = value; NotifyOfPropertyChange("StepSkipValue"); } } private int _stepWaitValue=0; public int StepWaitValue { get => _stepWaitValue; set { _stepWaitValue = value; NotifyOfPropertyChange("StepWaitValue"); } } public bool IsSave { get; set; } public RecipeSkipWaitCommandViewModel() { } public bool IsEnable => CGlobal.RecipeProcessEditViewEnable;//是否是View模式 public string RecipeType { get; set; } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); LoadData(); } public void StepClick(string cmd) { switch (cmd) { case "Skip": IsStepSkipIsChecked = !IsStepSkipIsChecked; break; case "Wait": IsStepWaitIsChecked = !IsStepWaitIsChecked; break; default: break; } } public string RtnString { get { StringBuilder stringBuilder = new StringBuilder(); if (IsStepSkipIsChecked) { stringBuilder.Append($"Skip:{StepSkipValue}"); } if (IsStepWaitIsChecked) { if (stringBuilder.Length == 0) { stringBuilder.Append($"Wait:{StepWaitValue}"); } else { stringBuilder.Append($";Wait:{StepWaitValue}"); } } return stringBuilder.ToString(); } } private void LoadData() { if (!string.IsNullOrEmpty(SkipWait)) { string[] temps = SkipWait.Split(';'); foreach (var item in temps) { if (item.Contains("Skip")) { var subTemps = item.Split(':'); if (subTemps.Length == 2) { IsStepSkipIsChecked = true; StepSkipValue =int.Parse(subTemps[1]); } } if (item.Contains("Wait")) { var subTemps = item.Split(':'); if (subTemps.Length == 2) { IsStepWaitIsChecked = true; StepWaitValue = int.Parse(subTemps[1]); } } } } } public void TempSetSave() { IsSave = true; ((Window)GetView()).DialogResult = true; } public void TempSetCancel() { IsSave = false; ((Window)GetView()).DialogResult = false; } } }