| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 | using OpenSEMI.ClientBase;using System;using System.Collections.Generic;using System.Globalization;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Media;using System.Windows.Media.Animation;namespace PunkHPX8_Themes.CustomControls{    public class WaferIntToColorConverter : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)        {            return int.Parse(value.ToString()) == 1 ? new SolidColorBrush(Colors.Red) : new SolidColorBrush(Colors.Green);        }        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }    public class WaferIntToVisibilityConverter : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)        {            return int.Parse(value.ToString()) == 1 ? Visibility.Visible : Visibility.Hidden;        }        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)        {            throw new NotImplementedException();        }    }    public enum WaferRobotXAction    {        X_Origin,        Extend,        Retract,        Extend2,        Retract2    }    public enum WaferRobotTAction    {        T_Origin,        PMA,        PMB,        PMC,             PMD,        LLA,        LLB,        LP1,        LP2,         LP3,        Aligner1,        RightLocation,        LeftLocation,        PUF1,        PUF2,        Dummy1,        Dummy2,        SRD1,        SRD2    }    public class WaferRobotControl : Control    {        static WaferRobotControl()        {            DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferRobotControl), new FrameworkPropertyMetadata(typeof(WaferRobotControl)));        }        public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(WaferRobotControl));        public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }        public static readonly DependencyProperty ExtendTimeProperty = DependencyProperty.Register("ExtendTime", typeof(KeyTime), typeof(WaferRobotControl),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(WaferRobotControl));        public WaferInfo RobotWafer        {            get => (WaferInfo)GetValue(RobotWaferProperty);            set => SetValue(RobotWaferProperty, value);        }        public static readonly DependencyProperty RobotXActionProperty = DependencyProperty.Register(            "RobotXAction",            typeof(WaferRobotXAction),            typeof(WaferRobotControl),            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 WaferRobotControl;            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 RobotTActionProperty = DependencyProperty.Register(            "RobotTAction",            typeof(WaferRobotTAction),            typeof(WaferRobotControl),            new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));        public WaferRobotTAction RobotTAction        {            get => (WaferRobotTAction)GetValue(RobotTActionProperty);            set => SetValue(RobotTActionProperty, value);        }        public static readonly DependencyProperty RobotSpeedProperty = DependencyProperty.Register(           "RobotSpeed",           typeof(double),           typeof(WaferRobotControl),            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 OriginT { get; set; }        private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)        {            var control = d as WaferRobotControl;            var oldAct = (WaferRobotTAction)e.OldValue;            var newAct = (WaferRobotTAction)e.NewValue;            if(oldAct!=newAct)            {                VisualStateManager.GoToState(control, newAct.ToString(), true);            }        }        public override void OnApplyTemplate()        {            base.OnApplyTemplate();            VisualStateManager.GoToState(this, WaferRobotXAction.X_Origin.ToString(), true);            VisualStateManager.GoToState(this, OriginT, true);        }            }}
 |