Files
2024-12-18 15:50:21 +08:00

167 lines
7.0 KiB
XML

<UserControl
x:Class="CapMachine.Shared.Controls.Meter"
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:local="clr-namespace:CapMachine.Shared.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="MeterInstance"
Width="130"
Height="155"
BorderBrush="Gray"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition Height="3*" />
<RowDefinition Height="2*" />
</Grid.RowDefinitions>
<Border
Margin="3,3,3,0"
Background="#404040"
CornerRadius="3" />
<StackPanel Margin="3,3,3,0">
<DockPanel Margin="5">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
FontSize="22"
Foreground="White"
Text="PV" />
<TextBlock
Margin="5,0,5,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=PVValue}" />
<TextBlock
Margin="2,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
DockPanel.Dock="Right"
FontSize="12"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=Unit}" />
</DockPanel>
<DockPanel Margin="5,-3,5,0">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
FontSize="20"
FontStyle="Italic"
Foreground="Gold"
Text="SV" />
<TextBlock
Margin="10,0,5,0"
VerticalAlignment="Center"
FontSize="20"
Foreground="Gold"
Text="{Binding ElementName=MeterInstance, Path=SVValue}" />
<!--<TextBlock
Margin="2,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
DockPanel.Dock="Right"
FontSize="12"
Foreground="Gold"
Text="{Binding ElementName=MeterInstance, Path=Unit}" />-->
</DockPanel>
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Margin="0,3,0,0">
<!--
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
把整个控件作为参数传递进去
-->
<ToggleButton
x:Name="ToggleBtnAutoHand"
Width="40"
Click="ToggleBtnAutoHand_Click_1"
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
IsChecked="{Binding ElementName=MeterInstance, Path=AutoHandState}"
Style="{StaticResource MaterialDesignSwitchToggleButton}"
ToolTip="手自动" />
<TextBlock
Margin="0,5,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="3,3,3,0">
<StackPanel.Resources />
<!--
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}"
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
把整个控件作为参数传递进去
-->
<TextBox
x:Name="HandValueMV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueMV_KeyDown"
Text="{Binding ElementName=MeterInstance, Path=HandValueMVParameter}"
ToolTip="按【Enter】回车键才会发送生效"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="MV"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
</StackPanel>
<StackPanel Grid.Column="2" Margin="3,3,3,0">
<StackPanel.Resources />
<!--
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}"
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
把整个控件作为参数传递进去
-->
<TextBox
x:Name="HandValueSV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueSV_KeyDown"
Text="{Binding ElementName=MeterInstance, Path=HandValueSVParameter}"
ToolTip="按【Enter】回车键才会发送生效"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="SV"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
</StackPanel>
</Grid>
<Border
Grid.Row="2"
Margin="3,3,3,3"
Background="Gray"
CornerRadius="3">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=MeterName}" />
</Border>
</Grid>
</UserControl>