| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Aitex.Core.Equipment.SusceptorDefine;using Aitex.Core.Util;namespace Aitex.Core.UI.Control{    /// <summary>    /// Interaction logic for SusceptorControl.xaml    /// </summary>    public partial class SusceptorControl : UserControl    {        public WaferType DefaultWaferType { get; set; }        Susceptor _susceptorInfo;        bool _isShining = false;        public SusceptorControl()        {            InitializeComponent();        }        public static readonly DependencyProperty SusceptorInfoProperty = DependencyProperty.Register(            "SusceptorInfo", typeof(Susceptor), typeof(SusceptorControl),            new FrameworkPropertyMetadata(new Susceptor(), FrameworkPropertyMetadataOptions.AffectsRender));        public Susceptor SusceptorInfo        {            get            {                return (Susceptor)GetValue(SusceptorInfoProperty);            }            set            {                SetValue(SusceptorInfoProperty, value);            }        }        public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(            "IsActive", typeof(bool), typeof(SusceptorControl),            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        public bool IsActive        {            get            {                return (bool)GetValue(IsActiveProperty);            }            set            {                SetValue(IsActiveProperty, value);            }        }        public static readonly DependencyProperty IsReadonlyProperty = DependencyProperty.Register(            "IsReadonly", typeof(Boolean), typeof(SusceptorControl),            new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));        public bool IsReadonly        {            get            {                return (bool)GetValue(IsReadonlyProperty);            }            set            {                SetValue(IsReadonlyProperty, value);            }        }        public void StartShining(SolidColorBrush brush, bool isShining)        {            if (layout.Children != null && layout.Children.Count > 0)            {                ((Ellipse)layout.Children[0]).Fill = brush;            }            _isShining = isShining;        }        public void UpdateWaferType(WaferType waferType)        {            for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)            {                if (SusceptorInfo.WaferTypeArray[i] != WaferType.Empty)                    SusceptorInfo.WaferTypeArray[i] = waferType;            }            for (int i = 1; i < layout.Children.Count; i++)            {                SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;                control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];                control.Update();            }            DefaultWaferType = waferType;        }        public void SetAllHasWafer()        {            for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i<SusceptorInfo.Config.Notches.Count; i++)            {                    SusceptorInfo.WaferTypeArray[i] = DefaultWaferType;            }            for (int i = 1; i < layout.Children.Count; i++)            {                SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;                control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];                control.Update();            }        }        public void SetAllNoWafer()        {            for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)            {                SusceptorInfo.WaferTypeArray[i] = WaferType.Empty;            }            for (int i = 1; i < layout.Children.Count; i++)            {                SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;                control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];                control.Update();            }        }        public void RevertWaferType()        {            for (int i = 0; i < SusceptorInfo.WaferTypeArray.Length && i < SusceptorInfo.Config.Notches.Count; i++)            {                SusceptorInfo.WaferTypeArray[i] = SusceptorInfo.WaferTypeArray[i] == WaferType.Empty ? DefaultWaferType : WaferType.Empty;            }            for (int i = 1; i < layout.Children.Count; i++)            {                SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;                control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];                control.Update();            }        }        protected override void OnRender(DrawingContext drawingContext)        {            if (SusceptorInfo == null || SusceptorInfo.Id.Equals(Guid.Empty) || SusceptorInfo.Config == null)            {                layout.Children.Clear();                _susceptorInfo = null;            }            else            {                if (_susceptorInfo == null || _susceptorInfo.Type != SusceptorInfo.Type)                {                    layout.Children.Clear();                    DrawContour();                    DrawNotchControls();                    _susceptorInfo = SusceptorInfo;                }                Update();                layout.Width = _susceptorInfo.Config.Diameter;                layout.Height = _susceptorInfo.Config.Diameter;            }            if (!IsReadonly)            {                for (int i = 1; i < layout.Children.Count; i++)                {                    (layout.Children[i] as SusceptorNotchControl).IsReadonly = false;                }            }        }        void Update()        {            for (int i = 1; i < layout.Children.Count; i++)            {                SusceptorNotchControl control = layout.Children[i] as SusceptorNotchControl;                control.CurrentWaferType = SusceptorInfo.WaferTypeArray[control.Index-1];                control.CurrentSusceptorStatus = SusceptorInfo.Status;                control.Update();            }            if (!_isShining && layout.Children.Count > 0 && layout.Children[0].GetType() == typeof(Ellipse))            {                Ellipse ellipse = layout.Children[0] as Ellipse;                ellipse.Fill = (SusceptorInfo == null || SusceptorInfo.Status <= SusceptorStatus.Unprocessed) ? SusceptorBrush.BackgroundBrush : SusceptorBrush.GetBrush(SusceptorInfo.Status);            }        }        void DrawContour()        {            Ellipse contourEllipse = new Ellipse()            {                Fill = (SusceptorInfo == null || SusceptorInfo.Status <= SusceptorStatus.Unprocessed) ? SusceptorBrush.BackgroundBrush : SusceptorBrush.GetBrush(SusceptorInfo.Status),                Stroke = SusceptorBrush.StrokeBrush,                Width = SusceptorInfo.Config.Diameter,                Height = SusceptorInfo.Config.Diameter,                Opacity = 1,            };            layout.Children.Add(contourEllipse);        }        void DrawNotchControls()        {            double diameter = SusceptorInfo.Config.NotchDiameter;            foreach (var notch in SusceptorInfo.Config.Notches)            {                double x = notch.X;                double y = notch.Y;                SusceptorNotchControl container = new SusceptorNotchControl()                {                    Width = diameter,                    Height = diameter,                    Index = notch.Index,                    DisplayIndex = notch.DisplayIndex,                    IsActive = IsActive,                    IsReadonly = IsReadonly,                    MouseDownCallback = (nc, isShiftDown) =>                    {                        if (nc.CurrentWaferType == WaferType.Empty)                        {                            nc.CurrentWaferType = DefaultWaferType;                            if (isShiftDown)                                nc.CurrentWaferStatus = WaferStatus.Dummy;                            SusceptorInfo.WaferTypeArray[nc.Index-1] = DefaultWaferType;                        }                        else                        {                            nc.CurrentWaferType = WaferType.Empty;                            nc.CurrentWaferStatus = WaferStatus.Normal;                            SusceptorInfo.WaferTypeArray[nc.Index-1] = WaferType.Empty;                        }                    },                };                container.SetValue(Canvas.LeftProperty, y + SusceptorInfo.Config.Diameter / 2 - SusceptorInfo.Config.NotchDiameter / 2);                container.SetValue(Canvas.TopProperty, x + SusceptorInfo.Config.Diameter / 2 - SusceptorInfo.Config.NotchDiameter / 2);                layout.Children.Add(container);            }        }    }}
 |