using Aitex.Core.Common; using Aitex.Core.UI.MVVM; using Aitex.Core.Utilities; using Aitex.Sorter.Common; using Aitex.Sorter.UI.ViewModel; using MECF.Framework.Common.Equipment; 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.Controls; using System.Windows.Input; namespace Aitex.Sorter.UI.Controls { public class TransferSelectionViewModel : FoupListViewModelBase { public ObservableCollection LoadPortList { get; set; } public TransferSelectionDialog MyTransferSelectionDialog { get; set; } public ICommand TransferCommand { get; set; } public ICommand OKCommand { get; set; } public ICommand CloseCommand { get; set; } public ICommand SelectionChangedCommand { get; set; } public ICommand QselectCommand { get; set; } public ICommand WaferTransferCommand { get; set; } public string TransferType { get; set; } public ObservableCollection TransferItems { get; set; } public void SetFoupCount(int foupCount) { LoadPortList = new ObservableCollection(); for (int i = 0; i < foupCount; i++) { LoadPortList.Add($"LP{ i + 1}"); } } public string OriginalSelectedValue { get; set; } public string DestinationSelectedValue { get; set; } public TransferSelectionViewModel() : base("TransferSelection", 8) { TransferCommand = new DelegateCommand(DoTransferCommand); OKCommand = new DelegateCommand(DoOKCommand); CloseCommand = new DelegateCommand(DoCloseCommand); SelectionChangedCommand = new DelegateCommand(DoSelectionChangedCommand); QselectCommand=new DelegateCommand(DoQselectCommand); WaferTransferCommand = new DelegateCommand(DoWaferTransferCommand); TransferItems = new ObservableCollection(); } private void DoWaferTransferCommand(object obj) { // TransferItems.Add(obj); } private void DoQselectCommand(object obj) { var placeMode = MyTransferSelectionDialog.CmbPlaceMode.Text; var cboOriginalTxt = MyTransferSelectionDialog.CboOriginal.Text; var cboDestination = MyTransferSelectionDialog.CboDestination.Text; if (placeMode != "") { switch (placeMode) { case "Opposite": foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots) { if (((WaferInfo)item).IsChecked) { var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem(); sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt); sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot; sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination); sorterRecipeTransferTableItem.DestinationSlot =24- ((WaferInfo)item).Slot; TransferItems.Add(sorterRecipeTransferTableItem); } } break; case "Same": foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots) { if (((WaferInfo)item).IsChecked) { var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem(); sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt); sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot; sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination); sorterRecipeTransferTableItem.DestinationSlot = ((WaferInfo)item).Slot; TransferItems.Add(sorterRecipeTransferTableItem); } } break; case "FromTop": int indexadd = 0; foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots) { if (((WaferInfo)item).IsChecked) { var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem(); sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt); sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot; sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination); sorterRecipeTransferTableItem.DestinationSlot = indexadd; TransferItems.Add(sorterRecipeTransferTableItem); indexadd++; } } break; case "FromButtom": int indexsub = 24; foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots) { if (((WaferInfo)item).IsChecked) { var sorterRecipeTransferTableItem = new SorterRecipeTransferTableItem(); sorterRecipeTransferTableItem.SourceStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboOriginalTxt); sorterRecipeTransferTableItem.SourceSlot = ((WaferInfo)item).Slot; sorterRecipeTransferTableItem.DestinationStation = (ModuleName)Enum.Parse(typeof(ModuleName), cboDestination); sorterRecipeTransferTableItem.DestinationSlot = indexsub; TransferItems.Add(sorterRecipeTransferTableItem); indexsub--; } } break; default: break; } } } private void DoSelectionChangedCommand(object obj) { ComboBox comboBox = (ComboBox)obj; if (comboBox.Name == "CboOriginal") { if (MyTransferSelectionDialog.OriginalFoupItem.Slots != null) { foreach (var item in MyTransferSelectionDialog.OriginalFoupItem.Slots) { ((WaferInfo)item).IsChecked = false; } } MyTransferSelectionDialog.OriginalFoupItem.Slots = FoupList[int.Parse(((string)comboBox.SelectedValue).Replace("LP", "")) - 1].WaferInfos; } if (((ComboBox)obj).Name == "CboDestination") { foreach (var item in MyTransferSelectionDialog.DestinationFoupItem.Slots) { ((WaferInfo)item).IsChecked = false; } MyTransferSelectionDialog.DestinationFoupItem.Slots = FoupList[int.Parse(((string)comboBox.SelectedValue).Replace("LP", "")) - 1].WaferInfos; } } private void DoCloseCommand(object obj) { MyTransferSelectionDialog.DialogResult = false; MyTransferSelectionDialog.Close(); } private void DoOKCommand(object obj) { MyTransferSelectionDialog.DialogResult = true; MyTransferSelectionDialog.Close(); } //直接执行函数 private void DoTransferCommand(string obj) { TransferType = obj; //switch (obj) //{ // case "Opposite": // break; // case "Same": // break; // case "FromTop": // break; // case "FromButtom": // break; // default: // break; //} } } }