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 RecipeLoaderCommandViewModel : FurnaceUIViewModelBase { public ObservableCollection NameList { get; set; } = new ObservableCollection(); private Dictionary boatCmd = new Dictionary(); public bool IsSave { get; set; } private string _description = ""; public string Description { get => _description; set { _description = value; NotifyOfPropertyChange(nameof(Description)); } } public string SelectedCmd { get; set; } public string ReturnString { get; set; } = ""; public bool SetRecipeProcessEditViewEnable { get; set; } = true; public RecipeLoaderCommandViewModel() { CreateRadioButton(); } private void CreateRadioButton() { boatCmd.Clear(); boatCmd.Add("None", ""); boatCmd.Add("Boat Load", "The boat is loaded in the furnace.(Speed set avai lable)"); boatCmd.Add("Boat Unload", "The boat is unloaded f rom the furnace.(Speed set available)"); boatCmd.Add("Boat Loader Home", "Boat Loader ismoved to the home position."); boatCmd.Add("Boat Rotate", "The boat is rotated."); boatCmd.Add("Boat Rotate Stop", "The rotat ion of the boat is stopped and R-axis is moved to the home position."); boatCmd.Add("Boat CAP2", "Boat Loader is moved to CAP2 position.(CAP2 : CAP position in condition to not seal the reactor)"); boatCmd.Add("Stop(Include R-axis)", "Boat Loader is stopped. (Include R-axis."); NameList.Clear(); foreach (var item in boatCmd.Keys) { if (item != "None") { NameList.Add(new BoatCommand() { Name = item, Description = boatCmd[item] }); } } } public void RdoChecked(object sender) { Description = boatCmd[(string)((RadioButton)sender).Content]; if ((bool)((RadioButton)sender).IsChecked) { ReturnString = (string)((RadioButton)sender).Content; } } public bool IsEnable { get { if (SetRecipeProcessEditViewEnable) { return CGlobal.RecipeProcessEditViewEnable;//是否是View模式 } else { return true; } } } public string RecipeType { get; set; } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); LoadData(); } private void LoadData() { if (!string.IsNullOrEmpty(SelectedCmd) && NameList.Count > 0) { var item = NameList.Where(x => x.Name == SelectedCmd).FirstOrDefault(); if (item != null) { item.IsChecked = true; } ReturnString = SelectedCmd; } } public void TempSetSave() { IsSave = true; ((Window)GetView()).DialogResult = true; } public void TempSetCancel() { IsSave = false; ((Window)GetView()).DialogResult = false; } } public class BoatCommand : PropertyChangedBase { private string _name; public string Name { get => _name; set { _name = value; NotifyOfPropertyChange(nameof(Name)); } } private string _description; public string Description { get => _description; set { _description = value; NotifyOfPropertyChange(nameof(Description)); } } private bool _isChecked; public bool IsChecked { get => _isChecked; set { _isChecked = value; NotifyOfPropertyChange(nameof(IsChecked)); } } } }