首次上传

This commit is contained in:
hanqiangqiang
2026-06-15 10:56:30 +08:00
commit b0213b94d6
4160 changed files with 736101 additions and 0 deletions
@@ -0,0 +1,12 @@
<UserControl x:Class="MECF.Framework.UI.Core.CommonControl.AITInterlockSensor"
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.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Aitex.Core.Common.DeviceData;
namespace MECF.Framework.UI.Core.CommonControl
{
/// <summary>
/// AITInterlockSensor.xaml 的交互逻辑
/// </summary>
public partial class AITInterlockSensor : UserControl
{
public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
"DeviceData", typeof(AITSensorData), typeof(AITInterlockSensor),
new FrameworkPropertyMetadata(new AITSensorData(), FrameworkPropertyMetadataOptions.AffectsRender));
public AITSensorData DeviceData
{
get
{
return (AITSensorData)this.GetValue(DeviceDataProperty);
}
set
{
this.SetValue(DeviceDataProperty, value);
}
}
public bool LightOnValue
{
get { return (bool)GetValue(LightOnValueProperty); }
set { SetValue(LightOnValueProperty, value); }
}
public static readonly DependencyProperty LightOnValueProperty =
DependencyProperty.Register("LightOnValue", typeof(bool), typeof(AITInterlockSensor), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));
public AITInterlockSensor()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (DeviceData == null)
{
sensor.Fill = new SolidColorBrush(Colors.Gray);
return;
}
if (DeviceData.Value == LightOnValue)
sensor.Fill = new SolidColorBrush(Colors.Red);
else
{
sensor.Fill = new SolidColorBrush(Colors.Gray);
}
//if (DeviceData.IsError)
// sensor.Fill = new SolidColorBrush(Colors.Red);
//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["GlobalLableSensorToolTip"].ToString(),
"Sensor",
DeviceData.DisplayName,
DeviceData.DeviceSchematicId,
DeviceData.Value);
ToolTip = tooltipValue;
}
}
}
}
@@ -0,0 +1,30 @@
<UserControl x:Class="MECF.Framework.UI.Core.CommonControl.AITScBoolRow"
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"
x:Name="self"
d:DesignHeight="30" d:DesignWidth="450">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=self,Path=NameWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=FeedbackWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=SetPointWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=CommandWidth }" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#376092" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="0" FontSize="15" Text="{Binding ElementName=self, Path=ScName }" Foreground="White" />
<Rectangle Grid.Column="1" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<CheckBox Grid.Column="1" IsEnabled="False" IsChecked="{Binding ElementName=self, Path=ScFeedback}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="11" />
<Rectangle Grid.Column="2" x:Name="RectangleSetPoint" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<CheckBox Grid.Column="2" IsChecked="{Binding ElementName=self, Path=ScSetPoint}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="11" />
<Rectangle Grid.Column="3" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<Button Grid.Column="3" Content="Set" VerticalAlignment="Center" FontSize="16" Width="{Binding ElementName=self, Path=CommandWidth}" Height="26" Margin="2" Click="Button_Click"/>
</Grid>
</UserControl>
@@ -0,0 +1,169 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MECF.Framework.UI.Core.CommonControl
{
/// <summary>
/// AITScBoolRow.xaml 的交互逻辑
/// </summary>
public partial class AITScBoolRow : UserControl
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
"NameWidth", typeof(int), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
public int NameWidth
{
get
{
return (int)this.GetValue(NameWidthProperty);
}
set
{
this.SetValue(NameWidthProperty, value);
}
}
public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
"FeedbackWidth", typeof(int), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int FeedbackWidth
{
get
{
return (int)this.GetValue(FeedbackWidthProperty);
}
set
{
this.SetValue(FeedbackWidthProperty, value);
}
}
public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
"SetPointWidth", typeof(int), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int SetPointWidth
{
get
{
return (int)this.GetValue(SetPointWidthProperty);
}
set
{
this.SetValue(SetPointWidthProperty, value);
}
}
public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
"CommandWidth", typeof(int), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int CommandWidth
{
get
{
return (int)this.GetValue(CommandWidthProperty);
}
set
{
this.SetValue(CommandWidthProperty, value);
}
}
public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
"ScId", typeof(string), typeof(AITScBoolRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScId
{
get
{
return (string)this.GetValue(ScIdProperty);
}
set
{
this.SetValue(ScIdProperty, value);
}
}
public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
"ScName", typeof(string), typeof(AITScBoolRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScName
{
get
{
return (string)this.GetValue(ScNameProperty);
}
set
{
this.SetValue(ScNameProperty, value);
}
}
public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
"ScFeedback", typeof(bool), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool ScFeedback
{
get
{
return (bool)this.GetValue(ScFeedbackProperty);
}
set
{
this.SetValue(ScFeedbackProperty, value);
}
}
public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
"ScSetPoint", typeof(bool), typeof(AITScBoolRow),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));
public bool ScSetPoint
{
get
{
return (bool)this.GetValue(ScSetPointProperty);
}
set
{
this.SetValue(ScSetPointProperty, value);
}
}
public AITScBoolRow()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
RectangleSetPoint.Fill = ScSetPoint == ScFeedback
? new SolidColorBrush(Color.FromRgb(0x95, 0xB3, 0xD7))
: new SolidColorBrush(Colors.Yellow);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Command.Execute(new object[] { ScId, ScSetPoint.ToString() });
}
}
}
@@ -0,0 +1,31 @@
<UserControl x:Class="MECF.Framework.UI.Core.CommonControl.AITScDoubleRow"
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"
x:Name="self"
d:DesignHeight="30" d:DesignWidth="450">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=self,Path=NameWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=FeedbackWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=SetPointWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=CommandWidth }" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#376092" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="0" FontSize="15" Text="{Binding ElementName=self, Path=ScName }" Foreground="White" />
<Rectangle Grid.Column="1" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="1" TextAlignment="Center" FontSize="20" Width="{Binding ElementName=self,Path=FeedbackWidth }" Height="25" Margin="3" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScFeedback, StringFormat={}{0:F0}}" />
<Rectangle Grid.Column="2" Fill="#95B3D7" x:Name="RectangleSetPoint" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBox Grid.Column="2" PreviewTextInput="OnPreviewTextInput" x:Name="InputSetPoint" TextAlignment="Center" FontSize="20" Width="{Binding ElementName=self,Path=SetPointWidth }" Height="25" Margin="3,3,0,0" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScSetPoint}" />
<Rectangle Grid.Column="3" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<Button Grid.Column="3" Content="Set" VerticalAlignment="Center" FontSize="16" Width="{Binding ElementName=self, Path=CommandWidth}" Height="26" Margin="2" Click="Button_Click"/>
</Grid>
</UserControl>
@@ -0,0 +1,187 @@
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MECF.Framework.UI.Core.CommonControl
{
/// <summary>
/// AITSCRow.xaml 的交互逻辑
/// </summary>
public partial class AITScDoubleRow : UserControl
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
"NameWidth", typeof(int), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
public int NameWidth
{
get
{
return (int)this.GetValue(NameWidthProperty);
}
set
{
this.SetValue(NameWidthProperty, value);
}
}
public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
"FeedbackWidth", typeof(int), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int FeedbackWidth
{
get
{
return (int)this.GetValue(FeedbackWidthProperty);
}
set
{
this.SetValue(FeedbackWidthProperty, value);
}
}
public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
"SetPointWidth", typeof(int), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int SetPointWidth
{
get
{
return (int)this.GetValue(SetPointWidthProperty);
}
set
{
this.SetValue(SetPointWidthProperty, value);
}
}
public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
"CommandWidth", typeof(int), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int CommandWidth
{
get
{
return (int)this.GetValue(CommandWidthProperty);
}
set
{
this.SetValue(CommandWidthProperty, value);
}
}
public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
"ScId", typeof(string), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScId
{
get
{
return (string)this.GetValue(ScIdProperty);
}
set
{
this.SetValue(ScIdProperty, value);
}
}
public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
"ScName", typeof(string), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScName
{
get
{
return (string)this.GetValue(ScNameProperty);
}
set
{
this.SetValue(ScNameProperty, value);
}
}
public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
"ScFeedback", typeof(double), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public double ScFeedback
{
get
{
return (double)this.GetValue(ScFeedbackProperty);
}
set
{
this.SetValue(ScFeedbackProperty, value);
}
}
public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
"ScSetPoint", typeof(double), typeof(AITScDoubleRow),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public double ScSetPoint
{
get
{
return (double)this.GetValue(ScSetPointProperty);
}
set
{
this.SetValue(ScSetPointProperty, value);
}
}
public AITScDoubleRow()
{
InitializeComponent();
}
private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text);
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
RectangleSetPoint.Fill = Math.Abs(ScSetPoint - ScFeedback) < 0.001
? new SolidColorBrush(Color.FromRgb(0x95, 0xB3, 0xD7))
: new SolidColorBrush(Colors.Yellow);
InputSetPoint.Background = Math.Abs(ScSetPoint - ScFeedback) < 0.001
? new SolidColorBrush(Color.FromRgb(0xDC, 0xF7, 0xF6))
: new SolidColorBrush(Colors.Yellow);
}
private static bool IsTextAllowed(string text)
{
Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
return !regex.IsMatch(text);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Command.Execute(new object[] { ScId, ScSetPoint.ToString()});
}
}
}
@@ -0,0 +1,30 @@
<UserControl x:Class="MECF.Framework.UI.Core.CommonControl.AITScReadOnlyDoubleRow"
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"
x:Name="self"
d:DesignHeight="30" d:DesignWidth="450">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=self,Path=NameWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=FeedbackWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=SetPointWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=CommandWidth }" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#376092" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="0" FontSize="15" Text="{Binding ElementName=self, Path=ScName }" Foreground="White" />
<Rectangle Grid.Column="1" Grid.ColumnSpan="3" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="1" Grid.ColumnSpan="3" TextAlignment="Center" FontSize="13" Width="88" Height="25" Margin="3" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScFeedback, StringFormat={}{0:F0}}" />
<!--<Rectangle Grid.Column="2" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBox Grid.Column="2" PreviewTextInput="OnPreviewTextInput" TextAlignment="Center" FontSize="11" Width="80" Height="25" Margin="3,3,0,0" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScSetPoint}" />
<Rectangle Grid.Column="3" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<Button Grid.Column="3" Content="Set" VerticalAlignment="Center" FontSize="16" Width="{Binding ElementName=self, Path=CommandWidth}" Height="26" Margin="2" Click="Button_Click"/>-->
</Grid>
</UserControl>
@@ -0,0 +1,171 @@
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace MECF.Framework.UI.Core.CommonControl
{
/// <summary>
/// AITScReadOnlyDoubleRow.xaml 的交互逻辑
/// </summary>
public partial class AITScReadOnlyDoubleRow : UserControl
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
"NameWidth", typeof(int), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
public int NameWidth
{
get
{
return (int)this.GetValue(NameWidthProperty);
}
set
{
this.SetValue(NameWidthProperty, value);
}
}
public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
"FeedbackWidth", typeof(int), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int FeedbackWidth
{
get
{
return (int)this.GetValue(FeedbackWidthProperty);
}
set
{
this.SetValue(FeedbackWidthProperty, value);
}
}
public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
"SetPointWidth", typeof(int), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int SetPointWidth
{
get
{
return (int)this.GetValue(SetPointWidthProperty);
}
set
{
this.SetValue(SetPointWidthProperty, value);
}
}
public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
"CommandWidth", typeof(int), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int CommandWidth
{
get
{
return (int)this.GetValue(CommandWidthProperty);
}
set
{
this.SetValue(CommandWidthProperty, value);
}
}
public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
"ScId", typeof(string), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScId
{
get
{
return (string)this.GetValue(ScIdProperty);
}
set
{
this.SetValue(ScIdProperty, value);
}
}
public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
"ScName", typeof(string), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScName
{
get
{
return (string)this.GetValue(ScNameProperty);
}
set
{
this.SetValue(ScNameProperty, value);
}
}
public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
"ScFeedback", typeof(double), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public double ScFeedback
{
get
{
return (double)this.GetValue(ScFeedbackProperty);
}
set
{
this.SetValue(ScFeedbackProperty, value);
}
}
public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
"ScSetPoint", typeof(double), typeof(AITScReadOnlyDoubleRow),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));
public double ScSetPoint
{
get
{
return (double)this.GetValue(ScSetPointProperty);
}
set
{
this.SetValue(ScSetPointProperty, value);
}
}
public AITScReadOnlyDoubleRow()
{
InitializeComponent();
}
private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !IsTextAllowed(e.Text);
}
private static bool IsTextAllowed(string text)
{
Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
return !regex.IsMatch(text);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
}
}
}
@@ -0,0 +1,30 @@
<UserControl x:Class="MECF.Framework.UI.Core.CommonControl.AITScStringRow"
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"
x:Name="self"
d:DesignHeight="30" d:DesignWidth="450">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=self,Path=NameWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=FeedbackWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=SetPointWidth }" />
<ColumnDefinition Width="{Binding ElementName=self,Path=CommandWidth }" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#376092" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="0" FontSize="15" Text="{Binding ElementName=self, Path=ScName }" Foreground="White" />
<Rectangle Grid.Column="1" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBlock Grid.Column="1" TextAlignment="Center" FontSize="13" Width="{Binding ElementName=self,Path=FeedbackWidth }" Height="25" Margin="3" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScFeedback}" />
<Rectangle Grid.Column="2" x:Name="RectangleSetPoint" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<TextBox Grid.Column="2" x:Name="InputSetPoint" TextAlignment="Center" FontSize="11" Width="{Binding ElementName=self,Path=SetPointWidth }" Height="25" Margin="3,3,0,0" Padding="0,0,0,0" Text="{Binding ElementName=self,Path=ScSetPoint}" />
<Rectangle Grid.Column="3" Fill="#95B3D7" Margin="0" Stroke="White" StrokeThickness="1"></Rectangle>
<Button Grid.Column="3" Content="Set" VerticalAlignment="Center" FontSize="16" Width="{Binding ElementName=self, Path=CommandWidth}" Height="26" Margin="2" Click="Button_Click"/>
</Grid>
</UserControl>
@@ -0,0 +1,174 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MECF.Framework.UI.Core.CommonControl
{
/// <summary>
/// AITSCRow.xaml 的交互逻辑
/// </summary>
public partial class AITScStringRow : UserControl
{
public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
"Command", typeof(ICommand), typeof(AITScStringRow),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ICommand Command
{
get
{
return (ICommand)this.GetValue(CommandProperty);
}
set
{
this.SetValue(CommandProperty, value);
}
}
public static readonly DependencyProperty NameWidthProperty = DependencyProperty.Register(
"NameWidth", typeof(int), typeof(AITScStringRow),
new FrameworkPropertyMetadata(180, FrameworkPropertyMetadataOptions.AffectsRender));
public int NameWidth
{
get
{
return (int)this.GetValue(NameWidthProperty);
}
set
{
this.SetValue(NameWidthProperty, value);
}
}
public static readonly DependencyProperty FeedbackWidthProperty = DependencyProperty.Register(
"FeedbackWidth", typeof(int), typeof(AITScStringRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int FeedbackWidth
{
get
{
return (int)this.GetValue(FeedbackWidthProperty);
}
set
{
this.SetValue(FeedbackWidthProperty, value);
}
}
public static readonly DependencyProperty SetPointWidthProperty = DependencyProperty.Register(
"SetPointWidth", typeof(int), typeof(AITScStringRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int SetPointWidth
{
get
{
return (int)this.GetValue(SetPointWidthProperty);
}
set
{
this.SetValue(SetPointWidthProperty, value);
}
}
public static readonly DependencyProperty CommandWidthProperty = DependencyProperty.Register(
"CommandWidth", typeof(int), typeof(AITScStringRow),
new FrameworkPropertyMetadata(90, FrameworkPropertyMetadataOptions.AffectsRender));
public int CommandWidth
{
get
{
return (int)this.GetValue(CommandWidthProperty);
}
set
{
this.SetValue(CommandWidthProperty, value);
}
}
public static readonly DependencyProperty ScIdProperty = DependencyProperty.Register(
"ScId", typeof(string), typeof(AITScStringRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScId
{
get
{
return (string)this.GetValue(ScIdProperty);
}
set
{
this.SetValue(ScIdProperty, value);
}
}
public static readonly DependencyProperty ScNameProperty = DependencyProperty.Register(
"ScName", typeof(string), typeof(AITScStringRow),
new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScName
{
get
{
return (string)this.GetValue(ScNameProperty);
}
set
{
this.SetValue(ScNameProperty, value);
}
}
public static readonly DependencyProperty ScFeedbackProperty = DependencyProperty.Register(
"ScFeedback", typeof(string), typeof(AITScStringRow),
new FrameworkPropertyMetadata("127.0.0.1", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScFeedback
{
get
{
return (string)this.GetValue(ScFeedbackProperty);
}
set
{
this.SetValue(ScFeedbackProperty, value);
}
}
public static readonly DependencyProperty ScSetPointProperty = DependencyProperty.Register(
"ScSetPoint", typeof(string), typeof(AITScStringRow),
new FrameworkPropertyMetadata("127.0.0.1", FrameworkPropertyMetadataOptions.AffectsRender));
public string ScSetPoint
{
get
{
return (string)this.GetValue(ScSetPointProperty);
}
set
{
this.SetValue(ScSetPointProperty, value);
}
}
public AITScStringRow()
{
InitializeComponent();
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
RectangleSetPoint.Fill = ScSetPoint == ScFeedback
? new SolidColorBrush(Color.FromRgb(0x95, 0xB3, 0xD7))
: new SolidColorBrush(Colors.Yellow);
InputSetPoint.Background = ScSetPoint == ScFeedback
? new SolidColorBrush(Color.FromRgb(0xDC, 0xF7, 0xF6))
: new SolidColorBrush(Colors.Yellow);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Command.Execute(new object[] { ScId, ScSetPoint.ToString()});
}
}
}