123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.IOCore;
- using OpenSEMI.ClientBase;
- 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;
- namespace FurnaceUI.Views.Operations
- {
- public class InterlockItemViewModel : FurnaceUIViewModelBase
- {
- public string ItemType { get; set; }
- public ObservableCollection<InterlockItem> InterlockItems { get; set; } = new ObservableCollection<InterlockItem>();
- private InterlockItem _interlockSelectedItem;
- public InterlockItem InterlockSelectedItem
- {
- get => _interlockSelectedItem;
- set
- {
- _interlockSelectedItem = value;
- NotifyOfPropertyChange(nameof(InterlockSelectedItem));
- }
- }
- private string _selectedItem;
- public string SelectedItem
- {
- get => _selectedItem;
- set
- {
- _selectedItem = value;
- NotifyOfPropertyChange(nameof(SelectedItem));
- }
- }
- private string _searchKey;
- public string SearchKey
- {
- get => _searchKey;
- set
- {
- _searchKey = value;
- NotifyOfPropertyChange(nameof(SearchKey));
- }
- }
- public InterlockItemViewModel(string itemType)
- {
- ItemType = itemType;
- }
- protected override void OnInitialize()
- {
- InitItem();
- base.OnInitialize();
- }
- private void InitItem()
- {
- if (ItemType == "Action")
- {
- List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();
- notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- }
- else
- {
- List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();
- notifiableIoItems = QueryDataClient.Instance.Service.GetDiList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- notifiableIoItems = QueryDataClient.Instance.Service.GetAiList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- }
- }
- public void SearchItem()
- {
- if (!string.IsNullOrEmpty(SearchKey))
- {
- InterlockItems.Clear();
- if (ItemType == "Action")
- {
- List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();
- notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- if (notifiableIoItems[i].Name.Contains(SearchKey))
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- }
- else
- {
- List<NotifiableIoItem> notifiableIoItems = new List<NotifiableIoItem>();
- notifiableIoItems = QueryDataClient.Instance.Service.GetDiList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- if (notifiableIoItems[i].Name.Contains(SearchKey))
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- notifiableIoItems = QueryDataClient.Instance.Service.GetAiList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- if (notifiableIoItems[i].Name.Contains(SearchKey))
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- notifiableIoItems = QueryDataClient.Instance.Service.GetDoList($"System.PM1");
- for (int i = 0; i < notifiableIoItems.Count; i++)
- {
- if (notifiableIoItems[i].Name.Contains(SearchKey))
- InterlockItems.Add(new InterlockItem() { ItemName = notifiableIoItems[i].Name });
- }
- }
- }
- else
- {
- DialogBox.ShowWarning("Please input search key!");
- }
- }
- public void SelectItem()
- {
- if (InterlockSelectedItem == null)
- SelectedItem = "";
- else
- SelectedItem = InterlockSelectedItem.ItemName;
- }
- public void SaveCmd()
- {
- if (string.IsNullOrEmpty(SelectedItem))
- {
- DialogBox.ShowWarning("SelectedItem is empty!");
- return;
- }
- ((Window)GetView()).DialogResult = true;
- }
- public void CloseCmd()
- {
- ((Window)GetView()).DialogResult = false;
- }
- }
- public class InterlockItem : NotifiableItem
- {
- private string _itemName;
- public string ItemName
- {
- get => _itemName;
- set
- {
- _itemName = value;
- InvokePropertyChanged(nameof(ItemName));
- }
- }
- }
- }
|