97 lines
5.0 KiB
XML
97 lines
5.0 KiB
XML
<Window x:Class="PLCDataMonitor.MainWindow"
|
||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||
xmlns:local="clr-namespace:PLCDataMonitor"
|
||
mc:Ignorable="d"
|
||
Title="PLC压力与摩擦力监控系统" Height="600" Width="1000"
|
||
Closing="Window_Closing" WindowStyle="SingleBorderWindow"
|
||
ResizeMode="CanResizeWithGrip" FontFamily="Microsoft YaHei" Loaded="Window_Loaded">
|
||
|
||
<Grid>
|
||
<!-- 定义3行布局:导航栏60px + 内容区自适应 + 底部栏40px -->
|
||
<Grid.RowDefinitions>
|
||
<RowDefinition Height="60"/>
|
||
<RowDefinition Height="*"/>
|
||
<RowDefinition Height="40"/>
|
||
</Grid.RowDefinitions>
|
||
|
||
<!-- 背景图:最下层,覆盖整个窗口 -->
|
||
<Image Source="Img/background.jpg"
|
||
Stretch="UniformToFill"
|
||
Opacity="0.15"
|
||
Panel.ZIndex="-1"
|
||
Grid.RowSpan="3"/>
|
||
|
||
<!-- 顶部导航栏:用Grid列布局替代Width="*",解决错误 -->
|
||
<Grid Grid.Row="0" Background="#2C3E50" Panel.ZIndex="10">
|
||
<!-- 关键:定义2列布局,左侧自适应(导航按钮),右侧占满剩余空间(连接区域) -->
|
||
<Grid.ColumnDefinitions>
|
||
<ColumnDefinition Width="Auto"/>
|
||
<!-- 左侧:导航按钮,宽度自适应 -->
|
||
<ColumnDefinition Width="*"/>
|
||
<!-- 右侧:连接区域,占满剩余空间 -->
|
||
</Grid.ColumnDefinitions>
|
||
|
||
<!-- 左侧:系统标题 + 导航按钮 -->
|
||
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="20,0" VerticalAlignment="Center">
|
||
<TextBlock Text="PLC监控系统" FontSize="22" FontWeight="Bold"
|
||
Foreground="White" Margin="0,0,40,0"/>
|
||
|
||
<Button x:Name="BtnHome" Content="数据监控" Width="120" Height="40"
|
||
FontSize="16" Background="#3498DB" Foreground="White"
|
||
BorderThickness="0" Margin="0,0,10,0" Click="BtnHome_Click"/>
|
||
|
||
<Button x:Name="BtnReport" Content="报表记录" Width="120" Height="40"
|
||
FontSize="16" Background="#2C3E50" Foreground="White"
|
||
BorderThickness="0" Margin="0,0,10,0" Click="BtnReport_Click"/>
|
||
|
||
<Button x:Name="BtnCurve" Content="曲线记录" Width="120" Height="40"
|
||
FontSize="16" Background="#2C3E50" Foreground="White"
|
||
BorderThickness="0" Margin="0,0,10,0" Click="BtnCurve_Click"/>
|
||
</StackPanel>
|
||
|
||
<!-- 右侧:PLC连接区域 + 连接状态 + IP/端口 + 连接按钮 -->
|
||
<StackPanel Grid.Column="1" Orientation="Horizontal"
|
||
HorizontalAlignment="Right"
|
||
VerticalAlignment="Center"
|
||
Margin="0,0,20,0">
|
||
<!-- IP和端口显示 -->
|
||
<TextBlock x:Name="TxtPLCIP" Text="IP: " FontSize="12" Foreground="White" Margin="0,0,5,0" VerticalAlignment="Center"/>
|
||
<TextBlock x:Name="TxtPLCIPValue" Text="192.168.1.170" FontSize="12" Foreground="White" Margin="0,0,15,0" VerticalAlignment="Center"/>
|
||
<TextBlock x:Name="TxtPLCPort" Text="Port: " FontSize="12" Foreground="White" Margin="0,0,5,0" VerticalAlignment="Center"/>
|
||
<TextBlock x:Name="TxtPLCPortValue" Text="502" FontSize="12" Foreground="White" Margin="0,0,15,0" VerticalAlignment="Center"/>
|
||
|
||
<!-- 连接按钮 -->
|
||
<Button x:Name="BtnConnectPLC" Content="连接PLC" Width="80" Height="30"
|
||
FontSize="12" Background="#27AE60" Foreground="White"
|
||
BorderThickness="0" Margin="10,0,0,0" Click="ConnectButton_Click"/>
|
||
|
||
<!-- 连接状态指示 -->
|
||
<StackPanel Orientation="Horizontal" Margin="15,0,0,0"
|
||
VerticalAlignment="Center">
|
||
<Ellipse Width="18" Height="18" Fill="{Binding StatusColor}"
|
||
Margin="0,0,8,0"/>
|
||
<TextBlock Text="{Binding ConnectionStatus}"
|
||
FontSize="12" Foreground="White"/>
|
||
</StackPanel>
|
||
</StackPanel>
|
||
</Grid>
|
||
|
||
<!-- 中间内容区域 -->
|
||
<Frame x:Name="MainContentFrame"
|
||
Grid.Row="1"
|
||
Margin="20"
|
||
BorderThickness="0"
|
||
NavigationUIVisibility="Hidden"
|
||
Panel.ZIndex="5"/>
|
||
|
||
<!-- 底部信息栏 -->
|
||
<Grid Grid.Row="2" Background="#ECF0F1" Panel.ZIndex="10">
|
||
<TextBlock Text="© 2025 PLC监控系统 | 数据刷新间隔:100ms"
|
||
FontSize="12" Foreground="#7F8C8D"
|
||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||
</Grid>
|
||
</Grid>
|
||
</Window> |