using OpenSEMI.ClientBase; using System; using System.Windows; using System.Windows.Controls; using System.Windows.Media.Animation; namespace PunkHPX8_Themes.CustomControls { public class PunkRobotControl : Control { static PunkRobotControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(PunkRobotControl), new FrameworkPropertyMetadata(typeof(PunkRobotControl))); } public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(PunkRobotControl)); public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); } public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(PunkRobotControl), new PropertyMetadata(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9)))); public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); } public static readonly DependencyProperty Robot2WaferProperty = DependencyProperty.Register( "Robot2Wafer", typeof(WaferInfo), typeof(PunkRobotControl)); public WaferInfo Robot2Wafer { get => (WaferInfo)GetValue(Robot2WaferProperty); set => SetValue(Robot2WaferProperty, value); } public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register( "RobotWafer", typeof(WaferInfo), typeof(PunkRobotControl)); public WaferInfo RobotWafer { get => (WaferInfo)GetValue(RobotWaferProperty); set => SetValue(RobotWaferProperty, value); } public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register( "RobotXAction", typeof(WaferRobotXAction), typeof(PunkRobotControl), new PropertyMetadata(WaferRobotXAction.X_Origin, RobotXActionPropertyChangedCallback)); public WaferRobotXAction RobotXAction { get => (WaferRobotXAction)GetValue(RobotXActionProperty); set => SetValue(RobotXActionProperty, value); } private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9)); var control = d as PunkRobotControl; var oldAct = (WaferRobotXAction)e.OldValue; var newAct = (WaferRobotXAction)e.NewValue; switch (newAct) { case WaferRobotXAction.X_Origin: VisualStateManager.GoToState(control, newAct.ToString(), true); break; case WaferRobotXAction.Extend: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; case WaferRobotXAction.Extend2: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; case WaferRobotXAction.Retract2: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; case WaferRobotXAction.Retract: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; default: break; } } public static readonly DependencyProperty RobotFActionProperty = DependencyProperty.Register( "RobotFAction", typeof(WaferRobotFAction), typeof(PunkRobotControl), new PropertyMetadata(WaferRobotFAction.None, RobotFActionPropertyChangedCallback)); public WaferRobotFAction RobotFAction { get => (WaferRobotFAction)GetValue(RobotFActionProperty); set => SetValue(RobotFActionProperty, value); } private static void RobotFActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { //KeyTime value = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9)); var control = d as PunkRobotControl; var oldAct = (WaferRobotFAction)e.OldValue; var newAct = (WaferRobotFAction)e.NewValue; switch (newAct) { case WaferRobotFAction.UpperToDown: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; case WaferRobotFAction.DownToUpper: if (newAct != oldAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } break; default: break; } } public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register( "RobotTAction", typeof(WaferRobotTAction), typeof(PunkRobotControl), new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback)); public WaferRobotTAction RobotTAction { get => (WaferRobotTAction)GetValue(RobotTActionProperty); set => SetValue(RobotTActionProperty, value); } private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as PunkRobotControl; var oldAct = (WaferRobotTAction)e.OldValue; var newAct = (WaferRobotTAction)e.NewValue; if (oldAct != newAct) { VisualStateManager.GoToState(control, newAct.ToString(), true); } } public string OriginT { get; set; } public override void OnApplyTemplate() { base.OnApplyTemplate(); VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true); VisualStateManager.GoToState(this, WaferRobotTAction.T_Origin.ToString(), true); VisualStateManager.GoToState(this, WaferRobotFAction.DownToUpper.ToString(), true); } } }