123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- using OpenSEMI.ClientBase;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media.Animation;
- namespace Venus_Themes.CustomControls
- {
- public class DERobot: Control
- {
- public enum DERobotXAction
- {
- X_Origin,
- Extend,
- ToVCE,
- FromVCE,
- Retract,
- X_Origin2,
- Extend2,
- ToVCE2,
- FromVCE2,
- Retract2
- }
- public enum DERobotTAction
- {
- T_Origin,
- PMA,
- PMB,
- PMC,
- PMD,
- VCEA,
- VCEB,
- Aligner1
- }
- static DERobot()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(DERobot), new FrameworkPropertyMetadata(typeof(DERobot)));
- }
- //注册Wafer、ExtendTime、RobotWafer、RobotXAction属性
- public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(DERobot));
- public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }
- public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(DERobot), new PropertyMetadata(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(9))));
- public KeyTime ExtendTime { get => (KeyTime)GetValue(ExtendTimeProperty); set => SetValue(ExtendTimeProperty, value); }
- public static readonly DependencyProperty RobotWaferProperty = DependencyProperty.Register(
- "RobotWafer",
- typeof(WaferInfo),
- typeof(DERobot));
- public WaferInfo RobotWafer
- {
- get => (WaferInfo)GetValue(RobotWaferProperty);
- set => SetValue(RobotWaferProperty, value);
- }
- public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(
- "RobotXAction",
- typeof(DERobotXAction),
- typeof(DERobot),
- new PropertyMetadata(DERobotXAction.X_Origin, RobotXActionPropertyChangedCallback));
- public DERobotXAction RobotXAction
- {
- get => (DERobotXAction)GetValue(RobotXActionProperty);
- set => SetValue(RobotXActionProperty, value);
- }
- //RobotXAction依赖属性的值被改变之后此委托会被调用
- private static void RobotXActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var control = d as DERobot;
- var oldAct = (DERobotXAction)e.OldValue; //现在的位置
- var newAct = (DERobotXAction)e.NewValue; //下一个位置
- switch (newAct)
- {
- case DERobotXAction.X_Origin:
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- break;
- case DERobotXAction.Extend:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.Retract:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.ToVCE:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.FromVCE:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.X_Origin2:
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- break;
- case DERobotXAction.Extend2:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.Retract2:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.ToVCE2:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- case DERobotXAction.FromVCE2:
- if (newAct != oldAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);
- }
- break;
- default:
- break;
- }
- }
- public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register(
- "RobotTAction",
- typeof(DERobotTAction),
- typeof(DERobot),
- new PropertyMetadata(DERobotTAction.T_Origin, RobotTActionPropertyChangedCallback));
- public DERobotTAction RobotTAction
- {
- get => (DERobotTAction)GetValue(RobotTActionProperty);
- set => SetValue(RobotTActionProperty, value);
- }
- public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(
- "RobotSpeed",
- typeof(double),
- typeof(DERobot),
- new PropertyMetadata(9.0d, RobotSpeedPropertyChangedCallback));
- public double RobotSpeed
- {
- get => (double)GetValue(RobotSpeedProperty);
- set => SetValue(RobotSpeedProperty, value);
- }
- private static void RobotSpeedPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- }
- public string OriginX { get; set; }
- public string OriginT { get; set; }
- private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- var control = d as DERobot;
- var oldAct = (DERobotTAction)e.OldValue;
- var newAct = (DERobotTAction)e.NewValue;
- //while (newAct.ToString() == "Aligner1" && !control.PMDIsInstalled)
- //{
- // newAct = DERobotTAction.VPARight;
- //}
- if (oldAct != newAct)
- {
- VisualStateManager.GoToState(control, newAct.ToString(), true);//前后动作不一致,改变控件状态
- }
- }
- public override void OnApplyTemplate()
- {
- base.OnApplyTemplate();
- VisualStateManager.GoToState(this, OriginX, true);
- //VisualStateManager.GoToState(this, DERobotXAction.X_Origin.ToString(), true);
- VisualStateManager.GoToState(this, OriginT, true);
- }
- }
- }
|