| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 | using Aitex.Sorter.Common;using Aitex.Sorter.UI.Controls;using MECF.Framework.Common.Equipment;using System;using System.Collections;using System.Globalization;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Input;namespace EfemUI.Controls{    /// <summary>    /// Foup6.xaml 的交互逻辑    /// </summary>    public partial class FoupItem : UserControl    {        public FoupItem()        {            InitializeComponent();            root.DataContext = this;            Slot.DataContext = this;        }        public bool IsSlotShowOpposite        {            get { return (bool)GetValue(IsSlotShowOppositeProperty); }            set { SetValue(IsSlotShowOppositeProperty, value); }        }        // Using a DependencyProperty as the backing store for IsSlotShowOpposite.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty IsSlotShowOppositeProperty =            DependencyProperty.Register("IsSlotShowOpposite", typeof(bool), typeof(FoupItem), new PropertyMetadata(false));        public bool IsEnableTextMenu        {            get { return (bool)GetValue(IsEnableTextMenuProperty); }            set { SetValue(IsEnableTextMenuProperty, value); }        }        // Using a DependencyProperty as the backing store for IsEnableTextMenu.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty IsEnableTextMenuProperty =            DependencyProperty.Register("IsEnableTextMenu", typeof(bool), typeof(FoupItem), new PropertyMetadata(true));        public static readonly DependencyProperty SlotsProperty = DependencyProperty.Register(        "Slots", typeof(IEnumerable), typeof(FoupItem),        new FrameworkPropertyMetadata(null));        public Visibility ShowSlotsIndex        {            get { return (Visibility)GetValue(ShowSlotsIndexProperty); }            set { SetValue(ShowSlotsIndexProperty, value); }        }        public static readonly DependencyProperty ShowSlotsIndexProperty =            DependencyProperty.Register("ShowSlotsIndex", typeof(Visibility), typeof(FoupItem), new PropertyMetadata(Visibility.Collapsed));        public int FoupCount        {            get { return (int)GetValue(FoupCountProperty); }            set { SetValue(FoupCountProperty, value); }        }        public static readonly DependencyProperty FoupCountProperty =            DependencyProperty.Register("FoupCount", typeof(int), typeof(FoupItem), new PropertyMetadata(8));        public bool ShowControl        {            get { return (bool)GetValue(ShowControlProperty); }            set            {                SetValue(ShowControlProperty, value);            }        }        public static readonly DependencyProperty ShowControlProperty =            DependencyProperty.Register("ShowControl", typeof(bool), typeof(FoupItem), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None));        public IEnumerable Slots        {            get            {                return (IEnumerable)GetValue(SlotsProperty);            }            set            {                SetValue(SlotsProperty, value);            }        }        public int SlotCount        {            get { return (int)GetValue(SlotCountProperty); }            set { SetValue(SlotCountProperty, value); }        }        // Using a DependencyProperty as the backing store for SlotCount.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty SlotCountProperty =            DependencyProperty.Register("SlotCount", typeof(int), typeof(FoupItem), new PropertyMetadata(25));        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(FoupItem), 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(FoupItem), 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(FoupItem), 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(FoupItem), new PropertyMetadata(null));        public LoadPortCarrierMode CarrierMode        {            get { return (LoadPortCarrierMode)GetValue(CarrierModeProperty); }            set { SetValue(CarrierModeProperty, value); }        }        // Using a DependencyProperty as the backing store for CarrierMode.  This enables animation, styling, binding, etc...        public static readonly DependencyProperty CarrierModeProperty =            DependencyProperty.Register("CarrierMode", typeof(LoadPortCarrierMode), typeof(FoupItem), new PropertyMetadata(LoadPortCarrierMode.Both));        public bool FristChick { get; set; } = true;        private WaferPro fristwafer;        private WaferPro endwafer;        private void lbItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)        {            //if (Keyboard.IsKeyDown(Key.LeftCtrl))            //{            var obj = (WaferPro)sender;            if (obj.WaferItem.Status != Aitex.Core.Common.WaferStatus.Empty)            {                obj.WaferItem.IsChecked = !obj.WaferItem.IsChecked;            }            // }            //if (Keyboard.IsKeyDown(Key.LeftShift))            //{            //    if (FristChick)            //    {            //        FristChick = false;            //        fristwafer = (WaferPro)sender;            //        fristwafer.WaferItem.IsChecked = true;            //    }            //    else            //    {            //        FristChick = true;            //        endwafer = (WaferPro)sender;            //        var fristSlot = fristwafer.WaferItem.Slot < endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;            //        var endSlot = fristwafer.WaferItem.Slot > endwafer.WaferItem.Slot ? fristwafer.WaferItem.Slot : endwafer.WaferItem.Slot;            //        for (int i = fristSlot; i < endSlot + 1; i++)            //        {            //            if (((WaferInfo)this.Slot.Items[24 - i]).Status != Aitex.Core.Common.WaferStatus.Empty)            //            {            //                ((WaferInfo)this.Slot.Items[24 - i]).IsChecked = true;            //            }            //        }            //    }            //}            //if (!(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))            //{            //    foreach (var item in this.Slot.Items)            //    {            //        ((WaferInfo)item).IsChecked = false;            //    }            //}        }        private void lbItem_PreviewMouseMove(object sender, MouseEventArgs e)        {            //if (e.LeftButton == MouseButtonState.Pressed && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)))            //{            //    var data = new DataObject();            //    data.SetData("Station", Station);            //    data.SetData("Slots", Slots);            //    DragDrop.DoDragDrop(sender as DependencyObject,            //                 data,            //                 DragDropEffects.Copy | DragDropEffects.Move);            //    FristChick = true;            //}        }        private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)        {            int keyValue = KeyInterop.VirtualKeyFromKey(e.Key);        }        private void Slot_Drop(object sender, DragEventArgs e)        {            //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))            //{            //    var dialog = new TransferSelectionDialog();            //    dialog.DestinationStation = ((WaferPro)e.Source).Station;            //    dialog.DestinationName = ((WaferPro)e.Source).Name;            //    dialog.FoupCount = FoupCount;            //    var sourceStation = (ModuleName)e.Data.GetData("Station");            //    var sourceSlots = (IEnumerable)e.Data.GetData("Slots");            //    List<WaferInfo> DestinationWaferInfos = new List<WaferInfo>();            //    dialog.OriginalFoupItem.Slots = sourceSlots;            //    dialog.DestinationFoupItem.Slots = this.Slots;            //    dialog.Closing += Dialog_Closing;            //    FristChick = true;            // //   dialog.Show();            //    dialog.TransferSelectionViewModel.OriginalSelectedValue = sourceStation.ToString();            //    dialog.TransferSelectionViewModel.DestinationSelectedValue = ((WaferPro)e.Source).Station.ToString();            //    ////对话框关闭后下指令            //    if (dialog.ShowDialog() == true)            //    {            //        //下命令            //    }            //}        }        private void Dialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)        {            //var dialog = (TransferSelectionDialog)sender;            //foreach (var item in dialog.OriginalFoupItem.Slots)            //{            //    ((WaferInfo)item).IsChecked = false;            //}            //foreach (var item in dialog.DestinationFoupItem.Slots)            //{            //    ((WaferInfo)item).IsChecked = false;            //}        }    }    /// <summary>    /// SlotItemIndexConverter    /// </summary>    public class SlotItemIndexConverter : IMultiValueConverter    {        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)        {            var index = (int)values[0];            var count = (int)values[1];            var isShowOpposite = (bool)values[2];            return isShowOpposite ? index : count - index - 1;        }        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }    /// <summary>    /// SlotItemIndexConverter2    /// </summary>    public class SlotItemIndexConverter2 : IMultiValueConverter    {        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)        {            var index = (int)values[0];            var count = (int)values[1];            var isShowOpposite = (bool)values[2];            return isShowOpposite ? (index + 1).ToString("D2") : (count - index).ToString("D2");        }        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }    /// <summary>    /// ShowSlotItemIndexConverter (bool)    /// </summary>    public class ShowSlotItemIndexConverter : IMultiValueConverter    {        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)        {            var index = (int)values[0];            var count = (int)values[1];            return index < count ? true : false;        }        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }    /// <summary>    /// SlotItemVisibilityConverter (Visibility)    /// </summary>    public class SlotItemVisibilityConverter : IMultiValueConverter    {        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)        {            var index = (int)values[0];            var count = (int)values[1];            return (25 - index - 1) < count ? Visibility.Visible : Visibility.Hidden;        }        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }}
 |