using Aitex.Core.Common; using Aitex.Core.RT.SCCore; using Aitex.Core.UI.MVVM; using Aitex.Sorter.Common; using MECF.Framework.Common.OperationCenter; using System; using System.ComponentModel; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using MECF.Framework.Common.Equipment; namespace Aitex.Sorter.UI.Controls { /// /// Wafer.xaml 的交互逻辑 /// public partial class WaferPro : UserControl { public bool IsEnableTextMenu1 { get { return (bool)GetValue(IsEnableTextMenu1Property); } set { SetValue(IsEnableTextMenu1Property, value); } } // Using a DependencyProperty as the backing store for IsEnableTextMenu. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsEnableTextMenu1Property = DependencyProperty.Register("IsEnableTextMenu1", typeof(bool), typeof(WaferPro), new PropertyMetadata(true)); public static readonly DependencyProperty WaferItemProperty = DependencyProperty.Register( "WaferItem", typeof(WaferInfo), typeof(WaferPro), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender)); public WaferInfo WaferItem { get { return (WaferInfo)GetValue(WaferItemProperty); } set { SetValue(WaferItemProperty, value); } } public int Slot { get { return (int)GetValue(SlotProperty); } set { SetValue(SlotProperty, value); } } // Using a DependencyProperty as the backing store for Slot. This enables animation, styling, binding, etc... public static readonly DependencyProperty SlotProperty = DependencyProperty.Register("Slot", typeof(int), typeof(WaferPro), new PropertyMetadata(-1)); 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(WaferPro), new PropertyMetadata(ModuleName.System)); public ICommand WaferTransferCommand { get { return (ICommand)GetValue(WaferTransferCommandProperty); } set { SetValue(WaferTransferCommandProperty, value); } } public bool ShowSlot { get { return (bool)GetValue(ShowSlotProperty); } set { SetValue(ShowSlotProperty, value); } } // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc... public static readonly DependencyProperty ShowSlotProperty = DependencyProperty.Register("ShowSlot", typeof(bool), typeof(WaferPro), new PropertyMetadata(false)); public bool ShowControl { get { return (bool)GetValue(ShowControlProperty); } set { SetValue(ShowControlProperty, value); } } public static readonly DependencyProperty ShowControlProperty = DependencyProperty.Register("ShowControl", typeof(bool), typeof(WaferPro), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.None)); public Visibility ShowSlotIndex { get { return (Visibility)GetValue(ShowSlotIndexProperty); } set { SetValue(ShowSlotIndexProperty, value); } } // Using a DependencyProperty as the backing store for ShowSlot. This enables animation, styling, binding, etc... public static readonly DependencyProperty ShowSlotIndexProperty = DependencyProperty.Register("ShowSlotIndex", typeof(Visibility), typeof(WaferPro), new PropertyMetadata(Visibility.Hidden)); // 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(WaferPro), new PropertyMetadata(null)); public WaferDisplayMode WaferIDDisplayMode { get { return (WaferDisplayMode)GetValue(WaferDisplayModeProperty); } set { SetValue(WaferDisplayModeProperty, value); } } // Using a DependencyProperty as the backing store for WaferIDDisplayMode. This enables animation, styling, binding, etc... public static readonly DependencyProperty WaferDisplayModeProperty = DependencyProperty.Register("WaferIDDisplayMode", typeof(WaferDisplayMode), typeof(WaferPro), new PropertyMetadata(WaferDisplayMode.None)); 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(WaferPro), new PropertyMetadata(null)); public ICommand CreateDeleteWaferCommand { get { return (ICommand)GetValue(CreateDeleteWaferCommandProperty); } set { SetValue(CreateDeleteWaferCommandProperty, value); } } // Using a DependencyProperty as the backing store for CreateDeleteWaferCommand. This enables animation, styling, binding, etc... public static readonly DependencyProperty CreateDeleteWaferCommandProperty = DependencyProperty.Register("CreateDeleteWaferCommand", typeof(ICommand), typeof(WaferPro), new PropertyMetadata(null)); private WaferStyle waferStyle = WaferStyle.Rect; public WaferStyle WaferStyle { get { return waferStyle; } set { waferStyle = value; } } public WaferPro() { InitializeComponent(); CreateDeleteWaferCommand = new DelegateCommand(CreateDeleteWafer); root.DataContext = this; } private void PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { e.Handled = IsEnableTextMenu1 ? false : true; } private void Wafer_MouseMove(object sender, MouseEventArgs e) { if (WaferItem == null || !ShowSlot) { return; } //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)) //{ return; } if (e.LeftButton == MouseButtonState.Pressed && (WaferItem.Status == WaferStatus.Normal || WaferItem.Status == WaferStatus.Dummy) && !WaferItem.IsSource) { var data = new DataObject(); data.SetData("Object", WaferItem); data.SetData("Station", Station); data.SetData("Slot", Slot); DragDrop.DoDragDrop(sender as DependencyObject, data, DragDropEffects.Copy | DragDropEffects.Move); } } private void Wafer_Drop(object sender, DragEventArgs e) { //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)) //{ return; } if (sender != null) { var target = (Border)sender; target.BorderThickness = new Thickness(0); if (target.ToolTip as ToolTip != null) ((ToolTip)target.ToolTip).IsOpen = false; var sourceWafer = (WaferInfo)e.Data.GetData("Object"); var sourceStation = (ModuleName)e.Data.GetData("Station"); var sourceSlot = (int)e.Data.GetData("Slot"); if (sourceWafer == null) { return; } if (sourceStation == ModuleName.Robot && Station == ModuleName.Robot) { return; } WaferTransferOption transferOption = null; if (WaferTransferOptionCommand != null) { transferOption = new WaferTransferOption(); WaferTransferOptionCommand.Execute(transferOption); } //if (sourceWafer.SubstE90Status == EnumE90Status.InProcess || sourceWafer.SubstE90Status== EnumE90Status.NeedProcessing) //{ // return; //} var dialog = new WaferTransferDialog(sourceWafer, sourceStation, sourceSlot, Station, Slot, transferOption); //dialog.SetControlShow(ShowControl); dialog.Owner = Window.GetWindow(this); if (dialog.ShowDialog() == true) { if (sourceWafer.Status == WaferStatus.Empty) { if (WaferTransferCommand != null) { WaferTransferCommand.Execute(new SorterRecipeTransferTableItem { SourceStation = sourceStation, SourceSlot = sourceSlot, DestinationStation = Station, DestinationSlot = Slot, IsAlign = dialog.Aligner, IsTurnOver = dialog.TurnOver, IsReadLaserMarker = dialog.ReadLaserMarker, IsReadT7Code = dialog.ReadT7Code, AlignAngle = dialog.AlignerAngle }); } } else { if (WaferTransferCommand != null) { WaferTransferCommand.Execute(new SorterRecipeTransferTableItem { SourceStation = sourceStation, SourceSlot = sourceSlot, DestinationStation = Station, DestinationSlot = Slot, IsAlign = dialog.Aligner, IsTurnOver = dialog.TurnOver, IsReadLaserMarker = dialog.ReadLaserMarker, IsReadT7Code = dialog.ReadT7Code, AlignAngle = dialog.AlignerAngle }); } else { var moveType = MoveType.Move; MoveOption moveOption = 0; if (dialog.Aligner) { moveOption |= MoveOption.Align; } if (dialog.TurnOver) { moveOption |= MoveOption.Turnover; } if (dialog.ReadLaserMarker) { moveOption |= MoveOption.ReadID; } if (dialog.ReadT7Code) { moveOption |= MoveOption.ReadID2; } var hand = (Hand)dialog.Blade; object[] param; if (hand == Hand.Both) { param = new object[] { moveType, moveOption, hand, sourceStation, sourceSlot, Station, Slot }; InvokeClient.Instance.Service.DoOperation(OperationName.MultiMoveWafer, param); } else { param = new object[] { moveType, moveOption, hand, sourceStation, sourceSlot, Station, Slot }; InvokeClient.Instance.Service.DoOperation(OperationName.MoveWafer.ToString(), param); } } } } } } private void CreateDeleteWafer(string cmd) { var param = new object[] { Station, Slot, WaferStatus.Normal }; InvokeClient.Instance.Service.DoOperation(cmd, param); } private void Border_DragOver(object sender, DragEventArgs e) { //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)) //{ return; } var sourceWafer = (WaferInfo)e.Data.GetData("Object"); var sourceStation = (ModuleName)e.Data.GetData("Station"); var sourceSlot = (int)e.Data.GetData("Slot"); if (!(sourceStation == Station && sourceSlot == Slot)) { var target = (Border)sender; target.BorderThickness = new Thickness(1); ((ToolTip)target.ToolTip).Content = Slot + 1; ((ToolTip)target.ToolTip).IsOpen = true; } } private void Border_DragLeave(object sender, DragEventArgs e) { //if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift)) //{ return; } var sourceWafer = (WaferInfo)e.Data.GetData("Object"); var sourceStation = (ModuleName)e.Data.GetData("Station"); var sourceSlot = (int)e.Data.GetData("Slot"); if (!(sourceStation == Station && sourceSlot == Slot)) { var target = (Border)sender; target.BorderThickness = new Thickness(0); ((ToolTip)target.ToolTip).IsOpen = false; } } } }