添加配置连接窗口已经相关S7与ModbusTCP连接功能

This commit is contained in:
20492
2026-06-12 08:38:43 +08:00
parent 5d14afcb66
commit 1ff51cbc45
13 changed files with 1785 additions and 105 deletions

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="MainModule.Views.MainView"
<UserControl x:Class="MainModule.Views.MainView"
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"
@@ -21,7 +21,45 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="环境箱监控状态面板" FontSize="20" FontWeight="Bold" Foreground="#2C3E50" Margin="12,4,0,16"/>
<DockPanel Grid.Row="0" Margin="12,4,12,16">
<TextBlock Text="环境箱监控状态面板" FontSize="20" FontWeight="Bold" Foreground="#2C3E50" VerticalAlignment="Center"/>
<!-- 顶部工具栏按钮 -->
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<!-- 配置连接按钮 -->
<Button Content="配置连接"
Command="{Binding ConfigCommand}"
Style="{StaticResource MaterialDesignFlatButton}"
Foreground="#805AD5"
FontSize="13"
Margin="0,0,8,0"
ToolTip="配置设备连接参数"/>
<!-- 连接/断开按钮 -->
<Button Content="{Binding ConnectButtonText}"
Command="{Binding ConnectCommand}"
Style="{StaticResource MaterialDesignFlatButton}"
Foreground="#3182CE"
FontSize="13"
Margin="0,0,8,0"
ToolTip="点击连接/断开设备">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="连接设备" Command="{Binding ConnectCommand}"/>
<MenuItem Header="断开连接" Command="{Binding DisconnectCommand}"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
<!-- 刷新按钮 -->
<Button Content="刷新数据"
Command="{Binding RefreshCommand}"
Style="{StaticResource MaterialDesignFlatButton}"
Foreground="#38A169"
FontSize="13"
ToolTip="手动刷新设备数据"/>
</StackPanel>
</DockPanel>
<ItemsControl Grid.Row="1" ItemsSource="{Binding Chambers}">
<ItemsControl.ItemsPanel>
@@ -40,6 +78,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DockPanel Grid.Row="0" LastChildFill="False">
@@ -95,10 +134,30 @@
</StackPanel>
</StackPanel>
</UniformGrid>
<!-- 连接按钮 -->
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,16,0,0">
<Button Content="{Binding ConnectButtonText}"
Command="{Binding DataContext.ConnectDeviceCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}"
Width="100"
Height="36">
<Button.Style>
<Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}">
<Setter Property="Foreground" Value="#3182CE"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsConnected}" Value="True">
<Setter Property="Foreground" Value="#E53E3E"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
</UserControl>