This commit is contained in:
GukSang.Jin
2026-05-29 14:33:24 +08:00
parent 1e5e8e1f5b
commit 8c102e4336
2 changed files with 120 additions and 32 deletions

View File

@@ -144,10 +144,104 @@
<Setter Property="BorderThickness" Value="1" />
</Style>
<Style TargetType="TabControl">
<Setter Property="Background" Value="#FFFFFF" />
<Setter Property="BorderBrush" Value="#C9D4DD" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="18" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabControl">
<Grid KeyboardNavigation.TabNavigation="Local"
SnapsToDevicePixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Background="#E6EDF3"
BorderBrush="#C6D2DC"
BorderThickness="1"
CornerRadius="10"
Padding="6"
Margin="0,0,0,10">
<TabPanel x:Name="HeaderPanel"
IsItemsHost="True"
KeyboardNavigation.TabIndex="1"
Panel.ZIndex="1" />
</Border>
<Border Grid.Row="1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="8"
Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="PART_SelectedContentHost"
ContentSource="SelectedContent"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TabItem">
<Setter Property="FontSize" Value="19" />
<Setter Property="MinWidth" Value="172" />
<Setter Property="MinHeight" Value="48" />
<Setter Property="Margin" Value="2,0" />
<Setter Property="Padding" Value="22,10" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Padding" Value="24,11" />
<Setter Property="Foreground" Value="#415466" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border x:Name="Chrome"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="7"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<Grid>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
TextElement.Foreground="{TemplateBinding Foreground}" />
<Border x:Name="Accent"
Height="3"
Margin="14,0"
VerticalAlignment="Bottom"
Background="#0F766E"
CornerRadius="2"
Opacity="0" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Chrome" Property="Background" Value="#F8FAFC" />
<Setter TargetName="Chrome" Property="BorderBrush" Value="#D4DEE7" />
<Setter Property="Foreground" Value="#0F2F45" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Chrome" Property="Background" Value="#FFFFFF" />
<Setter TargetName="Chrome" Property="BorderBrush" Value="#AFC1CF" />
<Setter Property="Foreground" Value="#0F4A66" />
<Setter Property="FontWeight" Value="Bold" />
<Setter TargetName="Accent" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="Chrome" Property="Opacity" Value="0.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PanelBorder" TargetType="Border">
@@ -207,7 +301,7 @@
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
PanningMode="VerticalOnly">
<Grid Margin="0,14,0,0">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -227,7 +321,7 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="实时千分表数值" Style="{StaticResource MetricTitle}" />
<TextBlock Text="实时千分表" Style="{StaticResource MetricTitle}" />
<TextBlock Grid.Row="1"
x:Name="RelativeDisplacementText"
Text="{Binding RelativeDisplacementText}"
@@ -295,7 +389,7 @@
Style="{StaticResource MutedText}"
Margin="0,8,0,0" />
<TextBlock Grid.Row="2" Text="轴向力设置" Style="{StaticResource FormLabel}" Margin="0,18,0,0" />
<TextBlock Grid.Row="2" Text="轴向拉力/跳动力设置" Style="{StaticResource FormLabel}" Margin="0,18,0,0" />
<Grid Grid.Row="2" Grid.Column="1" Margin="0,18,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@@ -353,7 +447,7 @@
</Grid>
</Grid>
<TextBlock Grid.Row="3" Text="轴向力保持时间设置" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="3" Text="轴向力时间设置" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<Grid Grid.Row="3" Grid.Column="1" Margin="0,14,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
@@ -368,7 +462,7 @@
Margin="10,0,0,0" />
</Grid>
<TextBlock Grid.Row="4" Text="2号当前位置" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="4" Text="当前位置" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="4"
Grid.Column="1"
x:Name="AxialAxisPositionText"
@@ -376,7 +470,7 @@
Style="{StaticResource ResultValue}"
Margin="0,14,0,0" />
<TextBlock Grid.Row="5" Text="采集数据1-1/1-2" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="5" Text="采集数据" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="5"
Grid.Column="1"
x:Name="AxialSamplePairText"
@@ -384,7 +478,7 @@
Style="{StaticResource ResultValue}"
Margin="0,14,0,0" />
<TextBlock Grid.Row="6" Text="数据差值1" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="6" Text="数据差值" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="6"
Grid.Column="1"
x:Name="AxialSampleDifferenceText"
@@ -441,11 +535,11 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Content="2号前进"
<Button Content="前进"
Command="{Binding ForwardDisplacementCommand}"
Margin="0,0,8,0" />
<Button Grid.Column="1"
Content="2号后退"
Content="后退"
Command="{Binding BackwardDisplacementCommand}"
Margin="8,0,8,0" />
<Button Grid.Column="2"
@@ -473,7 +567,7 @@
<ScrollViewer VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
PanningMode="VerticalOnly">
<Grid Margin="0,12,0,0">
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -547,11 +641,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--<TextBlock Text="扭矩曲线"
FontSize="15"
FontWeight="SemiBold"
Foreground="#334155"
Margin="2,0,0,4" />-->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="17*"/>
@@ -655,7 +744,7 @@
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="1号当前位置" Style="{StaticResource FormLabel}" />
<TextBlock Text="当前位置" Style="{StaticResource FormLabel}" />
<TextBlock Grid.Column="1"
x:Name="SpeedTorqueAxisPositionText"
Text="{Binding SpeedTorqueAxisPositionText}"
@@ -710,11 +799,11 @@
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Content="1号前进"
<Button Content="前进"
Command="{Binding ForwardSpeedTorqueCommand}"
Margin="0,0,8,0" />
<Button Grid.Column="1"
Content="1号后退"
Content="后退"
Command="{Binding BackwardSpeedTorqueCommand}"
Margin="8,0,8,0" />
<Button Grid.Column="2"
@@ -769,15 +858,15 @@
<TextBlock Grid.ColumnSpan="3" Text="轴向移动量参数2号轴" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
<TextBlock Grid.Row="1" Text="2号位移极限" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />
<TextBlock Grid.Row="1" Text="位移极限" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="AxialDisplacementLimitInput" Text="{Binding AxialDisplacementLimitInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,16,10,0" />
<TextBlock Grid.Row="1" Grid.Column="2" Text="mm" Style="{StaticResource MutedText}" Margin="0,16,0,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="2" Text="2号手/自动速度" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="2" Text="手/自动速度" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBox Grid.Row="2" Grid.Column="1" x:Name="AxialSpeedInput" Text="{Binding AxialSpeedInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
<TextBlock Grid.Row="2" Grid.Column="2" Text="mm/min" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="3" Text="2号手动位移" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="3" Text="手动位移" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBox Grid.Row="3" Grid.Column="1" x:Name="AxialManualDisplacementInput" Text="{Binding AxialManualDisplacementInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
<TextBlock Grid.Row="3" Grid.Column="2" Text="mm" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
@@ -820,15 +909,15 @@
<TextBlock Grid.ColumnSpan="3" Text="转速/扭矩参数1号轴" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
<TextBlock Grid.Row="1" Text="1号位移极限" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />
<TextBlock Grid.Row="1" Text="位移极限" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="SpeedTorqueDisplacementLimitInput" Text="{Binding SpeedTorqueDisplacementLimitInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,16,10,0" />
<TextBlock Grid.Row="1" Grid.Column="2" Text="mm" Style="{StaticResource MutedText}" Margin="0,16,0,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="2" Text="1号手/自动速度" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="2" Text="手/自动速度" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBox Grid.Row="2" Grid.Column="1" x:Name="SpeedTorqueSpeedInput" Text="{Binding SpeedTorqueSpeedInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
<TextBlock Grid.Row="2" Grid.Column="2" Text="mm/min" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
<TextBlock Grid.Row="3" Text="1号手动位移" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBlock Grid.Row="3" Text="手动位移" Style="{StaticResource FormLabel}" Margin="0,14,0,0" />
<TextBox Grid.Row="3" Grid.Column="1" x:Name="SpeedTorqueManualDisplacementInput" Text="{Binding SpeedTorqueManualDisplacementInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,14,10,0" />
<TextBlock Grid.Row="3" Grid.Column="2" Text="mm" Style="{StaticResource MutedText}" Margin="0,14,0,0" VerticalAlignment="Center" />
@@ -870,8 +959,7 @@
<ColumnDefinition Width="90" />
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="6" Text="PLC通讯" Style="{StaticResource MetricTitle}" HorizontalAlignment="Left" />
<TextBlock Grid.Row="1" Text="IP地址" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="PlcIpAddressInput" Text="{Binding PlcIpAddressInput, UpdateSourceTrigger=PropertyChanged}" Margin="0,16,10,0" />
<TextBlock Grid.Row="1" Grid.Column="3" Text="端口" Style="{StaticResource FormLabel}" Margin="0,16,0,0" />

View File

@@ -536,7 +536,7 @@ public sealed class MainWindowViewModel : ObservableObject
if (_lastRealtimeReadFailed)
{
StatusText = "PLC实时数据已恢复";
StatusText = "实时数据已恢复";
_lastRealtimeReadFailed = false;
}
}
@@ -544,7 +544,7 @@ public sealed class MainWindowViewModel : ObservableObject
{
if (!_lastRealtimeReadFailed)
{
StatusText = $"PLC实时数据读取失败:{ex.Message}";
StatusText = $"实时数据读取失败:{ex.Message}";
_lastRealtimeReadFailed = true;
}
}
@@ -636,11 +636,11 @@ public sealed class MainWindowViewModel : ObservableObject
UpdateSpeedTorqueDisplay(SpeedTorqueStatusText);
_hasLoadedParameterConfigFromPlc = true;
_parameterRetryTimer.Stop();
ParameterStatusText = "PLC配置读取成功";
ParameterStatusText = "通信读取成功";
}
catch (Exception ex)
{
ParameterStatusText = $"PLC配置读取失败,正在重试:{ex.Message}";
ParameterStatusText = $"通信读取失败,正在重试:{ex.Message}";
}
finally
{