wenxiangchao
2026-11-02 9d1660270272180cd71147d6ddd53d1382643d2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<hb:SimpleMaskControl x:Class="Plugin.DeviceDebug.DeviceDebug"
             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" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:hb="clr-namespace:HMI.Base;assembly=HMI.Base"
             xmlns:ui="clr-namespace:HMI.UI;assembly=HMI.UI"
             xmlns:uic="clr-namespace:HMI.UI.Converter;assembly=HMI.UI"
             xmlns:pw="https://opensource.panuon.com/wpf"
             xmlns:pu="https://opensource.panuon.com/wpf-ui"
             xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
             xmlns:local="clr-namespace:Plugin.DeviceDebug"
             xmlns:panels="clr-namespace:Plugin.DeviceDebug.Panels"
             mc:Ignorable="d"
             Loaded="SimpleMaskControl_Loaded"
             d:DesignHeight="600" d:DesignWidth="1000">
    <hb:SimpleMaskControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/HMI.UI;component/Style/PanuonListView.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="TitleBox" TargetType="TextBlock">
                <Setter Property="FontSize" Value="14"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
                <Setter Property="Padding" Value="8,4"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>
            <BooleanToVisibilityConverter x:Key="BoolToVis"/>
        </ResourceDictionary>
    </hb:SimpleMaskControl.Resources>
 
    <Grid dp:GridHelper.Space="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
 
        <!-- 顶部标题栏 -->
        <DockPanel Grid.Row="0">
            <StackPanel dp:StackPanelHelper.ChildSpace="10" DockPanel.Dock="Right" Orientation="Horizontal">
                <ComboBox x:Name="deviceSelector" Width="240" 
                          ItemsSource="{Binding DeviceList}"
                          SelectedItem="{Binding SelectedDevice}"
                          SelectionChanged="DeviceSelector_SelectionChanged"
                          VerticalContentAlignment="Center" Padding="6,4"/>
                <Button Style="{StaticResource RfhBtn}" x:Name="rfhBtn" Click="RfhBtn_Click"/>
            </StackPanel>
            <TextBlock Style="{StaticResource TitleBox}" Text="硬件调试"/>
        </DockPanel>
 
        <!-- 设备信息栏 -->
        <Border Grid.Row="1" BorderBrush="#CCCCCC" BorderThickness="1" Padding="10,6" Background="#F9F9F9"
                Visibility="{Binding HasDevice, Converter={StaticResource BoolToVis}}">
            <WrapPanel dp:StackPanelHelper.ChildSpace="20">
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="设备ID:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding CurrentDeviceId}" Style="{StaticResource ListTableTextBlock}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="型号:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding CurrentDeviceKind}" Style="{StaticResource ListTableTextBlock}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="连接状态:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding ConnectionStateText}" Foreground="{Binding ConnectionBrush}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="版本:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding CurrentEffectiveVersion}" Style="{StaticResource ListTableTextBlock}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="预约状态:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding ReservationStatusText}" Style="{StaticResource ListTableTextBlock}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="4">
                    <TextBlock Text="会话状态:" FontWeight="Bold" Foreground="#555"/>
                    <TextBlock Text="{Binding SessionStateText}" Foreground="{Binding SessionStateBrush}" FontWeight="Bold"/>
                </StackPanel>
            </WrapPanel>
        </Border>
 
        <!-- 操作按钮栏 -->
        <StackPanel Grid.Row="2" Orientation="Horizontal" dp:StackPanelHelper.ChildSpace="10"
                    Visibility="{Binding HasDevice, Converter={StaticResource BoolToVis}}">
            <Button x:Name="enterMaintenanceBtn" Content="进入维护控制" Padding="14,6"
                    IsEnabled="{Binding CanEnterMaintenance}"
                    Click="EnterMaintenanceBtn_Click"
                    Background="#2196F3" Foreground="White" BorderThickness="0" Cursor="Hand"/>
            <Button x:Name="exitMaintenanceBtn" Content="退出维护" Padding="14,6"
                    IsEnabled="{Binding CanExitMaintenance}"
                    Click="ExitMaintenanceBtn_Click"
                    Background="#FF5722" Foreground="White" BorderThickness="0" Cursor="Hand"/>
        </StackPanel>
 
        <!-- 主体区域 -->
        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="350"/>
            </Grid.ColumnDefinitions>
 
            <!-- 左侧面板容器 -->
            <Border Grid.Column="0" BorderBrush="#DDDDDD" BorderThickness="1" Margin="0,0,8,0">
                <ContentControl x:Name="panelContainer">
                    <TextBlock Text="请选择设备" HorizontalAlignment="Center" VerticalAlignment="Center"
                               FontSize="16" Foreground="#999"/>
                </ContentControl>
            </Border>
 
            <!-- 右侧操作日志 -->
            <Border Grid.Column="1" BorderBrush="#DDDDDD" BorderThickness="1">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" Background="#F0F0F0" Padding="8,6">
                        <TextBlock Text="操作日志" FontWeight="Bold" FontSize="14"/>
                    </Border>
                    <ListView Grid.Row="1" x:Name="operationLogList"
                              ItemsSource="{Binding OperationLogs}"
                              Style="{StaticResource DefaultListTable}"
                              VirtualizingPanel.IsVirtualizing="True"
                              VirtualizingPanel.VirtualizationMode="Standard">
                        <ListView.View>
                            <GridView AllowsColumnReorder="False">
                                <GridViewColumn Width="60" Header="类型">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Border Style="{StaticResource CellBorder}">
                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
                                                           Text="{Binding CommandType}"/>
                                            </Border>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Width="120" Header="参数">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Border Style="{StaticResource CellBorder}">
                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
                                                           Text="{Binding Parameters}" TextTrimming="CharacterEllipsis"
                                                           ToolTip="{Binding Parameters}"/>
                                            </Border>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Width="60" Header="结果">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Border Style="{StaticResource CellBorder}">
                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
                                                           Text="{Binding Outcome}"/>
                                            </Border>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Width="100" Header="时间">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Border Style="{StaticResource CellBorder}">
                                                <TextBlock Style="{StaticResource ListTableTextBlock}" 
                                                           Text="{Binding Timestamp, StringFormat=HH:mm:ss}"/>
                                            </Border>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</hb:SimpleMaskControl>