using Aitex.Core.Common; using Aitex.Sorter.Common; using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; using MECF.Framework.Common.Equipment; namespace Aitex.Sorter.UI.Controls { /// /// Foup.xaml 的交互逻辑 /// public partial class Foup : UserControl { public Foup() { InitializeComponent(); root.DataContext = this; Slot.DataContext = this; } public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register( "Slots", typeof(IEnumerable), typeof(Foup), new FrameworkPropertyMetadata(null)); public IEnumerable Slots { get { return (IEnumerable)GetValue(SlotsProperty); } set { SetValue(SlotsProperty, value); } } public int SlotCount { get; set; } public CheckedItem[] SlotIndexes { get { var indexes = new CheckedItem[SlotCount]; for (int i = 0; i < SlotCount; i++) { indexes[i] = new CheckedItem { ItemIndex = SlotCount - i - 1 }; } return indexes; } } public ModuleName Station { get { return (ModuleName)GetValue(StationProperty); } set { SetValue(StationProperty, value); } } // Using a DependencyProperty as the backing store for Station. This enables animation, styling, binding, etc... public static readonly DependencyProperty StationProperty = DependencyProperty.Register("Station", typeof(ModuleName), typeof(Foup), new PropertyMetadata(ModuleName.System)); public string Title { get { return (string)GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } } // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc... public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(Foup), new PropertyMetadata(null)); public ICommand WaferTransferCommand { get { return (ICommand)GetValue(WaferTransferCommandProperty); } set { SetValue(WaferTransferCommandProperty, value); } } // Using a DependencyProperty as the backing store for WaferMovementCommand. This enables animation, styling, binding, etc... public static readonly DependencyProperty WaferTransferCommandProperty = DependencyProperty.Register("WaferTransferCommand", typeof(ICommand), typeof(Foup), new PropertyMetadata(null)); public SlotTransferInfo[] SlotTransferInfo { get { return (SlotTransferInfo[])GetValue(SlotTransferInfoProperty); } set { SetValue(SlotTransferInfoProperty, value); } } // Using a DependencyProperty as the backing store for SlotTransferInfo. This enables animation, styling, binding, etc... public static readonly DependencyProperty SlotTransferInfoProperty = DependencyProperty.Register("SlotTransferInfo", typeof(SlotTransferInfo[]), typeof(Foup), new PropertyMetadata(null)); public ICommand WaferTransferOptionCommand { get { return (ICommand)GetValue(WaferTransferOptionCommandProperty); } set { SetValue(WaferTransferOptionCommandProperty, value); } } // Using a DependencyProperty as the backing store for WaferTransferOptionCommand. This enables animation, styling, binding, etc... public static readonly DependencyProperty WaferTransferOptionCommandProperty = DependencyProperty.Register("WaferTransferOptionCommand", typeof(ICommand), typeof(Foup), new PropertyMetadata(null)); } public class CheckedItem : INotifyPropertyChanged { private int itemIndex; private bool isChecked; public int ItemIndex { get { return itemIndex; } set { itemIndex = value; Notify("ItemIndex"); } } public bool IsChecked { get { return isChecked; } set { isChecked = value; Notify("IsChecked"); } } private void Notify(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } public event PropertyChangedEventHandler PropertyChanged; } public class TransferInfoConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var slot = (int)values[0]; var slotTransferInfos = (SlotTransferInfo[])values[1]; if (slotTransferInfos != null) { return slotTransferInfos[slot]; } return null; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }