Files
XplorePlane/XP.Hardware.PLC.Sentry/Views/SentryMainWindow.xaml
T

177 lines
9.9 KiB
XML

<Window x:Class="XP.Hardware.PLC.Sentry.Views.SentryMainWindow"
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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:views="clr-namespace:XP.Hardware.PLC.Sentry.Views"
xmlns:converters="clr-namespace:XP.Hardware.PLC.Sentry.Converters"
mc:Ignorable="d"
Title="PLC Sentry Monitor"
Icon="/XplorerPlane.ico"
Width="1200" Height="1000"
MinWidth="900" MinHeight="600"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<converters:LogLevelToColorConverter x:Key="LogLevelToColorConverter"/>
<converters:ConnectionStatusToColorConverter x:Key="ConnectionStatusToColorConverter"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<!-- 工具栏 | Toolbar -->
<RowDefinition Height="Auto"/>
<!-- 信号监控区域 | Signal monitor area -->
<RowDefinition Height="*" MinHeight="200"/>
<!-- 可拖拽分隔条 | Draggable splitter -->
<RowDefinition Height="5"/>
<!-- 操作日志面板 | Operation log panel -->
<RowDefinition Height="300" MinHeight="100"/>
<!-- 状态栏 | Status bar -->
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- === 操作按钮区域 | Action buttons area === -->
<DockPanel Grid.Row="0" Margin="8,6" LastChildFill="False">
<!-- 左侧:连接、断开 | Left: Connect, Disconnect -->
<StackPanel DockPanel.Dock="Left" Orientation="Horizontal">
<telerik:RadButton Command="{Binding ConnectCommand}"
telerik:StyleManager.Theme="Crystal"
Content="连接 PLC"
ToolTip="连接 PLC | Connect PLC"
Padding="10,4" Margin="0,0,6,0"/>
<telerik:RadButton Command="{Binding DisconnectCommand}"
telerik:StyleManager.Theme="Crystal"
Content="断开 PLC"
ToolTip="断开 PLC | Disconnect PLC"
Padding="10,4"/>
</StackPanel>
<!-- 右侧:PLC 连接管理、刷新信号定义 | Right: PLC Config, Refresh -->
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<telerik:RadButton Command="{Binding OpenConfigEditorCommand}"
telerik:StyleManager.Theme="Crystal"
Content="PLC 信号地址定义编辑"
ToolTip="PLC 信号地址定义编辑器 | PLC Signal Address Definition Editor"
Padding="10,4" Margin="0,0,6,0"/>
<telerik:RadButton Command="{Binding RefreshSignalDefinitionsCommand}"
telerik:StyleManager.Theme="Crystal"
Content="刷新PLC信号定义"
ToolTip="刷新PLC信号定义 | Refresh PLC Signal Definitions"
Padding="10,4" Margin="0,0,6,0"/>
<telerik:RadButton Command="{Binding OpenSignalDataDemoCommand}"
telerik:StyleManager.Theme="Crystal"
Content="PLC信号读写测试"
ToolTip="打开 ISignalDataService DEMO 窗口 | Open Signal Data Demo Window"
Padding="10,4"/>
</StackPanel>
</DockPanel>
<!-- === 信号监控区域 | Signal monitor area === -->
<views:SignalMonitorView Grid.Row="1" Margin="4,4,4,0"
DataContext="{Binding}"/>
<!-- === 可拖拽分隔条 | Draggable GridSplitter === -->
<GridSplitter Grid.Row="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Height="5"
Background="#FFCCCCCC"
ResizeDirection="Rows"
ShowsPreview="True"/>
<!-- === 操作日志面板 | Operation log panel === -->
<GroupBox Grid.Row="3" Header="操作日志 | Operation Log" Margin="4,0,4,4">
<DockPanel>
<!-- 清除日志按钮 | Clear log button -->
<telerik:RadButton DockPanel.Dock="Bottom"
Content="清除日志 | Clear Log"
telerik:StyleManager.Theme="Crystal"
Command="{Binding ClearLogCommand}"
HorizontalAlignment="Right"
Width="120" Margin="0,4,0,0" Padding="5,3"/>
<!-- 日志表格 | Log grid -->
<telerik:RadGridView ItemsSource="{Binding LogEntries}"
telerik:StyleManager.Theme="Crystal"
AutoGenerateColumns="False"
IsReadOnly="True"
RowIndicatorVisibility="Collapsed"
ShowGroupPanel="False"
ShowColumnHeaders="True"
CanUserFreezeColumns="False"
CanUserReorderColumns="False"
CanUserSortColumns="False"
CanUserResizeColumns="True"
IsFilteringAllowed="False"
SelectionMode="Single"
FontFamily="Consolas"
FontSize="12"
Background="#FFF9F9F9"
BorderBrush="#FFBDBDBD"
Margin="0,5,0,0">
<telerik:RadGridView.Columns>
<!-- 时间戳列 | Timestamp column -->
<telerik:GridViewDataColumn Header="时间 | Time"
DataMemberBinding="{Binding TimestampDisplay}"
Width="110"
IsReadOnly="True"/>
<!-- 级别列 | Level column -->
<telerik:GridViewDataColumn Header="级别 | Level"
DataMemberBinding="{Binding Level}"
Width="70"
IsReadOnly="True">
<telerik:GridViewDataColumn.CellStyle>
<Style TargetType="telerik:GridViewCell">
<Setter Property="Foreground" Value="{Binding Level, Converter={StaticResource LogLevelToColorConverter}}"/>
<Setter Property="FontWeight" Value="SemiBold"/>
</Style>
</telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>
<!-- 消息列 | Message column -->
<telerik:GridViewDataColumn Header="消息 | Message"
DataMemberBinding="{Binding Message}"
Width="*"
IsReadOnly="True">
<telerik:GridViewDataColumn.CellStyle>
<Style TargetType="telerik:GridViewCell">
<Setter Property="Foreground" Value="{Binding Level, Converter={StaticResource LogLevelToColorConverter}}"/>
</Style>
</telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</DockPanel>
</GroupBox>
<!-- === 状态栏 | Status bar === -->
<StatusBar Grid.Row="4" Background="#FFF0F0F0" BorderBrush="#FFCCCCCC" BorderThickness="0,1,0,0">
<!-- 连接状态指示灯和文本 | Connection status indicator and text -->
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<!-- 连接状态指示灯(绿/灰/黄)| Connection status indicator (green/gray/yellow) -->
<Ellipse Width="12" Height="12" VerticalAlignment="Center" Margin="4,0,6,0">
<Ellipse.Fill>
<MultiBinding Converter="{StaticResource ConnectionStatusToColorConverter}">
<Binding Path="IsConnected"/>
<Binding Path="StatusText"/>
</MultiBinding>
</Ellipse.Fill>
</Ellipse>
<TextBlock Text="{Binding StatusText}" VerticalAlignment="Center"
Foreground="#FF666666" FontSize="12"/>
</StackPanel>
</StatusBarItem>
<!-- 分隔符 | Separator -->
<Separator/>
<!-- 应用信息(右侧)| Application info (right side) -->
<StatusBarItem HorizontalAlignment="Right">
<TextBlock Text="PLC Sentry Monitor v1.0" Foreground="#FF999999" FontSize="11"/>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>