更改了现场发现的问题

This commit is contained in:
2025-01-03 09:11:02 +08:00
parent 6ff9103fa2
commit 3a5674054d
10 changed files with 408 additions and 244 deletions

View File

@@ -4,60 +4,67 @@
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="MeterInstance"
Width="130"
Width="140"
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
<materialDesign:Card
Margin="3"
Background="{DynamicResource MaterialDesignLightBackground}"
Foreground="{DynamicResource PrimaryHueLightForegroundBrush}"
UniformCornerRadius="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="4*" />
<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="3">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
FontSize="20"
Foreground="White"
Text="PV" />
<TextBlock
Margin="5,0,5,0"
VerticalAlignment="Center"
FontSize="18"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=PVValue}" />
<TextBlock
Margin="1,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
DockPanel.Dock="Right"
FontSize="12"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=Unit}" />
</DockPanel>
<DockPanel Margin="3,-3,3,0">
<TextBlock
VerticalAlignment="Center"
DockPanel.Dock="Left"
FontSize="20"
FontStyle="Italic"
Foreground="Gold"
Text="SV" />
<TextBlock
Margin="10,0,5,0"
VerticalAlignment="Center"
FontSize="18"
Foreground="Gold"
Text="{Binding ElementName=MeterInstance, Path=SVValue}" />
<!--<TextBlock
Margin="2,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
@@ -65,102 +72,106 @@
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}" />
</DockPanel>
</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}" />
<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
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>
FontSize="16"
Foreground="White"
Text="{Binding ElementName=MeterInstance, Path=MeterName}" />
</Border>
</Grid>
</materialDesign:Card>
<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>

View File

@@ -311,7 +311,7 @@ namespace CapMachine.Shared.Controls
{
//HandValueParameter 此时无法更新到最新的值(旧值),可能因为RaisePropertyChanged在ViewModel上不受这边的控制了所以直接取控件的数据
//HandValueParameter 没有使用直接取控件的值HandValueParameter作为初始值使用
if (int.TryParse(HandValueSV.Text, out int Result))
if (double.TryParse(HandValueSV.Text, out double Result))
{
//把整个控件打包发送过去无法访问Textbox的值那么直接传送模型的数据给ViewModel
HandValueCommand.Execute(new MeterChannelValue() { Name = MeterName, Value = Result, Type = "SV" });