using FurnaceUI.Models; using MECF.Framework.UI.Client.ClientBase; using OpenSEMI.Ctrlib.Controls; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; namespace FurnaceUI.Views.Jobs { public class SpecifiedMapViewModel : FurnaceModuleUIViewModelBase { public int point1Count { get; set; } public int point2Count { get; set; } public int point3Count { get; set; } public int point4Count { get; set; } public int point5Count { get; set; } public int point6Count { get; set; } public int point7Count { get; set; } public int point8Count { get; set; } public int point9Count { get; set; } public int point10Count { get; set; } public int point11Count { get; set; } public int point12Count { get; set; } public int point13Count { get; set; } public int point14Count { get; set; } public int point15Count { get; set; } public int point16Count { get; set; } public int point17Count { get; set; } public int point18Count { get; set; } public int point19Count { get; set; } public int point20Count { get; set; } public int point21Count { get; set; } public int point22Count { get; set; } public int point23Count { get; set; } public int point24Count { get; set; } public int point25Count { get; set; } public ModuleInfo WaferItem { get; set; } private int _SlotCount; public int SlotCount { get => _SlotCount; set { _SlotCount = value; NotifyOfPropertyChange("SlotCount"); } } private string _waferType; public string WaferType { get => _waferType; set { _waferType = value; NotifyOfPropertyChange(nameof(WaferType)); } } public ObservableCollection SlotNoList { get; set; } = new ObservableCollection(); public string SlotMap { get; set; } protected override void OnInitialize() { base.OnInitialize(); for (int i = 0; i < 25; i++) { SlotNoList.Add(new SlotItem() { SlotNoEnable = false, SlotNoExist = "None" }); } WaferItem = new ModuleInfo("Specified", "SpecifiedModule", "SpecifiedWafers", true, false); for (int i = 0; i < 25; i++) { WaferItem.WaferManager.Wafers.Add(new WaferInfo() { SlotID = 25 - i, SlotIndex = 25 - i }); } WaferItem.IsInstalled = true; } public void ClosedCmd(string cmdPar) { (GetView() as Window).DialogResult = false; ; } public void EXECCmd() { for (int i = WaferItem.WaferManager.Wafers.Count - 1; i >= 0; i--) { SlotMap += WaferItem.WaferManager.Wafers[i].WaferStatus; } (GetView() as Window).DialogResult = true; } public override void OnMouseUp(object sender, MouseButtonEventArgs e) { base.OnMouseUp(sender, e); if (e.ChangedButton == MouseButton.Left) { if (sender is Slot slot) { if (WaferItem.WaferManager.Wafers[25-slot.SlotID].WaferStatus == 0) { WaferItem.WaferManager.Wafers[25 - slot.SlotID ].WaferStatus = 1; } else { WaferItem.WaferManager.Wafers[25 - slot.SlotID].WaferStatus = 0; } if (slot.WaferStatus == 0) { SlotNoList[slot.SlotID - 1].SlotNoEnable = false; SlotNoList[slot.SlotID - 1].SlotNoExist = "None"; } else if (slot.WaferStatus == 1) { SlotNoList[slot.SlotID - 1].SlotNoEnable = true; SlotNoList[slot.SlotID - 1].SlotNoExist = "Exist"; } int pointCount = (int)this.GetType().GetProperty($"point{slot.SlotID}Count").GetValue(this); this.GetType().GetProperty($"point{slot.SlotID}Count").SetValue(this, ++pointCount); } SlotCount = SlotNoList.Where(s => s.SlotNoEnable == true).Count(); } } public void SlotNoCheck(string SlotNo) { switch (SlotNo) { case "1": point1Count++; if (point1Count % 2 == 0) { SlotNoList[0].SlotNoEnable = false; SlotNoList[0].SlotNoExist = "None"; } else { SlotNoList[0].SlotNoEnable = true; SlotNoList[0].SlotNoExist = "Exist"; } break; case "2": point2Count++; if (point2Count % 2 == 0) { SlotNoList[1].SlotNoEnable = false; SlotNoList[1].SlotNoExist = "None"; } else { SlotNoList[1].SlotNoEnable = true; SlotNoList[1].SlotNoExist = "Exist"; } break; case "3": point3Count++; if (point3Count % 2 == 0) { SlotNoList[2].SlotNoEnable = false; SlotNoList[2].SlotNoExist = "None"; } else { SlotNoList[2].SlotNoEnable = true; SlotNoList[2].SlotNoExist = "Exist"; } break; case "4": point4Count++; if (point4Count % 2 == 0) { SlotNoList[3].SlotNoEnable = false; SlotNoList[3].SlotNoExist = "None"; } else { SlotNoList[3].SlotNoEnable = true; SlotNoList[3].SlotNoExist = "Exist"; } break; case "5": point5Count++; if (point5Count % 2 == 0) { SlotNoList[4].SlotNoEnable = false; SlotNoList[4].SlotNoExist = "None"; } else { SlotNoList[4].SlotNoEnable = true; SlotNoList[4].SlotNoExist = "Exist"; } break; case "6": point6Count++; if (point6Count % 2 == 0) { SlotNoList[5].SlotNoEnable = false; SlotNoList[5].SlotNoExist = "None"; } else { SlotNoList[5].SlotNoEnable = true; SlotNoList[5].SlotNoExist = "Exist"; } break; case "7": point7Count++; if (point7Count % 2 == 0) { SlotNoList[6].SlotNoEnable = false; SlotNoList[6].SlotNoExist = "None"; } else { SlotNoList[6].SlotNoEnable = true; SlotNoList[6].SlotNoExist = "Exist"; } break; case "8": point8Count++; if (point8Count % 2 == 0) { SlotNoList[7].SlotNoEnable = false; SlotNoList[7].SlotNoExist = "None"; } else { SlotNoList[7].SlotNoEnable = true; SlotNoList[7].SlotNoExist = "Exist"; } break; case "9": point9Count++; if (point9Count % 2 == 0) { SlotNoList[8].SlotNoEnable = false; SlotNoList[8].SlotNoExist = "None"; } else { SlotNoList[8].SlotNoEnable = true; SlotNoList[8].SlotNoExist = "Exist"; } break; case "10": point10Count++; if (point10Count % 2 == 0) { SlotNoList[9].SlotNoEnable = false; SlotNoList[9].SlotNoExist = "None"; } else { SlotNoList[9].SlotNoEnable = true; SlotNoList[9].SlotNoExist = "Exist"; } break; case "11": point11Count++; if (point11Count % 2 == 0) { SlotNoList[10].SlotNoEnable = false; SlotNoList[10].SlotNoExist = "None"; } else { SlotNoList[10].SlotNoEnable = true; SlotNoList[10].SlotNoExist = "Exist"; } break; case "12": point12Count++; if (point12Count % 2 == 0) { SlotNoList[11].SlotNoEnable = false; SlotNoList[11].SlotNoExist = "None"; } else { SlotNoList[11].SlotNoEnable = true; SlotNoList[11].SlotNoExist = "Exist"; } break; case "13": point13Count++; if (point13Count % 2 == 0) { SlotNoList[12].SlotNoEnable = false; SlotNoList[12].SlotNoExist = "None"; } else { SlotNoList[12].SlotNoEnable = true; SlotNoList[12].SlotNoExist = "Exist"; } break; case "14": point14Count++; if (point14Count % 2 == 0) { SlotNoList[13].SlotNoEnable = false; SlotNoList[13].SlotNoExist = "None"; } else { SlotNoList[13].SlotNoEnable = true; SlotNoList[13].SlotNoExist = "Exist"; } break; case "15": point15Count++; if (point15Count % 2 == 0) { SlotNoList[14].SlotNoEnable = false; SlotNoList[14].SlotNoExist = "None"; } else { SlotNoList[14].SlotNoEnable = true; SlotNoList[14].SlotNoExist = "Exist"; } break; case "16": point16Count++; if (point16Count % 2 == 0) { SlotNoList[15].SlotNoEnable = false; SlotNoList[15].SlotNoExist = "None"; } else { SlotNoList[15].SlotNoEnable = true; SlotNoList[15].SlotNoExist = "Exist"; } break; case "17": point17Count++; if (point17Count % 2 == 0) { SlotNoList[16].SlotNoEnable = false; SlotNoList[16].SlotNoExist = "None"; } else { SlotNoList[16].SlotNoEnable = true; SlotNoList[16].SlotNoExist = "Exist"; } break; case "18": point18Count++; if (point18Count % 2 == 0) { SlotNoList[17].SlotNoEnable = false; SlotNoList[17].SlotNoExist = "None"; } else { SlotNoList[17].SlotNoEnable = true; SlotNoList[17].SlotNoExist = "Exist"; } break; case "19": point19Count++; if (point19Count % 2 == 0) { SlotNoList[18].SlotNoEnable = false; SlotNoList[18].SlotNoExist = "None"; } else { SlotNoList[18].SlotNoEnable = true; SlotNoList[18].SlotNoExist = "Exist"; } break; case "20": point20Count++; if (point20Count % 2 == 0) { SlotNoList[19].SlotNoEnable = false; SlotNoList[19].SlotNoExist = "None"; } else { SlotNoList[19].SlotNoEnable = true; SlotNoList[19].SlotNoExist = "Exist"; } break; case "21": point21Count++; if (point21Count % 2 == 0) { SlotNoList[20].SlotNoEnable = false; SlotNoList[20].SlotNoExist = "None"; } else { SlotNoList[20].SlotNoEnable = true; SlotNoList[20].SlotNoExist = "Exist"; } break; case "22": point22Count++; if (point22Count % 2 == 0) { SlotNoList[21].SlotNoEnable = false; SlotNoList[21].SlotNoExist = "None"; } else { SlotNoList[21].SlotNoEnable = true; SlotNoList[21].SlotNoExist = "Exist"; } break; case "23": point23Count++; if (point23Count % 2 == 0) { SlotNoList[22].SlotNoEnable = false; SlotNoList[22].SlotNoExist = "None"; } else { SlotNoList[22].SlotNoEnable = true; SlotNoList[22].SlotNoExist = "Exist"; } break; case "24": point24Count++; if (point24Count % 2 == 0) { SlotNoList[23].SlotNoEnable = false; SlotNoList[23].SlotNoExist = "None"; } else { SlotNoList[23].SlotNoEnable = true; SlotNoList[23].SlotNoExist = "Exist"; } break; case "25": point25Count++; if (point25Count % 2 == 0) { SlotNoList[24].SlotNoEnable = false; SlotNoList[24].SlotNoExist = "None"; } else { SlotNoList[24].SlotNoEnable = true; SlotNoList[24].SlotNoExist = "Exist"; } break; case "All": for (int i = 0; i < SlotNoList.Count; i++) { SlotNoList[i].SlotNoEnable = true; SlotNoList[i].SlotNoExist = "Exist"; } break; case "None": for (int i = 0; i < SlotNoList.Count; i++) { SlotNoList[i].SlotNoEnable = false; SlotNoList[i].SlotNoExist = "None"; } break; } if (SlotNo == "All") { for (int i = 0; i < WaferItem.WaferManager.Wafers.Count; i++) { WaferItem.WaferManager.Wafers[i].WaferType = Aitex.Core.Common.WaferType.P; WaferItem.WaferManager.Wafers[i].WaferStatus = 1; this.GetType().GetProperty($"point{WaferItem.WaferManager.Wafers[i].SlotID}Count").SetValue(this, 1); } } else if (SlotNo == "None") { for (int i = 0; i < WaferItem.WaferManager.Wafers.Count; i++) { WaferItem.WaferManager.Wafers[i].WaferType = Aitex.Core.Common.WaferType.None; WaferItem.WaferManager.Wafers[i].WaferStatus = 0; this.GetType().GetProperty($"point{WaferItem.WaferManager.Wafers[i].SlotID}Count").SetValue(this, 0); } } else { int pointCount = (int)this.GetType().GetProperty($"point{SlotNo}Count").GetValue(this); if (pointCount % 2 == 0) { WaferItem.WaferManager.Wafers.Where(x => x.SlotIndex == int.Parse(SlotNo)).FirstOrDefault().WaferType = Aitex.Core.Common.WaferType.None; WaferItem.WaferManager.Wafers.Where(x => x.SlotIndex == int.Parse(SlotNo)).FirstOrDefault().WaferStatus = 0; } else { WaferItem.WaferManager.Wafers.Where(x => x.SlotIndex == int.Parse(SlotNo)).FirstOrDefault().WaferType = Aitex.Core.Common.WaferType.P; WaferItem.WaferManager.Wafers.Where(x => x.SlotIndex == int.Parse(SlotNo)).FirstOrDefault().WaferStatus = 1; } } SlotCount = SlotNoList.Where(s => s.SlotNoEnable == true).Count(); } } public class SlotItem : FurnaceModuleUIViewModelBase { private bool _SlotNoEnable; public bool SlotNoEnable { get => _SlotNoEnable; set { _SlotNoEnable = value; NotifyOfPropertyChange("SlotNoEnable"); } } private string _SlotNoExist; public string SlotNoExist { get => _SlotNoExist; set { _SlotNoExist = value; NotifyOfPropertyChange("SlotNoExist"); } } } }