首次上传
This commit is contained in:
@@ -0,0 +1,406 @@
|
||||
using OpenSEMI.Ctrlib.Types;
|
||||
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.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;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public delegate void CarrierDragDropHandler(object sender, CarrierDragDropEventArgs e);
|
||||
|
||||
public class CarrierDragDropEventArgs : EventArgs
|
||||
{
|
||||
public CarrierContentControl TranferFrom { get; set; }
|
||||
public CarrierContentControl TranferTo { get; set; }
|
||||
|
||||
public CarrierDragDropEventArgs(CarrierContentControl p_TranferFrom, CarrierContentControl p_TranferTo)
|
||||
{
|
||||
this.TranferFrom = p_TranferFrom;
|
||||
this.TranferTo = p_TranferTo;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CarrierBorderStatus
|
||||
{
|
||||
MouseOver = 1,
|
||||
TransferSource = 2,
|
||||
TransferTarget = 4,
|
||||
Selected = 8,
|
||||
None = 16
|
||||
}
|
||||
|
||||
public class CarrierContentControl : ContentControl
|
||||
{
|
||||
public event MouseButtonEventHandler StageMouseButtonDown;
|
||||
public event CarrierDragDropHandler WaferTransferStarted;
|
||||
|
||||
static CarrierContentControl()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(CarrierContentControl), new FrameworkPropertyMetadata(typeof(CarrierContentControl)));
|
||||
}
|
||||
|
||||
|
||||
public bool IsDraggable { get; set; }
|
||||
public bool IsLeftMouseDown { get; set; } //confirm drag source is current Stage
|
||||
|
||||
public string ViewType
|
||||
{
|
||||
get { return (string)GetValue(ViewTypeProperty); }
|
||||
set { SetValue(ViewTypeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ViewTypeProperty =
|
||||
DependencyProperty.Register("ViewType", typeof(string), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata("Front"));
|
||||
|
||||
|
||||
public int WaferStatus
|
||||
{
|
||||
get { return (int)GetValue(WaferStatusProperty); }
|
||||
set { SetValue(WaferStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferStatusProperty =
|
||||
DependencyProperty.Register("WaferStatus", typeof(int), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(0, new PropertyChangedCallback(WaferStatusChangedCallBack)));
|
||||
|
||||
public int CarrierID
|
||||
{
|
||||
get { return (int)GetValue(CarrierIDProperty); }
|
||||
set { SetValue(CarrierIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty CarrierIDProperty =
|
||||
DependencyProperty.Register("CarrierID", typeof(int), typeof(CarrierContentControl), new UIPropertyMetadata(-1));
|
||||
|
||||
public string ModuleID
|
||||
{
|
||||
get { return (string)GetValue(ModuleIDProperty); }
|
||||
set { SetValue(ModuleIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ModuleIDProperty =
|
||||
DependencyProperty.Register("ModuleID", typeof(string), typeof(CarrierContentControl), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
public bool IsDragSource
|
||||
{
|
||||
get { return (bool)GetValue(IsDragSourceProperty); }
|
||||
set { SetValue(IsDragSourceProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDragSourceProperty =
|
||||
DependencyProperty.Register("IsDragSource", typeof(bool), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDragSourcePropertyChangedCallBack)));
|
||||
|
||||
public bool IsDropTarget
|
||||
{
|
||||
get { return (bool)GetValue(IsDropTargetProperty); }
|
||||
set { SetValue(IsDropTargetProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDropTargetProperty =
|
||||
DependencyProperty.Register("IsDropTarget", typeof(bool), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDropTargetPropertyChangedCallBack)));
|
||||
|
||||
public bool IsDragEnter
|
||||
{
|
||||
get { return (bool)GetValue(IsDragEnterProperty); }
|
||||
set { SetValue(IsDragEnterProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDragEnterProperty =
|
||||
DependencyProperty.Register("IsDragEnter", typeof(bool), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDragEnterPropertyChangedCallBack)));
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return (bool)GetValue(IsSelectedProperty); }
|
||||
set { SetValue(IsSelectedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsSelectedProperty =
|
||||
DependencyProperty.Register("IsSelected", typeof(bool), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsSelectedPropertyChangedCallBack)));
|
||||
|
||||
public bool HasWafer
|
||||
{
|
||||
get { return (bool)GetValue(HasWaferProperty); }
|
||||
set { SetValue(HasWaferProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty HasWaferProperty =
|
||||
DependencyProperty.Register("HasWafer", typeof(bool), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(false, HasWaferChanged));
|
||||
|
||||
public CarrierBorderStatus BorderStatus
|
||||
{
|
||||
get { return (CarrierBorderStatus)GetValue(BorderStatusProperty); }
|
||||
set { SetValue(BorderStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty BorderStatusProperty =
|
||||
DependencyProperty.Register("BorderStatus", typeof(CarrierBorderStatus), typeof(CarrierContentControl),
|
||||
new UIPropertyMetadata(CarrierBorderStatus.None));
|
||||
|
||||
public string SourceName
|
||||
{
|
||||
get { return (string)GetValue(SourceNameProperty); }
|
||||
set { SetValue(SourceNameProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SourceNameProperty =
|
||||
DependencyProperty.Register("SourceName", typeof(string), typeof(CarrierContentControl), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
|
||||
public bool CanDragDrop
|
||||
{
|
||||
get { return (bool)GetValue(CanDragDropProperty); }
|
||||
set { SetValue(CanDragDropProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty CanDragDropProperty =
|
||||
DependencyProperty.Register("CanDragDrop", typeof(bool), typeof(CarrierContentControl), new UIPropertyMetadata(true, new PropertyChangedCallback(CanDragDropPropertyChangedCallBack)));
|
||||
|
||||
public string WaferTooltip
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipProperty); }
|
||||
set { SetValue(WaferTooltipProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipProperty =
|
||||
DependencyProperty.Register("WaferTooltip", typeof(string), typeof(CarrierContentControl), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string WaferTooltipExt
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipExtProperty); }
|
||||
set { SetValue(WaferTooltipExtProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipExtProperty =
|
||||
DependencyProperty.Register("WaferTooltipExt", typeof(string), typeof(CarrierContentControl), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string SeasoningWaferType
|
||||
{
|
||||
get { return (string)GetValue(SeasoningWaferTypeProperty); }
|
||||
set { SetValue(SeasoningWaferTypeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SeasoningWaferTypeProperty =
|
||||
DependencyProperty.Register("SeasoningWaferType", typeof(string), typeof(CarrierContentControl), new PropertyMetadata(string.Empty));
|
||||
|
||||
public Visibility DuplicatedVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(DuplicatedVisibilityProperty); }
|
||||
set { SetValue(DuplicatedVisibilityProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty DuplicatedVisibilityProperty =
|
||||
DependencyProperty.Register("DuplicatedVisibility", typeof(Visibility), typeof(CarrierContentControl), new UIPropertyMetadata(Visibility.Collapsed));
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
DragDropStatusControl(this);
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
this.IsDragEnter = true;
|
||||
}
|
||||
|
||||
protected override void OnDragLeave(DragEventArgs e)
|
||||
{
|
||||
base.OnDragLeave(e);
|
||||
this.IsDragEnter = false;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
if (MouseButtonState.Pressed == e.LeftButton)
|
||||
IsLeftMouseDown = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
IsLeftMouseDown = false;
|
||||
|
||||
MouseButtonEventHandler handler = StageMouseButtonDown;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
this.BorderStatus = this.BorderStatus | CarrierBorderStatus.MouseOver;
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
IsLeftMouseDown = false;
|
||||
this.BorderStatus = this.BorderStatus & (~CarrierBorderStatus.MouseOver);
|
||||
}
|
||||
|
||||
private static void DragDropStatusControl(CarrierContentControl p_Stage)
|
||||
{
|
||||
p_Stage.AllowDrop = false;
|
||||
p_Stage.IsDraggable = false;
|
||||
|
||||
if (p_Stage.CanDragDrop)
|
||||
{
|
||||
if (!p_Stage.IsDropTarget && p_Stage.WaferStatus == 0)
|
||||
p_Stage.AllowDrop = true;
|
||||
|
||||
if (!p_Stage.IsDragSource && p_Stage.WaferStatus != 0)
|
||||
p_Stage.IsDraggable = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void IsDropTargetPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
|
||||
if (m_Stage.IsDropTarget)
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus | CarrierBorderStatus.TransferTarget; //add
|
||||
else
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus & (~CarrierBorderStatus.TransferTarget); //remove
|
||||
|
||||
DragDropStatusControl(m_Stage);
|
||||
}
|
||||
|
||||
private static void IsDragSourcePropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
|
||||
if (m_Stage.IsDragSource)
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus | CarrierBorderStatus.TransferSource; //add
|
||||
else
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus & (~CarrierBorderStatus.TransferSource); //remove
|
||||
|
||||
DragDropStatusControl(m_Stage);
|
||||
}
|
||||
|
||||
private static void IsSelectedPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
|
||||
if (m_Stage.IsSelected)
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus | CarrierBorderStatus.Selected; //add
|
||||
else
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus & (~CarrierBorderStatus.Selected); //remove
|
||||
}
|
||||
|
||||
private static void CanDragDropPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
DragDropStatusControl(m_Stage);
|
||||
}
|
||||
|
||||
private static void IsDragEnterPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
|
||||
if (m_Stage.IsDragEnter)
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus | CarrierBorderStatus.TransferTarget; //add
|
||||
else
|
||||
m_Stage.BorderStatus = m_Stage.BorderStatus & (~CarrierBorderStatus.TransferTarget); //remove
|
||||
}
|
||||
|
||||
private static void WaferStatusChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
m_Stage.IsDragSource = false;
|
||||
m_Stage.IsDropTarget = false;
|
||||
m_Stage.IsDragEnter = false;
|
||||
DragDropStatusControl(m_Stage);
|
||||
}
|
||||
|
||||
public static void HasWaferChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
CarrierContentControl m_Stage = d as CarrierContentControl;
|
||||
if (m_Stage != null)
|
||||
{
|
||||
if (m_Stage.HasWafer)
|
||||
m_Stage.WaferStatus = 7;
|
||||
else
|
||||
m_Stage.WaferStatus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseMove(e);
|
||||
if (e.LeftButton == MouseButtonState.Pressed && IsDraggable && IsLeftMouseDown)
|
||||
{
|
||||
DataObject data = new DataObject(typeof(CarrierContentControl), this);
|
||||
DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrop(DragEventArgs e)
|
||||
{
|
||||
if (this.AllowDrop)
|
||||
{
|
||||
try
|
||||
{
|
||||
IDataObject data = e.Data;
|
||||
if (data.GetDataPresent(typeof(CarrierContentControl)))
|
||||
{
|
||||
CarrierContentControl m_dragSource = (CarrierContentControl)data.GetData(typeof(CarrierContentControl));
|
||||
m_dragSource.IsDragSource = true; //source
|
||||
this.IsDropTarget = true; //target
|
||||
if (WaferTransferStarted != null)
|
||||
{
|
||||
CarrierDragDropEventArgs m_arg = new CarrierDragDropEventArgs(m_dragSource, this);
|
||||
WaferTransferStarted(this, m_arg);
|
||||
}
|
||||
}
|
||||
else //to support another type of wafer
|
||||
{
|
||||
//var sourceWafer = (WaferInfo)e.Data.GetData("Object");
|
||||
var sourceStation = e.Data.GetData("Station").ToString();
|
||||
var sourceStage = (int)e.Data.GetData("Stage");
|
||||
CarrierContentControl m_dragSource = new CarrierContentControl() { ModuleID = sourceStation, CarrierID = sourceStage };
|
||||
if (WaferTransferStarted != null)
|
||||
{
|
||||
CarrierDragDropEventArgs m_arg = new CarrierDragDropEventArgs(m_dragSource, this);
|
||||
WaferTransferStarted(this, m_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsValidStage()
|
||||
{
|
||||
if (this.ModuleID.Length >0 && this.CarrierID >= 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsSameStage(CarrierContentControl Stage)
|
||||
{
|
||||
if (Stage.IsValidStage() && this.IsValidStage())
|
||||
{
|
||||
if (this.ModuleID == Stage.ModuleID && this.CarrierID == Stage.CarrierID)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void ClearDragDropStatus()
|
||||
{
|
||||
this.IsDragEnter = false;
|
||||
this.IsDragSource = false;
|
||||
this.IsDropTarget = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class CheckBoxExt:CheckBox
|
||||
{
|
||||
public bool CheckBoxSaved
|
||||
{
|
||||
get { return (bool)GetValue(CheckBoxSavedProperty); }
|
||||
set { SetValue(CheckBoxSavedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty CheckBoxSavedProperty =
|
||||
DependencyProperty.Register("CheckBoxSaved", typeof(bool), typeof(CheckBoxExt),
|
||||
new UIPropertyMetadata(true));
|
||||
|
||||
protected override void OnUnchecked(RoutedEventArgs e)
|
||||
{
|
||||
base.OnUnchecked(e);
|
||||
this.CheckBoxSaved = false;
|
||||
}
|
||||
protected override void OnChecked(RoutedEventArgs e)
|
||||
{
|
||||
base.OnChecked(e);
|
||||
this.CheckBoxSaved = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class ComboBoxExt : ComboBox
|
||||
{
|
||||
public bool ComboBoxSaved
|
||||
{
|
||||
get { return (bool)GetValue(ComboBoxSavedProperty); }
|
||||
set { SetValue(ComboBoxSavedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ComboBoxSavedProperty =
|
||||
DependencyProperty.Register("ComboBoxSaved", typeof(bool), typeof(ComboBoxExt),
|
||||
new UIPropertyMetadata(true));
|
||||
|
||||
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
|
||||
{
|
||||
base.OnSelectionChanged(e);
|
||||
this.ComboBoxSaved = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class ComboTextBlock : TextBlock
|
||||
{
|
||||
public EditBoxMode EditBoxMode
|
||||
{
|
||||
get { return (EditBoxMode)GetValue(EditBoxModeProperty); }
|
||||
set { SetValue(EditBoxModeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty EditBoxModeProperty = DependencyProperty.Register("EditBoxMode", typeof(EditBoxMode), typeof(ComboTextBlock), new UIPropertyMetadata(EditBoxMode.Default));
|
||||
|
||||
|
||||
private bool m_AllowEmpty = true;
|
||||
public bool AllowEmpty
|
||||
{
|
||||
get { return m_AllowEmpty; }
|
||||
set { m_AllowEmpty = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a flag to indicate that whether to change the bg color
|
||||
/// when the text changed by backgroud not by GUI side.
|
||||
/// This flag is true when control is bound to display text from dialog
|
||||
/// </summary>
|
||||
private bool m_AllowBackgroundChange = false;
|
||||
public bool AllowBackgroundChange
|
||||
{
|
||||
get { return m_AllowBackgroundChange; }
|
||||
set { m_AllowBackgroundChange = value; }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(ComboTextBlock), new UIPropertyMetadata(double.NaN));
|
||||
public double MaxValue
|
||||
{
|
||||
get { return (double)GetValue(MaxValueProperty); }
|
||||
set { SetValue(MaxValueProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public double MinValue
|
||||
{
|
||||
get { return (double)GetValue(MinValueProperty); }
|
||||
set { SetValue(MinValueProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty MinValueProperty =
|
||||
DependencyProperty.Register("MinValue", typeof(double), typeof(ComboTextBlock), new UIPropertyMetadata(double.NaN));
|
||||
|
||||
public Int32 Accuracy
|
||||
{
|
||||
get { return (Int32)GetValue(AccuracyProperty); }
|
||||
set { SetValue(AccuracyProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty AccuracyProperty =
|
||||
DependencyProperty.Register("Accuracy", typeof(Int32), typeof(ComboTextBlock), new UIPropertyMetadata(4));
|
||||
|
||||
|
||||
public bool TextSaved
|
||||
{
|
||||
get { return (bool)GetValue(TextSavedProperty); }
|
||||
set { SetValue(TextSavedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TextSavedProperty =
|
||||
DependencyProperty.Register("TextSaved", typeof(bool), typeof(ComboTextBlock),
|
||||
new UIPropertyMetadata(true, new PropertyChangedCallback(TextSavedChangedCallBack)));
|
||||
|
||||
|
||||
public Boolean IsScrollToEnd
|
||||
{
|
||||
get { return (Boolean)GetValue(ScrollToEndProperty); }
|
||||
set { SetValue(ScrollToEndProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static readonly DependencyProperty ScrollToEndProperty =
|
||||
DependencyProperty.Register("IsScrollToEnd", typeof(Boolean), typeof(ComboTextBlock), new UIPropertyMetadata(false));
|
||||
|
||||
|
||||
private static void TextSavedChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
ComboTextBlock m_txt = d as ComboTextBlock;
|
||||
if (m_txt != null)
|
||||
{
|
||||
//SetBGColor(m_txt);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemsSourceProperty =
|
||||
DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(ComboTextBlock), new UIPropertyMetadata(null));
|
||||
public IEnumerable ItemsSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IEnumerable)GetValue(ItemsSourceProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedItemProperty =
|
||||
DependencyProperty.Register("SelectedItem", typeof(object), typeof(ComboTextBlock), new UIPropertyMetadata(null));
|
||||
public object SelectedItem
|
||||
{
|
||||
get
|
||||
{
|
||||
return (object)GetValue(SelectedItemProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(SelectedItemProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IsInEditModeProperty =
|
||||
DependencyProperty.Register("IsInEditMode", typeof(bool), typeof(ComboTextBlock), new UIPropertyMetadata(false, IsInEditModeUpdate));
|
||||
|
||||
public bool IsInEditMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)GetValue(IsInEditModeProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(IsInEditModeProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool IsEditable
|
||||
{
|
||||
get { return (bool)GetValue(IsEditableProperty); }
|
||||
set { SetValue(IsEditableProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsEditableProperty =
|
||||
DependencyProperty.Register("IsEditable", typeof(bool), typeof(ComboTextBlock),
|
||||
new UIPropertyMetadata(false));
|
||||
|
||||
|
||||
public bool IsLoopItem
|
||||
{
|
||||
get { return (bool)GetValue(IsLoopItemProperty); }
|
||||
set { SetValue(IsLoopItemProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsLoopItemProperty =
|
||||
DependencyProperty.Register("IsLoopItem", typeof(bool), typeof(ComboTextBlock),
|
||||
new UIPropertyMetadata(false));
|
||||
|
||||
|
||||
private ComboTextBlockAdorner _adorner;
|
||||
|
||||
static ComboTextBlock()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ComboTextBlock), new FrameworkPropertyMetadata(typeof(ComboTextBlock)));
|
||||
|
||||
}
|
||||
|
||||
private static void IsInEditModeUpdate(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
ComboTextBlock textBlock = obj as ComboTextBlock;
|
||||
if (null != textBlock)
|
||||
{
|
||||
//Get the adorner layer of the uielement (here TextBlock)
|
||||
AdornerLayer layer = AdornerLayer.GetAdornerLayer(textBlock);
|
||||
if (layer == null)
|
||||
return;
|
||||
|
||||
//If the IsInEditMode set to true means the user has enabled the edit mode then
|
||||
//add the adorner to the adorner layer of the TextBlock.
|
||||
if (textBlock.IsInEditMode)
|
||||
{
|
||||
if (null == textBlock._adorner)
|
||||
{
|
||||
textBlock._adorner = new ComboTextBlockAdorner(textBlock);
|
||||
|
||||
//Events wired to exit edit mode when the user presses Enter key or leaves the control.
|
||||
//textBlock._adorner.TextBoxKeyUp += textBlock.TextBoxKeyUp;
|
||||
//textBlock._adorner.TextBoxLostFocus += textBlock.TextBoxLostFocus;
|
||||
}
|
||||
layer.Add(textBlock._adorner);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Remove the adorner from the adorner layer.
|
||||
Adorner[] adorners = layer.GetAdorners(textBlock);
|
||||
if (adorners != null)
|
||||
{
|
||||
foreach (Adorner adorner in adorners)
|
||||
{
|
||||
if (adorner is ComboTextBlockAdorner)
|
||||
{
|
||||
layer.Remove(adorner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LeaveEditMode()
|
||||
{
|
||||
IsInEditMode = false;
|
||||
|
||||
//if (!IsLoopItem)
|
||||
// Background = Brushes.Transparent;
|
||||
|
||||
}
|
||||
|
||||
public void TextBoxLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LeaveEditMode();
|
||||
|
||||
}
|
||||
internal void DropDownClosedLostFocus(object sender, EventArgs e)
|
||||
{
|
||||
LeaveEditMode();
|
||||
}
|
||||
/// <summary>
|
||||
/// release the edit mode when user presses enter.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="System.Windows.Input.KeyEventArgs"/> instance containing the event data.</param>
|
||||
private void TextBoxKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
IsInEditMode = false;
|
||||
//TextBoxEx atb = sender as TextBoxEx;
|
||||
//if (atb == null)
|
||||
// return;
|
||||
//if (this.EditBoxMode == EditBoxMode.Decimal || this.EditBoxMode == EditBoxMode.UnSignDecimal ||
|
||||
// this.EditBoxMode == EditBoxMode.SignInteger || this.EditBoxMode == EditBoxMode.UnSignInteger)
|
||||
//{
|
||||
// double dataValue = 0;
|
||||
// if (!double.TryParse(atb.Text, out dataValue))
|
||||
// return;
|
||||
|
||||
// if (MinValue == MaxValue && MinValue == 0)
|
||||
// return;
|
||||
|
||||
// this.Background = (dataValue < MinValue || dataValue > MaxValue) ? Brushes.Red : Brushes.Transparent;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when an unhandled <see cref="E:System.Windows.Input.Mouse.MouseDown"/> attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param>
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.MiddleButton == MouseButtonState.Pressed)
|
||||
{
|
||||
IsInEditMode = true;
|
||||
}
|
||||
else if (e.ClickCount == 1)
|
||||
{
|
||||
IsInEditMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class ComboTextBlockAdorner: Adorner
|
||||
{
|
||||
public ComboBoxExt TextBox
|
||||
{
|
||||
get { return this._comboBox; }
|
||||
}
|
||||
|
||||
private readonly VisualCollection _collection;
|
||||
private readonly ComboBoxExt _comboBox;
|
||||
private readonly ComboTextBlock _textBlock;
|
||||
|
||||
private TextBox _textboxInEditableComboBox;
|
||||
|
||||
public ComboTextBlockAdorner(ComboTextBlock adornedElement)
|
||||
: base(adornedElement)
|
||||
{
|
||||
_collection = new VisualCollection(this);
|
||||
|
||||
_comboBox = new ComboBoxExt();
|
||||
_comboBox.DisplayMemberPath = "DisplayName";
|
||||
_comboBox.IsEditable = adornedElement.IsEditable;
|
||||
|
||||
|
||||
_textBlock = adornedElement;
|
||||
|
||||
|
||||
Binding binding = new Binding("ItemsSource") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_comboBox.SetBinding(ComboBoxExt.ItemsSourceProperty, binding);
|
||||
|
||||
binding = new Binding("SelectedItem") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_comboBox.SetBinding(ComboBoxExt.SelectedItemProperty, binding);
|
||||
|
||||
binding = new Binding("Text") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_comboBox.SetBinding(ComboBoxExt.TextProperty, binding);
|
||||
_comboBox.Text = _textBlock.Text;
|
||||
|
||||
binding = new Binding("TextSaved") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_comboBox.SetBinding(ComboBoxExt.ComboBoxSavedProperty, binding);
|
||||
//_textBox.KeyUp += _textBox_KeyUp;
|
||||
|
||||
_comboBox.Loaded += _comboBox_Loaded;
|
||||
_comboBox.Unloaded += _comboBox_Unloaded;
|
||||
|
||||
_collection.Add(_comboBox);
|
||||
}
|
||||
|
||||
private void _comboBox_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_comboBox.IsEditable)
|
||||
{
|
||||
_textboxInEditableComboBox = (_comboBox.Template.FindName("PART_EditableTextBox", _comboBox) as TextBox);
|
||||
if (_textboxInEditableComboBox != null)
|
||||
{
|
||||
_textboxInEditableComboBox.LostFocus -= _textBlock.TextBoxLostFocus;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//_comboBox.SelectionChanged -= _textBlock.TextBoxLostFocus;
|
||||
|
||||
_comboBox.DropDownClosed -= _textBlock.DropDownClosedLostFocus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void _comboBox_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_comboBox.IsEditable)
|
||||
{
|
||||
_textboxInEditableComboBox = (_comboBox.Template.FindName("PART_EditableTextBox", _comboBox) as TextBox);
|
||||
if (_textboxInEditableComboBox != null)
|
||||
{
|
||||
_textboxInEditableComboBox.LostFocus += _textBlock.TextBoxLostFocus;
|
||||
|
||||
_textboxInEditableComboBox.Focus();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//_comboBox.SelectionChanged += _textBlock.TextBoxLostFocus;
|
||||
|
||||
_comboBox.IsDropDownOpen = true;
|
||||
|
||||
_comboBox.DropDownClosed += _textBlock.DropDownClosedLostFocus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public event RoutedEventHandler TextBoxLostFocus
|
||||
{
|
||||
add
|
||||
{
|
||||
|
||||
if (_textboxInEditableComboBox != null)
|
||||
_textboxInEditableComboBox.LostFocus += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
//var textBox = (_comboBox.Template.FindName("PART_EditableTextBox", _comboBox) as TextBox);
|
||||
if (_textboxInEditableComboBox != null)
|
||||
_textboxInEditableComboBox.LostFocus -= value;
|
||||
}
|
||||
}
|
||||
//public event KeyEventHandler TextBoxKeyUp
|
||||
//{
|
||||
// add
|
||||
// {
|
||||
// _textBox.KeyUp += value;
|
||||
// }
|
||||
// remove
|
||||
// {
|
||||
// _textBox.KeyUp -= value;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return _collection[index];
|
||||
}
|
||||
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Count;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
_comboBox.Arrange(new Rect(0, 0, _textBlock.ActualWidth, _textBlock.ActualHeight));
|
||||
//if (_textbox == null)
|
||||
// _comboBox.Focus();
|
||||
//_comboBox.ScrollToEnd();
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
private void _textBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
//if (e.Key == Key.Enter)
|
||||
//{
|
||||
// _textBox.Text = _textBox.Text.Replace("\r\n", string.Empty);
|
||||
// BindingExpression expression = _textBox.GetBindingExpression(TextBoxEx.TextProperty);
|
||||
// if (null != expression)
|
||||
// expression.UpdateSource();
|
||||
|
||||
// expression = _textBox.GetBindingExpression(TextBoxEx.TextSavedProperty);
|
||||
// if (null != expression)
|
||||
// expression.UpdateSource();
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.CoolingWaterDataPresenter"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:deviceControl="clr-namespace:Aitex.Core.UI.DeviceControl;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:deviceData="clr-namespace:MECF.Framework.Common.Aitex.Core.Common.DeviceData;assembly=MECF.Framework.Common"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DataContext="{d:DesignInstance Type=deviceData:AITWaterFlowData,
|
||||
IsDesignTimeCreatable=False}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
lex:LocalizeDictionary.DesignCulture="zh"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_pm"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
|
||||
<local:CoolingWaterAlarmTipsConverter x:Key="AlarmTipsConverter" />
|
||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
|
||||
<Style x:Key="WaterTempBackground" TargetType="Border">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Table_BD}" />
|
||||
<Setter Property="BorderThickness" Value="0,0,1,1" />
|
||||
<Setter Property="Padding" Value="5,1" />
|
||||
<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<ToolTip Content="{Binding Converter={StaticResource AlarmTipsConverter}}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="false" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="true" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="#f4b575" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="False" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="#f49f9f" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="True" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="#f49f9f" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WaterTempForeground" TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="FontFamily" Value="Arial" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
<Setter Property="Text" Value="{Binding Value, StringFormat=0.00}" />
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="false" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="{DynamicResource FG_Black}" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="true" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="false" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="#e66e2e" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="False" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="#ff0f0f" />
|
||||
</MultiDataTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding IsWarning}" Value="True" />
|
||||
<Condition Binding="{Binding IsAlarm}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Foreground" Value="#ff0f0f" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="0,0,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="23" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="70" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title_Inner}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1,0,1,1">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_pm_terms"
|
||||
Text="{lex:Loc {Binding DisplayName, FallbackValue=Unknown}}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Column="1"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content_Inner}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
|
||||
<deviceControl:AITSensor
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
CustomColorOff="Red"
|
||||
CustomColorOn="Lime"
|
||||
IsCustomRender="True"
|
||||
LightOnValue="{Binding IsFlowSW}"
|
||||
Visibility="{Binding Converter={StaticResource NullToVisibilityConverter}, Mode=OneTime}" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2" Style="{StaticResource WaterTempBackground}">
|
||||
<TextBlock Style="{StaticResource WaterTempForeground}" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,46 @@
|
||||
using Aitex.Core.Common.DeviceData.IoDevice;
|
||||
using System.Globalization;
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// CoolingWaterResPresenter.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CoolingWaterDataPresenter : UserControl
|
||||
{
|
||||
public CoolingWaterDataPresenter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class CoolingWaterAlarmTipsConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is AITWaterFlowData data)
|
||||
{
|
||||
return $"Realtime: {data.Value:F1}℃" +
|
||||
$"\r\nWarning: {(data.IsWarning?"Yes" : "No")}" +
|
||||
$"\r\nAlarm: {(data.IsAlarm?"Yes" : "No")}" +
|
||||
$"\r\nWarning Range: {data.WarningLimitLow:F1}℃ - {data.WarningLimitHigh:F1}℃" +
|
||||
$"\r\nAlarm Range: {data.AlarmLimitLow:F1}℃ - {data.AlarmLimitHigh:F1}℃" +
|
||||
$"\r\nWater Flow: {(data.IsFlowSW ? "Normal" : "Fault")}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class EditTextBlock : TextBlock
|
||||
{
|
||||
static EditTextBlock()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(EditTextBlock), new FrameworkPropertyMetadata(typeof(EditTextBlock)));
|
||||
|
||||
}
|
||||
public static readonly DependencyProperty IsInEditModeProperty =
|
||||
DependencyProperty.Register("IsInEditMode", typeof(bool), typeof(EditTextBlock), new UIPropertyMetadata(false, IsInEditModeUpdate));
|
||||
|
||||
public bool IsInEditMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)GetValue(IsInEditModeProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(IsInEditModeProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void IsInEditModeUpdate(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
EditTextBlock textBlock = obj as EditTextBlock;
|
||||
if (null != textBlock)
|
||||
{
|
||||
//Get the adorner layer of the uielement (here TextBlock)
|
||||
AdornerLayer layer = AdornerLayer.GetAdornerLayer(textBlock);
|
||||
if (layer == null)
|
||||
return;
|
||||
|
||||
//If the IsInEditMode set to true means the user has enabled the edit mode then
|
||||
//add the adorner to the adorner layer of the TextBlock.
|
||||
if (textBlock.IsInEditMode)
|
||||
{
|
||||
if (null == textBlock._adorner)
|
||||
{
|
||||
textBlock._adorner = new EditTextBlockAdorner(textBlock);
|
||||
|
||||
//Events wired to exit edit mode when the user presses Enter key or leaves the control.
|
||||
textBlock._adorner.TextBoxKeyUp += textBlock.TextBoxKeyUp;
|
||||
textBlock._adorner.TextBoxLostFocus += textBlock.TextBoxLostFocus;
|
||||
textBlock._adorner.TextBox.SelectAll();
|
||||
}
|
||||
layer.Add(textBlock._adorner);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Remove the adorner from the adorner layer.
|
||||
Adorner[] adorners = layer.GetAdorners(textBlock);
|
||||
if (adorners != null)
|
||||
{
|
||||
foreach (Adorner adorner in adorners)
|
||||
{
|
||||
if (adorner is EditTextBlockAdorner)
|
||||
{
|
||||
layer.Remove(adorner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBoxLostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
IsInEditMode = false;
|
||||
TextBoxEx atb = sender as TextBoxEx;
|
||||
if (atb == null)
|
||||
return;
|
||||
if (this.EditBoxMode == EditBoxMode.Decimal || this.EditBoxMode == EditBoxMode.UnSignDecimal ||
|
||||
this.EditBoxMode == EditBoxMode.SignInteger || this.EditBoxMode == EditBoxMode.UnSignInteger)
|
||||
{
|
||||
double dataValue = 0;
|
||||
if (!double.TryParse(atb.Text, out dataValue))
|
||||
return;
|
||||
|
||||
if (MinValue == MaxValue && MinValue == 0)
|
||||
return;
|
||||
|
||||
this.Background = (dataValue < MinValue || dataValue > MaxValue) ? Brushes.Red : Brushes.Transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// release the edit mode when user presses enter.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="System.Windows.Input.KeyEventArgs"/> instance containing the event data.</param>
|
||||
private void TextBoxKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
IsInEditMode = false;
|
||||
TextBoxEx atb = sender as TextBoxEx;
|
||||
if (atb == null)
|
||||
return;
|
||||
if (this.EditBoxMode == EditBoxMode.Decimal || this.EditBoxMode == EditBoxMode.UnSignDecimal ||
|
||||
this.EditBoxMode == EditBoxMode.SignInteger || this.EditBoxMode == EditBoxMode.UnSignInteger)
|
||||
{
|
||||
double dataValue = 0;
|
||||
if (!double.TryParse(atb.Text, out dataValue))
|
||||
return;
|
||||
|
||||
if (MinValue == MaxValue && MinValue == 0)
|
||||
return;
|
||||
|
||||
this.Background = (dataValue < MinValue || dataValue > MaxValue) ? Brushes.Red : Brushes.Transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when an unhandled <see cref="E:System.Windows.Input.Mouse.MouseDown"/> attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. This event data reports details about the mouse button that was pressed and the handled state.</param>
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.MiddleButton == MouseButtonState.Pressed)
|
||||
{
|
||||
IsInEditMode = true;
|
||||
}
|
||||
else if (e.ClickCount == 1)
|
||||
{
|
||||
IsInEditMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region EditTextBox properties
|
||||
|
||||
public EditBoxMode EditBoxMode
|
||||
{
|
||||
get { return (EditBoxMode)GetValue(EditBoxModeProperty); }
|
||||
set { SetValue(EditBoxModeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty EditBoxModeProperty = DependencyProperty.Register("EditBoxMode", typeof(EditBoxMode), typeof(EditTextBlock), new UIPropertyMetadata(EditBoxMode.Default));
|
||||
|
||||
|
||||
private bool m_AllowEmpty = true;
|
||||
public bool AllowEmpty
|
||||
{
|
||||
get { return m_AllowEmpty; }
|
||||
set { m_AllowEmpty = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a flag to indicate that whether to change the bg color
|
||||
/// when the text changed by backgroud not by GUI side.
|
||||
/// This flag is true when control is bound to display text from dialog
|
||||
/// </summary>
|
||||
private bool m_AllowBackgroundChange = false;
|
||||
public bool AllowBackgroundChange
|
||||
{
|
||||
get { return m_AllowBackgroundChange; }
|
||||
set { m_AllowBackgroundChange = value; }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(EditTextBlock), new UIPropertyMetadata(double.NaN));
|
||||
public double MaxValue
|
||||
{
|
||||
get { return (double)GetValue(MaxValueProperty); }
|
||||
set { SetValue(MaxValueProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double MinValue
|
||||
{
|
||||
get { return (double)GetValue(MinValueProperty); }
|
||||
set { SetValue(MinValueProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register("MinValue", typeof(double), typeof(EditTextBlock), new UIPropertyMetadata(double.NaN));
|
||||
|
||||
public Int32 Accuracy
|
||||
{
|
||||
get { return (Int32)GetValue(AccuracyProperty); }
|
||||
set { SetValue(AccuracyProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty AccuracyProperty = DependencyProperty.Register("Accuracy", typeof(Int32), typeof(EditTextBlock), new UIPropertyMetadata(4));
|
||||
|
||||
|
||||
public bool TextSaved
|
||||
{
|
||||
get { return (bool)GetValue(TextSavedProperty); }
|
||||
set { SetValue(TextSavedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TextSavedProperty =
|
||||
DependencyProperty.Register("TextSaved", typeof(bool), typeof(EditTextBlock),
|
||||
new UIPropertyMetadata(true, new PropertyChangedCallback(TextSavedChangedCallBack)));
|
||||
|
||||
|
||||
public Boolean IsScrollToEnd
|
||||
{
|
||||
get { return (Boolean)GetValue(ScrollToEndProperty); }
|
||||
set { SetValue(ScrollToEndProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ScrollToEndProperty = DependencyProperty.Register("IsScrollToEnd", typeof(Boolean), typeof(EditTextBlock), new UIPropertyMetadata(false));
|
||||
|
||||
|
||||
private static void TextSavedChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
EditTextBlock m_txt = d as EditTextBlock;
|
||||
if (m_txt != null)
|
||||
{
|
||||
//SetBGColor(m_txt);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private EditTextBlockAdorner _adorner;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class EditTextBlockAdorner: Adorner
|
||||
{
|
||||
|
||||
public TextBoxEx TextBox
|
||||
{
|
||||
get { return this._textBox; }
|
||||
}
|
||||
|
||||
private readonly VisualCollection _collection;
|
||||
private readonly TextBoxEx _textBox;
|
||||
private readonly TextBlock _textBlock;
|
||||
|
||||
public EditTextBlockAdorner(EditTextBlock adornedElement)
|
||||
: base(adornedElement)
|
||||
{
|
||||
_collection = new VisualCollection(this);
|
||||
_textBox = new TextBoxEx();
|
||||
_textBlock = adornedElement;
|
||||
Binding binding = new Binding("Text") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_textBox.SetBinding(TextBoxEx.TextProperty, binding);
|
||||
|
||||
_textBox.EditBoxMode = adornedElement.EditBoxMode;
|
||||
_textBox.AllowEmpty = adornedElement.AllowEmpty;
|
||||
_textBox.AllowBackgroundChange = adornedElement.AllowBackgroundChange;
|
||||
_textBox.MaxValue = adornedElement.MaxValue;
|
||||
_textBox.MinValue = adornedElement.MinValue;
|
||||
_textBox.Accuracy = adornedElement.Accuracy;
|
||||
_textBox.IsScrollToEnd = adornedElement.IsScrollToEnd;
|
||||
|
||||
binding = new Binding("TextSaved") { Source = adornedElement };
|
||||
binding.Mode = BindingMode.TwoWay;
|
||||
_textBox.SetBinding(TextBoxEx.TextSavedProperty, binding);
|
||||
|
||||
|
||||
_textBox.KeyUp += _textBox_KeyUp;
|
||||
_collection.Add(_textBox);
|
||||
|
||||
if (!adornedElement.IsEnabled)
|
||||
_textBlock.Background = Brushes.Gray;
|
||||
}
|
||||
|
||||
public event RoutedEventHandler TextBoxLostFocus
|
||||
{
|
||||
add
|
||||
{
|
||||
_textBox.LostFocus += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_textBox.LostFocus -= value;
|
||||
}
|
||||
}
|
||||
public event KeyEventHandler TextBoxKeyUp
|
||||
{
|
||||
add
|
||||
{
|
||||
_textBox.KeyUp += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_textBox.KeyUp -= value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override Visual GetVisualChild(int index)
|
||||
{
|
||||
return _collection[index];
|
||||
}
|
||||
|
||||
protected override int VisualChildrenCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _collection.Count;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
_textBox.Arrange(new Rect(0, 0, _textBlock.ActualWidth, _textBlock.ActualHeight));
|
||||
_textBox.Focus();
|
||||
_textBox.ScrollToEnd();
|
||||
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
private void _textBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
_textBox.Text = _textBox.Text.Replace("\r\n", string.Empty);
|
||||
BindingExpression expression = _textBox.GetBindingExpression(TextBoxEx.TextProperty);
|
||||
if (null != expression)
|
||||
expression.UpdateSource();
|
||||
|
||||
expression = _textBox.GetBindingExpression(TextBoxEx.TextSavedProperty);
|
||||
if (null != expression)
|
||||
expression.UpdateSource();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class Gasline : Control
|
||||
{
|
||||
static Gasline()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Gasline), new FrameworkPropertyMetadata(typeof(Gasline)));
|
||||
}
|
||||
|
||||
public Orientation Orientation
|
||||
{
|
||||
get { return (Orientation)GetValue(OrientationProperty); }
|
||||
set { SetValue(OrientationProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Gasline), new PropertyMetadata(Orientation.Horizontal));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using OpenSEMI.Ctrlib.Types;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class GaslineJoint : Control
|
||||
{
|
||||
static GaslineJoint()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(GaslineJoint), new FrameworkPropertyMetadata(typeof(GaslineJoint)));
|
||||
}
|
||||
|
||||
public JointType JointType
|
||||
{
|
||||
get { return (JointType)GetValue(JointTypeProperty); }
|
||||
set { SetValue(JointTypeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty JointTypeProperty = DependencyProperty.Register("JointType", typeof(JointType), typeof(GaslineJoint), new PropertyMetadata(JointType.CROSS));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.HeaterResPresenter"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:deviceControl="clr-namespace:Aitex.Core.UI.DeviceControl;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:ioDevice="clr-namespace:Aitex.Core.Common.DeviceData.IoDevice;assembly=MECF.Framework.Common"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Controls"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DataContext="{d:DesignInstance Type=ioDevice:IoPsuData,
|
||||
IsDesignTimeCreatable=False}"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<local:IoPsuResistanceSummaryConverter x:Key="resSummaryConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="0,0,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="23" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="50" />
|
||||
<ColumnDefinition Width="70" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Title_Inner}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="1,0,1,1">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Caption, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
|
||||
TextWrapping="Wrap" />
|
||||
</Border>
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content_Inner}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
|
||||
<deviceControl:AITSensor
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
CustomColorOff="Lime"
|
||||
CustomColorOn="Red"
|
||||
IsCustomRender="True"
|
||||
LightOnValue="{Binding IsResistanceOutOfRange}" />
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
Grid.Column="3"
|
||||
Padding="5,1"
|
||||
Background="{DynamicResource Table_BG_Content_Inner}"
|
||||
BorderBrush="{DynamicResource Table_BD}"
|
||||
BorderThickness="0,0,1,1">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
Text="{Binding Resistance, StringFormat={}{0:F3}}"
|
||||
ToolTip="{Binding Converter={StaticResource resSummaryConverter}}" />
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using Aitex.Core.Common.DeviceData.IoDevice;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for HeaterResistanceOverview.xaml
|
||||
/// </summary>
|
||||
public partial class HeaterResPresenter : UserControl
|
||||
{
|
||||
public HeaterResPresenter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Dps
|
||||
|
||||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
|
||||
nameof(Caption), typeof(string), typeof(HeaterResPresenter), new PropertyMetadata(default(string)));
|
||||
|
||||
public string Caption
|
||||
{
|
||||
get => (string)GetValue(CaptionProperty);
|
||||
set => SetValue(CaptionProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class IoPsuResistanceSummaryConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is IoPsuData data)
|
||||
{
|
||||
return $"Realtime: {data.Resistance:F1}Ω" +
|
||||
$"\r\nLimit High: {data.ResistanceLimitMax:F1}Ω" +
|
||||
$"\r\nVoltage: {data.OutputVoltageFeedback:F1}V" +
|
||||
$"\r\nAmps: {data.OutputArmsFeedBack:F1}A";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.ModuleStatusIndicator"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Controls"
|
||||
xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="50" d:DesignWidth="800"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_terms"
|
||||
SnapsToDevicePixels="True">
|
||||
<UserControl.Resources>
|
||||
<converters:BoolReverseConverter x:Key="BoolReverseConverter"/>
|
||||
<converters:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
|
||||
<local:ModuleIsOnlineToBgColorConverter x:Key="IsOnlineToBdrColor"/>
|
||||
<local:ModuleStatusToBackgroundColorConverter x:Key="StatusToBgColor"/>
|
||||
</UserControl.Resources>
|
||||
<DockPanel LastChildFill="True" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Mode=OneTime}">
|
||||
<Label
|
||||
DockPanel.Dock="Left"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
Width="{Binding CaptionWidth}"
|
||||
BorderBrush="{Binding IsOnline, Converter={StaticResource IsOnlineToBdrColor}}"
|
||||
Content="{Binding Caption}"
|
||||
ToolTip="{Binding ModuleDescription}"
|
||||
Style="{StaticResource TopLable_LeftTop}"
|
||||
HorizontalAlignment="Left"
|
||||
d:Content="Caption"
|
||||
d:BorderBrush="{SolidColorBrush LawnGreen}">
|
||||
<Label.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
x:Name="CmSetOnline"
|
||||
Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.Content}"
|
||||
HeaderStringFormat="Set {0} Online"
|
||||
IsEnabled="{Binding IsOnline, Converter={StaticResource BoolReverseConverter}}"
|
||||
Click="CmSetOnline_OnClick"/>
|
||||
<MenuItem
|
||||
x:Name="CmSetOffline"
|
||||
Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.Content}"
|
||||
HeaderStringFormat="Set {0} Offline"
|
||||
IsEnabled="{Binding IsOnline}"
|
||||
Click="CmSetOffline_OnClick"/>
|
||||
</ContextMenu>
|
||||
</Label.ContextMenu>
|
||||
</Label>
|
||||
|
||||
<Grid>
|
||||
<Image
|
||||
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/SystemLog/Warning.png"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0 0 10 0"
|
||||
Height="16"
|
||||
Width="16"
|
||||
Visibility="{Binding HasWarning, Converter={StaticResource BoolVisibilityConverter}, ConverterParameter=True}"
|
||||
ToolTip="{Binding WarningTip}"
|
||||
Panel.ZIndex="999"/>
|
||||
<TextBox
|
||||
VerticalContentAlignment="Center"
|
||||
Background="{Binding Status, Converter={StaticResource StatusToBgColor}}"
|
||||
BorderBrush="{Binding IsOnline, Converter={StaticResource IsOnlineToBdrColor}}"
|
||||
Style="{StaticResource TextBox_Top}"
|
||||
Text="{lex:Loc {Binding Status, Mode=OneWay}}"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"/>
|
||||
</Grid>
|
||||
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.UI.Client.Core;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ModuleStatusIndicator.xaml
|
||||
/// </summary>
|
||||
public partial class ModuleStatusIndicator : UserControl
|
||||
{
|
||||
public ModuleStatusIndicator()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
#region DP - Caption
|
||||
|
||||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register(
|
||||
nameof(Caption), typeof(string), typeof(ModuleStatusIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回标题
|
||||
/// </summary>
|
||||
public string Caption
|
||||
{
|
||||
get => (string)GetValue(CaptionProperty);
|
||||
set => SetValue(CaptionProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - Caption Width
|
||||
|
||||
public static readonly DependencyProperty CaptionWidthProperty = DependencyProperty.Register(
|
||||
nameof(CaptionWidth), typeof(double), typeof(ModuleStatusIndicator), new PropertyMetadata(100.0d));
|
||||
|
||||
public double CaptionWidth
|
||||
{
|
||||
get => (double)GetValue(CaptionWidthProperty);
|
||||
set => SetValue(CaptionWidthProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - Status
|
||||
|
||||
public static readonly DependencyProperty StatusProperty = DependencyProperty.Register(
|
||||
nameof(Status), typeof(string), typeof(ModuleStatusIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
public string Status
|
||||
{
|
||||
get => (string)GetValue(StatusProperty);
|
||||
set => SetValue(StatusProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - IsOnline
|
||||
|
||||
public static readonly DependencyProperty IsOnlineProperty = DependencyProperty.Register(
|
||||
nameof(IsOnline), typeof(bool), typeof(ModuleStatusIndicator), new PropertyMetadata(default(bool)));
|
||||
|
||||
public bool IsOnline
|
||||
{
|
||||
get => (bool)GetValue(IsOnlineProperty);
|
||||
set => SetValue(IsOnlineProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - ModuleName
|
||||
|
||||
public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
|
||||
nameof(ModuleName), typeof(string), typeof(ModuleStatusIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
public string ModuleName
|
||||
{
|
||||
get => (string)GetValue(ModuleNameProperty);
|
||||
set => SetValue(ModuleNameProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - Module Description
|
||||
|
||||
public static readonly DependencyProperty ModuleDescriptionProperty = DependencyProperty.Register(
|
||||
nameof(ModuleDescription), typeof(string), typeof(ModuleStatusIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
public string ModuleDescription
|
||||
{
|
||||
get => (string)GetValue(ModuleDescriptionProperty);
|
||||
set => SetValue(ModuleDescriptionProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - HasWarning
|
||||
|
||||
public static readonly DependencyProperty HasWarningProperty = DependencyProperty.Register(
|
||||
nameof(HasWarning), typeof(bool), typeof(ModuleStatusIndicator), new PropertyMetadata(default(bool)));
|
||||
|
||||
public bool HasWarning
|
||||
{
|
||||
get => (bool)GetValue(HasWarningProperty);
|
||||
set => SetValue(HasWarningProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - WarningTips
|
||||
|
||||
public static readonly DependencyProperty WarningTipProperty = DependencyProperty.Register(
|
||||
nameof(WarningTip), typeof(string), typeof(ModuleStatusIndicator), new PropertyMetadata(default(string)));
|
||||
|
||||
public string WarningTip
|
||||
{
|
||||
get => (string)GetValue(WarningTipProperty);
|
||||
set => SetValue(WarningTipProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - SetOnline Command
|
||||
|
||||
public static readonly DependencyProperty SetOnlineCommandProperty = DependencyProperty.Register(
|
||||
nameof(SetOnlineCommand), typeof(ICommand), typeof(ModuleStatusIndicator), new PropertyMetadata(default(ICommand)));
|
||||
|
||||
public ICommand SetOnlineCommand
|
||||
{
|
||||
get => (ICommand)GetValue(SetOnlineCommandProperty);
|
||||
set => SetValue(SetOnlineCommandProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DP - SetOffline Command
|
||||
|
||||
public static readonly DependencyProperty SetOfflineCommandProperty = DependencyProperty.Register(
|
||||
nameof(SetOfflineCommand), typeof(ICommand), typeof(ModuleStatusIndicator), new PropertyMetadata(default(ICommand)));
|
||||
|
||||
public ICommand SetOfflineCommand
|
||||
{
|
||||
get => (ICommand)GetValue(SetOfflineCommandProperty);
|
||||
set => SetValue(SetOfflineCommandProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handler
|
||||
|
||||
private void CmSetOnline_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RaiseEvent(new RoutedEventArgs(SetOnlineEvent));
|
||||
}
|
||||
|
||||
private void CmSetOffline_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
RaiseEvent(new RoutedEventArgs(SetOfflineEvent));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Routed Events
|
||||
|
||||
public static readonly RoutedEvent SetOnlineEvent = EventManager.RegisterRoutedEvent(nameof(SetOnline), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UserControl));
|
||||
|
||||
public event RoutedEventHandler SetOnline
|
||||
{
|
||||
add => AddHandler(SetOnlineEvent, value);
|
||||
remove => RemoveHandler(SetOnlineEvent, value);
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent SetOfflineEvent = EventManager.RegisterRoutedEvent(nameof(SetOffline), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(UserControl));
|
||||
|
||||
public event RoutedEventHandler SetOffline
|
||||
{
|
||||
add => AddHandler(SetOfflineEvent, value);
|
||||
remove => RemoveHandler(SetOfflineEvent, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
internal class ModuleIsOnlineToBgColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool isOnline)
|
||||
{
|
||||
return isOnline
|
||||
? Helper.FindSkinResource("TopFrame_TableBG_Highligh", new SolidColorBrush(Colors.LawnGreen))
|
||||
: Helper.FindSkinResource("TopFrame_TableBD_Highlight", new SolidColorBrush(Colors.Gray));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal class ModuleStatusToBackgroundColorConverter : IValueConverter
|
||||
{
|
||||
private static SolidColorBrush GetStatusBackground(string status)
|
||||
{
|
||||
SolidColorBrush brush;
|
||||
|
||||
if (status != null)
|
||||
status = status.Trim().ToLower();
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case "error":
|
||||
brush = Helper.FindSkinResource("TopFrame_TableBG_Error", new SolidColorBrush(Colors.OrangeRed));
|
||||
break;
|
||||
case "processidle":
|
||||
case "vacidle":
|
||||
case "idle":
|
||||
case "manual":
|
||||
brush = Helper.FindSkinResource("TopFrame_TableBG_Common", new SolidColorBrush(Colors.White));
|
||||
break;
|
||||
case "notconnect":
|
||||
case "init":
|
||||
brush = Helper.FindSkinResource("TopFrame_TableBG_Init", new SolidColorBrush(Colors.Yellow));
|
||||
break;
|
||||
case "offline":
|
||||
case "notinstall":
|
||||
brush = Helper.FindSkinResource("TopFrame_TableBG_Lowlight", new SolidColorBrush(Colors.Gray));
|
||||
break;
|
||||
|
||||
default:
|
||||
brush = Helper.FindSkinResource("TopFrame_TableBG_Highlight", new SolidColorBrush(Colors.LawnGreen));
|
||||
break;
|
||||
}
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string status)
|
||||
{
|
||||
return GetStatusBackground(status);
|
||||
}
|
||||
|
||||
return Colors.BlanchedAlmond;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.PanelLocker"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="1000" d:DesignWidth="1000"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_messagebox">
|
||||
<Border Background="Transparent">
|
||||
<Border Width="318" Height="148"
|
||||
BorderBrush="{DynamicResource Button_BG}"
|
||||
BorderThickness="10,10,10,10" CornerRadius="10,10,10,10"
|
||||
Background="{DynamicResource Color_BD_LoginPanel}"
|
||||
Padding="5,5,5,5">
|
||||
<Grid VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{lex:Loc ID_TXT_InputPasswordToUnlock}" HorizontalAlignment="Center" Margin="0,0,10,5" VerticalAlignment="Center"/>
|
||||
<PasswordBox
|
||||
x:Name="txtPass" Grid.Column="1" Height="28"
|
||||
HorizontalContentAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
MaxLength="15" Grid.Row="1"
|
||||
FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"
|
||||
PreviewKeyDown="TxtPass_OnPreviewKeyDown"/>
|
||||
<TextBlock x:Name="txtInfo" Grid.Row="2" Grid.ColumnSpan="3" FontSize="9" HorizontalAlignment="Center" Margin="0,5,0,0" FontStyle="Italic" Foreground="Red"/>
|
||||
<Button
|
||||
x:Name="btnUnlock" Content="{lex:Loc ID_BTN_Unlock_Content}"
|
||||
Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"
|
||||
HorizontalAlignment="Center" Margin="0,10,0,0"
|
||||
Click="BtnUnlock_OnClick"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,296 @@
|
||||
// /************************************************************************
|
||||
// * @file RecipeLockPanel.xaml.cs
|
||||
// * @author Su Liang
|
||||
// * @date 2023/03/08
|
||||
// *
|
||||
// * @copyright © Sicentury Inc.
|
||||
// *
|
||||
// * @brief
|
||||
// *
|
||||
// * @details
|
||||
// *
|
||||
// *
|
||||
// * *****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using Aitex.Core.Util;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using Panel = System.Windows.Controls.Panel;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
||||
{
|
||||
public partial class PanelLocker
|
||||
{
|
||||
/// <summary>
|
||||
/// 锁定时背景模糊半径
|
||||
/// </summary>
|
||||
private const double BLUR_RADIUS = 30;
|
||||
|
||||
/// <summary>
|
||||
/// 默认密码admin的SHA256
|
||||
/// </summary>
|
||||
private const string DEF_PASSWORD = "8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918";
|
||||
|
||||
// 阻止密码攻击定时器
|
||||
private readonly DeviceTimer _timPassAttackDetector;
|
||||
|
||||
// 密码连续重试次数
|
||||
private int _retryTimes;
|
||||
|
||||
// 自动锁定计时器
|
||||
private readonly Stopwatch _swAutoLock;
|
||||
|
||||
private PeriodicJob _pjobAutoLock;
|
||||
|
||||
private int _timeoutAutoLock = int.MaxValue;
|
||||
|
||||
public PanelLocker()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_timPassAttackDetector = new DeviceTimer();
|
||||
_retryTimes = 0;
|
||||
|
||||
_pjobAutoLock = new PeriodicJob(int.MaxValue, () =>
|
||||
{
|
||||
Dispatcher.Invoke(Lock);
|
||||
return true;
|
||||
}, "AutoLockRecipeEditor");
|
||||
|
||||
// Lock面板加载后,或重新激活后,将焦点自动设置到PasswordBox
|
||||
Loaded += (sender, args) =>
|
||||
{
|
||||
txtPass.Focus();
|
||||
};
|
||||
}
|
||||
|
||||
#region Dps
|
||||
|
||||
public static readonly DependencyProperty LockTargetProperty = DependencyProperty.Register(
|
||||
nameof(LockTarget), typeof(Panel), typeof(PanelLocker), new PropertyMetadata(default(Panel), (sender, args) =>
|
||||
{
|
||||
// 初次拿到LockTarget对象时,锁定对象
|
||||
if (sender is PanelLocker pl && args.NewValue is Panel)
|
||||
{
|
||||
pl.Lock();
|
||||
}
|
||||
}));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回待锁定的界面
|
||||
/// </summary>
|
||||
public Panel LockTarget
|
||||
{
|
||||
get => (Panel)GetValue(LockTargetProperty);
|
||||
set => SetValue(LockTargetProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty ScPathPasswordProperty = DependencyProperty.Register(
|
||||
nameof(ScPathPassword), typeof(string), typeof(PanelLocker), new PropertyMetadata("System.Recipe.EditorPassword"));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回SC中存放密码的节点。
|
||||
/// </summary>
|
||||
public string ScPathPassword
|
||||
{
|
||||
get => (string)GetValue(ScPathPasswordProperty);
|
||||
set => SetValue(ScPathPasswordProperty, value);
|
||||
}
|
||||
|
||||
|
||||
public static readonly DependencyProperty ScPathIsResetPasswordProperty = DependencyProperty.Register(
|
||||
nameof(ScPathIsResetPassword), typeof(string), typeof(PanelLocker), new PropertyMetadata("System.Recipe.ResetEditorPassword"));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回SC中复位密码的节点。
|
||||
/// </summary>
|
||||
public string ScPathIsResetPassword
|
||||
{
|
||||
get => (string)GetValue(ScPathIsResetPasswordProperty);
|
||||
set => SetValue(ScPathIsResetPasswordProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OpPathSetNewPasswordProperty = DependencyProperty.Register(
|
||||
nameof(OpPathSetNewPassword), typeof(string), typeof(PanelLocker), new PropertyMetadata("System.SetNewRecipeEditorPassword"));
|
||||
|
||||
/// <summary>
|
||||
/// 设置或返回RT中注册的用于设置新密码的OP。
|
||||
/// </summary>
|
||||
public string OpPathSetNewPassword
|
||||
{
|
||||
get => (string)GetValue(OpPathSetNewPasswordProperty);
|
||||
set => SetValue(OpPathSetNewPasswordProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OpPathResetPasswordToDefaultProperty = DependencyProperty.Register(
|
||||
nameof(OpPathResetPasswordToDefault), typeof(string), typeof(PanelLocker), new PropertyMetadata("System.ResetRecipeEditorPassword"));
|
||||
|
||||
public string OpPathResetPasswordToDefault
|
||||
{
|
||||
get => (string)GetValue(OpPathResetPasswordToDefaultProperty);
|
||||
set => SetValue(OpPathResetPasswordToDefaultProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
txtPass.Focus();
|
||||
}
|
||||
|
||||
public void Lock()
|
||||
{
|
||||
txtPass.Password = "";
|
||||
txtInfo.Text = "";
|
||||
|
||||
LockTarget.Effect = new BlurEffect();
|
||||
Visibility = Visibility.Visible;
|
||||
var aniBlurFadeOut = new DoubleAnimation(0, BLUR_RADIUS, new Duration(TimeSpan.FromMilliseconds(300)));
|
||||
LockTarget.Effect.BeginAnimation(BlurEffect.RadiusProperty, aniBlurFadeOut);
|
||||
|
||||
// 停止自动锁定计时器
|
||||
//_swAutoLock.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置自动锁定超时计时器
|
||||
/// </summary>
|
||||
public void ResetAutoLockTimer()
|
||||
{
|
||||
_pjobAutoLock.Stop();
|
||||
_pjobAutoLock.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验密码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool CheckPassword()
|
||||
{
|
||||
// 是否请求重置密码
|
||||
var reqResetPass = (bool)QueryDataClient.Instance.Service.GetConfig(ScPathIsResetPassword);
|
||||
if (reqResetPass)
|
||||
{
|
||||
// 密码重置为admin
|
||||
InvokeClient.Instance.Service.DoOperation(OpPathResetPasswordToDefault, DEF_PASSWORD);
|
||||
}
|
||||
|
||||
// 读取系统配置中的Password,如果读取失败,使用默认密码admin
|
||||
var passInSc = QueryDataClient.Instance.Service.GetConfig(ScPathPassword).ToString();
|
||||
if (string.IsNullOrEmpty(passInSc))
|
||||
passInSc = DEF_PASSWORD;
|
||||
|
||||
using (var sha = SHA256.Create())
|
||||
{
|
||||
var bytesHash = sha.ComputeHash(Encoding.UTF8.GetBytes(txtPass.Password));
|
||||
var passInput = BitConverter.ToString(bytesHash).Replace("-", "");
|
||||
if (passInput == passInSc)
|
||||
{
|
||||
txtPass.Password = "";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 检测是否5s内重试密码5次以上。
|
||||
if (_timPassAttackDetector.IsIdle() || _timPassAttackDetector.IsTimeout())
|
||||
{
|
||||
_timPassAttackDetector.Start(5000);
|
||||
_retryTimes = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_retryTimes++;
|
||||
if (_retryTimes > 5)
|
||||
{
|
||||
btnUnlock.IsEnabled = false;
|
||||
txtPass.IsEnabled = false;
|
||||
|
||||
// 如果5s内重试的次数大于5次,禁用解锁窗口5秒钟
|
||||
Task.Run(() =>
|
||||
{
|
||||
var deniedSec = 5;
|
||||
while (deniedSec-- > 0)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
txtInfo.Text = $"You have retried too many times, try again in {deniedSec} seconds";
|
||||
});
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
txtInfo.Text = "";
|
||||
btnUnlock.IsEnabled = true;
|
||||
txtPass.IsEnabled = true;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
txtInfo.Text = "Incorrect Password";
|
||||
txtPass.Password = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
private void BtnUnlock_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!CheckPassword())
|
||||
{
|
||||
txtPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (LockTarget.Effect is BlurEffect eff)
|
||||
{
|
||||
var aniBlurFadeOut = new DoubleAnimation(BLUR_RADIUS, 0, new Duration(TimeSpan.FromMilliseconds(300)));
|
||||
eff.BeginAnimation(BlurEffect.RadiusProperty, aniBlurFadeOut);
|
||||
}
|
||||
|
||||
LockTarget.Effect = null;
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 启动自动锁定计时器
|
||||
/*var autoLockTimeout = (int)QueryDataClient.Instance.Service.GetConfig("System.RecipeEditorAutoLockTimeout");
|
||||
if (autoLockTimeout <= 0)
|
||||
autoLockTimeout = 60;
|
||||
_swAutoLock.Interval = autoLockTimeout;
|
||||
_swAutoLock.Start();*/
|
||||
}
|
||||
|
||||
private void TxtPass_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
BtnUnlock_OnClick(this, new RoutedEventArgs());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<Window x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.PanelLockerPasswordChanger"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
Title="Change Password" Height="220" Width="356"
|
||||
WindowStyle="ToolWindow"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<Style TargetType="PasswordBox">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Height" Value="25"/>
|
||||
<Setter Property="MaxLength" Value="15"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
<Setter Property="Margin" Value="0 0 10 0"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="35"/>
|
||||
<RowDefinition Height="35"/>
|
||||
<RowDefinition Height="35"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="Old Password"/>
|
||||
<TextBlock Grid.Row="1" Text="New Password"/>
|
||||
<TextBlock Grid.Row="2" Text="Confirm Password"/>
|
||||
|
||||
<PasswordBox x:Name="txtOldPass" Grid.Row="0" Grid.Column="1" FocusManager.FocusedElement="{Binding RelativeSource={RelativeSource Self}}"/>
|
||||
<PasswordBox x:Name="txtNewPass" Grid.Row="1" Grid.Column="1" />
|
||||
<PasswordBox x:Name="txtConfirmPass" Grid.Row="2" Grid.Column="1" />
|
||||
|
||||
<TextBlock x:Name="txtInfo" Text="" Grid.Row="3" HorizontalAlignment="Center" Grid.ColumnSpan="2" FontStyle="Italic" Foreground="Red" Margin="0,5,0,5"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="4" VerticalAlignment="Center" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,5,0,0">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="Width" Value="70"/>
|
||||
<Setter Property="Margin" Value="2 0"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button x:Name="btnOk" Content="OK" Click="btnOk_Click"/>
|
||||
<Button x:Name="btnCancel" Content="Cancel" Click="btnCancel_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,84 @@
|
||||
// /************************************************************************
|
||||
// * @file PasswordChangeDialog.xaml.cs
|
||||
// * @author Su Liang
|
||||
// * @date 2023/03/09
|
||||
// *
|
||||
// * @copyright © Sicentury Inc.
|
||||
// *
|
||||
// * @brief
|
||||
// *
|
||||
// * @details
|
||||
// *
|
||||
// *
|
||||
// * *****************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.Common.Utilities;
|
||||
|
||||
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
||||
{
|
||||
public partial class PanelLockerPasswordChanger : Window
|
||||
{
|
||||
public PanelLockerPasswordChanger()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
base.OnRender(drawingContext);
|
||||
txtOldPass.Focus();
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
#region Validation
|
||||
|
||||
if (txtOldPass.Password == "")
|
||||
{
|
||||
txtInfo.Text = "Invalid Old Password";
|
||||
txtOldPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (txtNewPass.Password == "")
|
||||
{
|
||||
txtInfo.Text = "Invalid New Password";
|
||||
txtNewPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (txtNewPass.Password != txtConfirmPass.Password)
|
||||
{
|
||||
txtInfo.Text = "New password does not equal to Confirm Password";
|
||||
txtNewPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
if (txtNewPass.Password == txtOldPass.Password)
|
||||
{
|
||||
txtInfo.Text = "New password can not be equal to old password";
|
||||
txtOldPass.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// 获取密码密文
|
||||
var oldPassHash = Sha256.EncodeString(txtOldPass.Password);
|
||||
var newPassHash = Sha256.EncodeString(txtNewPass.Password);
|
||||
|
||||
// 发送到RT进行保存
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetNewRecipeEditorPassword", oldPassHash, newPassHash);
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,458 @@
|
||||
using OpenSEMI.Ctrlib.Types;
|
||||
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.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;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
|
||||
public delegate void DragDropHandler(object sender, DragDropEventArgs e);
|
||||
|
||||
public class DragDropEventArgs : EventArgs
|
||||
{
|
||||
public Slot TranferFrom { get; set; }
|
||||
public Slot TranferTo { get; set; }
|
||||
|
||||
public DragDropEventArgs(Slot p_TranferFrom, Slot p_TranferTo)
|
||||
{
|
||||
this.TranferFrom = p_TranferFrom;
|
||||
this.TranferTo = p_TranferTo;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SlotBorderStatus
|
||||
{
|
||||
MouseOver = 1,
|
||||
TransferSource = 2,
|
||||
TransferTarget = 4,
|
||||
Selected = 8,
|
||||
None = 16
|
||||
}
|
||||
|
||||
public class Slot : ContentControl
|
||||
{
|
||||
public event MouseButtonEventHandler SlotMouseButtonDown;
|
||||
public event DragDropHandler WaferTransferStarted;
|
||||
|
||||
static Slot()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Slot), new FrameworkPropertyMetadata(typeof(Slot)));
|
||||
}
|
||||
|
||||
|
||||
public bool IsDraggable { get; set; }
|
||||
public bool IsLeftMouseDown { get; set; } //confirm drag source is current slot
|
||||
|
||||
public string ViewType
|
||||
{
|
||||
get { return (string)GetValue(ViewTypeProperty); }
|
||||
set { SetValue(ViewTypeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ViewTypeProperty =
|
||||
DependencyProperty.Register("ViewType", typeof(string), typeof(Slot),
|
||||
new UIPropertyMetadata("Front"));
|
||||
|
||||
|
||||
public int WaferStatus
|
||||
{
|
||||
get { return (int)GetValue(WaferStatusProperty); }
|
||||
set { SetValue(WaferStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferStatusProperty =
|
||||
DependencyProperty.Register("WaferStatus", typeof(int), typeof(Slot),
|
||||
new UIPropertyMetadata(0, new PropertyChangedCallback(WaferStatusChangedCallBack)));
|
||||
|
||||
public int TrayStatus
|
||||
{
|
||||
get { return (int)GetValue(TrayStatusProperty); }
|
||||
set { SetValue(TrayStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TrayStatusProperty =
|
||||
DependencyProperty.Register("TrayStatus", typeof(int), typeof(Slot),
|
||||
new UIPropertyMetadata(0, new PropertyChangedCallback(TrayStatusChangedCallBack)));
|
||||
|
||||
public string TrayBelongTo
|
||||
{
|
||||
get { return (string)GetValue(TrayBelongToProperty); }
|
||||
set { SetValue(TrayBelongToProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TrayBelongToProperty =
|
||||
DependencyProperty.Register("TrayBelongTo", typeof(string), typeof(Slot),
|
||||
new UIPropertyMetadata("", new PropertyChangedCallback(TrayStatusChangedCallBack)));
|
||||
|
||||
public int SlotID
|
||||
{
|
||||
get { return (int)GetValue(SlotIDProperty); }
|
||||
set { SetValue(SlotIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SlotIDProperty =
|
||||
DependencyProperty.Register("SlotID", typeof(int), typeof(Slot), new UIPropertyMetadata(-1));
|
||||
|
||||
|
||||
public string LotID
|
||||
{
|
||||
get { return (string)GetValue(LotIDProperty); }
|
||||
set { SetValue(LotIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty LotIDProperty =
|
||||
DependencyProperty.Register("LotID", typeof(string), typeof(Slot), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
public int TrayProcessCount
|
||||
{
|
||||
get { return (int)GetValue(TrayProcessCountProperty); }
|
||||
set { SetValue(TrayProcessCountProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TrayProcessCountProperty =
|
||||
DependencyProperty.Register("TrayProcessCount", typeof(int), typeof(Slot), new UIPropertyMetadata(0));
|
||||
|
||||
public string RecipeName
|
||||
{
|
||||
get { return (string)GetValue(RecipeNameProperty); }
|
||||
set { SetValue(RecipeNameProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty RecipeNameProperty =
|
||||
DependencyProperty.Register("RecipeName", typeof(string), typeof(Slot), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
public string ModuleID
|
||||
{
|
||||
get { return (string)GetValue(ModuleIDProperty); }
|
||||
set { SetValue(ModuleIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ModuleIDProperty =
|
||||
DependencyProperty.Register("ModuleID", typeof(string), typeof(Slot), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
public bool IsDragSource
|
||||
{
|
||||
get { return (bool)GetValue(IsDragSourceProperty); }
|
||||
set { SetValue(IsDragSourceProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDragSourceProperty =
|
||||
DependencyProperty.Register("IsDragSource", typeof(bool), typeof(Slot),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDragSourcePropertyChangedCallBack)));
|
||||
|
||||
public bool IsDropTarget
|
||||
{
|
||||
get { return (bool)GetValue(IsDropTargetProperty); }
|
||||
set { SetValue(IsDropTargetProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDropTargetProperty =
|
||||
DependencyProperty.Register("IsDropTarget", typeof(bool), typeof(Slot),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDropTargetPropertyChangedCallBack)));
|
||||
|
||||
public bool IsDragEnter
|
||||
{
|
||||
get { return (bool)GetValue(IsDragEnterProperty); }
|
||||
set { SetValue(IsDragEnterProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsDragEnterProperty =
|
||||
DependencyProperty.Register("IsDragEnter", typeof(bool), typeof(Slot),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsDragEnterPropertyChangedCallBack)));
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return (bool)GetValue(IsSelectedProperty); }
|
||||
set { SetValue(IsSelectedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsSelectedProperty =
|
||||
DependencyProperty.Register("IsSelected", typeof(bool), typeof(Slot),
|
||||
new UIPropertyMetadata(false, new PropertyChangedCallback(IsSelectedPropertyChangedCallBack)));
|
||||
|
||||
public bool HasWafer
|
||||
{
|
||||
get { return (bool)GetValue(HasWaferProperty); }
|
||||
set { SetValue(HasWaferProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty HasWaferProperty =
|
||||
DependencyProperty.Register("HasWafer", typeof(bool), typeof(Slot),
|
||||
new UIPropertyMetadata(false, HasWaferChanged));
|
||||
|
||||
public SlotBorderStatus BorderStatus
|
||||
{
|
||||
get { return (SlotBorderStatus)GetValue(BorderStatusProperty); }
|
||||
set { SetValue(BorderStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty BorderStatusProperty =
|
||||
DependencyProperty.Register("BorderStatus", typeof(SlotBorderStatus), typeof(Slot),
|
||||
new UIPropertyMetadata(SlotBorderStatus.None));
|
||||
|
||||
public string SourceName
|
||||
{
|
||||
get { return (string)GetValue(SourceNameProperty); }
|
||||
set { SetValue(SourceNameProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SourceNameProperty =
|
||||
DependencyProperty.Register("SourceName", typeof(string), typeof(Slot), new UIPropertyMetadata(string.Empty));
|
||||
|
||||
|
||||
public bool CanDragDrop
|
||||
{
|
||||
get { return (bool)GetValue(CanDragDropProperty); }
|
||||
set { SetValue(CanDragDropProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty CanDragDropProperty =
|
||||
DependencyProperty.Register("CanDragDrop", typeof(bool), typeof(Slot), new UIPropertyMetadata(true, new PropertyChangedCallback(CanDragDropPropertyChangedCallBack)));
|
||||
|
||||
public string WaferTooltip
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipProperty); }
|
||||
set { SetValue(WaferTooltipProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipProperty =
|
||||
DependencyProperty.Register("WaferTooltip", typeof(string), typeof(Slot), new PropertyMetadata(string.Empty));
|
||||
|
||||
public string WaferTooltipExt
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipExtProperty); }
|
||||
set { SetValue(WaferTooltipExtProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipExtProperty =
|
||||
DependencyProperty.Register("WaferTooltipExt", typeof(string), typeof(Slot), new PropertyMetadata(string.Empty));
|
||||
|
||||
public Visibility DuplicatedVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(DuplicatedVisibilityProperty); }
|
||||
set { SetValue(DuplicatedVisibilityProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty DuplicatedVisibilityProperty =
|
||||
DependencyProperty.Register("DuplicatedVisibility", typeof(Visibility), typeof(Slot), new UIPropertyMetadata(Visibility.Collapsed));
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
DragDropStatusControl(this);
|
||||
}
|
||||
|
||||
protected override void OnDragEnter(DragEventArgs e)
|
||||
{
|
||||
base.OnDragEnter(e);
|
||||
this.IsDragEnter = true;
|
||||
}
|
||||
|
||||
protected override void OnDragLeave(DragEventArgs e)
|
||||
{
|
||||
base.OnDragLeave(e);
|
||||
this.IsDragEnter = false;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
if (MouseButtonState.Pressed == e.LeftButton)
|
||||
IsLeftMouseDown = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
IsLeftMouseDown = false;
|
||||
|
||||
MouseButtonEventHandler handler = SlotMouseButtonDown;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseEnter(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseEnter(e);
|
||||
this.BorderStatus = this.BorderStatus | SlotBorderStatus.MouseOver;
|
||||
var tip = this.ToolTip as ToolTip;
|
||||
if (tip != null)
|
||||
tip.IsOpen = true;
|
||||
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
IsLeftMouseDown = false;
|
||||
this.BorderStatus = this.BorderStatus & (~SlotBorderStatus.MouseOver);
|
||||
var tip = this.ToolTip as ToolTip;
|
||||
if (tip != null)
|
||||
tip.IsOpen = false;
|
||||
}
|
||||
|
||||
private static void DragDropStatusControl(Slot p_slot)
|
||||
{
|
||||
p_slot.AllowDrop = false;
|
||||
p_slot.IsDraggable = false;
|
||||
|
||||
if (p_slot.CanDragDrop)
|
||||
{
|
||||
if (!p_slot.IsDropTarget && !((p_slot.WaferStatus > 0 && p_slot.WaferStatus < 10) && p_slot.TrayStatus != 0))
|
||||
p_slot.AllowDrop = true;
|
||||
|
||||
if (!p_slot.IsDragSource && ((p_slot.WaferStatus > 0 && p_slot.WaferStatus < 10) || p_slot.TrayStatus != 0))
|
||||
p_slot.IsDraggable = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static void IsDropTargetPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
|
||||
if (m_slot.IsDropTarget)
|
||||
m_slot.BorderStatus = m_slot.BorderStatus | SlotBorderStatus.TransferTarget; //add
|
||||
else
|
||||
m_slot.BorderStatus = m_slot.BorderStatus & (~SlotBorderStatus.TransferTarget); //remove
|
||||
|
||||
DragDropStatusControl(m_slot);
|
||||
}
|
||||
|
||||
private static void IsDragSourcePropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
|
||||
if (m_slot.IsDragSource)
|
||||
m_slot.BorderStatus = m_slot.BorderStatus | SlotBorderStatus.TransferSource; //add
|
||||
else
|
||||
m_slot.BorderStatus = m_slot.BorderStatus & (~SlotBorderStatus.TransferSource); //remove
|
||||
|
||||
DragDropStatusControl(m_slot);
|
||||
}
|
||||
|
||||
private static void IsSelectedPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
|
||||
if (m_slot.IsSelected)
|
||||
m_slot.BorderStatus = m_slot.BorderStatus | SlotBorderStatus.Selected; //add
|
||||
else
|
||||
m_slot.BorderStatus = m_slot.BorderStatus & (~SlotBorderStatus.Selected); //remove
|
||||
}
|
||||
|
||||
private static void CanDragDropPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
DragDropStatusControl(m_slot);
|
||||
}
|
||||
|
||||
private static void IsDragEnterPropertyChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
|
||||
if (m_slot.IsDragEnter)
|
||||
m_slot.BorderStatus = m_slot.BorderStatus | SlotBorderStatus.TransferTarget; //add
|
||||
else
|
||||
m_slot.BorderStatus = m_slot.BorderStatus & (~SlotBorderStatus.TransferTarget); //remove
|
||||
}
|
||||
|
||||
private static void WaferStatusChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
m_slot.IsDragSource = false;
|
||||
m_slot.IsDropTarget = false;
|
||||
m_slot.IsDragEnter = false;
|
||||
DragDropStatusControl(m_slot);
|
||||
}
|
||||
|
||||
private static void TrayStatusChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
m_slot.IsDragSource = false;
|
||||
m_slot.IsDropTarget = false;
|
||||
m_slot.IsDragEnter = false;
|
||||
DragDropStatusControl(m_slot);
|
||||
}
|
||||
|
||||
public static void HasWaferChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
Slot m_slot = d as Slot;
|
||||
if (m_slot != null)
|
||||
{
|
||||
if (m_slot.HasWafer)
|
||||
m_slot.WaferStatus = 7;
|
||||
else
|
||||
m_slot.WaferStatus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseMove(e);
|
||||
if (e.LeftButton == MouseButtonState.Pressed && IsDraggable && IsLeftMouseDown)
|
||||
{
|
||||
DataObject data = new DataObject(typeof(Slot), this);
|
||||
DragDrop.DoDragDrop(this, data, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDrop(DragEventArgs e)
|
||||
{
|
||||
if (this.AllowDrop)
|
||||
{
|
||||
try
|
||||
{
|
||||
IDataObject data = e.Data;
|
||||
if (data.GetDataPresent(typeof(Slot)))
|
||||
{
|
||||
Slot m_dragSource = (Slot)data.GetData(typeof(Slot));
|
||||
m_dragSource.IsDragSource = true; //source
|
||||
this.IsDropTarget = true; //target
|
||||
if (WaferTransferStarted != null)
|
||||
{
|
||||
DragDropEventArgs m_arg = new DragDropEventArgs(m_dragSource, this);
|
||||
WaferTransferStarted(this, m_arg);
|
||||
}
|
||||
}
|
||||
else //to support another type of wafer
|
||||
{
|
||||
//var sourceWafer = (WaferInfo)e.Data.GetData("Object");
|
||||
var sourceStation = e.Data.GetData("Station").ToString();
|
||||
var sourceSlot = (int)e.Data.GetData("Slot");
|
||||
Slot m_dragSource = new Slot() { ModuleID = sourceStation, SlotID = sourceSlot };
|
||||
if (WaferTransferStarted != null)
|
||||
{
|
||||
DragDropEventArgs m_arg = new DragDropEventArgs(m_dragSource, this);
|
||||
WaferTransferStarted(this, m_arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsValidSlot()
|
||||
{
|
||||
if (this.ModuleID.Length > 0 && this.SlotID >= 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsSameSlot(Slot slot)
|
||||
{
|
||||
if (slot.IsValidSlot() && this.IsValidSlot())
|
||||
{
|
||||
if (this.ModuleID == slot.ModuleID && this.SlotID == slot.SlotID)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void ClearDragDropStatus()
|
||||
{
|
||||
this.IsDragEnter = false;
|
||||
this.IsDragSource = false;
|
||||
this.IsDropTarget = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class SwitchButton : Button
|
||||
{
|
||||
public static readonly DependencyProperty ONProperty;
|
||||
static SwitchButton()
|
||||
{
|
||||
ONProperty = DependencyProperty.Register("ON", typeof(bool), typeof(SwitchButton));
|
||||
}
|
||||
|
||||
public bool ON
|
||||
{
|
||||
get { return (bool)GetValue(ONProperty); }
|
||||
set { SetValue(ONProperty, value); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
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;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public enum EditBoxMode
|
||||
{
|
||||
Default,
|
||||
SignInteger,
|
||||
UnSignInteger,
|
||||
Decimal,
|
||||
UnSignDecimal,
|
||||
Email,
|
||||
Time,
|
||||
FileName
|
||||
}
|
||||
|
||||
public class TextBoxEx : TextBox
|
||||
{
|
||||
public event KeyEventHandler TextBoxExEnterKeyDown;
|
||||
|
||||
#region define fields & properties
|
||||
private string m_strOldValue = string.Empty;
|
||||
|
||||
public EditBoxMode EditBoxMode
|
||||
{
|
||||
get { return (EditBoxMode)GetValue(EditBoxModeProperty); }
|
||||
set { SetValue(EditBoxModeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty EditBoxModeProperty = DependencyProperty.Register("EditBoxMode", typeof(EditBoxMode), typeof(TextBoxEx), new UIPropertyMetadata(EditBoxMode.Default));
|
||||
|
||||
#region NormalColor (DependencyProperty)
|
||||
public static readonly DependencyProperty NormalColorProperty = DependencyProperty.Register("NormalColor", typeof(Brush), typeof(TextBoxEx));
|
||||
public Brush NormalColor
|
||||
{
|
||||
get { return (Brush)GetValue(NormalColorProperty); }
|
||||
set { SetValue(NormalColorProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ChangedColor (DependencyProperty)
|
||||
public static readonly DependencyProperty ChangedColorProperty = DependencyProperty.Register("ChangedColor", typeof(Brush), typeof(TextBoxEx));
|
||||
public Brush ChangedColor
|
||||
{
|
||||
get { return (Brush)GetValue(ChangedColorProperty); }
|
||||
set { SetValue(ChangedColorProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WarningColor (DependencyProperty)
|
||||
public static readonly DependencyProperty WarningColorProperty = DependencyProperty.Register("WarningColor", typeof(Brush), typeof(TextBoxEx));
|
||||
public Brush WarningColor
|
||||
{
|
||||
get { return (Brush)GetValue(WarningColorProperty); }
|
||||
set { SetValue(WarningColorProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
private bool m_AllowEmpty = true;
|
||||
public bool AllowEmpty
|
||||
{
|
||||
get { return m_AllowEmpty; }
|
||||
set { m_AllowEmpty = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is a flag to indicate that whether to change the bg color
|
||||
/// when the text changed by backgroud not by GUI side.
|
||||
/// This flag is true when control is bound to display text from dialog
|
||||
/// </summary>
|
||||
private bool m_AllowBackgroundChange = true;
|
||||
public bool AllowBackgroundChange
|
||||
{
|
||||
get { return m_AllowBackgroundChange; }
|
||||
set { m_AllowBackgroundChange = value; }
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
//this.TextSaved = true;
|
||||
}
|
||||
#region MaxValue (DependencyProperty)
|
||||
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register("MaxValue", typeof(double), typeof(TextBoxEx), new UIPropertyMetadata(double.NaN));
|
||||
public double MaxValue
|
||||
{
|
||||
get { return (double)GetValue(MaxValueProperty); }
|
||||
set { SetValue(MaxValueProperty, value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MinValue (DependencyProperty)
|
||||
public double MinValue
|
||||
{
|
||||
get { return (double)GetValue(MinValueProperty); }
|
||||
set { SetValue(MinValueProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register("MinValue", typeof(double), typeof(TextBoxEx), new UIPropertyMetadata(double.NaN));
|
||||
#endregion
|
||||
|
||||
#region Accuracy (DependencyProperty)
|
||||
public Int32 Accuracy
|
||||
{
|
||||
get { return (Int32)GetValue(AccuracyProperty); }
|
||||
set { SetValue(AccuracyProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty AccuracyProperty = DependencyProperty.Register("Accuracy", typeof(Int32), typeof(TextBoxEx), new UIPropertyMetadata(4));
|
||||
#endregion
|
||||
|
||||
#region TextSaved (DependencyProperty)
|
||||
public bool TextSaved
|
||||
{
|
||||
get { return (bool)GetValue(TextSavedProperty); }
|
||||
set { SetValue(TextSavedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty TextSavedProperty =
|
||||
DependencyProperty.Register("TextSaved", typeof(bool), typeof(TextBoxEx),
|
||||
new UIPropertyMetadata(true, new PropertyChangedCallback(TextSavedChangedCallBack)));
|
||||
#endregion
|
||||
|
||||
#region IsScrollToEnd (DependencyProperty)
|
||||
public Boolean IsScrollToEnd
|
||||
{
|
||||
get { return (Boolean)GetValue(ScrollToEndProperty); }
|
||||
set { SetValue(ScrollToEndProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ScrollToEndProperty = DependencyProperty.Register("IsScrollToEnd", typeof(Boolean), typeof(TextBoxEx), new UIPropertyMetadata(false));
|
||||
#endregion
|
||||
|
||||
public Boolean IsTextboxFocused
|
||||
{
|
||||
get { return (Boolean)GetValue(IsTextboxFocusedProperty); }
|
||||
set { SetValue(IsTextboxFocusedProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty IsTextboxFocusedProperty = DependencyProperty.Register("IsTextboxFocused", typeof(Boolean), typeof(TextBoxEx), new UIPropertyMetadata(false));
|
||||
#endregion
|
||||
|
||||
static TextBoxEx()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxEx), new FrameworkPropertyMetadata(typeof(TextBoxEx)));
|
||||
}
|
||||
|
||||
|
||||
#region Input Control
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
switch (this.EditBoxMode)
|
||||
{
|
||||
case EditBoxMode.SignInteger:
|
||||
AllowInteger(e);
|
||||
break;
|
||||
case EditBoxMode.UnSignInteger:
|
||||
AllowUnsignInteger(e);
|
||||
break;
|
||||
case EditBoxMode.Decimal:
|
||||
AllowDecimal(e);
|
||||
break;
|
||||
case EditBoxMode.UnSignDecimal:
|
||||
AllowUnSignDecimal(e);
|
||||
break;
|
||||
case EditBoxMode.Time:
|
||||
AllowTime(e);
|
||||
break;
|
||||
case EditBoxMode.FileName:
|
||||
AllowFileName(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AllowInteger(KeyEventArgs e)
|
||||
{
|
||||
bool isControl = ((Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Shift)
|
||||
|| e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert
|
||||
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up
|
||||
|| e.Key == Key.Tab
|
||||
|| e.Key == Key.PageDown || e.Key == Key.PageUp
|
||||
|| e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape
|
||||
|| e.Key == Key.Home || e.Key == Key.End);
|
||||
|
||||
//if (this.Text.IndexOfAny(new char[] { '-' }, 0) > -1 && this.CaretIndex == 0 && !isControl) //Disable input before minus
|
||||
//{
|
||||
// e.Handled = true;
|
||||
// return;
|
||||
//}
|
||||
|
||||
bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
|
||||
bool isNumeric = (e.Key >= Key.D0 && e.Key <= Key.D9);
|
||||
|
||||
if ((isNumeric || isNumPadNumeric) && Keyboard.Modifiers != ModifierKeys.None)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//Minus
|
||||
if (e.Key == Key.OemMinus || e.Key == Key.Subtract)
|
||||
{
|
||||
if (Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
{
|
||||
isControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (this.Text.IndexOfAny(new char[] { '-' }, 0) == -1 && this.CaretIndex == 0)
|
||||
{
|
||||
isControl = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = !isControl && !isNumeric && !isNumPadNumeric;
|
||||
}
|
||||
|
||||
private void AllowUnsignInteger(KeyEventArgs e)
|
||||
{
|
||||
bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
|
||||
bool isNumeric = (e.Key >= Key.D0 && e.Key <= Key.D9);
|
||||
|
||||
if ((isNumeric || isNumPadNumeric) && Keyboard.Modifiers != ModifierKeys.None)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool isControl = ((Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Shift)
|
||||
|| e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert
|
||||
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up
|
||||
|| e.Key == Key.Tab
|
||||
|| e.Key == Key.PageDown || e.Key == Key.PageUp
|
||||
|| e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape
|
||||
|| e.Key == Key.Home || e.Key == Key.End);
|
||||
|
||||
e.Handled = !isControl && !isNumeric && !isNumPadNumeric;
|
||||
}
|
||||
|
||||
private void AllowDecimal(KeyEventArgs e)
|
||||
{
|
||||
bool isControl = ((Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Shift)
|
||||
|| e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert
|
||||
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up
|
||||
|| e.Key == Key.Tab
|
||||
|| e.Key == Key.PageDown || e.Key == Key.PageUp
|
||||
|| e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape
|
||||
|| e.Key == Key.Home || e.Key == Key.End);
|
||||
|
||||
//if (this.Text.IndexOfAny(new char[] { '-' }, 0) > -1 && this.CaretIndex == 0 && !isControl) //Disable input before minus
|
||||
//{
|
||||
// e.Handled = true;
|
||||
// return;
|
||||
//}
|
||||
|
||||
bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
|
||||
bool isNumeric = (e.Key >= Key.D0 && e.Key <= Key.D9);
|
||||
|
||||
if ((isNumeric || isNumPadNumeric) && Keyboard.Modifiers != ModifierKeys.None)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//Minus
|
||||
if (e.Key == Key.OemMinus || e.Key == Key.Subtract)
|
||||
{
|
||||
if (Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
{
|
||||
isControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (this.Text.IndexOfAny(new char[] { '-' }, 0) == -1 && this.CaretIndex == 0)
|
||||
{
|
||||
isControl = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Decimal point
|
||||
if (e.Key == Key.OemPeriod || e.Key == Key.Decimal)
|
||||
{
|
||||
if (Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
{
|
||||
isControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Text.IndexOfAny(new char[] { '.' }, 0) == -1 && this.CaretIndex > 0
|
||||
&& this.CaretIndex + this.Accuracy >= this.Text.Length) //Accuracy
|
||||
{
|
||||
isControl = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Accuracy
|
||||
int pointIndex = this.Text.IndexOf('.');
|
||||
if (pointIndex > -1 && this.CaretIndex > pointIndex)
|
||||
{
|
||||
if (this.Text.Length - pointIndex > this.Accuracy)
|
||||
{
|
||||
isNumeric = isNumPadNumeric = false;
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = !isControl && !isNumeric && !isNumPadNumeric;
|
||||
}
|
||||
|
||||
private void AllowUnSignDecimal(KeyEventArgs e)
|
||||
{
|
||||
bool isNumPadNumeric = (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9);
|
||||
bool isNumeric = (e.Key >= Key.D0 && e.Key <= Key.D9);
|
||||
|
||||
if ((isNumeric || isNumPadNumeric) && Keyboard.Modifiers != ModifierKeys.None)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool isControl = ((Keyboard.Modifiers != ModifierKeys.None && Keyboard.Modifiers != ModifierKeys.Shift)
|
||||
|| e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Insert
|
||||
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up
|
||||
|| e.Key == Key.Tab
|
||||
|| e.Key == Key.PageDown || e.Key == Key.PageUp
|
||||
|| e.Key == Key.Enter || e.Key == Key.Return || e.Key == Key.Escape
|
||||
|| e.Key == Key.Home || e.Key == Key.End);
|
||||
|
||||
//Decimal point
|
||||
if (e.Key == Key.OemPeriod || e.Key == Key.Decimal)
|
||||
{
|
||||
if (Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
{
|
||||
isControl = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Text.IndexOfAny(new char[] { '.' }, 0) == -1 && this.CaretIndex > 0
|
||||
&& this.CaretIndex + this.Accuracy >= this.Text.Length) //Accuracy
|
||||
{
|
||||
isControl = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Accuracy
|
||||
int pointIndex = this.Text.IndexOf('.');
|
||||
if (pointIndex > -1 && this.CaretIndex > pointIndex)
|
||||
{
|
||||
if (this.Text.Length - pointIndex > this.Accuracy)
|
||||
{
|
||||
isNumeric = isNumPadNumeric = false;
|
||||
}
|
||||
}
|
||||
e.Handled = !isControl && !isNumeric && !isNumPadNumeric;
|
||||
}
|
||||
|
||||
private void AllowTime(KeyEventArgs e)
|
||||
{
|
||||
AllowDecimal(e);
|
||||
|
||||
if (e.Key == Key.Oem1 && Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
e.Handled = false;
|
||||
|
||||
if (e.Key == Key.OemMinus || e.Key == Key.Subtract)
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void AllowFileName(KeyEventArgs e)
|
||||
{
|
||||
if (this.Text.Length >= 128)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Keyboard.Modifiers == ModifierKeys.Shift)
|
||||
{
|
||||
if (e.Key == Key.OemPeriod || //>
|
||||
e.Key == Key.OemComma || //<
|
||||
e.Key == Key.D8 || //*
|
||||
e.Key == Key.Oem1 || //:
|
||||
e.Key == Key.Oem7 //"
|
||||
)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (e.Key == Key.Oem2 || //? /
|
||||
e.Key == Key.Oem5) //\ |
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Range Control
|
||||
public bool IsOutOfRange()
|
||||
{
|
||||
if (!double.IsNaN(this.MinValue) && !double.IsNaN(this.MaxValue))
|
||||
{
|
||||
double value;
|
||||
bool m_flag = double.TryParse(this.Text, out value);
|
||||
|
||||
if (value > this.MaxValue)
|
||||
return true;
|
||||
else if (value < this.MinValue)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(RoutedEventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
this.IsTextboxFocused = false;
|
||||
if (this.Text.Length == 0)
|
||||
{
|
||||
if (!AllowEmpty)
|
||||
this.Text = m_strOldValue;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EditBoxMode == EditBoxMode.UnSignDecimal || EditBoxMode == EditBoxMode.Decimal || EditBoxMode == EditBoxMode.SignInteger || EditBoxMode == EditBoxMode.UnSignInteger)
|
||||
{
|
||||
if (IsOutOfRange())
|
||||
{
|
||||
this.Background = Brushes.Red;
|
||||
this.ToolTip = this.MinValue + "-" + this.MaxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBGColor(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Expose an event to support save function by ENTER key
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Tab)
|
||||
{
|
||||
this.SelectAll();
|
||||
}
|
||||
KeyEventHandler handler = this.TextBoxExEnterKeyDown;
|
||||
if (handler != null && e.Key == Key.Enter)
|
||||
{
|
||||
if (IsOutOfRange())
|
||||
{
|
||||
this.Background = Brushes.Red; //this.WarningColor
|
||||
this.ToolTip = this.MinValue + "-" + this.MaxValue;
|
||||
}
|
||||
else
|
||||
handler(this, e);
|
||||
}
|
||||
if (e.Key == Key.Return || e.Key == Key.Enter)
|
||||
{
|
||||
if (IsOutOfRange())
|
||||
{
|
||||
this.Background = Brushes.Red;
|
||||
this.ToolTip = this.MinValue + "-" + this.MaxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBGColor(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected override void OnTextChanged(TextChangedEventArgs e)
|
||||
{
|
||||
base.OnTextChanged(e);
|
||||
if (IsInitialized)
|
||||
{
|
||||
//text changed because of binding changed
|
||||
if (m_strOldValue != this.Text && this.IsFocused && AllowBackgroundChange)
|
||||
{
|
||||
this.TextSaved = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_strOldValue = this.Text;
|
||||
this.TextSaved = true;
|
||||
}
|
||||
|
||||
|
||||
if (EditBoxMode == EditBoxMode.FileName)
|
||||
{
|
||||
Regex regex = new Regex("\\*|\\\\|\\/|\\?|\"|:|\\<|\\>|\\|"); //*:"<>?/\|
|
||||
this.Text = regex.Replace(this.Text, String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsScrollToEnd)
|
||||
{
|
||||
this.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
if (e.ClickCount == 2)
|
||||
{
|
||||
this.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
|
||||
{
|
||||
base.OnGotKeyboardFocus(e);
|
||||
this.IsTextboxFocused = true;
|
||||
}
|
||||
|
||||
private static void TextSavedChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
TextBoxEx m_txt = d as TextBoxEx;
|
||||
if (m_txt != null)
|
||||
{
|
||||
if (m_txt.IsOutOfRange())
|
||||
{
|
||||
m_txt.Background = Brushes.Red;
|
||||
m_txt.ToolTip = m_txt.MinValue + "-" + m_txt.MaxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetBGColor(m_txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the Background of textbox according to the TextSaved property
|
||||
/// </summary>
|
||||
private static void SetBGColor(TextBoxEx tb)
|
||||
{
|
||||
if (tb.TextSaved)
|
||||
{
|
||||
tb.m_strOldValue = tb.Text;
|
||||
if (tb.NormalColor != null)
|
||||
tb.Background = tb.NormalColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tb.ChangedColor != null)
|
||||
tb.Background = tb.ChangedColor;
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveText()
|
||||
{
|
||||
this.TextSaved = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using OpenSEMI.Ctrlib.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public enum ValveLogicType
|
||||
{
|
||||
Positive,
|
||||
Nagative
|
||||
}
|
||||
|
||||
public class Valve : Button
|
||||
{
|
||||
#region Properties and Fields
|
||||
#region ValveState (DependencyProperty)
|
||||
public ValveState ValveState
|
||||
{
|
||||
get { return (ValveState)GetValue(ValveStateProperty); }
|
||||
set { SetValue(ValveStateProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ValveStateProperty =
|
||||
DependencyProperty.Register("ValveState", typeof(ValveState), typeof(Valve),
|
||||
new UIPropertyMetadata(ValveState.UNKNOWN));
|
||||
#endregion
|
||||
|
||||
#region Value (DependencyProperty)
|
||||
public int Value
|
||||
{
|
||||
get { return (int)GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ValueProperty =
|
||||
DependencyProperty.Register("Value", typeof(int), typeof(Valve),
|
||||
new UIPropertyMetadata(-1, new PropertyChangedCallback(ValueChangedCallBack)));
|
||||
#endregion
|
||||
|
||||
#region ValveType (DependencyProperty)
|
||||
public Orientation Orientation
|
||||
{
|
||||
get { return (Orientation)GetValue(OrientationProperty); }
|
||||
set { SetValue(OrientationProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty OrientationProperty =
|
||||
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Valve),
|
||||
new UIPropertyMetadata(Orientation.Vertical));
|
||||
#endregion
|
||||
|
||||
private ValveLogicType m_ValveLogic = ValveLogicType.Positive;
|
||||
public ValveLogicType ValveLogic
|
||||
{
|
||||
get { return m_ValveLogic; }
|
||||
set { m_ValveLogic = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
static Valve()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Valve), new FrameworkPropertyMetadata(typeof(Valve)));
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
SetValveState(this);
|
||||
}
|
||||
|
||||
public static void ValueChangedCallBack(DependencyObject d, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
Valve v = d as Valve;
|
||||
if (v != null)
|
||||
{
|
||||
SetValveState(v);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetValveState(Valve v)
|
||||
{
|
||||
if (v.Value == 0)
|
||||
{
|
||||
if (v.ValveLogic == ValveLogicType.Positive)
|
||||
v.ValveState = ValveState.OFF;
|
||||
else
|
||||
v.ValveState = ValveState.ON;
|
||||
}
|
||||
else if (v.Value == 1)
|
||||
{
|
||||
if (v.ValveLogic == ValveLogicType.Positive)
|
||||
v.ValveState = ValveState.ON;
|
||||
else
|
||||
v.ValveState = ValveState.OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
v.ValveState = ValveState.UNKNOWN;
|
||||
}
|
||||
|
||||
//ControlValveDisplay(v);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using OpenSEMI.Ctrlib.Types;
|
||||
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.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;
|
||||
|
||||
namespace OpenSEMI.Ctrlib.Controls
|
||||
{
|
||||
public class Wafer : Control
|
||||
{
|
||||
static Wafer()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Wafer), new FrameworkPropertyMetadata(typeof(Wafer)));
|
||||
}
|
||||
|
||||
#region ViewType (DependencyProperty)Front/Top
|
||||
public string ViewType
|
||||
{
|
||||
get { return (string)GetValue(ViewTypeProperty); }
|
||||
set { SetValue(ViewTypeProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ViewTypeProperty =
|
||||
DependencyProperty.Register("ViewType", typeof(string), typeof(Wafer),
|
||||
new UIPropertyMetadata("Front"));
|
||||
#endregion
|
||||
|
||||
#region int (DependencyProperty)
|
||||
/// <summary>
|
||||
/// refer to enum WaferStatus in CommonEnums.cs
|
||||
/// </summary>
|
||||
public int WaferStatus
|
||||
{
|
||||
get { return (int)GetValue(WaferStatusProperty); }
|
||||
set { SetValue(WaferStatusProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferStatusProperty =
|
||||
DependencyProperty.Register("WaferStatus", typeof(int), typeof(Wafer),
|
||||
new UIPropertyMetadata(0));
|
||||
#endregion
|
||||
|
||||
#region SlotID (DependencyProperty)
|
||||
public int SlotID
|
||||
{
|
||||
get { return (int)GetValue(SlotIDProperty); }
|
||||
set { SetValue(SlotIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SlotIDProperty =
|
||||
DependencyProperty.Register("SlotID", typeof(int), typeof(Wafer),
|
||||
new UIPropertyMetadata(0));
|
||||
#endregion
|
||||
|
||||
#region ModuleID (DependencyProperty)
|
||||
public string ModuleID
|
||||
{
|
||||
get { return (string)GetValue(ModuleIDProperty); }
|
||||
set { SetValue(ModuleIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty ModuleIDProperty =
|
||||
DependencyProperty.Register("ModuleID", typeof(string), typeof(Wafer), new UIPropertyMetadata(string.Empty));
|
||||
#endregion
|
||||
|
||||
#region LotID (DependencyProperty)
|
||||
public string LotID
|
||||
{
|
||||
get { return (string)GetValue(LotIDProperty); }
|
||||
set { SetValue(LotIDProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty LotIDProperty =
|
||||
DependencyProperty.Register("LotID", typeof(string), typeof(Wafer), new UIPropertyMetadata(string.Empty));
|
||||
#endregion
|
||||
|
||||
#region WaferTooltip (DependencyProperty)
|
||||
public string WaferTooltip
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipProperty); }
|
||||
set { SetValue(WaferTooltipProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipProperty =
|
||||
DependencyProperty.Register("WaferTooltip", typeof(string), typeof(Wafer), new PropertyMetadata(string.Empty));
|
||||
#endregion
|
||||
|
||||
#region WaferTooltipExt (DependencyProperty)
|
||||
public string WaferTooltipExt
|
||||
{
|
||||
get { return (string)GetValue(WaferTooltipExtProperty); }
|
||||
set { SetValue(WaferTooltipExtProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty WaferTooltipExtProperty =
|
||||
DependencyProperty.Register("WaferTooltipExt", typeof(string), typeof(Wafer), new PropertyMetadata(string.Empty));
|
||||
#endregion
|
||||
|
||||
#region SourceName (DependencyProperty)
|
||||
public string SourceName
|
||||
{
|
||||
get { return (string)GetValue(SourceNameProperty); }
|
||||
set { SetValue(SourceNameProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty SourceNameProperty =
|
||||
DependencyProperty.Register("SourceName", typeof(string), typeof(Wafer), new UIPropertyMetadata(string.Empty));
|
||||
#endregion
|
||||
|
||||
#region VisiblilityDuplicated (DependencyProperty)
|
||||
public Visibility DuplicatedVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(DuplicatedVisibilityProperty); }
|
||||
set { SetValue(DuplicatedVisibilityProperty, value); }
|
||||
}
|
||||
public static readonly DependencyProperty DuplicatedVisibilityProperty =
|
||||
DependencyProperty.Register("DuplicatedVisibility", typeof(Visibility), typeof(Wafer), new UIPropertyMetadata(Visibility.Collapsed));
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user