123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using DocumentFormat.OpenXml.Bibliography;
- using FurnaceUI.Models;
- using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
- using MECF.Framework.UI.Client.CenterViews.Editors.Sequence;
- using MECF.Framework.UI.Client.CenterViews.Parameter;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace FurnaceUI.Views.Editors
- {
- public class AlarmErrorCallRecipeViewModel : FurnaceUIViewModelBase
- {
- private ObservableCollection<ParameterTable> _steps = new ObservableCollection<ParameterTable>();
- public ObservableCollection<ParameterTable> Steps
- {
- get { return _steps; }
- set { _steps = value; this.NotifyOfPropertyChange(nameof(Steps)); }
- }
- private ObservableCollection<ParameterTable> _selectItemTable = new ObservableCollection<ParameterTable>();
- public ObservableCollection<ParameterTable> SelectItemTable
- {
- get { return _selectItemTable; }
- set { _selectItemTable = value; this.NotifyOfPropertyChange(nameof(SelectItemTable)); }
- }
- private string _selectItemName;
- public string SelectItemName
- {
- get { return _selectItemName; }
- set { _selectItemName = value; this.NotifyOfPropertyChange(nameof(SelectItemName)); }
- }
- private string _selectItemEndStatus;
- public string SelectItemEndStatus
- {
- get { return _selectItemEndStatus; }
- set { _selectItemEndStatus = value; this.NotifyOfPropertyChange(nameof(SelectItemEndStatus)); }
- }
- private Visibility _isAlarmVisibility;
- public Visibility IsAlarmVisibility
- {
- get { return _isAlarmVisibility; }
- set { _isAlarmVisibility = value; this.NotifyOfPropertyChange(nameof(IsAlarmVisibility)); }
- }
- private RecipeProvider _recipeProvider = new RecipeProvider();
- public string ResultParameterStr { get; set; }
- private RecipeDataBase _CurrentRecipe = new RecipeDataBase();
- public RecipeDataBase CurrentRecipe
- {
- get { return _CurrentRecipe; }
- set { _CurrentRecipe = value; this.NotifyOfPropertyChange(nameof(CurrentRecipe)); }
- }
- protected override void OnInitialize()
- {
- base.OnInitialize();
- LoadData();
- }
- private void LoadData()
- {
- CurrentRecipe.Clear();
- var prefixPath = "Furnace\\alarm";
- var recipes = _recipeProvider.GetXmlRecipeList(prefixPath);
- var firstFile = RecipeSequenceTreeBuilder.BuildFileNode(prefixPath, "", false, recipes)[0].Files.FirstOrDefault();
- if (firstFile != null)
- {
- var recipeContent = _recipeProvider.LoadRecipe(prefixPath, firstFile.Name);
- CurrentRecipe.InitData(prefixPath, firstFile.Name, recipeContent, "PM1");
- foreach (var item in CurrentRecipe.Tables)
- {
- var stepItem = new ParameterTable()
- {
- StepNo = item.Index,
- Name = item.Name,
- IsChecked = false,
- };
- Steps.Add(stepItem);
- }
- if (ResultParameterStr != null)
- {
- var stepNo = ResultParameterStr.Split(':')[0];
- var one = Steps.Where(a => a.StepNo.Equals(int.Parse(stepNo))).FirstOrDefault();
- one.IsChecked = true;
- SelectItemName = one.Name;
- }
- else
- {
- var first = Steps.FirstOrDefault();
- if (first != null)
- {
- first.IsChecked = true;
- SelectItemName = first.Name;
- ResultParameterStr = $"{first.StepNo}:{first.Name}";
- }
- }
- }
- }
- public void SelectTable(object step)
- {
- if (step != null)
- {
- var step1 = step as ParameterTable;
- var SelectedStep = this.Steps.Where(x => x.StepNo == step1.StepNo).FirstOrDefault();
- SelectedStep.IsChecked = true;
- SelectItemName = step1.Name;
- SelectItemTable = new ObservableCollection<ParameterTable>();
- ResultParameterStr = $"{step1.StepNo}:{step1.Name}";
- }
- }
- public void AlarmTableSelected(object step)
- {
- if (step != null)
- {
- var step1 = step as ParameterTable;
- var SelectedStep = this.Steps.Where(x => x.StepNo == step1.StepNo).FirstOrDefault();
- SelectedStep.IsChecked = true;
- SelectItemName = step1.Name;
- SelectItemTable = new ObservableCollection<ParameterTable>();
- ResultParameterStr = $"{step1.StepNo}:{step1.Name}";
- }
- }
- public void CloseCommand()
- {
- ((Window)GetView()).DialogResult = false;
- }
- public void OKCommand()
- {
- ((Window)GetView()).DialogResult = true;
- }
- }
- }
|