123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 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;
- namespace Aitex.Core.UI.Control
- {
- /// <summary>
- /// Interaction logic for SusceptorNotchControl.xaml
- /// </summary>
- public partial class SusceptorNotchControl : UserControl
- {
- public Action<SusceptorNotchControl, bool> MouseDownCallback;
- public int Index { get; set; }
- public bool IsInputValid { private set; get; }
- public static readonly DependencyProperty DisplayIndexProperty = DependencyProperty.Register(
- "DisplayIndex", typeof(int), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));
- public int DisplayIndex
- {
- get
- {
- return (int)GetValue(DisplayIndexProperty);
- }
- set
- {
- SetValue(DisplayIndexProperty, value);
- }
- }
- public static readonly DependencyProperty CurrentSusceptorStatusProperty = DependencyProperty.Register(
- "CurrentSusceptorStatus", typeof(SusceptorStatus), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(SusceptorStatus.Empty, FrameworkPropertyMetadataOptions.AffectsRender));
- public SusceptorStatus CurrentSusceptorStatus
- {
- get
- {
- return (SusceptorStatus)GetValue(CurrentSusceptorStatusProperty);
- }
- set
- {
- SetValue(CurrentSusceptorStatusProperty, value);
- }
- }
- public static readonly DependencyProperty CurrentWaferStatusProperty = DependencyProperty.Register(
- "CurrentWaferStatus", typeof(WaferStatus), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(WaferStatus.Normal, FrameworkPropertyMetadataOptions.AffectsRender));
- public WaferStatus CurrentWaferStatus
- {
- get
- {
- return (WaferStatus)GetValue(CurrentWaferStatusProperty);
- }
- set
- {
- SetValue(CurrentWaferStatusProperty, value);
- }
- }
- public static readonly DependencyProperty CurrentWaferTypeProperty = DependencyProperty.Register(
- "CurrentWaferType", typeof(WaferType), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(WaferType.Empty, FrameworkPropertyMetadataOptions.AffectsRender));
- public WaferType CurrentWaferType
- {
- get
- {
- return (WaferType)GetValue(CurrentWaferTypeProperty);
- }
- set
- {
- SetValue(CurrentWaferTypeProperty, value);
- }
- }
- //如果Ture,鼠标在notch上面移动,显示颜色变化
- public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
- "IsActive", typeof(Boolean), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
- public bool IsActive
- {
- get
- {
- return (bool)GetValue(IsActiveProperty);
- }
- set
- {
- SetValue(IsActiveProperty, value);
- }
- }
- //如果Ture,nnotch可以编辑
- public static readonly DependencyProperty IsReadonlyProperty = DependencyProperty.Register(
- "IsReadonly", typeof(Boolean), typeof(SusceptorNotchControl),
- new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
- public bool IsReadonly
- {
- get
- {
- return (bool)GetValue(IsReadonlyProperty);
- }
- set
- {
- SetValue(IsReadonlyProperty, value);
- }
- }
- public SusceptorNotchControl()
- {
- InitializeComponent();
- }
- public void Update()
- {
- textBoxWafer.Text = DisplayIndex.ToString();
- textBoxWafer.Background = SusceptorBrush.GetNotchBackgroundBrush(CurrentSusceptorStatus, CurrentWaferType, CurrentWaferStatus);
- }
- protected override void OnRender(DrawingContext drawingContext)
- {
- Update();
- }
- private void Label_MouseEnter(object sender, MouseEventArgs e)
- {
- if (!IsActive) return;
- if (CurrentWaferType == WaferType.Empty)
- textBoxWafer.Background = SusceptorBrush.OnEnteringBrush;
- }
- private void Label_MouseLeave(object sender, MouseEventArgs e)
- {
- if (!IsActive) return;
- if (CurrentWaferType == WaferType.Empty)
- textBoxWafer.Background = SusceptorBrush.EmptyBrush;
- }
- private void Label_MouseDown(object sender, MouseButtonEventArgs e)
- {
- if (IsActive && MouseDownCallback != null)
- {
- MouseDownCallback.Invoke(this, IsReadonly &&( Keyboard.IsKeyDown(Key.LeftShift)||Keyboard.IsKeyDown(Key.RightShift)));
- }
- e.Handled = false;
- }
- private void textBoxWafer_TextChanged(object sender, TextChangedEventArgs e)
- {
- int result;
- IsInputValid = !string.IsNullOrWhiteSpace(textBoxWafer.Text) && int.TryParse(textBoxWafer.Text, out result);
- Rectangle r = FindFirstVisualChild<Rectangle>(textBoxWafer, "rectangle1");
- if (r != null)
- r.Stroke = new SolidColorBrush(IsInputValid ? Colors.Black : Colors.Red);
- }
- T FindFirstVisualChild<T>(DependencyObject obj, string childName) where T : DependencyObject
- {
- for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
- {
- DependencyObject child = VisualTreeHelper.GetChild(obj, i);
- if (child is T && child.GetValue(NameProperty).ToString() == childName)
- {
- return (T)child;
- }
- else
- {
- T childOfChild = FindFirstVisualChild<T>(child, childName);
- if (childOfChild != null)
- {
- return childOfChild;
- }
- }
- }
- return null;
- }
- }
- }
|