refactor: 将Framework库和RT、UI放在同一个解决方案中。

This commit is contained in:
SL
2026-06-01 17:48:28 +08:00
parent 1948f4290d
commit b73d39a6b1
4331 changed files with 506148 additions and 49363 deletions
@@ -0,0 +1,40 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITBarcodeTextBox"
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" d:DesignHeight="35" d:DesignWidth="300" x:Name="self">
<Grid HorizontalAlignment="Stretch" Margin="0">
<TextBox Foreground="White" FontSize="30" AcceptsReturn="True" InputMethod.PreferredImeState="Off"
InputMethod.IsInputMethodEnabled="False" Text="{Binding ElementName=self, Path=BarcodeText}" TextChanged="TextBoxBase_OnTextChanged" PreviewTextInput="UIElement_OnPreviewTextInput" TabIndex="0" BorderThickness="1" Margin="0" Padding="0" HorizontalAlignment="Stretch" TextAlignment="Center" VerticalContentAlignment="Center" >
<TextBox.Background>
<ImageBrush Stretch="Fill" x:Name="BarcodeBrushName" Opacity="0.1" AlignmentX="Center" AlignmentY="Center">
<ImageBrush.ImageSource>
<BitmapImage UriSource="/MECF.Framework.Common;component/Resources/barcode.png"/>
</ImageBrush.ImageSource>
</ImageBrush>
</TextBox.Background>
<TextBox.Triggers>
<EventTrigger RoutedEvent="TextBox.GotFocus">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BarcodeBrushName" Storyboard.TargetProperty="Opacity" AutoReverse="True" RepeatBehavior="Forever"
From="0" To="0.3" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="TextBox.LostFocus">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="BarcodeBrushName" Storyboard.TargetProperty="Opacity" AutoReverse="False" From="0.3" To="0.1" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBox.Triggers>
</TextBox>
</Grid>
</UserControl>
@@ -0,0 +1,178 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
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 Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITBarcodeTextBox.xaml 的交互逻辑
/// </summary>
public partial class AITBarcodeTextBox : UserControl
{
public static readonly DependencyProperty BarcodeTextProperty = DependencyProperty.Register(
"BarcodeText", typeof(string), typeof(AITBarcodeTextBox),
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.AffectsRender));
public string BarcodeText
{
get
{
return (string)this.GetValue(BarcodeTextProperty);
}
set
{
this.SetValue(BarcodeTextProperty, value);
}
}
public static readonly DependencyProperty BarcodeLengthProperty = DependencyProperty.Register(
"BarcodeLength", typeof(int), typeof(AITBarcodeTextBox),
new FrameworkPropertyMetadata(6, FrameworkPropertyMetadataOptions.AffectsRender));
public int BarcodeLength
{
get
{
return (int)this.GetValue(BarcodeLengthProperty);
}
set
{
this.SetValue(BarcodeLengthProperty, value);
}
}
public static readonly DependencyProperty MaxScanCountProperty = DependencyProperty.Register(
"MaxScanCount", typeof(int), typeof(AITBarcodeTextBox),
new FrameworkPropertyMetadata(9999, FrameworkPropertyMetadataOptions.AffectsRender));
public int MaxScanCount
{
get
{
return (int)this.GetValue(MaxScanCountProperty);
}
set
{
this.SetValue(MaxScanCountProperty, value);
}
}
public static readonly DependencyProperty BarcodeInputChangedCommandProperty = DependencyProperty.Register(
"BarcodeInputChangedCommand", typeof(ICommand), typeof(AITBarcodeTextBox),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand BarcodeInputChangedCommand
{
get
{
return (ICommand)this.GetValue(BarcodeInputChangedCommandProperty);
}
set
{
this.SetValue(BarcodeInputChangedCommandProperty, value);
}
}
//private string _preInput;
public AITBarcodeTextBox()
{
InitializeComponent();
}
private void UIElement_OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text);
}
private static bool IsTextAllowed(string text)
{
return true;
//Regex regex = new Regex("[^0-9.]+"); //regex that matches disallowed text
//return !regex.IsMatch(text);
}
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
{
TextBox control = (TextBox)sender;
string value = control.Text;
string origin = value;
if (value.Contains(Environment.NewLine))
{
//int pos = value.IndexOf("/");
//string newInput = value.Substring(value.IndexOf("/") + 1, value.IndexOf(Environment.NewLine));
origin = value.Replace(Environment.NewLine, "");
if (!origin.EndsWith("/"))
origin = origin + "/";
if (!string.IsNullOrEmpty(origin))
{
var elements = origin.Split('/');
//if (elements.Length > 0)
// ;
}
}
control.Text = origin;
control.CaretIndex = control.Text.Length;
if (BarcodeInputChangedCommand != null )
{
BarcodeInputChangedCommand.Execute(origin);
}
//string origin = value.Replace("\r\n", "/");
//System.Diagnostics.Trace.WriteLine(value);
//string origin = value.Replace("/", "");
//while (origin.Length > MaxScanCount * BarcodeLength)
//{
// origin = origin.Substring(BarcodeLength);
//}
//if (MaxScanCount > 1 && origin.Length > BarcodeLength)
//{
// string split = "";
// while (origin.Length > BarcodeLength)
// {
// split += origin.Substring(0, BarcodeLength) + "/";
// origin = origin.Substring(BarcodeLength);
// }
// split += origin;
// origin = split;
//}
}
}
}
@@ -0,0 +1,67 @@
<Window x:Class="Aitex.Core.UI.DeviceControl.AITBoostPumpInputDialogBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Aitex.Core.UI.Control"
Height="265" Width="310" MaxHeight="265" MinHeight="265" MaxWidth="310" MinWidth="310" WindowStyle="ToolWindow"
WindowStartupLocation="CenterOwner"
KeyDown="OnEnterKeyIsHit"
Title="{Binding Path=DeviceId, StringFormat={}{0} SetPoint}">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="50" />
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="13" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="25" />
</Style>
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<my:DoubleConverter x:Key="doubleConverter"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="Device Name:" />
<Label Grid.Row="1" Grid.Column="1" Content="Unit:" />
<Label Grid.Row="2" Grid.Column="1" Content="Max:" />
<Label Grid.Row="3" Grid.Column="1" Content="Frequency:" />
<Label Grid.Row="4" Grid.Column="1" Content="CurrentSetPoint:" />
<Label Grid.Row="5" Grid.Column="1" Content="Set Pressure:" />
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=DeviceName}" Width="150" Height="28" HorizontalAlignment="Left" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" VerticalContentAlignment="Center" />
<Label Grid.Row="1" Grid.Column="2" Content="{Binding Path=Unit}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="2" Grid.Column="2" Content="{Binding Path=MaxValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="3" Grid.Column="2" Content="{Binding Path=Frequency}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=RealValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="2" x:Name="inputBox" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBox_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Microsoft YaHei" Height="30" VerticalContentAlignment="Center" />
<StackPanel Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Set" x:Name="btnSet" Click="ButtonSet_Click" Width="60" Height="26" VerticalAlignment="Top" Margin="5,3,0,0" />
<Button Content="Cancel" Click="ButtonCancel_Click" Width="60" Height="26" VerticalAlignment="Top" Margin="50,3,0,0" />
</StackPanel>
</Grid>
</Window>
@@ -0,0 +1,202 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Aitex.Core.RT.Log;
namespace Aitex.Core.UI.DeviceControl
{
public partial class AITBoostPumpInputDialogBox : Window
{
public AITBoostPumpInputDialogBox()
{
InitializeComponent();
DataContext = this;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
public void FocasAll()
{
inputBox.Text = Math.Round(SetPoint, 2).ToString();
inputBox.Focus();
inputBox.SelectAll();
}
/// <summary>
/// Vilidate input range
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBox.Text, out input))
btnSet.IsEnabled = false;
else if (input < 0 || input > MaxValue)
btnSet.IsEnabled = false;
else
btnSet.IsEnabled = true;
inputBox.Foreground = btnSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
public static readonly DependencyProperty DeviceNameProperty = DependencyProperty.Register(
"DeviceName", typeof(string), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceIdProperty = DependencyProperty.Register(
"DeviceId", typeof(string), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register(
"MaxValue", typeof(double), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty FrequencyProperty = DependencyProperty.Register(
"Frequency", typeof(double), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty RealValueProperty = DependencyProperty.Register(
"RealValue", typeof(string), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata("0.0", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(
"Unit", typeof(string), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointProperty = DependencyProperty.Register(
"SetPoint", typeof(double), typeof(AITBoostPumpInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
/// <summary>
/// 是否百分比显示
/// </summary>
public bool IsPercent
{
get;
set;
}
public string DeviceName
{
get
{
return (string)this.GetValue(DeviceNameProperty);
}
set
{
if (!string.IsNullOrEmpty(value) && !value.StartsWith("_"))
value = "_" + value;
this.SetValue(DeviceNameProperty, value);
}
}
public string DeviceId
{
get
{
return (string)this.GetValue(DeviceIdProperty);
}
set
{
this.SetValue(DeviceIdProperty, value);
}
}
public double MaxValue
{
get
{
return (double)this.GetValue(MaxValueProperty);
}
set
{
this.SetValue(MaxValueProperty, value);
// validationRule.MaxInput = value;
}
}
public double Frequency
{
get
{
return (double)this.GetValue(FrequencyProperty);
}
set
{
this.SetValue(FrequencyProperty, value);
}
}
public string RealValue
{
get
{
return (string)this.GetValue(RealValueProperty);
}
set
{
this.SetValue(RealValueProperty, value);
}
}
public string Unit
{
get
{
return (string)this.GetValue(UnitProperty);
}
set
{
this.SetValue(UnitProperty, value);
}
}
public double SetPoint
{
get
{
return (double)this.GetValue(SetPointProperty);
}
set
{
this.SetValue(SetPointProperty, value);
}
}
public Action<double> SetPressureCommandDelegate;
private void ButtonSet_Click(object sender, RoutedEventArgs e)
{
try
{
SetPressureCommandDelegate(Convert.ToDouble(inputBox.Text));
Close();
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
{
try
{
if (!btnSet.IsEnabled)
return;
if (e.Key == Key.Return)
{
ButtonSet_Click(null, null);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}
@@ -0,0 +1,14 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITFlowMeter"
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" Height="40" Width="75" BorderThickness="1" x:Name="self">
<Grid Height="30" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Background="Transparent" x:Name="bdRectangle" BorderThickness="1">
<Rectangle RadiusX="2" RadiusY="2" Name="rectBkground" Stroke="#373737" Margin="1" Opacity="1" Height="26" Fill="DarkSlateBlue" StrokeThickness="1" />
</Border>
<Label Content="{Binding ElementName=self, Path=DeviceData.FeedBack}" ContentStringFormat="{Binding ElementName=self, Path=StringFormat}" FontFamily="Verdana" FontSize="12" HorizontalContentAlignment="Center" x:Name="labelValue" Margin="0,-2,-2,-2" VerticalContentAlignment="Center" Foreground="Yellow" />
</Grid>
</UserControl>
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITFlowMeter.xaml 的交互逻辑
/// </summary>
public partial class AITFlowMeter : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITWaterFlowMeterData), typeof(AITFlowMeter),
new FrameworkPropertyMetadata(new AITWaterFlowMeterData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITWaterFlowMeterData DeviceData
{
get
{
return (AITWaterFlowMeterData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty StringFormatProperty = DependencyProperty.Register(
"StringFormat", typeof(string), typeof(AITFlowMeter),
new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
public string StringFormat
{
get
{
return (string)this.GetValue(StringFormatProperty);
}
set
{
this.SetValue(StringFormatProperty, value);
}
}
public AITFlowMeter()
{
InitializeComponent();
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format(Application.Current.Resources["GlobalLableFlowMeterToolTip"].ToString(),
DeviceData.Type,
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.FeedBack.ToString(StringFormat),
DeviceData.Unit);
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,55 @@
<UserControl
x:Class="Aitex.Core.UI.DeviceControl.AITGasValve"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="32"
Height="32"
Loaded="AITGasValve_OnLoaded"
mc:Ignorable="d">
<UserControl.Resources>
<Storyboard x:Key="OpenValveStoryBoard">
<DoubleAnimation
FillBehavior="HoldEnd"
Storyboard.TargetName="rotateTransform"
Storyboard.TargetProperty="Angle"
To="90"
Duration="0:0:0.3" />
<DoubleAnimation
FillBehavior="HoldEnd"
Storyboard.TargetName="imgValveClose"
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.3" />
</Storyboard>
<Storyboard x:Key="CloseValveStoryBoard">
<DoubleAnimation
FillBehavior="HoldEnd"
Storyboard.TargetName="rotateTransform"
Storyboard.TargetProperty="Angle"
To="0"
Duration="0:0:0.3" />
<DoubleAnimation
FillBehavior="HoldEnd"
Storyboard.TargetName="imgValveClose"
Storyboard.TargetProperty="Opacity"
To="100"
Duration="0:0:0.3" />
</Storyboard>
</UserControl.Resources>
<UserControl.RenderTransform>
<RotateTransform x:Name="rotateTransform" CenterX="16" CenterY="16" />
</UserControl.RenderTransform>
<Canvas>
<Image Name="imgValveOpen" />
<Image Name="imgValveClose">
<Image.ContextMenu>
<ContextMenu Visibility="{Binding MenuVisibility}">
<MenuItem Click="OpenValve" Header="Open Valve" />
<MenuItem Click="CloseValve" Header="Close Valve" />
</ContextMenu>
</Image.ContextMenu>
</Image>
</Canvas>
</UserControl>
@@ -0,0 +1,238 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using Aitex.Core.Util;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// TexGasValve.xaml 的交互逻辑
/// </summary>
public partial class AITGasValve : UserControl
{
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITGasValve),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public Visibility MenuVisibility
{
get { return (Visibility)this.GetValue(MenuVisibilityProperty); }
set { this.SetValue(MenuVisibilityProperty, value); }
}
// Using a DependencyProperty as the backing store for MenuVisibility. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MenuVisibilityProperty =
DependencyProperty.Register("MenuVisibility", typeof(Visibility), typeof(AITGasValve),
new FrameworkPropertyMetadata(Visibility.Visible));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITValveData), typeof(AITGasValve),
new FrameworkPropertyMetadata(new AITValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITValveData DeviceData
{
get
{
var data = (AITValveData)this.GetValue(DeviceDataProperty);
rdTrig.CLK = (data == null || data.IsOpen);
if (rdTrig.R)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Storyboard sb = this.FindResource("OpenValveStoryBoard") as Storyboard;
sb.Begin();
if (imgValveClose.ContextMenu.Items != null && imgValveClose.ContextMenu.Items.Count == 2)
{
((MenuItem)imgValveClose.ContextMenu.Items[0]).IsEnabled = !IsOpen;
((MenuItem)imgValveClose.ContextMenu.Items[1]).IsEnabled = IsOpen;
}
}));
}
if (rdTrig.T)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Storyboard sb = this.FindResource("CloseValveStoryBoard") as Storyboard;
sb.Begin();
if (imgValveClose.ContextMenu.Items != null && imgValveClose.ContextMenu.Items.Count == 2)
{
((MenuItem)imgValveClose.ContextMenu.Items[0]).IsEnabled = !IsOpen;
((MenuItem)imgValveClose.ContextMenu.Items[1]).IsEnabled = IsOpen;
}
}));
}
return data;
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty EnableServiceControlProperty = DependencyProperty.Register(
"EnableServiceControl", typeof(bool), typeof(AITGasValve),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableServiceControl
{
get
{
return (bool)this.GetValue(EnableServiceControlProperty);
}
set
{
this.SetValue(EnableServiceControlProperty, value);
}
}
public static readonly DependencyProperty DeviceData2Property = DependencyProperty.Register(
"DeviceData2", typeof(AITValveData), typeof(AITGasValve),
new FrameworkPropertyMetadata(new AITValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITValveData DeviceData2
{
get
{
return (AITValveData)this.GetValue(DeviceData2Property);
}
set
{
this.SetValue(DeviceData2Property, value);
}
}
public static readonly DependencyProperty ValveOpenOrientationProperty = DependencyProperty.Register(
"ValveOpenOrientation", typeof(LineOrientation), typeof(AITGasValve),
new FrameworkPropertyMetadata(LineOrientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsRender));
public LineOrientation ValveOpenOrientation
{
get { return (LineOrientation)GetValue(ValveOpenOrientationProperty); }
set { SetValue(ValveOpenOrientationProperty, value); }
}
public bool IsOpen => DeviceData == null || DeviceData.IsOpen;
private DispatcherTimer valveTimer = new DispatcherTimer();
RD_TRIG rdTrig = new RD_TRIG();
public AITGasValve()
{
InitializeComponent();
}
private BitmapSource GetImage(string name)
{
return new BitmapImage(new Uri($"pack://application:,,,/MECF.Framework.UI.Core;component/Resources/Valve/{name}"));
}
protected override void OnRender(DrawingContext drawingContext)
{
if (DeviceData != null)
{
this.ToolTip =
$"Valve Name:{DeviceData.DisplayName} \r\n Device ID:{DeviceData.DeviceSchematicId} \r\n Status:";
ToolTip += DeviceData.Feedback ? "Open" : "Closed";
}
base.OnRender(drawingContext);
}
private void OpenValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.UniqueName}.{AITValveOperation.GVTurnValve}", true);
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITValveOperation.GVTurnValve, true });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITValveOperation.GVTurnValve, false });
}
}
private void CloseValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.UniqueName}.{AITValveOperation.GVTurnValve}", false);
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITValveOperation.GVTurnValve, false });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITValveOperation.GVTurnValve, true });
}
}
private void AITGasValve_OnLoaded(object sender, RoutedEventArgs e)
{
imgValveOpen.Source = GetImage(ValveOpenOrientation == LineOrientation.Horizontal ? "valveopenvertical.png" : "valveopenhorizontal.png");
imgValveClose.Source = GetImage(ValveOpenOrientation == LineOrientation.Vertical ? "valveclosevertical.png" : "valveclosehorizontal.png");
if (DeviceData == null || DeviceData.IsOpen)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Storyboard sb = this.FindResource("OpenValveStoryBoard") as Storyboard;
sb.Begin();
if (imgValveClose.ContextMenu.Items != null && imgValveClose.ContextMenu.Items.Count == 2)
{
((MenuItem)imgValveClose.ContextMenu.Items[0]).IsEnabled = !IsOpen;
((MenuItem)imgValveClose.ContextMenu.Items[1]).IsEnabled = IsOpen;
}
}));
}
else
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Storyboard sb = this.FindResource("CloseValveStoryBoard") as Storyboard;
sb.Begin();
if (imgValveClose.ContextMenu.Items != null && imgValveClose.ContextMenu.Items.Count == 2)
{
((MenuItem)imgValveClose.ContextMenu.Items[0]).IsEnabled = !IsOpen;
((MenuItem)imgValveClose.ContextMenu.Items[1]).IsEnabled = IsOpen;
}
}));
}
//valveTimer.Start();
}
}
}
@@ -0,0 +1,19 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITHeaterControl"
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" d:DesignHeight="24" d:DesignWidth="45" BorderThickness="1" x:Name="self">
<Grid MouseLeftButtonUp="Grid_MouseLeftButtonUp" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Background="Transparent" x:Name="bdRectangle" BorderThickness="1">
<Rectangle Style="{x:Null}" RadiusX="2" RadiusY="2" Name="rectBkground"
Stroke="#373737" Margin="1" Opacity="1" Fill="Gray" StrokeThickness="1"/>
</Border>
<Label Content="{Binding ElementName=self, Path=DeviceData.FeedBack}"
VerticalContentAlignment="Center"
ContentStringFormat="{}{0:F1}°C" FontFamily="Verdana"
FontSize="{Binding ElementName=self, Path=FontSizeSetting}"
HorizontalContentAlignment="Center"
x:Name="labelValue" Margin="0,-2,-2,-2" Foreground="{Binding ElementName=self, Path=ForegroundSetting}" />
</Grid>
</UserControl>
@@ -0,0 +1,296 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITHeaterControl.xaml 的交互逻辑
/// </summary>
public partial class AITHeaterControl : UserControl
{
public AITHeaterControl()
{
InitializeComponent();
}
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITHeaterData), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(new AITHeaterData(), FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
"BackColor", typeof(Brush), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(Brushes.DarkMagenta, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty HideDialogProperty = DependencyProperty.Register(
"HideDialog", typeof(bool), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty AlwaysPowerOnProperty = DependencyProperty.Register(
"AlwaysPowerOn", typeof(bool), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EnablePowerControlProperty = DependencyProperty.Register(
"EnablePowerControl", typeof(bool), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EnableTemperatureSettingProperty = DependencyProperty.Register(
"EnableTemperatureSetting", typeof(bool), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty FontSizeSettingProperty = DependencyProperty.Register(
"FontSizeSetting", typeof(int), typeof(AITHeaterControl),
new FrameworkPropertyMetadata(13, FrameworkPropertyMetadataOptions.AffectsRender));
public int FontSizeSetting
{
get
{
return (int)this.GetValue(FontSizeSettingProperty);
}
set
{
this.SetValue(FontSizeSettingProperty, value);
}
}
public static readonly DependencyProperty ForegroundSettingProperty = DependencyProperty.Register(
"ForegroundSetting", typeof(string), typeof(AITHeaterControl),
new FrameworkPropertyMetadata("LightYellow", FrameworkPropertyMetadataOptions.AffectsRender));
public string ForegroundSetting
{
get
{
return (string)this.GetValue(ForegroundSettingProperty);
}
set
{
this.SetValue(ForegroundSettingProperty, value);
}
}
/// <summary>
/// 输入值是否百分比,默认否
/// </summary>
public bool IsPercent { get; set; }
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITHeaterData DeviceData
{
get
{
return (AITHeaterData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public Brush BackColor
{
get
{
return (Brush)this.GetValue(BackColorProperty);
}
set
{
this.SetValue(BackColorProperty, value);
}
}
public bool HideDialog
{
get
{
return (bool)this.GetValue(HideDialogProperty);
}
set
{
this.SetValue(HideDialogProperty, value);
}
}
public bool AlwaysPowerOn
{
get
{
return (bool)this.GetValue(AlwaysPowerOnProperty);
}
set
{
this.SetValue(AlwaysPowerOnProperty, value);
}
}
public bool EnableTemperatureSetting
{
get
{
return (bool)this.GetValue(EnableTemperatureSettingProperty);
}
set
{
this.SetValue(EnableTemperatureSettingProperty, value);
}
}
public bool EnablePowerControl
{
get
{
return (bool)this.GetValue(EnablePowerControlProperty);
}
set
{
this.SetValue(EnablePowerControlProperty, value);
}
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
//draw background color
if (DeviceData != null)
{
rectBkground.Fill = (DeviceData.IsPowerOn || AlwaysPowerOn) ? Brushes.DarkMagenta : Brushes.Gray;
//draw red board if mfc meets a warning
rectBkground.Stroke = DeviceData.IsWarning ? Brushes.Red : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0X37, 0X37, 0X37));
labelValue.Foreground = DeviceData.IsWarning ? Brushes.Pink : Brushes.LightYellow;
rectBkground.StrokeThickness = DeviceData.IsWarning ? 2 : 1;
if (dialogBox != null)
{
dialogBox.RealValue = DeviceData.FeedBack.ToString("F1");
dialogBox.IsHeaterOn = DeviceData.IsPowerOn;
dialogBox.SetPoint = DeviceData.SetPoint;
}
}
}
private void ExecutePowerOnOff(bool value)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.SetPowerOnOff", value.ToString());
}
else
{
Command.Execute(new object[] { DeviceData.DeviceName, AITHeaterOperation.SetPowerOnOff.ToString(), value.ToString() });
}
}
private void ExecuteSetHeaterValue(double power)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.Ramp",
power.ToString());
}
else
{
Command.Execute(new object[]
{DeviceData.DeviceName, AITHeaterOperation.Ramp.ToString(), power.ToString()});
}
}
private AITHeaterInputDialogBox dialogBox;
public Window AnalogOwner { get; set; }
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData == null)
return;
if (HideDialog)
return;
dialogBox = new AITHeaterInputDialogBox
{
SetHeaterValueCommandDelegate = ExecuteSetHeaterValue,
SetHeaterPowerOnOffCommandDelegate = ExecutePowerOnOff,
DeviceName = DeviceData.DisplayName,
DeviceId = DeviceData.DeviceSchematicId,
DefaultValue = DeviceData.DefaultValue,
RealValue = DeviceData.FeedBack.ToString("F1"),
SetPoint = Math.Round(DeviceData.SetPoint, 1),
MaxValue = DeviceData.Scale,
Unit = DeviceData.Unit,
IsHeaterOn = DeviceData.IsPowerOn,
EnablePowerControl = EnablePowerControl,
EnableTemperatureSetting = EnableTemperatureSetting,
};
if (AnalogOwner != null)
dialogBox.Owner = AnalogOwner;
dialogBox.Topmost = true;
dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
dialogBox.FocasAll();
dialogBox.ShowDialog();
dialogBox = null;
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format("{0}:{1}\r\n\r\nID:{2}\r\nScale:{3} {4}\r\nSetPoint:{5} {4} \r\nFeedback:{6} {4}\r\nHeaterPower:{7}",
DeviceData.Type,
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.Scale,
DeviceData.Unit,
DeviceData.SetPoint.ToString("F1"),
DeviceData.FeedBack.ToString("F1"),
DeviceData.IsPowerOn ? "On" : "Off");
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,69 @@
<Window x:Class="Aitex.Core.UI.DeviceControl.AITHeaterInputDialogBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Aitex.Core.UI.Control"
Height="265" Width="310" MaxHeight="265" MinHeight="265" MaxWidth="310" MinWidth="310" WindowStyle="ToolWindow"
WindowStartupLocation="CenterOwner"
KeyDown="OnEnterKeyIsHit"
Title="{Binding Path=DeviceId, StringFormat={}{0} SetPoint}">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="50" />
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="13" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="25" />
</Style>
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<my:DoubleConverter x:Key="doubleConverter"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="Device Name:" />
<Label Grid.Row="1" Grid.Column="1" Content="Unit:" />
<Label Grid.Row="2" Grid.Column="1" Content="Max:" />
<Label Grid.Row="3" Grid.Column="1" Content="Default:" />
<Label Grid.Row="4" Grid.Column="1" Content="Feedback:" />
<Label Grid.Row="5" Grid.Column="1" Content="Set Point:" />
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=DeviceName}" Width="150" Height="28" HorizontalAlignment="Left" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" VerticalContentAlignment="Center" />
<Label Grid.Row="1" Grid.Column="2" Content="{Binding Path=Unit}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="2" Grid.Column="2" Content="{Binding Path=MaxValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="3" Grid.Column="2" Content="{Binding Path=DefaultValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=RealValue}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Microsoft YaHei" Height="28" VerticalContentAlignment="Center" />
<TextBox Grid.Row="5" Grid.Column="2" x:Name="inputBox" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBox_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Microsoft YaHei" Height="30" VerticalContentAlignment="Center" />
<StackPanel Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" Orientation="Horizontal">
<Button Content="Set" x:Name="btnSet" Click="ButtonSet_Click" Width="60" Height="26" VerticalAlignment="Top" Margin="5,3,0,0" />
<Button Content="Heater On" x:Name="btnHeaterOn" Click="ButtonHeaterOn_Click" Width="70" Height="26" VerticalAlignment="Top" Margin="5,3,0,0" />
<Button Content="Heater Off" x:Name="btnHeaterOff" Click="ButtonHeaterOff_Click" Width="70" Height="26" VerticalAlignment="Top" Margin="5,3,0,0" />
<Button Content="Cancel" Click="ButtonCancel_Click" Width="60" Height="26" VerticalAlignment="Top" Margin="10,3,0,0" />
</StackPanel>
</Grid>
</Window>
@@ -0,0 +1,406 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;
using Aitex.Core.RT.Log;
namespace Aitex.Core.UI.DeviceControl
{
public class DoubleConverter : IValueConverter
{
public DoubleConverter()
{
}
// Summary:
// Converts a value.
//
// Parameters:
// value:
// The value produced by the binding source.
//
// targetType:
// The type of the binding target property.
//
// parameter:
// The converter parameter to use.
//
// culture:
// The culture to use in the converter.
//
// Returns:
// A converted value. If the method returns null, the valid null value is used.
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value.ToString();
}
//
// Summary:
// Converts a value.
//
// Parameters:
// value:
// The value that is produced by the binding target.
//
// targetType:
// The type to convert to.
//
// parameter:
// The converter parameter to use.
//
// culture:
// The culture to use in the converter.
//
// Returns:
// A converted value. If the method returns null, the valid null value is used.
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
string input = (string)value;
double result = 0;
if (double.TryParse(input, out result))
{
return result;
}
return DependencyProperty.UnsetValue;
}
}
public class InputDialogValidationRule : ValidationRule
{
double minInput;
double maxInput;
public double MinInput
{
get
{
return this.minInput;
}
set
{
this.minInput = value;
}
}
public double MaxInput
{
get
{
return this.maxInput;
}
set
{
this.maxInput = value;
}
}
public InputDialogValidationRule()
{
}
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
double result;
// Is a number?
if (!double.TryParse((string)value, out result))
{
string msg = string.Format("‘{0}’不是一个数.", value);
return new ValidationResult(false, msg);
}
// Is in range?
if ((result < this.minInput) || (result > this.maxInput))
{
string msg = string.Format("输入值必须在‘{0}’与‘{1}’之间.", this.minInput, this.maxInput);
return new ValidationResult(false, msg);
}
// Number is valid
return new ValidationResult(true, null);
}
}
/// <summary>
/// Interaction logic for InputDialogBox.xaml
/// </summary>
public partial class AITHeaterInputDialogBox : Window
{
public static readonly DependencyProperty DeviceNameProperty = DependencyProperty.Register(
"DeviceName", typeof(string), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceIdProperty = DependencyProperty.Register(
"DeviceId", typeof(string), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValueProperty = DependencyProperty.Register(
"MaxValue", typeof(double), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register(
"DefaultValue", typeof(double), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty RealValueProperty = DependencyProperty.Register(
"RealValue", typeof(string), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata("0.0", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(
"Unit", typeof(string), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointProperty = DependencyProperty.Register(
"SetPoint", typeof(double), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsHeaterOnProperty = DependencyProperty.Register(
"IsHeaterOn", typeof(bool), typeof(AITHeaterInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
/// <summary>
/// 是否百分比显示
/// </summary>
public bool IsPercent
{
get;
set;
}
public string DeviceName
{
get
{
return (string)this.GetValue(DeviceNameProperty);
}
set
{
if (!string.IsNullOrEmpty(value) && !value.StartsWith("_"))
value = "_" + value;
this.SetValue(DeviceNameProperty, value);
}
}
public string DeviceId
{
get
{
return (string)this.GetValue(DeviceIdProperty);
}
set
{
this.SetValue(DeviceIdProperty, value);
}
}
public double MaxValue
{
get
{
return (double)this.GetValue(MaxValueProperty);
}
set
{
this.SetValue(MaxValueProperty, value);
// validationRule.MaxInput = value;
}
}
public double DefaultValue
{
get
{
return (double)this.GetValue(DefaultValueProperty);
}
set
{
this.SetValue(DefaultValueProperty, value);
}
}
public string RealValue
{
get
{
return (string)this.GetValue(RealValueProperty);
}
set
{
this.SetValue(RealValueProperty, value);
}
}
public string Unit
{
get
{
return (string)this.GetValue(UnitProperty);
}
set
{
this.SetValue(UnitProperty, value);
}
}
public double SetPoint
{
get
{
return (double)this.GetValue(SetPointProperty);
}
set
{
this.SetValue(SetPointProperty, value);
}
}
public bool IsHeaterOn
{
get
{
return (bool)this.GetValue(IsHeaterOnProperty);
}
set
{
this.SetValue(IsHeaterOnProperty, value);
btnHeaterOff.IsEnabled = value;
btnHeaterOn.IsEnabled = !value;
}
}
public bool EnableTemperatureSetting
{
get;
set;
}
public bool EnablePowerControl
{
get;
set;
}
public Action<bool> SetHeaterPowerOnOffCommandDelegate;
public Action<double> SetHeaterValueCommandDelegate;
public AITHeaterInputDialogBox()
{
InitializeComponent();
DataContext = this;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
this.Loaded += AITHeaterInputDialogBox_Loaded;
}
private void AITHeaterInputDialogBox_Loaded(object sender, RoutedEventArgs e)
{
btnHeaterOn.Visibility = EnablePowerControl ? Visibility.Visible : Visibility.Hidden;
btnHeaterOff.Visibility = EnablePowerControl ? Visibility.Visible : Visibility.Hidden;
btnSet.IsEnabled = EnableTemperatureSetting;
inputBox.IsEnabled = EnableTemperatureSetting;
}
public void FocasAll()
{
inputBox.Text = Math.Round(SetPoint, 2).ToString();
inputBox.Focus();
inputBox.SelectAll();
}
/// <summary>
/// Vilidate input range
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InputTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBox.Text, out input))
btnSet.IsEnabled = false;
else if (input < 0 || input > MaxValue)
btnSet.IsEnabled = false;
else
btnSet.IsEnabled = true;
inputBox.Foreground = btnSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
private void ButtonSet_Click(object sender, RoutedEventArgs e)
{
try
{
SetHeaterValueCommandDelegate(Convert.ToDouble(inputBox.Text));
//Close();
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
{
try
{
if (!btnSet.IsEnabled)
return;
if (e.Key == Key.Return)
{
ButtonSet_Click(null, null);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonHeaterOn_Click(object sender, RoutedEventArgs e)
{
try
{
if (SetHeaterPowerOnOffCommandDelegate != null)
{
SetHeaterPowerOnOffCommandDelegate(true);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonHeaterOff_Click(object sender, RoutedEventArgs e)
{
try
{
if (SetHeaterPowerOnOffCommandDelegate != null)
{
SetHeaterPowerOnOffCommandDelegate(false);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
}
}
@@ -0,0 +1,22 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITIsoGasValve"
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"
Name="myself"
Height="32" Width="32">
<UserControl.RenderTransform>
<RotateTransform x:Name="rotateTransform" Angle="0" CenterX="16" CenterY="16"/>
</UserControl.RenderTransform>
<Canvas>
<Image Name="imagePicture">
<Image.ContextMenu>
<ContextMenu>
<MenuItem Header="Open Valve" Click="OpenValve"/>
<MenuItem Header="Close Valve" Click="CloseValve" />
</ContextMenu>
</Image.ContextMenu>
</Image>
</Canvas>
</UserControl>
@@ -0,0 +1,167 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// TexGasValve.xaml 的交互逻辑
/// </summary>
public partial class AITIsoGasValve : UserControl
{
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITIsoGasValve),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITCylinderData), typeof(AITIsoGasValve),
new FrameworkPropertyMetadata(new AITCylinderData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITCylinderData DeviceData
{
get
{
return (AITCylinderData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty EnableServiceControlProperty = DependencyProperty.Register(
"EnableServiceControl", typeof(bool), typeof(AITIsoGasValve),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableServiceControl
{
get
{
return (bool)this.GetValue(EnableServiceControlProperty);
}
set
{
this.SetValue(EnableServiceControlProperty, value);
}
}
public static readonly DependencyProperty DeviceData2Property = DependencyProperty.Register(
"DeviceData2", typeof(AITCylinderData), typeof(AITIsoGasValve),
new FrameworkPropertyMetadata(new AITCylinderData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITCylinderData DeviceData2
{
get
{
return (AITCylinderData)this.GetValue(DeviceData2Property);
}
set
{
this.SetValue(DeviceData2Property, value);
}
}
public static readonly DependencyProperty ValveOpenOrientationProperty = DependencyProperty.Register(
"ValveOpenOrientation", typeof(LineOrientation), typeof(AITIsoGasValve),
new FrameworkPropertyMetadata(LineOrientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsRender));
public LineOrientation ValveOpenOrientation
{
get { return (LineOrientation)GetValue(ValveOpenOrientationProperty); }
set { SetValue(ValveOpenOrientationProperty, value); }
}
public AITIsoGasValve()
{
InitializeComponent();
}
private BitmapSource GetImage(string name)
{
return
new BitmapImage(new Uri(string.Format("pack://application:,,,/MECF.Framework.Common;component/Resources/Valve/{0}", name)));
}
protected override void OnRender(DrawingContext drawingContext)
{
rotateTransform.Angle = ValveOpenOrientation == LineOrientation.Horizontal ? 0 : 90;
bool IsOpen = DeviceData == null || (DeviceData.OpenSetPoint && !DeviceData.CloseSetPoint);
imagePicture.Source = GetImage(IsOpen ? "ValveOpenHorizontal.png" : "ValveCloseHorizontal.png");
if (DeviceData != null)
{
this.ToolTip =
$"Valve Name:{DeviceData.DisplayName} \r\n Device ID:{DeviceData.DeviceSchematicId} \r\n SetPoint:{DeviceData.StringStatus} \r\n Status:{DeviceData.StringStatus}";
}
base.OnRender(drawingContext);
}
private void OpenValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITCylinderOperation.Open}" );
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITCylinderOperation.Open });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITCylinderOperation.Open });
}
}
private void CloseValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITCylinderOperation.Close}" );
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITCylinderOperation.Close });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITCylinderOperation.Close });
}
}
}
}
@@ -0,0 +1,24 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITParameterCheckBox"
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" d:DesignHeight="35" d:DesignWidth="500" x:Name="self">
<Grid HorizontalAlignment="Stretch" Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#376092" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="0" FontSize="15" Text=" " Foreground="White" />
<Rectangle Grid.Column="1" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" />
<Rectangle Grid.Column="2" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<Button Grid.Column="2" Content="{DynamicResource GlobalLableConfigButtonSet}" Command="{Binding SetConfigCommand}" CommandParameter="Barcode" FontSize="16" Width="80" Height="26" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</UserControl>
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITParameterCheckBox.xaml 的交互逻辑
/// </summary>
public partial class AITParameterCheckBox : UserControl
{
public AITParameterCheckBox()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,44 @@
<UserControl
x:Class="Aitex.Core.UI.DeviceControl.AITPressureMeter"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="self"
d:DesignHeight="24"
d:DesignWidth="45"
BorderThickness="1"
mc:Ignorable="d">
<Grid
Cursor="Hand"
MouseEnter="Grid_MouseEnter"
Opacity="1">
<Border
x:Name="bdRectangle"
Background="Transparent"
BorderThickness="1"
Style="{x:Null}">
<Rectangle
Name="rectBkground"
Margin="1"
Fill="CadetBlue"
Opacity="1"
RadiusX="2"
RadiusY="2"
Stroke="#373737"
StrokeThickness="1"
Style="{x:Null}" />
</Border>
<Label
x:Name="labelValue"
Margin="0,-2,-2,-2"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Content="{Binding ElementName=self, Path=DeviceData.Display}"
ContentStringFormat="F0"
FontFamily="Verdana"
FontSize="{Binding ElementName=self, Path=FontSizeSetting}"
Foreground="{Binding ElementName=self, Path=ForegroundSetting}" />
</Grid>
</UserControl>
@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITPressureMeter.xaml 的交互逻辑
/// </summary>
public partial class AITPressureMeter : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITPressureMeterData), typeof(AITPressureMeter),
new FrameworkPropertyMetadata(new AITPressureMeterData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITPressureMeterData DeviceData
{
get
{
return (AITPressureMeterData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty FontSizeSettingProperty = DependencyProperty.Register(
"FontSizeSetting", typeof(int), typeof(AITPressureMeter),
new FrameworkPropertyMetadata(13, FrameworkPropertyMetadataOptions.AffectsRender));
public int FontSizeSetting
{
get
{
return (int)this.GetValue(FontSizeSettingProperty);
}
set
{
this.SetValue(FontSizeSettingProperty, value);
}
}
public static readonly DependencyProperty ForegroundSettingProperty = DependencyProperty.Register(
"ForegroundSetting", typeof(string), typeof(AITPressureMeter),
new FrameworkPropertyMetadata("Yellow", FrameworkPropertyMetadataOptions.AffectsRender));
public string ForegroundSetting
{
get
{
return (string)this.GetValue(ForegroundSettingProperty);
}
set
{
this.SetValue(ForegroundSettingProperty, value);
}
}
public AITPressureMeter()
{
InitializeComponent();
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format("{0}:{1}\r\nID:{2}\r\n{3} {4}",
DeviceData.Type==""?"Name": DeviceData.Type,
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
!string.IsNullOrEmpty(DeviceData.FormatString) ? DeviceData.FeedBack.ToString(DeviceData.FormatString) : DeviceData.FeedBack.ToString("F1"),
DeviceData.Unit);
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,12 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITPressureSensor"
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"
d:DesignHeight="20" d:DesignWidth="20">
<Grid MouseEnter="Grid_MouseEnter" >
<Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="DarkGray" x:Name="sensor" Style="{x:Null}"/>
</Grid>
</UserControl>
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITPressureSensor.xaml 的交互逻辑
/// </summary>
public partial class AITPressureSensor : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITPressureSensorData), typeof(AITPressureSensor),
new FrameworkPropertyMetadata(new AITPressureSensorData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITPressureSensorData DeviceData
{
get
{
return (AITPressureSensorData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public AITPressureSensor()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData == null)
{
sensor.Fill = new SolidColorBrush(Colors.DarkGray);
return;
}
if (DeviceData.IsError)
sensor.Fill = new SolidColorBrush(Colors.OrangeRed);
else if (DeviceData.IsWarning || DeviceData.IsOutOfRange)
sensor.Fill = new SolidColorBrush(Colors.Yellow);
else
{
sensor.Fill = new SolidColorBrush(Colors.Lime);
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format(Application.Current.Resources["GlobalLablePressureSensorToolTip"].ToString(),
"PS",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.FeedBack.ToString("F1"),
DeviceData.Unit,
DeviceData.IsError ? "Alarm" : (DeviceData.IsWarning ? "Warning" : (DeviceData.IsOutOfRange ? "Abnormal" : "Normal"))
);
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,57 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITPump"
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:converters="clr-namespace:Aitex.Core.UI.Converters"
mc:Ignorable="d" x:Name="Self" >
<UserControl.Resources>
<converters:bool2VisibilityConverter x:Key="Bool2VisibilityConvert"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
<ColumnDefinition Width="110"></ColumnDefinition>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="0,0,10,0" x:Name="StackPanelDryPump" Visibility="{Binding ElementName=Self, Path=IsShowSensor,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<StackPanel Orientation="Horizontal" Height="22.5" HorizontalAlignment="Right" x:Name="StackPanelWaterFlow">
<TextBlock Text="Water Flow" Padding="0,0,5,0"/>
<Ellipse HorizontalAlignment="Left" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="{Binding ElementName=Self, Path=WaterFlowStatusColor, Mode=OneWay}" Style="{x:Null}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="22.5" HorizontalAlignment="Right" x:Name="StackPanelN2Pressure">
<TextBlock Text="N2 Purge" Padding="0,0,5,0"/>
<Ellipse HorizontalAlignment="Left" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="{Binding ElementName=Self, Path=N2PressureStatusColor, Mode=OneWay}" Style="{x:Null}"/>
</StackPanel>
</StackPanel>
<Image Grid.Column="1" Width="109" Height="45" x:Name="imagePicture" Source="/MECF.Framework.Common;component/Resources/Pump/pump_off.png" >
<Image.ContextMenu>
<ContextMenu Visibility="{Binding ElementName=Self, Path=EnableControl,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<MenuItem Header="Pump On" IsEnabled="{Binding ElementName=Self, Path=EnableControl,Mode=OneWay}" Click="PumpOn"/>
<MenuItem Header="Pump Off" IsEnabled="{Binding ElementName=Self, Path=EnableControl,Mode=OneWay}" Click="PumpOff" />
</ContextMenu>
</Image.ContextMenu>
</Image>
<StackPanel Grid.Column="2" Orientation="Vertical" HorizontalAlignment="Left" Margin="0,5,5,0" Visibility="{Binding ElementName=Self, Path=IsShowSpeed,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<Border BorderBrush="black" BorderThickness="1,1,1,1" >
<StackPanel Orientation="Horizontal" Height="18" HorizontalAlignment="Right" >
<Border BorderBrush="black" BorderThickness="0,0,1,0" Background="DarkGray" >
<TextBlock Text="Speed(rpm):" Width="80" Padding="0,0,5,0" VerticalAlignment="Center"/>
</Border>
<TextBlock x:Name="txtSpeed" Text="{Binding ElementName=Self, Path=DeviceData.Speed, Mode=OneWay}" VerticalAlignment="Stretch" Width="60" Padding="0,0,5,0"/>
</StackPanel>
</Border>
<Border BorderBrush="black" BorderThickness="1,0,1,1" >
<StackPanel Orientation="Horizontal" Height="18" HorizontalAlignment="Right" VerticalAlignment="Center" >
<Border BorderBrush="black" BorderThickness="0,0,1,0" Background="DarkGray" >
<TextBlock Text="Temp.(°C):" Width="80" Padding="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
</Border>
<TextBlock x:Name="txtTemp" VerticalAlignment="Center" Text="{Binding ElementName=Self, Path=DeviceData.Temperature, Mode=OneWay}" Width="60" Padding="0,0,5,0"/>
</StackPanel>
</Border>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,189 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Aitex.Core.Common.DeviceData;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITPump.xaml 的交互逻辑
/// </summary>
public partial class AITPump : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITPumpData), typeof(AITPump),
new FrameworkPropertyMetadata(new AITPumpData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITPumpData DeviceData
{
get
{
return (AITPumpData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty EnableControlProperty = DependencyProperty.Register(
"EnableControl", typeof(bool), typeof(AITPump),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableControl
{
get
{
return (bool)this.GetValue(EnableControlProperty);
}
set
{
this.SetValue(EnableControlProperty, value);
}
}
public static readonly DependencyProperty IsShowSpeedProperty = DependencyProperty.Register(
"IsShowSpeed", typeof(bool), typeof(AITPump),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsShowSpeed
{
get
{
return (bool)this.GetValue(IsShowSpeedProperty);
}
set
{
this.SetValue(IsShowSpeedProperty, value);
}
}
public static readonly DependencyProperty IsShowSensorProperty = DependencyProperty.Register(
"IsShowSensor", typeof(bool), typeof(AITPump),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsShowSensor
{
get
{
return (bool)this.GetValue(IsShowSensorProperty);
}
set
{
this.SetValue(IsShowSensorProperty, value);
}
}
public static readonly DependencyProperty WaterFlowStatusColorProperty = DependencyProperty.Register(
"WaterFlowStatusColor", typeof(SolidColorBrush), typeof(AITPump),
new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
public SolidColorBrush WaterFlowStatusColor
{
get
{
return (SolidColorBrush)this.GetValue(WaterFlowStatusColorProperty);
}
set
{
this.SetValue(WaterFlowStatusColorProperty, value);
}
}
public static readonly DependencyProperty N2PressureStatusColorProperty = DependencyProperty.Register(
"N2PressureStatusColor", typeof(SolidColorBrush), typeof(AITPump),
new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
public SolidColorBrush N2PressureStatusColor
{
get
{
return (SolidColorBrush)this.GetValue(N2PressureStatusColorProperty);
}
set
{
this.SetValue(N2PressureStatusColorProperty, value);
}
}
public AITPump()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData == null)
return;
if (DeviceData.IsError || DeviceData.IsOverLoad)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_error.png"));
else if (DeviceData.IsWarning)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_warning.png"));
else if (DeviceData.IsOn)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_on.png"));
else
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_off.png"));
StackPanelN2Pressure.Visibility = (DeviceData.IsN2PressureEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
StackPanelWaterFlow.Visibility = (DeviceData.IsWaterFlowEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
StackPanelDryPump.Visibility = (DeviceData.IsDryPumpEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
WaterFlowStatusColor = DeviceData.WaterFlowAlarm
? Brushes.Red
: (DeviceData.WaterFlowWarning ? Brushes.Yellow : Brushes.Lime);
N2PressureStatusColor = DeviceData.N2PressureAlarm
? Brushes.Red
: (DeviceData.N2PressureWarning ? Brushes.Yellow : Brushes.Lime);
txtSpeed.Background = DeviceData.AtSpeed ? Brushes.Transparent : Brushes.LimeGreen;
txtTemp.Background = DeviceData.OverTemp ? Brushes.OrangeRed : Brushes.Transparent;
if (imagePicture.ContextMenu!=null && imagePicture.ContextMenu.Items.Count == 2)
{
((MenuItem)imagePicture.ContextMenu.Items[0]).IsEnabled = !DeviceData.IsOn;
((MenuItem)imagePicture.ContextMenu.Items[1]).IsEnabled = DeviceData.IsOn;
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format("{0}:{1}\r\n\r\nID:{2} ",
"",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId );
ToolTip = tooltipValue;
}
}
private void PumpOn(object sender, RoutedEventArgs e)
{
if (EnableControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.DeviceModule}.{DeviceData.DeviceName}.{AITPumpOperation.PumpOn}");
}
}
private void PumpOff(object sender, RoutedEventArgs e)
{
if (EnableControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.DeviceModule}.{DeviceData.DeviceName}.{AITPumpOperation.PumpOff}");
}
}
}
}
@@ -0,0 +1,59 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITPump25"
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:converters="clr-namespace:Aitex.Core.UI.Converters"
xmlns:local="clr-namespace:Aitex.Core.UI.DeviceControl"
mc:Ignorable="d" x:Name="Self">
<UserControl.Resources>
<converters:bool2VisibilityConverter x:Key="Bool2VisibilityConvert"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"></ColumnDefinition>
<ColumnDefinition Width="110"></ColumnDefinition>
<ColumnDefinition Width="150"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" HorizontalAlignment="Right" Margin="0,0,10,0" x:Name="StackPanelDryPump" Visibility="{Binding ElementName=Self, Path=IsShowSensor,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<StackPanel Orientation="Horizontal" Height="22.5" HorizontalAlignment="Right" x:Name="StackPanelWaterFlow">
<TextBlock Text="Water Flow" Padding="0,0,5,0"/>
<Ellipse HorizontalAlignment="Left" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="{Binding ElementName=Self, Path=WaterFlowStatusColor, Mode=OneWay}" Style="{x:Null}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="22.5" HorizontalAlignment="Right" x:Name="StackPanelN2Pressure">
<TextBlock Text="N2 Purge" Padding="0,0,5,0"/>
<Ellipse HorizontalAlignment="Left" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="{Binding ElementName=Self, Path=N2PressureStatusColor, Mode=OneWay}" Style="{x:Null}"/>
</StackPanel>
</StackPanel>
<Image Grid.Column="1" Width="109" Height="45" x:Name="imagePicture" Source="/MECF.Framework.Common;component/Resources/Pump/pump_off.png" >
<Image.ContextMenu>
<ContextMenu Visibility="{Binding ElementName=Self, Path=EnableControl,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<MenuItem Header="Pump On" IsEnabled="{Binding ElementName=Self, Path=EnableControl,Mode=OneWay}" Click="PumpOn"/>
<MenuItem Header="Pump Off" IsEnabled="{Binding ElementName=Self, Path=EnableControl,Mode=OneWay}" Click="PumpOff" />
<MenuItem Header="Pump Utility" IsEnabled="{Binding ElementName=Self, Path=EnableControl,Mode=OneWay}" Click="PumpUtility" />
</ContextMenu>
</Image.ContextMenu>
</Image>
<StackPanel Grid.Column="2" Orientation="Vertical" HorizontalAlignment="Left" Margin="0,5,5,0" Visibility="{Binding ElementName=Self, Path=IsShowSpeed,Converter= {StaticResource Bool2VisibilityConvert}, Mode=OneWay}">
<Border BorderBrush="black" BorderThickness="1,1,1,1" >
<StackPanel Orientation="Horizontal" Height="18" HorizontalAlignment="Right" >
<Border BorderBrush="black" BorderThickness="0,0,1,0" Background="DarkGray" >
<TextBlock Text="Speed(rpm):" Width="80" Padding="0,0,5,0" VerticalAlignment="Center"/>
</Border>
<TextBlock x:Name="txtSpeed" Text="{Binding ElementName=Self, Path=DeviceData25.Speed, Mode=OneWay}" VerticalAlignment="Stretch" Width="60" Padding="0,0,5,0"/>
</StackPanel>
</Border>
<Border BorderBrush="black" BorderThickness="1,0,1,1" >
<StackPanel Orientation="Horizontal" Height="18" HorizontalAlignment="Right" VerticalAlignment="Center" >
<Border BorderBrush="black" BorderThickness="0,0,1,0" Background="DarkGray" >
<TextBlock Text="Temp.(°C):" Width="80" Padding="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
</Border>
<TextBlock x:Name="txtTemp" VerticalAlignment="Center" Text="{Binding ElementName=Self, Path=DeviceData25.Temperature, Mode=OneWay}" Width="60" Padding="0,0,5,0"/>
</StackPanel>
</Border>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,203 @@
using Aitex.Core.Common.DeviceData;
using MECF.Framework.Common.OperationCenter;
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 Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITPump25.xaml 的交互逻辑
/// </summary>
public partial class AITPump25 : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData25", typeof(AITPumpData), typeof(AITPump25),
new FrameworkPropertyMetadata(new AITPumpData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITPumpData DeviceData25
{
get
{
return (AITPumpData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty EnableControlProperty = DependencyProperty.Register(
"EnableControl", typeof(bool), typeof(AITPump25),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableControl
{
get
{
return (bool)this.GetValue(EnableControlProperty);
}
set
{
this.SetValue(EnableControlProperty, value);
}
}
public static readonly DependencyProperty IsShowSpeedProperty = DependencyProperty.Register(
"IsShowSpeed", typeof(bool), typeof(AITPump25),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsShowSpeed
{
get
{
return (bool)this.GetValue(IsShowSpeedProperty);
}
set
{
this.SetValue(IsShowSpeedProperty, value);
}
}
public static readonly DependencyProperty IsShowSensorProperty = DependencyProperty.Register(
"IsShowSensor", typeof(bool), typeof(AITPump25),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsShowSensor
{
get
{
return (bool)this.GetValue(IsShowSensorProperty);
}
set
{
this.SetValue(IsShowSensorProperty, value);
}
}
public static readonly DependencyProperty WaterFlowStatusColorProperty = DependencyProperty.Register(
"WaterFlowStatusColor", typeof(SolidColorBrush), typeof(AITPump25),
new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
public SolidColorBrush WaterFlowStatusColor
{
get
{
return (SolidColorBrush)this.GetValue(WaterFlowStatusColorProperty);
}
set
{
this.SetValue(WaterFlowStatusColorProperty, value);
}
}
public static readonly DependencyProperty N2PressureStatusColorProperty = DependencyProperty.Register(
"N2PressureStatusColor", typeof(SolidColorBrush), typeof(AITPump25),
new FrameworkPropertyMetadata(Brushes.DarkGray, FrameworkPropertyMetadataOptions.AffectsRender));
public SolidColorBrush N2PressureStatusColor
{
get
{
return (SolidColorBrush)this.GetValue(N2PressureStatusColorProperty);
}
set
{
this.SetValue(N2PressureStatusColorProperty, value);
}
}
public AITPump25()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData25 == null)
return;
if (DeviceData25.IsError || DeviceData25.IsOverLoad)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_error.png"));
else if (DeviceData25.IsWarning)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_warning.png"));
else if (DeviceData25.IsOn)
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_on.png"));
else
imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/MECF.Framework.Common;component/Resources/Pump/pump_off.png"));
StackPanelN2Pressure.Visibility = (DeviceData25.IsN2PressureEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
StackPanelWaterFlow.Visibility = (DeviceData25.IsWaterFlowEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
StackPanelDryPump.Visibility = (DeviceData25.IsDryPumpEnable && IsShowSensor) ? Visibility.Visible : Visibility.Hidden;
WaterFlowStatusColor = DeviceData25.WaterFlowAlarm
? Brushes.Red
: (DeviceData25.WaterFlowWarning ? Brushes.Yellow : Brushes.Lime);
N2PressureStatusColor = DeviceData25.N2PressureAlarm
? Brushes.Red
: (DeviceData25.N2PressureWarning ? Brushes.Yellow : Brushes.Lime);
txtSpeed.Background = DeviceData25.AtSpeed ? Brushes.Transparent : Brushes.LimeGreen;
txtTemp.Background = DeviceData25.OverTemp ? Brushes.OrangeRed : Brushes.Transparent;
if (imagePicture.ContextMenu != null && imagePicture.ContextMenu.Items.Count == 3)
{
((MenuItem)imagePicture.ContextMenu.Items[0]).IsEnabled = !DeviceData25.IsOn;
((MenuItem)imagePicture.ContextMenu.Items[1]).IsEnabled = DeviceData25.IsOn;
((MenuItem)imagePicture.ContextMenu.Items[2]).IsEnabled = DeviceData25.IsOn;
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData25 != null)
{
string tooltipValue =
string.Format("{0}:{1}\r\n\r\nID:{2} ",
"",
DeviceData25.DisplayName,
DeviceData25.DeviceSchematicId);
ToolTip = tooltipValue;
}
}
private void PumpOn(object sender, RoutedEventArgs e)
{
if (EnableControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData25.DeviceModule}.{DeviceData25.DeviceName}.PumpStart");
}
}
private void PumpOff(object sender, RoutedEventArgs e)
{
if (EnableControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData25.DeviceModule}.{DeviceData25.DeviceName}.PumpStop");
}
}
private void PumpUtility(object sender, RoutedEventArgs e)
{
if (EnableControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData25.DeviceModule}.{DeviceData25.DeviceName}.PumpUtility");
}
}
}
}
@@ -0,0 +1,28 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITRf"
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" d:DesignHeight="78" d:DesignWidth="90" BorderThickness="1" x:Name="self" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid Margin="0" MouseLeftButtonUp="Grid_MouseLeftButtonUp" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Style="{x:Null}" Background="Transparent" Margin="-2" x:Name="bdRectangle" BorderThickness="1">
<Rectangle Style="{x:Null}" RadiusX="2" RadiusY="2" Name="rectBkground" Stroke="Black" Margin="1" Opacity="1" Fill="Gray" StrokeThickness="1"/>
</Border>
<Label Background="Transparent" VerticalContentAlignment="Center" FontFamily="Verdana" HorizontalContentAlignment="Center" x:Name="labelValue" Foreground="MidnightBlue" />
</Grid>
<Grid Margin="0" Grid.Row="1" MouseLeftButtonUp="Grid_MouseLeftButtonUp" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Style="{x:Null}" Background="Transparent" Margin="-2" BorderThickness="1">
<Rectangle Style="{x:Null}" RadiusX="2" RadiusY="2" Stroke="Black" Margin="1" Opacity="1" Fill="Gray" StrokeThickness="1"/>
</Border>
<Label x:Name="LabelPower" VerticalContentAlignment="Center" FontFamily="Verdana" HorizontalContentAlignment="Center" Foreground="MidnightBlue" />
</Grid>
</Grid>
</UserControl>
@@ -0,0 +1,243 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITRfGenerator.xaml 的交互逻辑
/// </summary>
public partial class AITRf : UserControl
{
public AITRf()
{
InitializeComponent();
}
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITRf),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITRfData), typeof(AITRf),
new FrameworkPropertyMetadata(new AITRfData(), FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITRfData DeviceData
{
get
{
return (AITRfData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData != null)
{
//draw red board if meets a warning
//rectBkground.Stroke = DeviceData.HasError ? Brushes.Red : Brushes.Gray;
//labelValue.Foreground = !DeviceData.IsInterlockOK ? Brushes.Pink : Brushes.MidnightBlue;
rectBkground.StrokeThickness = DeviceData.HasError ? 2 : 1;
if (dialogBox != null)
{
dialogBox.ForwardPower = DeviceData.ForwardPower;
dialogBox.ReflectPower = DeviceData.ReflectPower;
dialogBox.IsRfOn = DeviceData.IsRfOn;
dialogBox.SetPointPower = DeviceData.PowerSetPoint;
dialogBox.IsContinuousMode = DeviceData.WorkMode == (int)RfMode.ContinuousWaveMode;
dialogBox.IsPulsingMode = DeviceData.WorkMode == (int)RfMode.PulsingMode;
dialogBox.Voltage = DeviceData.Voltage;
dialogBox.Current = DeviceData.Current;
}
rectBkground.Fill = DeviceData.IsRfOn ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(0xF1, 0xA2, 0xE4)) : (!DeviceData.HasError ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(0xD2, 0xD3, 0xD7)) : Brushes.Red);
if (DeviceData.EnableVoltageCurrent)
{
labelValue.Content = string.Format("{0}/{1}/{2}", DeviceData.ForwardPower.ToString("F0"), DeviceData.Voltage.ToString("F0"), DeviceData.Current.ToString("F0"));
}
else
{
labelValue.Content = string.Format("{0} : {1}", DeviceData.ForwardPower.ToString("F1"), DeviceData.ReflectPower.ToString("F1"));
}
LabelPower.Content = $"{DeviceData.PowerSetPoint:F1} w";
}
}
private AITRfInputDialogBox dialogBox;
public Window AnalogOwner { get; set; }
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData == null)
return;
dialogBox = new AITRfInputDialogBox
{
SetRfModeCommandDelegate = ExecuteSetMode,
SetContinuousCommandDelegate = ExecuteContinuous,
SetPulsingCommandDelegate = ExecutePulsing,
SetRfPowerOnOffCommandDelegate = ExecutePowerOnOff,
DeviceName = DeviceData.DisplayName,
DeviceId = DeviceData.DeviceSchematicId,
ForwardPower = DeviceData.ForwardPower,
ReflectPower = DeviceData.ReflectPower,
IsRfOn = DeviceData.IsRfOn,
Voltage = DeviceData.Voltage,
Current = DeviceData.Current,
SetPointPower = Math.Round(DeviceData.PowerSetPoint, 1),
MaxValuePower = DeviceData.ScalePower,
UnitPower = DeviceData.UnitPower,
SetPointFrequency = Math.Round(DeviceData.FrequencySetPoint, 1),
MaxValueFrequency = DeviceData.ScaleFrequency,
UnitFrequency = DeviceData.UnitFrequency,
SetPointDuty = Math.Round(DeviceData.DutySetPoint, 1),
MaxValueDuty = DeviceData.ScaleDuty,
UnitDuty = DeviceData.UnitDuty,
IsContinuousMode = DeviceData.WorkMode == (int)RfMode.ContinuousWaveMode,
IsPulsingMode = DeviceData.WorkMode == (int)RfMode.PulsingMode,
EnablePulsing = DeviceData.EnablePulsing,
GridLengthReflect = DeviceData.EnableReflectPower ? GridLength.Auto : new GridLength(0),
GridLengthVoltageCurrent = DeviceData.EnableVoltageCurrent ? GridLength.Auto : new GridLength(0),
GridLengthWorkMode = DeviceData.EnablePulsing ? GridLength.Auto : new GridLength(0),
};
if (AnalogOwner != null)
dialogBox.Owner = AnalogOwner;
dialogBox.Topmost = true;
dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
dialogBox.FocasAll();
dialogBox.ShowDialog();
dialogBox = null;
}
private void ExecuteSetMode(RfMode value)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetMode}", value.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetMode.ToString(), value.ToString() });
}
private void ExecutePowerOnOff(bool value)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetPowerOnOff}", value.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetPowerOnOff.ToString(), value.ToString() });
}
private void ExecuteContinuous(double power)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetContinuousPower}", power.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetContinuousPower.ToString(), power.ToString() });
}
private void ExecutePulsing(double power, double frequency, double duty)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetPulsingPower}", power.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetPulsingPower.ToString(), power.ToString(), frequency.ToString(), duty.ToString() });
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
try
{
string tooltipValue =
DeviceData.EnableVoltageCurrent
? string.Format("{0}:{1}\r\n\r\nID:{2}\r\nForward Power:{3} w\r\nVoltage:{4} \r\nCurrent:{5} \r\nSetPoint:{6} w",
"RF",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.ForwardPower.ToString("F1"),
DeviceData.Voltage.ToString("F1"),
DeviceData.Current.ToString("F1"),
DeviceData.PowerSetPoint.ToString("F1"))
: string.Format("{0}:{1}\r\n\r\nID:{2}\r\nForward Power:{3} w\r\nReflect Power:{4} w \r\nSetPoint:{5} w",
"RF",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.ForwardPower.ToString("F1"),
DeviceData.ReflectPower.ToString("F1"),
DeviceData.PowerSetPoint.ToString("F1"));
ToolTip = tooltipValue;
}
catch (Exception ex)
{
LOG.Write(ex);
}
}
}
}
}
@@ -0,0 +1,13 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITRfGenerator"
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" Height="24" Width="90" BorderThickness="1" x:Name="self">
<Grid Height="24" MouseLeftButtonUp="Grid_MouseLeftButtonUp" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Background="Transparent" x:Name="bdRectangle" BorderThickness="1">
<Rectangle Style="{x:Null}" RadiusX="2" RadiusY="2" Name="rectBkground" Stroke="Gray" Margin="1" Opacity="1" Fill="Gray" StrokeThickness="1"/>
</Border>
<Label VerticalContentAlignment="Center" Content="----/----/----" FontFamily="Verdana" FontSize="9" HorizontalContentAlignment="Center" x:Name="labelValue" Margin="0,-2,-2,-2" Foreground="MidnightBlue" />
</Grid>
</UserControl>
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.RT.Log;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITRfGenerator.xaml 的交互逻辑
/// </summary>
public partial class AITRfGenerator : UserControl
{
public AITRfGenerator()
{
InitializeComponent();
}
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITRfGenerator),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITRfData), typeof(AITRfGenerator),
new FrameworkPropertyMetadata(new AITRfData(), FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITRfData DeviceData
{
get
{
return (AITRfData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData != null)
{
//draw red board if meets a warning
rectBkground.Stroke = DeviceData.HasError ? Brushes.Red : Brushes.Gray;
//labelValue.Foreground = !DeviceData.IsInterlockOK ? Brushes.Pink : Brushes.MidnightBlue;
rectBkground.StrokeThickness = DeviceData.HasError ? 2 : 1;
if (dialogBox != null)
{
dialogBox.ForwardPower = DeviceData.ForwardPower ;
dialogBox.ReflectPower = DeviceData.ReflectPower ;
dialogBox.IsRfOn = DeviceData.IsRfOn;
dialogBox.SetPointPower = DeviceData.PowerSetPoint;
dialogBox.IsContinuousMode = DeviceData.WorkMode == (int) RfMode.ContinuousWaveMode;
dialogBox.IsPulsingMode = DeviceData.WorkMode == (int) RfMode.PulsingMode;
dialogBox.Voltage = DeviceData.Voltage;
dialogBox.Current = DeviceData.Current;
}
rectBkground.Fill = DeviceData.IsRfOn ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(0xF1, 0xA2, 0xE4)) : (!DeviceData.HasError ? new SolidColorBrush(System.Windows.Media.Color.FromRgb(0xD2, 0xD3, 0xD7)) : Brushes.Red);
if (DeviceData.EnableVoltageCurrent)
{
labelValue.Content = string.Format("{0}/{1}/{2}", DeviceData.ForwardPower.ToString("F0"), DeviceData.Voltage.ToString("F0"), DeviceData.Current.ToString("F0"));
}
else
{
labelValue.Content = string.Format("{0} : {1}", DeviceData.ForwardPower.ToString("F1"), DeviceData.ReflectPower.ToString("F1"));
}
}
}
private AITRfInputDialogBox dialogBox;
public Window AnalogOwner { get; set; }
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData == null)
return;
dialogBox = new AITRfInputDialogBox
{
SetRfModeCommandDelegate = ExecuteSetMode,
SetContinuousCommandDelegate = ExecuteContinuous,
SetPulsingCommandDelegate = ExecutePulsing,
SetRfPowerOnOffCommandDelegate = ExecutePowerOnOff,
DeviceName = DeviceData.DisplayName,
DeviceId = DeviceData.DeviceSchematicId,
ForwardPower = DeviceData.ForwardPower,
ReflectPower = DeviceData.ReflectPower,
IsRfOn = DeviceData.IsRfOn,
Voltage = DeviceData.Voltage,
Current = DeviceData.Current,
SetPointPower = Math.Round(DeviceData.PowerSetPoint, 1),
MaxValuePower = DeviceData.ScalePower,
UnitPower = DeviceData.UnitPower,
SetPointFrequency = Math.Round(DeviceData.FrequencySetPoint, 1),
MaxValueFrequency = DeviceData.ScaleFrequency,
UnitFrequency = DeviceData.UnitFrequency,
SetPointDuty = Math.Round(DeviceData.DutySetPoint, 1),
MaxValueDuty = DeviceData.ScaleDuty,
UnitDuty = DeviceData.UnitDuty,
IsContinuousMode = DeviceData.WorkMode == (int)RfMode.ContinuousWaveMode,
IsPulsingMode = DeviceData.WorkMode==(int)RfMode.PulsingMode,
EnablePulsing = DeviceData.EnablePulsing,
GridLengthReflect = DeviceData.EnableReflectPower ? GridLength.Auto : new GridLength(0),
GridLengthVoltageCurrent = DeviceData.EnableVoltageCurrent ? GridLength.Auto : new GridLength(0),
GridLengthWorkMode = DeviceData.EnablePulsing ? GridLength.Auto : new GridLength(0),
};
if (AnalogOwner != null)
dialogBox.Owner = AnalogOwner;
dialogBox.Topmost = true;
dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
dialogBox.FocasAll();
dialogBox.ShowDialog();
dialogBox = null;
}
private void ExecuteSetMode(RfMode value)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetMode}", value.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetMode.ToString(), value.ToString() });
}
private void ExecutePowerOnOff(bool value)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetPowerOnOff}", value.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetPowerOnOff.ToString(), value.ToString() });
}
private void ExecuteContinuous(double power)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetContinuousPower}", power.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetContinuousPower.ToString(), power.ToString() });
}
private void ExecutePulsing(double power, double frequency, double duty)
{
if (Command == null)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITRfOperation.SetPulsingPower}", power.ToString());
return;
}
Command.Execute(new object[] { DeviceData.DeviceName, AITRfOperation.SetPulsingPower.ToString(), power.ToString(), frequency.ToString(), duty.ToString() });
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
try
{
string tooltipValue =
DeviceData.EnableVoltageCurrent
? string.Format("{0}:{1}\r\n\r\nID:{2}\r\nForward Power:{3} w\r\nVoltage:{4} \r\nCurrent:{5} \r\nSetPoint:{6} w",
"RF",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.ForwardPower.ToString("F1"),
DeviceData.Voltage.ToString("F1"),
DeviceData.Current.ToString("F1"),
DeviceData.PowerSetPoint.ToString("F1"))
: string.Format("{0}:{1}\r\n\r\nID:{2}\r\nForward Power:{3} w\r\nReflect Power:{4} w \r\nSetPoint:{5} w",
"RF",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.ForwardPower.ToString("F1"),
DeviceData.ReflectPower.ToString("F1"),
DeviceData.PowerSetPoint.ToString("F1"));
ToolTip = tooltipValue;
}
catch (Exception ex)
{
LOG.Write(ex);
}
}
}
}
}
@@ -0,0 +1,86 @@
<Window x:Class="Aitex.Core.UI.Control.AITRfInputDialogBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Aitex.Core.UI.Control"
Height="355" Width="260" MaxHeight="355" MinHeight="355" MaxWidth="300" MinWidth="300" WindowStyle="ToolWindow"
WindowStartupLocation="CenterOwner"
KeyDown="OnEnterKeyIsHit"
Title="{Binding Path=DeviceId, StringFormat={}{0} SetPoint}">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="50" />
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="13" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="25" />
</Style>
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<my:DoubleConverter x:Key="doubleConverter"/>
</Window.Resources>
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="{Binding GridLengthWorkMode}"/>
<RowDefinition Height="{Binding GridLengthWorkMode}"/>
<RowDefinition Height="{Binding GridLengthWorkMode}"/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="{Binding GridLengthReflect}"/>
<RowDefinition Height="{Binding GridLengthVoltageCurrent}"/>
<RowDefinition Height="{Binding GridLengthVoltageCurrent}"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="Device Name:" />
<Label Grid.Row="1" Grid.Column="1" Content="WorkMode:" />
<Label Grid.Row="2" Grid.Column="1" Content="Pulsing Frequency:" x:Name="lblFrequency"/>
<Label Grid.Row="3" Grid.Column="1" Content="Pulsing Duty:" x:Name="lblDuty"/>
<Label Grid.Row="4" Grid.Column="1" Content="Max:" />
<Label Grid.Row="5" Grid.Column="1" Content="Forward Power:" />
<Label Grid.Row="6" Grid.Column="1" Content="Reflect Power:" />
<Label Grid.Row="7" Grid.Column="1" Content="Voltage:" />
<Label Grid.Row="8" Grid.Column="1" Content="Current:" />
<Label Grid.Row="9" Grid.Column="1" Content="Set Point:" />
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=DeviceName}" Width="150" Height="28" HorizontalAlignment="Left" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" VerticalContentAlignment="Center" />
<Label Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="10" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" >
<StackPanel Orientation="Horizontal">
<CheckBox x:Name="ckContinuous" Checked="CkContinuous_OnChecked" ButtonBase.Click="CkContinuous_OnClick" VerticalContentAlignment="Center">Continuous</CheckBox>
<CheckBox x:Name="ckPulsing" Checked="CkPulsing_OnChecked" ButtonBase.Click="CkPulsing_OnClick" Margin="10,0,0,0" VerticalContentAlignment="Center">Pulsing</CheckBox>
</StackPanel>
</Label>
<TextBox Grid.Row="2" Grid.Column="2" x:Name="inputBoxFrequency" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBoxFrequency_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center" />
<TextBox Grid.Row="3" Grid.Column="2" x:Name="inputBoxDuty" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBoxDuty_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center" />
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=MaxValuePower, StringFormat={}{0:F1}}" ContentStringFormat="{}{0:F2}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="5" Grid.Column="2" Content="{Binding Path=ForwardPower, StringFormat={}{0:F1}}" ContentStringFormat="{}{0:F2}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="6" Grid.Column="2" Content="{Binding Path=ReflectPower, StringFormat={}{0:F1}}" ContentStringFormat="{}{0:F2}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="7" Grid.Column="2" Content="{Binding Path=Voltage, StringFormat={}{0:F1}}" ContentStringFormat="{}{0:F2}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<Label Grid.Row="8" Grid.Column="2" Content="{Binding Path=Current, StringFormat={}{0:F1}}" ContentStringFormat="{}{0:F2}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" />
<TextBox Grid.Row="9" Grid.Column="2" x:Name="inputBoxPower" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" TextChanged="InputTextBoxPower_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center" />
<Button Grid.Row="10" Grid.ColumnSpan="2" Content="Set" x:Name="buttonSet" Click="ButtonSet_Click" Width="60" Height="23" VerticalAlignment="Top" Grid.Column="1" Margin="5,3,0,0" />
<Button Grid.Row="10" Grid.ColumnSpan="2" Content="PowerOn" x:Name="buttonRFOn" Click="ButtonRFOn_Click" Width="60" Height="23" VerticalAlignment="Top" Grid.Column="1" Margin="76,3,0,0" />
<Button Grid.Row="10" Content="PowerOff" x:Name="buttonRFOff" Click="ButtonRFOff_Click" Width="60" Height="23" VerticalAlignment="Top" Grid.Column="2" Margin="17,3,0,0" />
<Button Grid.Row="10" Grid.Column="2" Content="Cancel" Click="ButtonCancel_Click" Width="60" Height="23" VerticalAlignment="Top" Margin="86,3,0,0" />
</Grid>
</Window>
@@ -0,0 +1,588 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Globalization;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.RT.Log;
namespace Aitex.Core.UI.Control
{
/// <summary>
/// Interaction logic for InputDialogBox.xaml
/// </summary>
public partial class AITRfInputDialogBox : Window
{
public AITRfInputDialogBox()
{
InitializeComponent();
DataContext = this;
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
public void FocasAll()
{
inputBoxDuty.Text = Math.Round(SetPointDuty, 2).ToString();
inputBoxFrequency.Text = Math.Round(SetPointFrequency, 2).ToString();
inputBoxPower.Text = Math.Round(SetPointPower, 2).ToString();
inputBoxPower.Focus();
inputBoxPower.SelectAll();
}
/// <summary>
/// Vilidate input range
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InputTextBoxPower_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBoxPower.Text, out input)) buttonSet.IsEnabled = false;
else if (input < 0 || input > MaxValuePower) buttonSet.IsEnabled = false;
else buttonSet.IsEnabled = true;
inputBoxPower.Foreground = buttonSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
private void InputTextBoxFrequency_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBoxFrequency.Text, out input)) buttonSet.IsEnabled = false;
else if (input < 0 || input > MaxValueFrequency) buttonSet.IsEnabled = false;
else buttonSet.IsEnabled = true;
inputBoxFrequency.Foreground = buttonSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
private void InputTextBoxDuty_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBoxDuty.Text, out input)) buttonSet.IsEnabled = false;
else if (input < 0 || input > MaxValueDuty) buttonSet.IsEnabled = false;
else buttonSet.IsEnabled = true;
inputBoxDuty.Foreground = buttonSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
public static readonly DependencyProperty DeviceNameProperty = DependencyProperty.Register(
"DeviceName", typeof(string), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceIdProperty = DependencyProperty.Register(
"DeviceId", typeof(string), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty ForwardPowerProperty = DependencyProperty.Register(
"ForwardPower", typeof(float), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0f, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty ReflectPowerProperty = DependencyProperty.Register(
"ReflectPower", typeof(float), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0f, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitPowerProperty = DependencyProperty.Register(
"UnitPower", typeof(string), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointPowerProperty = DependencyProperty.Register(
"SetPointPower", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValuePowerProperty = DependencyProperty.Register(
"MaxValuePower", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty VoltageProperty = DependencyProperty.Register(
"Voltage", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty CurrentProperty = DependencyProperty.Register(
"Current", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitFrequencyProperty = DependencyProperty.Register(
"UnitFrequency", typeof(string), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointFrequencyProperty = DependencyProperty.Register(
"SetPointFrequency", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValueFrequencyProperty = DependencyProperty.Register(
"MaxValueFrequency", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitDutyProperty = DependencyProperty.Register(
"UnitDuty", typeof(string), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointDutyProperty = DependencyProperty.Register(
"SetPointDuty", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValueDutyProperty = DependencyProperty.Register(
"MaxValueDuty", typeof(double), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsRfOnProperty = DependencyProperty.Register(
"IsRfOn", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsContinuousModeProperty = DependencyProperty.Register(
"IsContinuousMode", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsPulsingModeProperty = DependencyProperty.Register(
"IsPulsingMode", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EnablePulsingProperty = DependencyProperty.Register(
"EnablePulsing", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EnableReflectProperty = DependencyProperty.Register(
"EnableReflect", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty EnableVoltageCurrentProperty = DependencyProperty.Register(
"EnableVoltageCurrent", typeof(bool), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty GridLengthReflectProperty = DependencyProperty.Register(
"GridLengthReflect", typeof(GridLength), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(GridLength.Auto, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty GridLengthVoltageCurrentProperty = DependencyProperty.Register(
"GridLengthVoltageCurrent", typeof(GridLength), typeof(AITRfInputDialogBox),
new FrameworkPropertyMetadata(GridLength.Auto, FrameworkPropertyMetadataOptions.AffectsRender));
/// <summary>
/// 是否百分比显示
/// </summary>
public bool IsPercent { get; set; }
public string DeviceName
{
get
{
return (string)this.GetValue(DeviceNameProperty);
}
set
{
if (!string.IsNullOrEmpty(value) && !value.StartsWith("_"))
value = "_" + value;
this.SetValue(DeviceNameProperty, value);
}
}
public string DeviceId
{
get
{
return (string)this.GetValue(DeviceIdProperty);
}
set
{
this.SetValue(DeviceIdProperty, value);
}
}
public string UnitPower
{
get
{
return (string)this.GetValue(UnitPowerProperty);
}
set
{
this.SetValue(UnitPowerProperty, value);
}
}
public double SetPointPower
{
get
{
return (double)this.GetValue(SetPointPowerProperty);
}
set
{
this.SetValue(SetPointPowerProperty, value);
}
}
public double MaxValuePower
{
get
{
return (double)this.GetValue(MaxValuePowerProperty);
}
set
{
this.SetValue(MaxValuePowerProperty, value);
}
}
public string UnitFrequency
{
get
{
return (string)this.GetValue(UnitFrequencyProperty);
}
set
{
this.SetValue(UnitFrequencyProperty, value);
}
}
public double SetPointFrequency
{
get
{
return (double)this.GetValue(SetPointFrequencyProperty);
}
set
{
this.SetValue(SetPointFrequencyProperty, value);
}
}
public double MaxValueFrequency
{
get
{
return (double)this.GetValue(MaxValueFrequencyProperty);
}
set
{
this.SetValue(MaxValueFrequencyProperty, value);
}
}
public double Voltage
{
get
{
return (double)this.GetValue(VoltageProperty);
}
set
{
this.SetValue(VoltageProperty, value);
}
}
public double Current
{
get
{
return (double)this.GetValue(CurrentProperty);
}
set
{
this.SetValue(CurrentProperty, value);
}
}
public string UnitDuty
{
get
{
return (string)this.GetValue(UnitDutyProperty);
}
set
{
this.SetValue(UnitDutyProperty, value);
}
}
public double SetPointDuty
{
get
{
return (double)this.GetValue(SetPointDutyProperty);
}
set
{
this.SetValue(SetPointDutyProperty, value);
}
}
public double MaxValueDuty
{
get
{
return (double)this.GetValue(MaxValueDutyProperty);
}
set
{
this.SetValue(MaxValueDutyProperty, value);
}
}
public float ForwardPower
{
get
{
return (float)this.GetValue(ForwardPowerProperty);
}
set
{
this.SetValue(ForwardPowerProperty, value);
}
}
public float ReflectPower
{
get
{
return (float)this.GetValue(ReflectPowerProperty);
}
set
{
this.SetValue(ReflectPowerProperty, value);
}
}
public bool IsRfOn
{
get
{
return (bool)this.GetValue(IsRfOnProperty);
}
set
{
this.SetValue(IsRfOnProperty, value);
buttonRFOff.IsEnabled = value;
buttonRFOn.IsEnabled = !value;
//if (!value)
// buttonSet.IsEnabled = false;
}
}
public bool IsContinuousMode
{
get
{
return (bool)this.GetValue(IsContinuousModeProperty);
}
set
{
this.SetValue(IsContinuousModeProperty, value);
ckContinuous.IsChecked = IsContinuousMode;
lblFrequency.Foreground = IsPulsingMode ? Brushes.Black : Brushes.Gray;
lblDuty.Foreground = IsPulsingMode ? Brushes.Black : Brushes.Gray;
inputBoxFrequency.IsEnabled = IsPulsingMode;
inputBoxDuty.IsEnabled = IsPulsingMode;
}
}
public bool IsPulsingMode
{
get
{
return (bool)this.GetValue(IsPulsingModeProperty);
}
set
{
this.SetValue(IsPulsingModeProperty, value);
ckPulsing.IsChecked = IsPulsingMode;
lblFrequency.Foreground = IsPulsingMode ? Brushes.Black : Brushes.Gray;
lblDuty.Foreground = IsPulsingMode ? Brushes.Black : Brushes.Gray;
inputBoxFrequency.IsEnabled = IsPulsingMode;
inputBoxDuty.IsEnabled = IsPulsingMode;
}
}
public bool EnablePulsing
{
get
{
return (bool)this.GetValue(EnablePulsingProperty);
}
set
{
this.SetValue(EnablePulsingProperty, value);
ckPulsing.Visibility = value ? Visibility.Visible : Visibility.Hidden;
}
}
public bool EnableReflect
{
get
{
return (bool)this.GetValue(EnableReflectProperty);
}
set
{
this.SetValue(EnableReflectProperty, value);
}
}
public bool EnableVoltageCurrent
{
get
{
return (bool)this.GetValue(EnableVoltageCurrentProperty);
}
set
{
this.SetValue(EnableVoltageCurrentProperty, value);
}
}
public GridLength GridLengthReflect
{
get
{
return (GridLength)this.GetValue(GridLengthReflectProperty);
}
set
{
this.SetValue(GridLengthReflectProperty, value);
}
}
public GridLength GridLengthWorkMode
{
get;
set;
}
public GridLength GridLengthVoltageCurrent
{
get
{
return (GridLength)this.GetValue(GridLengthVoltageCurrentProperty);
}
set
{
this.SetValue(GridLengthVoltageCurrentProperty, value);
}
}
public Action<RfMode> SetRfModeCommandDelegate;
public Action<bool> SetRfPowerOnOffCommandDelegate;
public Action<double> SetContinuousCommandDelegate;
public Action<double, double, double> SetPulsingCommandDelegate;
private void ButtonSet_Click(object sender, RoutedEventArgs e)
{
try
{
if (IsContinuousMode)
SetContinuousCommandDelegate(Convert.ToDouble(inputBoxPower.Text));
else if (IsPulsingMode)
SetPulsingCommandDelegate(Convert.ToDouble(inputBoxPower.Text), Convert.ToDouble(inputBoxFrequency.Text), Convert.ToDouble(inputBoxDuty.Text));
Close();
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
{
try
{
if (!buttonSet.IsEnabled) return;
if (e.Key == Key.Return)
{
ButtonSet_Click(null, null);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void CkPulsing_OnChecked(object sender, RoutedEventArgs e)
{
if (IsPulsingMode)
return;
ckPulsing.IsChecked = false;
try
{
if (SetRfModeCommandDelegate != null)
{
SetRfModeCommandDelegate(RfMode.PulsingMode);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void CkContinuous_OnChecked(object sender, RoutedEventArgs e)
{
if (IsContinuousMode)
return;
ckContinuous.IsChecked = false;
try
{
if (SetRfModeCommandDelegate != null)
{
SetRfModeCommandDelegate(RfMode.ContinuousWaveMode);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void CkContinuous_OnClick(object sender, RoutedEventArgs e)
{
ckContinuous.IsChecked = IsContinuousMode;
}
private void CkPulsing_OnClick(object sender, RoutedEventArgs e)
{
ckPulsing.IsChecked = IsPulsingMode;
}
private void ButtonRFOn_Click(object sender, RoutedEventArgs e)
{
try
{
if (SetRfPowerOnOffCommandDelegate != null)
{
SetRfPowerOnOffCommandDelegate(true);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonRFOff_Click(object sender, RoutedEventArgs e)
{
try
{
if (SetRfPowerOnOffCommandDelegate != null)
{
SetRfPowerOnOffCommandDelegate(false);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
}
}
@@ -0,0 +1,22 @@
<UserControl
x:Class="Aitex.Core.UI.DeviceControl.AITSensor"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="20"
d:DesignWidth="20"
mc:Ignorable="d">
<Grid MouseEnter="Grid_MouseEnter">
<Ellipse
x:Name="sensor"
Width="15"
Height="15"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="Gray"
Stroke="Gray"
StrokeThickness="2"
Style="{x:Null}" />
</Grid>
</UserControl>
@@ -0,0 +1,146 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITSensor.xaml 的交互逻辑
/// </summary>
public partial class AITSensor : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITSensorData), typeof(AITSensor), new FrameworkPropertyMetadata(new AITSensorData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITSensorData DeviceData
{
get { return (AITSensorData)this.GetValue(DeviceDataProperty); }
set { this.SetValue(DeviceDataProperty, value); }
}
public bool GreenColor
{
get { return (bool)GetValue(GreenColorProperty); }
set { SetValue(GreenColorProperty, value); }
}
// Using a DependencyProperty as the backing store for GreenColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty GreenColorProperty =
DependencyProperty.Register("GreenColor", typeof(bool), typeof(AITSensor), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableToolTip
{
get { return (bool)GetValue(EnableToolTipProperty); }
set { SetValue(EnableToolTipProperty, value); }
}
// Using a DependencyProperty as the backing store for EnableToolTip. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EnableToolTipProperty =
DependencyProperty.Register("EnableToolTip", typeof(bool), typeof(AITSensor), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool LightOnValue
{
get { return (bool)GetValue(LightOnValueProperty); }
set { SetValue(LightOnValueProperty, value); }
}
public static readonly DependencyProperty LightOnValueProperty =
DependencyProperty.Register("LightOnValue", typeof(bool), typeof(AITSensor), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsInterlockMode
{
get { return (bool)GetValue(IsInterlockModeProperty); }
set { SetValue(IsInterlockModeProperty, value); }
}
public static readonly DependencyProperty IsInterlockModeProperty =
DependencyProperty.Register("IsInterlockMode", typeof(bool), typeof(AITSensor), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsCustomRender
{
get { return (bool)GetValue(IsCustomRenderProperty); }
set { SetValue(IsCustomRenderProperty, value); }
}
public static readonly DependencyProperty IsCustomRenderProperty =
DependencyProperty.Register("IsCustomRender", typeof(bool), typeof(AITSensor), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public Brush CustomColorOn
{
get { return (Brush)GetValue(CustomColorOnProperty); }
set { SetValue(CustomColorOnProperty, value); }
}
public static readonly DependencyProperty CustomColorOnProperty =
DependencyProperty.Register("CustomColorOn", typeof(Brush), typeof(AITSensor), new FrameworkPropertyMetadata(new SolidColorBrush(Colors.Lime), FrameworkPropertyMetadataOptions.AffectsRender));
public Brush CustomColorOff
{
get { return (Brush)GetValue(CustomColorOffProperty); }
set { SetValue(CustomColorOffProperty, value); }
}
public static readonly DependencyProperty CustomColorOffProperty =
DependencyProperty.Register("CustomColorOff", typeof(Brush), typeof(AITSensor), new FrameworkPropertyMetadata(new SolidColorBrush(Colors.Gray), FrameworkPropertyMetadataOptions.AffectsRender));
public AITSensor()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (IsCustomRender)
{
if (DeviceData == null || string.IsNullOrEmpty(DeviceData.DeviceName))
{
sensor.Fill = LightOnValue? CustomColorOn : CustomColorOff;
}
else
{
sensor.Fill = DeviceData.Value ? CustomColorOn : CustomColorOff;
}
return;
}
if (DeviceData == null || string.IsNullOrEmpty(DeviceData.DeviceName))
{
if (LightOnValue)
sensor.Fill = (GreenColor ? new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF07FF07")) : new SolidColorBrush(Colors.Red));
else
sensor.Fill = new SolidColorBrush(Colors.Gray);
return;
}
if (IsInterlockMode)
{
sensor.Fill = DeviceData.Value ? new SolidColorBrush(Colors.Lime) : new SolidColorBrush(Colors.Red);
}
else
{
if (DeviceData.IsError)
{
sensor.Fill = new SolidColorBrush(Colors.Red);
}
else
{
sensor.Fill = DeviceData.Value ? new SolidColorBrush(Colors.Lime) : new SolidColorBrush(Colors.Gray);
}
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null && EnableToolTip)
{
ToolTip = $"Sensor \r\n {DeviceData.DisplayName} \r\n {DeviceData.Value}";
}
}
}
}
@@ -0,0 +1,128 @@
<UserControl
x:Class="Aitex.Core.UI.DeviceControl.AITSignalTower"
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="105"
d:DesignWidth="30"
mc:Ignorable="d">
<Border x:Name="TopGrid" Background="Transparent">
<Grid Width="30" Height="85">
<Grid.RowDefinitions>
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Image
Name="rectangle1"
Canvas.Left="0"
Canvas.Top="0"
Width="30"
Height="20"
VerticalAlignment="Top"
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/red.png"
Stretch="Fill">
<Image.Effect>
<DropShadowEffect
BlurRadius="20"
Opacity="1"
RenderingBias="Performance"
ShadowDepth="0"
Color="Red" />
</Image.Effect>
</Image>
<Image
Name="rectangle2"
Grid.Row="1"
Canvas.Left="0"
Canvas.Top="0"
Width="30"
Height="20"
VerticalAlignment="Bottom"
PreviewMouseDown="rectangle2_PreviewMouseDown"
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/yellow.png"
Stretch="Fill">
<Image.Effect>
<DropShadowEffect
BlurRadius="20"
Opacity="1"
RenderingBias="Performance"
ShadowDepth="0"
Color="Green" />
<!--<BlurEffect RenderingBias="Performance" Radius="15" >
</BlurEffect>-->
</Image.Effect>
</Image>
<Image
Name="rectangle3"
Grid.Row="2"
Canvas.Left="0"
Canvas.Top="0"
Width="30"
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/Lime.png"
Stretch="Fill">
<Image.Effect>
<DropShadowEffect
BlurRadius="20"
Opacity="1"
RenderingBias="Performance"
ShadowDepth="0"
Color="Green" />
<!--<BlurEffect RenderingBias="Performance" Radius="15" >
</BlurEffect>-->
</Image.Effect>
</Image>
<Image
Name="rectangle4"
Grid.Row="3"
Canvas.Left="0"
Canvas.Top="0"
Width="30"
Height="20"
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/Blue.png"
Stretch="Fill"
Visibility="Hidden">
<Image.Effect>
<DropShadowEffect
BlurRadius="20"
Opacity="1"
RenderingBias="Performance"
ShadowDepth="0"
Color="Green" />
<!--<BlurEffect RenderingBias="Performance" Radius="15" >
</BlurEffect>-->
</Image.Effect>
</Image>
<Image
Name="rectangle5"
Grid.Row="3"
Canvas.Left="0"
Canvas.Top="0"
Width="30"
Height="30"
Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/lights.png"
Stretch="Fill">
<Image.Effect>
<DropShadowEffect
BlurRadius="20"
Opacity="1"
RenderingBias="Performance"
ShadowDepth="0"
Color="White" />
<!--<BlurEffect RenderingBias="Performance" Radius="15" >
</BlurEffect>-->
</Image.Effect>
</Image>
</Grid>
</Border>
</UserControl>
@@ -0,0 +1,179 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Effects;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
public partial class AITSignalTower : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
nameof(DeviceData), typeof(AITSignalTowerData), typeof(AITSignalTower),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty BuzzingWarningConfigCommandProperty = DependencyProperty.Register(
nameof(BuzzingWarningConfigCallback), typeof(Action), typeof(AITSignalTower),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.None));
public Action BuzzingWarningConfigCallback
{
get => (Action)GetValue(BuzzingWarningConfigCommandProperty);
set => SetValue(BuzzingWarningConfigCommandProperty, value);
}
public AITSignalTowerData DeviceData
{
get => (AITSignalTowerData)GetValue(DeviceDataProperty);
set => SetValue(DeviceDataProperty, value);
}
private readonly DropShadowEffect _redLightEffect = new();
private readonly DropShadowEffect _yellowLightEffect = new();
private readonly DropShadowEffect _greenLightEffect = new();
private readonly DropShadowEffect _blueLightEffect = new();
private readonly DropShadowEffect _buzzerLightEffect = new();
public double OutLights = 0.2;
public AITSignalTower()
{
InitializeComponent();
_redLightEffect.BlurRadius = 20;
_redLightEffect.Opacity = 1;
_redLightEffect.Color = Colors.Red;
_yellowLightEffect.BlurRadius = 20;
_yellowLightEffect.Opacity = 1;
_yellowLightEffect.Color = Colors.Yellow;
_greenLightEffect.BlurRadius = 20;
_greenLightEffect.Opacity = 1;
_greenLightEffect.Color = Colors.Green;
_blueLightEffect.BlurRadius = 20;
_blueLightEffect.Opacity = 1;
_blueLightEffect.Color = Colors.Blue;
_buzzerLightEffect.BlurRadius = 20;
_buzzerLightEffect.Opacity = 1;
_buzzerLightEffect.Color = Colors.White;
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData == null)
return;
if (DeviceData.IsRedLightOn)
{
if (rectangle1.Opacity != 1)
{
rectangle1.Opacity = 1;
rectangle1.Effect = _redLightEffect;
}
}
else
{
if (rectangle1.Opacity != OutLights)
{
rectangle1.Opacity = OutLights;
rectangle1.Effect = null;
}
}
if (DeviceData.IsYellowLightOn)
{
if (rectangle2.Opacity != 1)
{
rectangle2.Opacity = 1;
rectangle2.Effect = _yellowLightEffect;
}
}
else
{
if (rectangle2.Opacity != OutLights)
{
rectangle2.Opacity = OutLights;
rectangle2.Effect = null;
}
}
if (DeviceData.IsGreenLightOn)
{
if (rectangle3.Opacity != 1)
{
rectangle3.Opacity = 1;
rectangle3.Effect = _greenLightEffect;
}
}
else
{
if (rectangle3.Opacity != OutLights)
{
rectangle3.Opacity = OutLights;
rectangle3.Effect = null;
}
}
if (DeviceData.IsBlueLightOn)
{
if (rectangle4.Opacity != 1)
{
rectangle4.Opacity = 1;
rectangle4.Effect = _blueLightEffect;
}
}
else
{
if (rectangle4.Opacity != OutLights)
{
rectangle4.Opacity = OutLights;
rectangle4.Effect = null;
}
}
if (DeviceData.IsBuzzerOn || DeviceData.IsBuzzer1On || DeviceData.IsBuzzer2On || DeviceData.IsBuzzer3On ||
DeviceData.IsBuzzer4On)
{
if (rectangle5.Opacity != 1)
{
rectangle5.Opacity = 1;
rectangle5.Effect = _buzzerLightEffect;
}
}
else
{
if (rectangle5.Opacity != OutLights)
{
rectangle5.Opacity = OutLights;
rectangle5.Effect = null;
}
}
}
private void rectangle2_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (BuzzingWarningConfigCallback != null)
{
BuzzingWarningConfigCallback.Invoke();
}
}
private void TopGrid_OnMouseEnter(object sender, MouseEventArgs e)
{
TopGrid.ToolTip = $"Red: {DeviceData.RedLightEvent}\r\n" +
$"Yellow: {DeviceData.YellowLightEvent}\r\n" +
$"Green: {DeviceData.GreenLightEvent}\r\n" +
$"Buzzer: {DeviceData.BuzzerEvent}";
}
}
}
@@ -0,0 +1,13 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITThermalCouple"
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" Height="24" Width="45" BorderThickness="1" x:Name="self">
<Grid Height="24" Cursor="Hand" Opacity="1" MouseEnter="Grid_MouseEnter">
<Border Background="Transparent" x:Name="bdRectangle" BorderThickness="1">
<Rectangle RadiusX="2" RadiusY="2" Name="rectBkground" Stroke="#373737" Margin="1" Opacity="1" Fill="DarkMagenta" StrokeThickness="1"/>
</Border>
<Label Content="{Binding ElementName=self, Path=DeviceData.FeedBack}" VerticalContentAlignment="Center" ContentStringFormat="F1" FontFamily="Verdana" FontSize="9" HorizontalContentAlignment="Center" x:Name="labelValue" Margin="0,-2,-2,-2" Foreground="LightYellow" />
</Grid>
</UserControl>
@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITThermalCouple.xaml 的交互逻辑
/// </summary>
public partial class AITThermalCouple : UserControl
{
public AITThermalCouple()
{
InitializeComponent();
}
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITThermalCoupleData), typeof(AITThermalCouple),
new FrameworkPropertyMetadata(new AITThermalCoupleData(), FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
"BackColor", typeof(Brush), typeof(AITThermalCouple),
new FrameworkPropertyMetadata(Brushes.DarkMagenta, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsControlTcProperty = DependencyProperty.Register(
"IsControlTc", typeof(bool), typeof(AITThermalCouple),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool IsControlTc
{
get
{
return (bool)this.GetValue(IsControlTcProperty);
}
set
{
this.SetValue(IsControlTcProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITThermalCoupleData DeviceData
{
get
{
return (AITThermalCoupleData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public Brush BackColor
{
get
{
return (Brush)this.GetValue(BackColorProperty);
}
set
{
this.SetValue(BackColorProperty, value);
}
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
Brush background = Brushes.DarkMagenta;
Brush foreground = Brushes.LightYellow;
if (!IsControlTc)
{
background = Brushes.DarkGray;
foreground = Brushes.Black;
}
if (DeviceData != null)
{
//rectBkground.Stroke = DeviceData.IsOffline ? Brushes.Pink : new SolidColorBrush(System.Windows.Media.Color.FromRgb(0X37, 0X37, 0X37));
//rectBkground.StrokeThickness = DeviceData.IsOffline ? 2 : 1;
//else
// labelValue.Foreground = DeviceData.IsOffline ? Brushes.Red : Brushes.LightYellow;
if (DeviceData.IsBroken || DeviceData.IsAlarm)
{
background = Brushes.Red;
}else if (DeviceData.IsOutOfTolerance)
{
background = Brushes.Gold;
}
}
rectBkground.Fill = background;
labelValue.Foreground = foreground;
}
public Window AnalogOwner { get; set; }
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format(Application.Current.Resources["GlobalLableThermoMeterToolTip"].ToString(),
DeviceData.Type,
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.FeedBack.ToString("F1"),
DeviceData.Unit,
DeviceData.IsAlarm ? "Alarm" : (DeviceData.IsWarning ? "Warning" : (DeviceData.IsOutOfTolerance ? "Abnormal" : "Normal")),
DeviceData.IsBroken ? "Broken" : "Normal");
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,22 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITThrottleValve"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="36" Width="36" MinWidth="36" MaxWidth="36" MinHeight="36" MaxHeight="36" BorderThickness="1 1 1 1">
<Grid>
<Grid Background=" Transparent" Cursor="Hand" MouseEnter="Grid_MouseEnter" MouseLeftButtonUp="Grid_MouseLeftButtonUp">
<Grid.RenderTransform>
<RotateTransform x:Name="rotateTransform" Angle="20" CenterX="18" CenterY="18" />
</Grid.RenderTransform>
<Ellipse Stroke="Black" Fill="White" Height="34" Width="34" />
<Line X1="3" Y1="17" X2="31" Y2="17" Stroke="Black" StrokeThickness="1.2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line X1="3" Y1="17" X2="9" Y2="15" Stroke="Black" StrokeThickness="1.2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
<Line X1="3" Y1="17" X2="9" Y2="19" Stroke="Black" StrokeThickness="1.2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" />
</Grid>
<Label Background="DarkGreen" FontFamily="Arial" Foreground="White" FontSize="12" HorizontalContentAlignment="Center" Name="labelAngle" Margin="39,-6,-76,0" Height="22" VerticalAlignment="Top"/>
<Label Background="DarkGreen" FontFamily="Arial" Foreground="White" FontSize="12" HorizontalContentAlignment="Center" Name="labelPressure" Margin="39,17,-76,-5" Height="22" VerticalAlignment="Top"/>
<Label FontFamily="Arial" FontSize="12" Name="labelPressureUnit" Margin="110,17,-121,-5" Height="22" Content=""/>
<Label FontFamily="Arial" FontSize="12" Name="labelAngleUnit" Margin="110,-30,-121,-5" Height="22" Content=""/>
</Grid>
</UserControl>
@@ -0,0 +1,240 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITThrottleValve.xaml 的交互逻辑
/// </summary>
public partial class AITThrottleValve : UserControl
{
public AITThrottleValve()
{
InitializeComponent();
}
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITThrottleValve),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITThrottleValveData), typeof(AITThrottleValve),
new FrameworkPropertyMetadata(new AITThrottleValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITThrottleValveData DeviceData
{
get
{
return (AITThrottleValveData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty SupportPressureModeProperty = DependencyProperty.Register(
"SupportPressureMode", typeof(bool), typeof(AITThrottleValve),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public bool SupportPressureMode
{
get
{
return (bool)this.GetValue(SupportPressureModeProperty);
}
set
{
this.SetValue(SupportPressureModeProperty, value);
}
}
public static readonly DependencyProperty PressureStringFormatProperty = DependencyProperty.Register(
"PressureStringFormat", typeof(string), typeof(AITThrottleValve),
new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
public string PressureStringFormat
{
get
{
return (string)this.GetValue(PressureStringFormatProperty);
}
set
{
this.SetValue(PressureStringFormatProperty, value);
}
}
public static readonly DependencyProperty PositionStringFormatProperty = DependencyProperty.Register(
"PositionStringFormat", typeof(string), typeof(AITThrottleValve),
new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
public string PositionStringFormat
{
get
{
return (string)this.GetValue(PositionStringFormatProperty);
}
set
{
this.SetValue(PositionStringFormatProperty, value);
}
}
private AITThrottleValveInputDialogBox _dialogBox;
public Window AnalogOwner { get; set; }
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData != null)
{
//if (DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl)
//{
// rotateTransform.Angle = DeviceData.PressureFeedback * -90.0 / DeviceData.MaxValuePressure;
//}
//else if (DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl)
//{
// rotateTransform.Angle = DeviceData.PositionFeedback * -90.0 / DeviceData.MaxValuePosition;
//}
rotateTransform.Angle = DeviceData.PositionFeedback * -90.0 / DeviceData.MaxValuePosition;
labelPressure.Content = DeviceData.PressureFeedback.ToString(PressureStringFormat);
labelAngle.Content = DeviceData.PositionFeedback.ToString(PositionStringFormat);
labelPressureUnit.Content = !string.IsNullOrEmpty(DeviceData.UnitPressure) ? DeviceData.UnitPressure : "mTorr";
labelAngleUnit.Content = !string.IsNullOrEmpty(DeviceData.UnitPosition) ? DeviceData.UnitPosition : "%";
if (_dialogBox != null)
{
_dialogBox.IsPositionMode = DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl;
_dialogBox.IsPressureMode = DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl;
//_dialogBox.IsCloseMode = DeviceData.Mode == (int)PressureCtrlMode.TVClose;
//_dialogBox.SetPointPosition = DeviceData.PositionSetPoint;
//_dialogBox.SetPointPressure = DeviceData.PressureSetPoint;
}
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
//if (DeviceData != null)
//{
// string tooltipValue =
// string.Format(Application.Current.Resources["GlobalLableThrottleValveToolTip"].ToString(),
// DeviceData.Type,
// DeviceData.DisplayName,
// DeviceData.DeviceSchematicId,
// DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl ? "Pressure" : (DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl ? "Position" : ""),
// DeviceData.PositionFeedback.ToString("F1"),
// DeviceData.PressureFeedback.ToString("F1"));
// ToolTip = tooltipValue;
//}
}
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData == null)
return;
_dialogBox = new AITThrottleValveInputDialogBox
{
SetThrottleModeCommandDelegate = SetThrottleModeExecute,
SetPressureCommandDelegate = SetPressureExecute,
SetPositionCommandDelegate = SetPositionExecute,
SetPressureCloseCommandDelegate = SetPressureImmediately,
DeviceName = string.Format("{0}: {1}", DeviceData.Type, DeviceData.DisplayName),
DeviceId = DeviceData.DeviceSchematicId,
SetPointPosition = Math.Round(DeviceData.PositionSetPoint, 1),
SetPointPressure = Math.Round(DeviceData.PressureSetPoint, 1),
MaxValuePressure = DeviceData.MaxValuePressure,
MaxValuePosition = DeviceData.MaxValuePosition,
UnitPosition = DeviceData.UnitPosition,
UnitPressure = DeviceData.UnitPressure,
FeedbackPosition = DeviceData.PositionFeedback,
FeedbackPressure = DeviceData.PressureFeedback,
//SupportPressureMode = SupportPressureMode,
IsPositionMode = DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl,
IsPressureMode = DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl,
//IsCloseMode = DeviceData.Mode == (int)PressureCtrlMode.TVClose,
};
if (AnalogOwner != null)
_dialogBox.Owner = AnalogOwner;
_dialogBox.Topmost = true;
_dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
_dialogBox.FocasAll();
_dialogBox.ShowDialog();
_dialogBox = null;
}
private void SetThrottleModeExecute(PressureCtrlMode value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetMode}", value.ToString());
}
private void SetPressureExecute(double value)
{
if (!SupportPressureMode)
return;
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPressure}", (float)value);
}
private void SetPositionExecute(double value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPosition}", (float)value);
}
private void SetPressureImmediately(double value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.SetPositionToZero", (float)value);
}
}
}
@@ -0,0 +1,122 @@
<UserControl
x:Class="Aitex.Core.UI.DeviceControl.AITThrottleValve2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="36"
Height="36"
MinWidth="36"
MinHeight="86"
MaxWidth="36"
MaxHeight="36"
BorderThickness="1,1,1,1">
<Grid>
<Grid
Height="36"
Margin="0,-50,0,0"
Background=" Transparent"
Cursor="Hand"
MouseEnter="Grid_MouseEnter"
MouseLeftButtonUp="Grid_MouseLeftButtonUp"
MouseRightButtonUp="Grid_MouseRightButtonUp">
<Grid.RenderTransform>
<RotateTransform x:Name="rotateTransform" Angle="20" CenterX="18" CenterY="18" />
</Grid.RenderTransform>
<Ellipse
x:Name="enable"
Width="34"
Height="34"
Fill="White"
Stroke="Black" />
<Line
Stroke="Black"
StrokeEndLineCap="Round"
StrokeStartLineCap="Round"
StrokeThickness="1.2"
X1="3"
X2="31"
Y1="17"
Y2="17" />
<Line
Stroke="Black"
StrokeEndLineCap="Round"
StrokeStartLineCap="Round"
StrokeThickness="1.2"
X1="3"
X2="9"
Y1="17"
Y2="15" />
<Line
Stroke="Black"
StrokeEndLineCap="Round"
StrokeStartLineCap="Round"
StrokeThickness="1.2"
X1="3"
X2="9"
Y1="17"
Y2="19" />
</Grid>
<Label
Name="PositionValue"
Height="22"
Margin="39,-14,-76,0"
VerticalAlignment="Top"
HorizontalContentAlignment="Center"
Background="DarkGreen"
ContentStringFormat="F1"
FontFamily="Arial"
FontSize="12"
Foreground="White" />
<Label
Name="PositionUnit"
Height="22"
Margin="110,-56,-121,6"
Content="%"
FontFamily="Arial"
FontSize="12" />
<Label
Name="PressureValue"
Height="22"
Margin="39,31,-76,0"
VerticalAlignment="Top"
HorizontalContentAlignment="Center"
Background="CadetBlue"
ContentStringFormat="F1"
FontFamily="Arial"
FontSize="12"
Foreground="White" />
<Label
Name="PressureUnit"
Height="22"
Margin="108,36,-119,2"
Content="mTorr"
FontFamily="Arial"
FontSize="12" />
<Label
Name="PositionSetValue"
Height="22"
Margin="39,8,-76,0"
VerticalAlignment="Top"
HorizontalContentAlignment="Center"
Background="#999999"
ContentStringFormat="F1"
FontFamily="Arial"
FontSize="12"
Foreground="White" />
<Label
Name="PressureSetValue"
Height="22"
Margin="39,53,-76,0"
VerticalAlignment="Top"
HorizontalContentAlignment="Center"
Background="#999999"
ContentStringFormat="F1"
FontFamily="Arial"
FontSize="12"
Foreground="White" />
</Grid>
</UserControl>
@@ -0,0 +1,486 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITThrottleValve.xaml 的交互逻辑
/// </summary>
public partial class AITThrottleValve2 : UserControl
{
public AITThrottleValve2()
{
InitializeComponent();
}
public event Action<string, string> clickAct;
public static readonly DependencyProperty OnOffProperty = DependencyProperty.Register(
"OnOff", typeof(object), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsManualModeProperty = DependencyProperty.Register(
"IsManualModeValve", typeof(bool), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty ValveNameProperty = DependencyProperty.Register(
"ValveName", typeof(string), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata("TV", FrameworkPropertyMetadataOptions.AffectsRender));
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty CommandCloseTVProperty = DependencyProperty.Register(
"CommandCloseTV", typeof(ICommand), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
// Using a DependencyProperty as the backing store for CommandReset. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CommandResetProperty =
DependencyProperty.Register("CommandReset", typeof(ICommand), typeof(AITThrottleValve2), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITThrottleValveData), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata(new AITThrottleValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand CommandCloseTV
{
get
{
return (ICommand)this.GetValue(CommandCloseTVProperty);
}
set
{
this.SetValue(CommandCloseTVProperty, value);
}
}
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public ICommand CommandReset
{
get => (ICommand)GetValue(CommandResetProperty);
set => SetValue(CommandResetProperty, value);
}
public bool IsManualModeValve
{
get
{
return (bool)GetValue(IsManualModeProperty);
}
set
{
SetValue(IsManualModeProperty, value);
}
}
public string ValveName
{
get
{
return (string)GetValue(ValveNameProperty);
}
set
{
SetValue(ValveNameProperty, value);
}
}
/// <summary>
/// set, get current progress value AnalogDeviceData
/// </summary>
public AITThrottleValveData DeviceData
{
get
{
return (AITThrottleValveData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty PressureStringFormatProperty = DependencyProperty.Register(
"PressureStringFormat", typeof(string), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
public string PressureStringFormat
{
get
{
return (string)this.GetValue(PressureStringFormatProperty);
}
set
{
this.SetValue(PressureStringFormatProperty, value);
}
}
public static readonly DependencyProperty PositionStringFormatProperty = DependencyProperty.Register(
"PositionStringFormat", typeof(string), typeof(AITThrottleValve2),
new FrameworkPropertyMetadata("F1", FrameworkPropertyMetadataOptions.AffectsRender));
public string PositionStringFormat
{
get
{
return (string)this.GetValue(PositionStringFormatProperty);
}
set
{
this.SetValue(PositionStringFormatProperty, value);
}
}
private AITThrottleValveInputDialogBox _dialogBox;
public Window AnalogOwner { get; set; }
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData != null)
{
//if (DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl)
//{
// rotateTransform.Angle = DeviceData.PressureFeedback * 90.0 / DeviceData.MaxValuePressure;
//}
//else if (DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl)
//{
rotateTransform.Angle = DeviceData.PositionFeedback * 90.0 / DeviceData.MaxValuePosition;
//}
PositionValue.Content = DeviceData.PositionFeedback.ToString(PositionStringFormat);
PositionUnit.Content = !string.IsNullOrEmpty(DeviceData.UnitPosition) ? DeviceData.UnitPosition : "%";
PressureValue.Content = DeviceData.PressureFeedback.ToString(PressureStringFormat);
PressureUnit.Content = !string.IsNullOrEmpty(DeviceData.UnitPressure) ? DeviceData.UnitPressure : "mTorr";
PositionSetValue.Content = DeviceData.PositionSetPointCurrent.ToString(PositionStringFormat);
PressureSetValue.Content = DeviceData.PressureSetPointCurrent.ToString(PositionStringFormat);
if (_dialogBox != null)
{
_dialogBox.IsPositionMode = DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl;
_dialogBox.IsPressureMode = DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl;
//_dialogBox.SetPointPosition = DeviceData.PositionSetPoint;
//_dialogBox.SetPointPressure = DeviceData.PressureSetPoint;
}
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
//string tooltipValue =
// string.Format("Mode:{3}\r\n PositionFeedback:{4}% \r\n PositionTargetSetPoint:{5}% \r\n PositionCurrentSetPoint:{6}%\r\n\r\n PressureFeedback:{7} \r\n PressureTargetSetPoint:{8} \r\n PressureCurrentSetPoint:{9}",
// DeviceData.DisplayName,
// DeviceData.MaxValuePressure,
// DeviceData.UnitPressure,
// DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl ? "Pressure" : (DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl ? "Position" : ""),
// DeviceData.PositionFeedback.ToString("F1"),
// DeviceData.PositionSetPoint.ToString("F1"),
// DeviceData.PositionSetPointCurrent.ToString("F1"),
// DeviceData.PressureFeedback.ToString("F1"),
// DeviceData.PressureSetPoint.ToString("F1"),
// DeviceData.PressureSetPointCurrent.ToString("F1"));
string tooltipValue =
string.Format("Mode:{0}\r\n PositionTargetSetPoint:{1}% \r\n PressureTargetSetPoint:{2} mbar",
DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl ? "Pressure" : (DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl ? "Position" : ""),
DeviceData.PositionSetPoint.ToString("F1"),
DeviceData.PressureSetPoint.ToString("F1"));
ToolTip = tooltipValue;
}
}
private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData == null)
{
return;
}
else
{
if (DeviceData.TVEnable!=true)
{
MessageBox.Show("TV is disable,Click mouse right buttom to turn on!");
return;
}
_dialogBox = new AITThrottleValveInputDialogBox
{
SetThrottleModeCommandDelegate = SetThrottleModeExecute,
SetPressureCommandDelegate = SetPressureExecute,
SetPositionCommandDelegate = SetPositionExecute,
SetPressureCloseCommandDelegate = SetPressureImmediately,
DeviceName = string.Format("{0}: {1}", DeviceData.Type, DeviceData.DisplayName),
DeviceId = DeviceData.DeviceSchematicId,
SetPointPosition = Math.Round(DeviceData.PositionSetPointCurrent, 1),
SetPointPressure = Math.Round(DeviceData.PressureSetPointCurrent, 1),
MaxValuePressure = DeviceData.MaxValuePressure,
MaxValuePosition = DeviceData.MaxValuePosition,
UnitPosition = DeviceData.UnitPosition,
UnitPressure = DeviceData.UnitPressure,
FeedbackPosition = DeviceData.PositionFeedback,
FeedbackPressure = DeviceData.PressureFeedback,
IsPositionMode = DeviceData.Mode == (int)PressureCtrlMode.TVPositionCtrl,
IsPressureMode = DeviceData.Mode == (int)PressureCtrlMode.TVPressureCtrl,
};
if (AnalogOwner != null)
_dialogBox.Owner = AnalogOwner;
_dialogBox.Topmost = true;
_dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
_dialogBox.FocasAll();
_dialogBox.ShowDialog();
_dialogBox = null;
}
}
private void SetThrottleModeExecute(PressureCtrlMode value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetMode}", value.ToString());
}
private void SetPressureExecute(double value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPressure}", (float)value);
}
private void SetPositionExecute(double value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.{AITThrottleValveOperation.SetPosition}", (float)value);
}
private void SetPressureImmediately(double value)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.SetPositionToZero");
}
private void SetPositionToZero()
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.Module}.{DeviceData.DeviceName}.SetPositionToZero");
}
public object OnOff
{
get
{
return GetValue(OnOffProperty);
}
set
{
SetValue(OnOffProperty, value);
}
}
private void Grid_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
if (DeviceData.TVEnable == true)
{
TvEnable(null,null);
}
else
{
TvDisEnable(null, null);
}
}
private void TvEnable(object sender, MouseButtonEventArgs e)
{
if (!IsManualModeValve)
return;
ContextMenu mouseClickMenu = new ContextMenu();
MenuItem item = new MenuItem();
item.Header = "_" + ValveName;
item.IsEnabled = false;
mouseClickMenu.Items.Add(item);
addCloseMenu(mouseClickMenu, item);
//addSetPositionToZeroMenu(mouseClickMenu, item);
mouseClickMenu.IsOpen = true;
}
private void TvDisEnable(object sender, MouseButtonEventArgs e)
{
if (!IsManualModeValve)
return;
ContextMenu mouseClickMenu = new ContextMenu();
MenuItem item = new MenuItem();
item.Header = "_" + ValveName;
item.IsEnabled = false;
mouseClickMenu.Items.Add(item);
addOpenMenu(mouseClickMenu, item);
addResetMenu(mouseClickMenu, item);
//addSetPositionToZeroMenu(mouseClickMenu, item);
mouseClickMenu.IsOpen = true;
}
void addSetPositionToZeroMenu(ContextMenu mouseClickMenu, MenuItem item)
{
item = new MenuItem();
item.Header = "CloseTV";
item.Click += TurnPositionToZero;
item.Tag = this.Tag;
mouseClickMenu.Items.Add(item);
}
void addOpenMenu(ContextMenu mouseClickMenu, MenuItem item)
{
item = new MenuItem();
item.Header = "Enable";
item.Click += TurnOnValve;
item.Tag = this.Tag;
mouseClickMenu.Items.Add(item);
}
void addResetMenu(ContextMenu mouseClickMenu, MenuItem item)
{
item = new MenuItem();
item.Header = "Reset";
item.Click += TurnOnReset;
item.Tag = this.Tag;
mouseClickMenu.Items.Add(item);
}
void addCloseMenu(ContextMenu mouseClickMenu, MenuItem item)
{
item = new MenuItem();
item.Header = "Disable";
item.Tag = this.Tag;
item.Click += TurnOffValve;
mouseClickMenu.Items.Add(item);
}
private void TurnOnValve(object sender, RoutedEventArgs e)
{
if (Command != null || clickAct != null)
{
AITValveData deviceData = OnOff as AITValveData;
if (deviceData != null)
{
deviceData.SetPoint = true;
}
}
if (Command != null)
{
KeyValuePair<string, string> pair = new KeyValuePair<string, string>(((MenuItem)e.Source).Tag + "", "true");
Command.Execute(pair);
}
else if (clickAct != null)
{
clickAct(((MenuItem)e.Source).Tag + "", "true");
}
}
private void TurnOffValve(object sender, RoutedEventArgs e)
{
if (Command != null || clickAct != null)
{
AITValveData deviceData = OnOff as AITValveData;
if (deviceData != null)
{
deviceData.SetPoint = false;
}
}
if (Command != null)
{
KeyValuePair<string, string> pair = new KeyValuePair<string, string>(((MenuItem)e.Source).Tag + "", "false");
Command.Execute(pair);
}
else if (clickAct != null)
{
clickAct(((MenuItem)e.Source).Tag + "", "false");
}
}
private void TurnOnReset(object sender, RoutedEventArgs e)
{
if (CommandReset != null || clickAct != null)
{
AITValveData deviceData = OnOff as AITValveData;
if (deviceData != null)
{
deviceData.SetPoint = true;
}
}
if (CommandReset != null)
{
KeyValuePair<string, string> pair = new KeyValuePair<string, string>(((MenuItem)e.Source).Tag + "", "true");
CommandReset.Execute(pair);
}
else if (clickAct != null)
{
clickAct(((MenuItem)e.Source).Tag + "", "true");
}
}
private void TurnPositionToZero(object sender, RoutedEventArgs e)
{
SetPositionToZero();
}
}
}
@@ -0,0 +1,102 @@
<Window x:Class="Aitex.Core.UI.Control.AITThrottleValveInputDialogBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Aitex.Core.UI.Control"
xmlns:converters="clr-namespace:Aitex.Core.UI.Converters"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
Height="265" Width="280" MaxHeight="265" MinHeight="265" MaxWidth="300" MinWidth="300" WindowStyle="ToolWindow"
WindowStartupLocation="CenterOwner"
KeyDown="OnEnterKeyIsHit"
Title="{Binding Path=DeviceId, StringFormat={}{0} SetPoint}">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FontSize" Value="12" />
<Setter Property="Height" Value="23" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Width" Value="50" />
</Style>
<Style TargetType="Label">
<Setter Property="FontFamily" Value="Arial" />
<Setter Property="FontSize" Value="13" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Height" Value="25" />
</Style>
<Style x:Key="textBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<my:DoubleConverter x:Key="doubleConverter"/>
<converters:BoolToValueConverter x:Key="BoolToValueConverter"/>
</Window.Resources>
<Grid>
<Grid.Resources>
<Style TargetType="RadioButton"/>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="1" Content="Device Name:" />
<Label Grid.Row="1" Grid.Column="1" Content="Work Mode:" />
<Label Grid.Row="2" Grid.Column="1" Content="Max:" />
<Label Grid.Row="3" Grid.Column="1" Content="Unit:" />
<Label Grid.Row="4" Grid.Column="1" Content="Feedback:" />
<Label Grid.Row="5" Grid.Column="1" Content="Set Point:" />
<Label Grid.Row="0" Grid.Column="2" Content="{Binding Path=DeviceName}" Width="150" Height="28" HorizontalAlignment="Left" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" VerticalContentAlignment="Center" />
<Label Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Left" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="12" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center" >
<StackPanel Orientation="Horizontal">
<CheckBox x:Name="ckPosition" Checked="CkPosition_OnChecked" ButtonBase.Click="CkPosition_OnClick" VerticalContentAlignment="Center">Position</CheckBox>
<CheckBox x:Name="ckPressure" Checked="CkPressure_OnChecked" ButtonBase.Click="CkPressure_OnClick" Margin="10,0,0,0" VerticalContentAlignment="Center">Pressure</CheckBox>
</StackPanel>
</Label>
<Label Grid.Row="2" Grid.Column="2" Content="{Binding Path=MaxValuePosition}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPosition, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Label Grid.Row="2" Grid.Column="2" Content="{Binding Path=MaxValuePressure}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPressure, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Label Grid.Row="3" Grid.Column="2" Content="{Binding Path=UnitPosition}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPosition, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Label Grid.Row="3" Grid.Column="2" Content="{Binding Path=UnitPressure}" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPressure, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=FeedbackPosition}" ContentStringFormat="F1" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPosition, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Label Grid.Row="4" Grid.Column="2" Content="{Binding Path=FeedbackPressure}" ContentStringFormat="F1" Width="150" BorderThickness="0,0,0,1" BorderBrush="Black" FontSize="13" FontFamily="Arial,SimSun" Height="28" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPressure, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<TextBox Grid.Row="5" Grid.Column="2" x:Name="inputBoxPosition" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" Padding="3,0,0,0"
TextChanged="InputTextBoxPosition_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPosition, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<TextBox Grid.Row="5" Grid.Column="2" x:Name="inputBoxPressure" BorderBrush="Green" BorderThickness="0,0,0,1" Style="{StaticResource textBoxInError}" Padding="3,0,0,0"
TextChanged="InputTextBoxPressure_TextChanged" Width="150" HorizontalAlignment="Left" FontSize="13" FontFamily="Arial,SimSun" Height="30" VerticalContentAlignment="Center"
Visibility="{Binding ElementName=ckPressure, Path=IsChecked, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Visible, FallbackValue=Collapsed}"/>
<Grid Grid.Row="6" Grid.ColumnSpan="4">
<StackPanel Orientation="Horizontal">
<Button Content="CLoseTV" x:Name="buttonClose" Click="ButtonClose_Click" Width="80" Height="26" VerticalAlignment="Top" Grid.Column="1" Margin="10,3,0,0" />
<Button Content="Set" x:Name="buttonSet" Click="ButtonSet_Click" Width="80" Height="26" VerticalAlignment="Top" Grid.Column="1" Margin="25,3,0,0" />
<Button Content="Cancel" Click="ButtonCancel_Click" Width="80" Height="26" VerticalAlignment="Top" Margin="5,3,0,0" />
</StackPanel>
</Grid>
</Grid>
</Window>
@@ -0,0 +1,377 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.RT.Log;
namespace Aitex.Core.UI.Control
{
/// <summary>
/// Interaction logic for InputDialogBox.xaml
/// </summary>
public partial class AITThrottleValveInputDialogBox : Window
{
public AITThrottleValveInputDialogBox()
{
InitializeComponent();
DataContext = this;
if (IsPressureMode)
{
this.ckPressure.IsChecked = true;
}
else
{
this.ckPosition.IsChecked = true;
}
WindowStartupLocation = WindowStartupLocation.CenterOwner;
}
public void FocasAll()
{
inputBoxPosition.Text = Math.Round(SetPointPosition, 2).ToString();
if (IsPositionMode)
{
inputBoxPosition.Focus();
inputBoxPosition.SelectAll();
}
inputBoxPressure.Text = Math.Round(SetPointPressure, 2).ToString();
if (IsPressureMode)
{
inputBoxPressure.Focus();
inputBoxPressure.SelectAll();
}
}
/// <summary>
/// Vilidate input range
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void InputTextBoxPosition_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBoxPosition.Text, out input)) buttonSet.IsEnabled = false;
else if (input < 0 || input > MaxValuePosition) buttonSet.IsEnabled = false;
else buttonSet.IsEnabled = true;
inputBoxPosition.Foreground = buttonSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
private void InputTextBoxPressure_TextChanged(object sender, TextChangedEventArgs e)
{
double input;
if (!double.TryParse(inputBoxPressure.Text, out input)) buttonSet.IsEnabled = false;
else if (input < 0 || input > MaxValuePressure) buttonSet.IsEnabled = false;
else buttonSet.IsEnabled = true;
inputBoxPressure.Foreground = buttonSet.IsEnabled ?
System.Windows.Media.Brushes.Black : System.Windows.Media.Brushes.Red;
}
public static readonly DependencyProperty DeviceNameProperty = DependencyProperty.Register(
"DeviceName", typeof(string), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty DeviceIdProperty = DependencyProperty.Register(
"DeviceId", typeof(string), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValuePositionProperty = DependencyProperty.Register(
"MaxValuePosition", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty MaxValuePressureProperty = DependencyProperty.Register(
"MaxValuePressure", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitPositionProperty = DependencyProperty.Register(
"UnitPosition", typeof(string), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty UnitPressureProperty = DependencyProperty.Register(
"UnitPressure", typeof(string), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointPositionProperty = DependencyProperty.Register(
"SetPointPosition", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty SetPointPressureProperty = DependencyProperty.Register(
"SetPointPressure", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty FeedbackPositionProperty = DependencyProperty.Register(
"FeedbackPosition", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty FeedbackPressureProperty = DependencyProperty.Register(
"FeedbackPressure", typeof(double), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsPositionModeProperty = DependencyProperty.Register(
"IsPositionMode", typeof(bool), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty IsPressureModeProperty = DependencyProperty.Register(
"IsPressureMode", typeof(bool), typeof(AITThrottleValveInputDialogBox),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
/// <summary>
/// 是否百分比显示
/// </summary>
public bool IsPercent { get; set; }
public string DeviceName
{
get
{
return (string)this.GetValue(DeviceNameProperty);
}
set
{
if (!string.IsNullOrEmpty(value) && !value.StartsWith("_"))
value = "_" + value;
this.SetValue(DeviceNameProperty, value);
}
}
public string DeviceId
{
get
{
return (string)this.GetValue(DeviceIdProperty);
}
set
{
this.SetValue(DeviceIdProperty, value);
}
}
public double MaxValuePosition
{
get
{
return (double)this.GetValue(MaxValuePositionProperty);
}
set
{
this.SetValue(MaxValuePositionProperty, value);
}
}
public double MaxValuePressure
{
get
{
return (double)this.GetValue(MaxValuePressureProperty);
}
set
{
this.SetValue(MaxValuePressureProperty, value);
}
}
public string UnitPosition
{
get
{
return (string)this.GetValue(UnitPositionProperty);
}
set
{
this.SetValue(UnitPositionProperty, value);
}
}
public string UnitPressure
{
get
{
return (string)this.GetValue(UnitPressureProperty);
}
set
{
this.SetValue(UnitPressureProperty, value);
}
}
public double SetPointPosition
{
get
{
return (double)this.GetValue(SetPointPositionProperty);
}
set
{
this.SetValue(SetPointPositionProperty, value);
}
}
public double SetPointPressure
{
get
{
return (double)this.GetValue(SetPointPressureProperty);
}
set
{
this.SetValue(SetPointPressureProperty, value);
}
}
public double FeedbackPosition
{
get
{
return (double)this.GetValue(FeedbackPositionProperty);
}
set
{
this.SetValue(FeedbackPositionProperty, value);
}
}
public double FeedbackPressure
{
get
{
return (double)this.GetValue(FeedbackPressureProperty);
}
set
{
this.SetValue(FeedbackPressureProperty, value);
}
}
public bool IsPositionMode
{
get
{
return (bool)this.GetValue(IsPositionModeProperty);
}
set
{
this.SetValue(IsPositionModeProperty, value);
ckPosition.IsChecked = IsPositionMode;
}
}
public bool IsPressureMode
{
get
{
return (bool)this.GetValue(IsPressureModeProperty);
}
set
{
this.SetValue(IsPressureModeProperty, value);
ckPressure.IsChecked = IsPressureMode;
}
}
public Action<PressureCtrlMode> SetThrottleModeCommandDelegate;
public Action<double> SetPositionCommandDelegate;
public Action<double> SetPressureCommandDelegate;
public Action<double> SetPressureCloseCommandDelegate;
private void ButtonSet_Click(object sender, RoutedEventArgs e)
{
if (IsPressureMode)
{
SetPressureCommandDelegate(Convert.ToDouble(inputBoxPressure.Text));
}
else if (IsPositionMode)
{
SetPositionCommandDelegate(Convert.ToDouble(inputBoxPosition.Text));
}
Close();
}
private void OnEnterKeyIsHit(object sender, KeyEventArgs e)
{
try
{
if (!buttonSet.IsEnabled) return;
if (e.Key == Key.Return)
{
ButtonSet_Click(null, null);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
SetPressureCloseCommandDelegate(0);
Close();
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void CkPosition_OnChecked(object sender, RoutedEventArgs e)
{
if (IsPositionMode)
return;
ckPosition.IsChecked = false;
try
{
if (SetThrottleModeCommandDelegate != null)
{
SetThrottleModeCommandDelegate(PressureCtrlMode.TVPositionCtrl);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void CkPressure_OnChecked(object sender, RoutedEventArgs e)
{
if (IsPressureMode)
return;
ckPressure.IsChecked = false;
try
{
if (SetThrottleModeCommandDelegate != null)
{
SetThrottleModeCommandDelegate(PressureCtrlMode.TVPressureCtrl);
}
}
catch (Exception ex)
{
LOG.Error(ex.Message);
}
}
private void CkPosition_OnClick(object sender, RoutedEventArgs e)
{
ckPosition.IsChecked = IsPositionMode;
}
private void CkPressure_OnClick(object sender, RoutedEventArgs e)
{
ckPressure.IsChecked = IsPressureMode;
}
}
}
@@ -0,0 +1,22 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITValve"
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"
Name="myself"
Height="40" Width="40">
<UserControl.RenderTransform>
<RotateTransform x:Name="rotateTransform" Angle="0" CenterX="22" CenterY="20"/>
</UserControl.RenderTransform>
<Grid>
<Image Name="imagePicture" Stretch="Fill" >
<Image.ContextMenu>
<ContextMenu Visibility="{Binding MenuVisibility}">
<MenuItem Header="Open Valve" Click="OpenValve"/>
<MenuItem Header="Close Valve" Click="CloseValve"/>
</ContextMenu>
</Image.ContextMenu>
</Image>
</Grid>
</UserControl>
@@ -0,0 +1,179 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.Control;
using MECF.Framework.Common.OperationCenter;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// TexGasValve.xaml 的交互逻辑
/// </summary>
public partial class AITValve : UserControl
{
// define dependency properties
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITValve),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public Visibility MenuVisibility
{
get { return (Visibility)this.GetValue(MenuVisibilityProperty); }
set { this.SetValue(MenuVisibilityProperty, value); }
}
// Using a DependencyProperty as the backing store for MenuVisibility. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MenuVisibilityProperty =
DependencyProperty.Register("MenuVisibility", typeof(Visibility), typeof(AITValve),
new FrameworkPropertyMetadata(Visibility.Visible));
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITValveData), typeof(AITValve),
new FrameworkPropertyMetadata(new AITValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITValveData DeviceData
{
get
{
return (AITValveData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public static readonly DependencyProperty EnableServiceControlProperty = DependencyProperty.Register(
"EnableServiceControl", typeof(bool), typeof(AITValve),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool EnableServiceControl
{
get
{
return (bool)this.GetValue(EnableServiceControlProperty);
}
set
{
this.SetValue(EnableServiceControlProperty, value);
}
}
public static readonly DependencyProperty DeviceData2Property = DependencyProperty.Register(
"DeviceData2", typeof(AITValveData), typeof(AITValve),
new FrameworkPropertyMetadata(new AITValveData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITValveData DeviceData2
{
get
{
return (AITValveData)this.GetValue(DeviceData2Property);
}
set
{
this.SetValue(DeviceData2Property, value);
}
}
public static readonly DependencyProperty ValveOpenOrientationProperty = DependencyProperty.Register(
"ValveOpenOrientation", typeof(LineOrientation), typeof(AITValve),
new FrameworkPropertyMetadata(LineOrientation.Horizontal, FrameworkPropertyMetadataOptions.AffectsRender));
public LineOrientation ValveOpenOrientation
{
get { return (LineOrientation)GetValue(ValveOpenOrientationProperty); }
set { SetValue(ValveOpenOrientationProperty, value); }
}
public AITValve()
{
InitializeComponent();
}
private BitmapSource GetImage(string name)
{
return
new BitmapImage(new Uri(string.Format("pack://application:,,,/MECF.Framework.Common;component/Resources/Valve/{0}", name)));
}
protected override void OnRender(DrawingContext drawingContext)
{
rotateTransform.Angle = ValveOpenOrientation == LineOrientation.Horizontal ? 0 : 90;
bool IsOpen = DeviceData == null || DeviceData.IsOpen;
IsOpen = IsOpen && (DeviceData2 == null || !DeviceData2.IsOpen);
imagePicture.Source = GetImage(IsOpen ? "ValveOpenHorizontal.png" : "ValveCloseHorizontal.png");
imagePicture.ContextMenu.Visibility = MenuVisibility;
if (DeviceData != null)
{
this.ToolTip =
$"Valve Name:{DeviceData.DisplayName} \r\n Device ID:{DeviceData.DeviceSchematicId} \r\n SetPoint:{DeviceData.SetPoint} \r\n Status:{DeviceData.Feedback}";
}
base.OnRender(drawingContext);
}
private void OpenValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.UniqueName}.{AITValveOperation.GVTurnValve}", true);
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITValveOperation.GVTurnValve, true });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITValveOperation.GVTurnValve, false });
}
}
private void CloseValve(object sender, RoutedEventArgs e)
{
if (EnableServiceControl)
{
InvokeClient.Instance.Service.DoOperation($"{DeviceData.UniqueName}.{AITValveOperation.GVTurnValve}", false);
return;
}
if (Command == null)
return;
Command.Execute(new object[] { DeviceData.DeviceName, AITValveOperation.GVTurnValve, false });
if (DeviceData2 != null && !string.IsNullOrEmpty(DeviceData2.DeviceName))
{
Command.Execute(new object[] { DeviceData2.DeviceName, AITValveOperation.GVTurnValve, true });
}
}
}
}
@@ -0,0 +1,12 @@
<UserControl x:Class="Aitex.Core.UI.DeviceControl.AITWaterFlowSensor"
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"
d:DesignHeight="20" d:DesignWidth="20">
<Grid MouseEnter="Grid_MouseEnter" >
<Ellipse HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="Gray" StrokeThickness="2" Width="15" Height="15"
Fill="DarkGray" x:Name="sensor" Style="{x:Null}"/>
</Grid>
</UserControl>
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Aitex.Core.Common.DeviceData;
namespace Aitex.Core.UI.DeviceControl
{
/// <summary>
/// AITWaterFlowSensor.xaml 的交互逻辑
/// </summary>
public partial class AITWaterFlowSensor : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITWaterFlowSensorData), typeof(AITWaterFlowSensor),
new FrameworkPropertyMetadata(new AITWaterFlowSensorData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITWaterFlowSensorData DeviceData
{
get
{
return (AITWaterFlowSensorData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public AITWaterFlowSensor()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData == null)
{
sensor.Fill = new SolidColorBrush(Colors.DarkGray);
return;
}
if (DeviceData.IsError)
sensor.Fill = new SolidColorBrush(Colors.OrangeRed);
else if (DeviceData.IsWarning || DeviceData.IsOutOfTolerance)
sensor.Fill = new SolidColorBrush(Colors.Yellow);
else
{
sensor.Fill = new SolidColorBrush(Colors.Lime);
}
}
private void Grid_MouseEnter(object sender, MouseEventArgs e)
{
if (DeviceData != null)
{
string tooltipValue =
string.Format(Application.Current.Resources["GlobalLableWaterFlowSensorToolTip"].ToString(),
"WaterFlow",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.FeedBack.ToString("F1"),
DeviceData.Unit,
DeviceData.IsError ? "Alarm" : (DeviceData.IsWarning ? "Warning" : (DeviceData.IsOutOfTolerance ? "Abnormal" : "Normal"))
);
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,52 @@
<UserControl x:Class="MECF.Framework.UI.Core.DeviceControl.EventLogComboView"
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.Core.DeviceControl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<local:DateTimeToTextConverter x:Key="dateTimeToTextConverter"/>
<local:CollectionLastIndexConverter x:Key="collectionLastIndexConverter" />
</UserControl.Resources>
<ComboBox ItemsSource="{Binding EventLogList}"
SelectedIndex="{Binding EventLogList.Count,Mode=OneWay,Converter={StaticResource collectionLastIndexConverter}}"
VerticalContentAlignment="Center" FontSize="20" Height="35" >
<ComboBox.ItemTemplate>
<DataTemplate>
<ContentControl>
<ContentControl.Style>
<Style TargetType="ContentControl">
<Setter Property="Background" Value="#F0F0F0"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Level}" Value="Alarm">
<Setter Property="Foreground" Value="Red"/>
</DataTrigger>
<DataTrigger Binding="{Binding Level}" Value="Warning">
<Setter Property="Foreground" Value="#FF8C00"/>
</DataTrigger>
<DataTrigger Binding="{Binding Level}" Value="Information">
<Setter Property="Foreground" Value="Black"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="130"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Margin="8,0,0,0" Grid.Column="0" Text="{Binding OccuringTime, Converter={StaticResource dateTimeToTextConverter}}" />
<TextBlock Grid.Column="2" Text="{Binding Id}" Margin="8,0,0,0"/>
<TextBlock Grid.Column="1" Text="{Binding Source}" Margin="8,0,0,0" />
<TextBlock Grid.Column="3" Text="{Binding Description}" Margin="8,0,0,0"/>
</Grid>
</ContentControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</UserControl>
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Globalization;
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 MECF.Framework.UI.Core.DeviceControl
{
/// <summary>
/// EventLogComboView.xaml 的交互逻辑
/// </summary>
public partial class EventLogComboView : UserControl
{
public EventLogComboView()
{
InitializeComponent();
}
}
public class CollectionLastIndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value - 1;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class DateTimeToTextConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return ((DateTime)value).ToString("HH:mm:ss.fff");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,27 @@
<UserControl x:Class="MECF.Framework.UI.Core.DeviceControl.ModuleControl"
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.Core.DeviceControl"
xmlns:converters="clr-namespace:Aitex.Core.UI.Converters"
mc:Ignorable="d" x:Name="self"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<converters:bool2VisibilityConverter x:Key="visibilityConverter" />
</UserControl.Resources>
<Grid Opacity="1" >
<Border Background="Transparent" x:Name="bdRectangle" BorderThickness="1">
<Rectangle RadiusX="2" RadiusY="2" Name="rectBkground" Stroke="#373737" Margin="1" Opacity="1" Fill="CadetBlue" StrokeThickness="1"/>
</Border>
<Ellipse Visibility="{Binding ElementName=self, Path=HasWafer, Converter={StaticResource visibilityConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="Gray" StrokeThickness="2" Width="35" Height="35"
Fill="DarkGray" x:Name="sensor" Style="{x:Null}"/>
<Label Content="{Binding ElementName=self, Path=ModuleName}" ContentStringFormat="F0" FontFamily="Verdana" FontSize="9" HorizontalContentAlignment="Center" x:Name="labelValue" Margin="0,-2,-2,-2" VerticalContentAlignment="Center" Foreground="Yellow" />
</Grid>
</UserControl>
@@ -0,0 +1,56 @@
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;
using Aitex.Core.Common.DeviceData;
using Aitex.Core.UI.DeviceControl;
namespace MECF.Framework.UI.Core.DeviceControl
{
/// <summary>
/// ModuleControl.xaml 的交互逻辑
/// </summary>
public partial class ModuleControl : UserControl
{
public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(
"ModuleName", typeof(string), typeof(ModuleControl),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ModuleName
{
get
{
return (string)this.GetValue(ModuleNameProperty);
}
set
{
this.SetValue(ModuleNameProperty, value);
}
}
public bool HasWafer
{
get { return (bool)GetValue(HasWaferProperty); }
set { SetValue(HasWaferProperty, value); }
}
public static readonly DependencyProperty HasWaferProperty =
DependencyProperty.Register("HasWafer", typeof(bool), typeof(ModuleControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public ModuleControl()
{
InitializeComponent();
}
}
}