更改主UI界面

This commit is contained in:
2025-04-27 17:50:57 +08:00
parent cf3d09cb3e
commit 96597c95f2
11 changed files with 545 additions and 284 deletions

View File

@@ -21,7 +21,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="2.2*" />
<RowDefinition Height="3*" />
<RowDefinition Height="1.5*" />
<RowDefinition Height="1.2*" />
</Grid.RowDefinitions>
<Border
Margin="1,3,1,0"
@@ -81,16 +81,9 @@
<RowDefinition Height="0.5*" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- 手自动切换 -->
<StackPanel
Grid.ColumnSpan="2"
Margin="5,3,3,0"
Orientation="Horizontal">
<StackPanel Margin="5,3,3,0" Orientation="Horizontal">
<!--
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
@@ -114,90 +107,128 @@
Foreground="CadetBlue"
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}" />
</StackPanel>
<!-- MV -->
<StackPanel
Grid.Row="1"
Grid.Column="0"
Margin="3,3,3,0">
<StackPanel.Resources />
<!--
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}"
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
把整个控件作为参数传递进去 Text="{Binding ElementName=MeterInstance, Path=HandValueMVParameter}"
-->
<TextBox
x:Name="HandValueMV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueMV_KeyDown"
ToolTip="按【Enter】回车键才会发送生效"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}">
<TextBox.Style>
<Style BasedOn="{StaticResource MaterialDesignTextBox}" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueTempMVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Background" Value="LimeGreen" />
</Trigger>
<Trigger Property="IsFocused" Value="False">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueMVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="MV"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
</StackPanel>
<!-- SV -->
<StackPanel
Grid.Row="1"
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}"
把整个控件作为参数传递进去 Text="{Binding ElementName=MeterInstance, Path=HandValueSVParameter, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
-->
<TextBox
x:Name="HandValueSV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueSV_KeyDown"
ToolTip="按【Enter】回车键才会发送生效"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}">
<TextBox.Style>
<Style BasedOn="{StaticResource MaterialDesignTextBox}" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueTempSVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Background" Value="LimeGreen" />
</Trigger>
<Trigger Property="IsFocused" Value="False">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueSVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="SV"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" />
</StackPanel>
<TabControl Grid.Row="1" Grid.ColumnSpan="2">
<TabControl.Template>
<ControlTemplate TargetType="TabControl">
<Grid>
<ContentPresenter ContentSource="SelectedContent" />
</Grid>
</ControlTemplate>
</TabControl.Template>
<TabControl.Style>
<Style TargetType="TabControl">
<Setter Property="SelectedIndex" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=ToggleBtnAutoHand}" Value="True">
<Setter Property="SelectedIndex" Value="1" />
</DataTrigger>
</Style.Triggers>
</Style>
</TabControl.Style>
<TabItem>
<TextBlock
Margin="2,2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
xml:space="preserve"
FontSize="12"
FontWeight="Bold"
Foreground="#404040"
Text="{Binding ElementName=MeterInstance, Path=StepExeInfo}"
TextAlignment="Center" />
</TabItem>
<TabItem>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- MV -->
<StackPanel Margin="3,3,3,0">
<StackPanel.Resources />
<!--
Text="{Binding ElementName=MeterInstance, Path=AutoStateMsg}"
Command="{Binding ElementName=MeterInstance, Path=AutoHandCommand}"
CommandParameter="{Binding ElementName=MeterInstance}"
把整个控件作为参数传递进去 Text="{Binding ElementName=MeterInstance, Path=HandValueMVParameter}"
Visibility="{Binding ElementName=MeterInstance, Path=IsHandValueShow}" 用TabControl控制了不需要显示了
-->
<TextBox
x:Name="HandValueMV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueMV_KeyDown"
ToolTip="按【Enter】回车键才会发送生效">
<TextBox.Style>
<Style BasedOn="{StaticResource MaterialDesignTextBox}" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueTempMVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Background" Value="LimeGreen" />
</Trigger>
<Trigger Property="IsFocused" Value="False">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueMVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="MV" />
</StackPanel>
<!-- SV -->
<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}"
把整个控件作为参数传递进去 Text="{Binding ElementName=MeterInstance, Path=HandValueSVParameter, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
-->
<TextBox
x:Name="HandValueSV"
Width="42"
HorizontalContentAlignment="Center"
KeyDown="HandValueSV_KeyDown"
ToolTip="按【Enter】回车键才会发送生效">
<TextBox.Style>
<Style BasedOn="{StaticResource MaterialDesignTextBox}" TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueTempSVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Setter Property="Background" Value="LimeGreen" />
</Trigger>
<Trigger Property="IsFocused" Value="False">
<Setter Property="Text" Value="{Binding ElementName=MeterInstance, Path=HandValueSVParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<TextBlock
Margin="0,2,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="CadetBlue"
Text="SV" />
</StackPanel>
</Grid>
</TabItem>
</TabControl>
</Grid>
<Border

View File

@@ -125,6 +125,24 @@ namespace CapMachine.Shared.Controls
public static readonly DependencyProperty AutoHandStateProperty = DependencyProperty.Register("AutoHandState", typeof(bool), typeof(Meter), new PropertyMetadata(false));
/// <summary>
/// 步骤执行信息
/// </summary>
public string StepExeInfo
{
get
{
return (string)base.GetValue(Meter.StepExeInfoProperty);
}
set
{
base.SetValue(Meter.StepExeInfoProperty, value);
}
}
public static readonly DependencyProperty StepExeInfoProperty = DependencyProperty.Register("StepExeInfo", typeof(string), typeof(Meter), new PropertyMetadata("--"));
private string _AutoStateMsg = "自动";
/// <summary>
/// 手自动的消息
@@ -202,12 +220,12 @@ namespace CapMachine.Shared.Controls
if (control != null && control.IsChecked == true)
{
AutoStateMsg = "手动";
IsHandValueShow = "Visible";
//IsHandValueShow = "Visible";//用TabControl控制了不需要显示了
}
else
{
AutoStateMsg = "自动";
IsHandValueShow = "Hidden";
//IsHandValueShow = "Hidden";//用TabControl控制了不需要显示了
}
}
@@ -215,19 +233,19 @@ namespace CapMachine.Shared.Controls
private string _IsHandValueShow = "Hidden";
/// <summary>
/// 手动设置的是值是否显示
/// </summary>
public string IsHandValueShow
{
get { return _IsHandValueShow; }
set
{
_IsHandValueShow = value;
OnRaisePropertyChanged("IsHandValueShow");
}
}
//private string _IsHandValueShow = "Hidden";
///// <summary>
///// 手动设置的是值是否显示
///// </summary>
//public string IsHandValueShow
//{
// get { return _IsHandValueShow; }
// set
// {
// _IsHandValueShow = value;
// OnRaisePropertyChanged("IsHandValueShow");
// }
//}
/// <summary>