| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 | 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);        }    }}
 |