using Aitex.Core.UI.MVVM; using Aitex.Sorter.Common; using MECF.Framework.Common.OperationCenter; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using MECF.Framework.Common.Equipment; namespace Aitex.Sorter.UI.Controls { /// /// LPStatus.xaml 的交互逻辑 /// public partial class LPStatus : UserControl { public bool Placed { get { return (bool)GetValue(PlacedProperty); } set { SetValue(PlacedProperty, value); } } // Using a DependencyProperty as the backing store for Placed. This enables animation, styling, binding, etc... public static readonly DependencyProperty PlacedProperty = DependencyProperty.Register("Placed", typeof(bool), typeof(LPStatus), new PropertyMetadata(false)); public bool Present { get { return (bool)GetValue(PresentProperty); } set { SetValue(PresentProperty, value); } } // Using a DependencyProperty as the backing store for Present. This enables animation, styling, binding, etc... public static readonly DependencyProperty PresentProperty = DependencyProperty.Register("Present", typeof(bool), typeof(LPStatus), new PropertyMetadata(false)); public ModuleName Station { get { return (ModuleName)GetValue(StationSetProperty); } set { SetValue(StationSetProperty, value); } } // Using a DependencyProperty as the backing store for UnitName. This enables animation, styling, binding, etc... public static readonly DependencyProperty StationSetProperty = DependencyProperty.Register("Station", typeof(ModuleName), typeof(LPStatus), new PropertyMetadata(ModuleName.System)); public string FoupID { get { return (string)GetValue(FoupIDProperty); } set { SetValue(FoupIDProperty, value); } } // Using a DependencyProperty as the backing store for FoupID. This enables animation, styling, binding, etc... public static readonly DependencyProperty FoupIDProperty = DependencyProperty.Register("FoupID", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public string RFReader { get { return (string)GetValue(RFReaderProperty); } set { SetValue(RFReaderProperty, value); } } // Using a DependencyProperty as the backing store for RFReader. This enables animation, styling, binding, etc... public static readonly DependencyProperty RFReaderProperty = DependencyProperty.Register("RFReader", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public string Status { get { return (string)GetValue(StatusProperty); } set { SetValue(StatusProperty, value); } } // Using a DependencyProperty as the backing store for Status. This enables animation, styling, binding, etc... public static readonly DependencyProperty StatusProperty = DependencyProperty.Register("Status", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public string CassetteState { get { return (string)GetValue(CassetteStateProperty); } set { SetValue(CassetteStateProperty, value); } } // Using a DependencyProperty as the backing store for CassetteState. This enables animation, styling, binding, etc... public static readonly DependencyProperty CassetteStateProperty = DependencyProperty.Register("CassetteState", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public string ClampStatus { get { return (string)GetValue(ClampStatusProperty); } set { SetValue(ClampStatusProperty, value); } } // Using a DependencyProperty as the backing store for ClampStatus. This enables animation, styling, binding, etc... public static readonly DependencyProperty ClampStatusProperty = DependencyProperty.Register("ClampStatus", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public string FoupDoorStatus { get { return (string)GetValue(FoupDoorStatusProperty); } set { SetValue(FoupDoorStatusProperty, value); } } // Using a DependencyProperty as the backing store for FoupDoorStatus. This enables animation, styling, binding, etc... public static readonly DependencyProperty FoupDoorStatusProperty = DependencyProperty.Register("FoupDoorStatus", typeof(string), typeof(LPStatus), new PropertyMetadata(null)); public bool LoadPortLoaded { get { return (bool)GetValue(LoadPortLoadedProperty); } set { SetValue(LoadPortLoadedProperty, value); } } // Using a DependencyProperty as the backing store for LoadPortLoaded. This enables animation, styling, binding, etc... public static readonly DependencyProperty LoadPortLoadedProperty = DependencyProperty.Register("LoadPortLoaded", typeof(bool), typeof(LPStatus), new PropertyMetadata(false)); public bool LoadPortUnloaded { get { return (bool)GetValue(LoadPortUnloadedProperty); } set { SetValue(LoadPortUnloadedProperty, value); } } // Using a DependencyProperty as the backing store for LoadPortUnloaded. This enables animation, styling, binding, etc... public static readonly DependencyProperty LoadPortUnloadedProperty = DependencyProperty.Register("LoadPortUnloaded", typeof(bool), typeof(LPStatus), new PropertyMetadata(false)); public bool IsAlarm { get { return (bool)GetValue(IsAlarmProperty); } set { SetValue(IsAlarmProperty, value); } } // Using a DependencyProperty as the backing store for IsAlarm. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsAlarmProperty = DependencyProperty.Register("IsAlarm", typeof(bool), typeof(LPStatus), new PropertyMetadata(false)); public int RoutManagerState { get { return (int)GetValue(RoutManagerStateProperty); } set { SetValue(RoutManagerStateProperty, value); } } // Using a DependencyProperty as the backing store for RoutManagerState. This enables animation, styling, binding, etc... public static readonly DependencyProperty RoutManagerStateProperty = DependencyProperty.Register("RoutManagerState", typeof(int), typeof(LPStatus), new PropertyMetadata((int)RtState.Init, StateChangedCallback)); public bool IsAutoMode { get { return (bool)GetValue(IsAutoModeProperty); } set { SetValue(IsAutoModeProperty, value); } } // Using a DependencyProperty as the backing store for IsAutoMode. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsAutoModeProperty = DependencyProperty.Register("IsAutoMode", typeof(bool), typeof(LPStatus), new PropertyMetadata(false, StateChangedCallback)); public bool IsManualMode { get { return (bool)GetValue(IsManualModeProperty); } set { SetValue(IsManualModeProperty, value); } } // Using a DependencyProperty as the backing store for IsAutoMode. This enables animation, styling, binding, etc... public static readonly DependencyProperty IsManualModeProperty = DependencyProperty.Register("IsManualMode", typeof(bool), typeof(LPStatus), new PropertyMetadata(false, StateChangedCallback)); public static void StateChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { var self = d as LPStatus; if (self.DeviceOperationCommand != null) { ((IDelegateCommand)self.DeviceOperationCommand).RaiseCanExecuteChanged(); } if (self.RFReaderCommand != null) { ((IDelegateCommand)self.RFReaderCommand).RaiseCanExecuteChanged(); } } public LPStatus() { InitializeComponent(); DeviceOperationCommand = new DelegateCommand(DeviceOperation, x => RoutManagerState != (int)RtState.Maintenance && !IsAutoMode); RFReaderCommand = new DelegateCommand(RFReaderOperation, x => RoutManagerState != (int)RtState.Maintenance && !IsAutoMode); root.DataContext = this; } public ICommand DeviceOperationCommand { get; private set; } public ICommand RFReaderCommand { get; private set; } void DeviceOperation(string cmd) { var deviceName = Station.ToString(); var param = new object[] { deviceName, cmd }; InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param); } void RFReaderOperation(string cmd) { var deviceName = RFReader; var param = new object[] { deviceName, cmd }; InvokeClient.Instance.Service.DoOperation(OperationName.DeviceOperation.ToString(), param); } } }