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.Recipes; namespace FurnaceUI.Views.Editors { public class RecipeMonitorPosViewModel : FurnaceUIViewModelBase { public RecipeLayoutEntityNormal NormalEntity { get; set; } private bool _isBetweenChecked; public bool IsBetweenChecked { get => _isBetweenChecked; set { _isBetweenChecked = value; NotifyOfPropertyChange(nameof(IsBetweenChecked)); } } private bool _isSlotChecked; public bool IsSlotChecked { get => _isSlotChecked; set { _isSlotChecked = value; NotifyOfPropertyChange(nameof(IsSlotChecked)); } } public void Close() { NormalEntity.MonitorPosition = IsBetweenChecked ? "BetweenCassette" : "Slot"; ((Window)GetView())?.Close(); } private ObservableCollection items = new ObservableCollection(); public ObservableCollection Items { get { return items; } set { items = value; NotifyOfPropertyChange(nameof(Items)); } } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); //if (string.IsNullOrEmpty(NormalEntity.MonitorBetweenCassetteNo)) //{ // for (int i = 1; i <= 7; i++) // { // Items.Add("None"); // } // return; //} //foreach (var item in NormalEntity.MonitorBetweenCassetteNo.Split(',')) //{ // Items.Add(item); //} IsSlotChecked = NormalEntity.MonitorPosition == "Slot"; IsBetweenChecked = !IsSlotChecked; } public void BtnClick(int iIndex, object strContent) { if (iIndex <= 0) return; string strValue = string.Empty; if (strContent.Equals("OFF")) strValue = "ON"; else strValue = "OFF"; Items[iIndex - 1] = strValue; } protected override void OnDeactivate(bool close) { base.OnDeactivate(close); //NormalEntity.MonitorBetweenCassetteNo = string.Empty; //foreach (var item in Items) //{ // NormalEntity.MonitorBetweenCassetteNo += "," + item; //} //NormalEntity.MonitorBetweenCassetteNo = NormalEntity.MonitorBetweenCassetteNo.Substring(1); } } }