schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<UserControl x:Class="XHandler.View.Device.DeveiceManagement"
             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:local="clr-namespace:XHandler.View"
             xmlns:str="clr-namespace:XHandler.Properties"
             xmlns:cons="clr-namespace:XHandler.View.Consumables"
             xmlns:ctrls="clr-namespace:XHandler.Controls"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             xmlns:local1="clr-namespace:XHandler.Class"
             xmlns:page="clr-namespace:XHandler.View.Page"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="1920"
             Loaded="UserControl_Loaded">
 
    <Grid Background="White">
        <Border Background="White" CornerRadius="0,10,10,0" Margin="10,10,10,0" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="6*"/>
                    <ColumnDefinition Width="4*"/>
                </Grid.ColumnDefinitions>
 
                <!--左侧-->
                <Border Grid.Row="0" Grid.Column="0" Background="{DynamicResource lightGrayBrush}" CornerRadius="5" BorderThickness="0" Margin="0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="10"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="50"/>
                            <RowDefinition Height="83*"/>
                            <RowDefinition Height="2*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
 
                        <Grid Grid.Row="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="240"/>
                                <ColumnDefinition Width="400"/>
                            </Grid.ColumnDefinitions>
 
                            <!--搜索框-->
                            <ctrls:SearchTextBox x:Name="searchDeviceName" Grid.Row="0" Grid.Column="0"
                                             Background="{DynamicResource middleGrayBrush}" Watermark="{x:Static str:Resources.strInputDeviceName}" 
                                             VerticalAlignment="Center" FontSize="16" VerticalContentAlignment="Center" Height="30" Width="220" 
                                             HorizontalAlignment="Left" Margin="13,0,0,0"/>
 
                            <!--搜索按钮-->
                            <Button x:Name="btnSearch" Grid.Row="0" Grid.Column="1" Content="搜索" Width="80" Height="30" VerticalContentAlignment="Center"
                                    HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="20,0,0,0" FontSize="16" Style="{DynamicResource BlueButtonStyle}" 
                                    Background="{DynamicResource blueBrush}" Click="btnSearch_Click"/>
 
 
                            <!--添加设备-->
                            <Button x:Name="btnAddDevice" Grid.Row="0" Grid.Column="1" Content="{x:Static str:Resources.strAddDevice}" Width="80" Height="30" VerticalContentAlignment="Center"
                                    HorizontalAlignment="Left" VerticalAlignment="Center" Margin="150 0" FontSize="16" Style="{DynamicResource BlueButtonStyle}" 
                                    Background="{DynamicResource blueBrush}" Click="btnAddDevice_Click"/>
                        </Grid>
 
                        <page:PagerToolsControl Grid.Row="2" x:Name="pagerToolsControl_paging" VerticalAlignment="Top" Margin="15,20,0,0" 
                                                PageCntChanged="pagerToolsControl_paging_PageCntChanged" OnePageRowCntChanged="pagerToolsControl_paging_OnePageRowCntChanged" />
 
                        <ScrollViewer Grid.Row="3" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" CanContentScroll="True">
                            <DataGrid x:Name="dgDeviceData" AutoGenerateColumns="False" BorderThickness="0" FontSize="16" 
                                  RowHeaderWidth="0" BorderBrush="LightGray" CanUserResizeColumns="True" CanUserResizeRows="False" Margin="20,20,20,12" Background="White"
                                  CanUserSortColumns="False" CanUserReorderColumns="False" CanUserAddRows="False" ColumnHeaderStyle="{DynamicResource dataGridColumnHeaderStyle}" Width="1030"
                                  GridLinesVisibility="None" IsReadOnly="True" RowStyle="{StaticResource dataGridRowStyle}" CellStyle="{StaticResource dataGridCellStyleDoubleClick}" ScrollViewer.HorizontalScrollBarVisibility="Auto">
 
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="80" Binding="{Binding SId}" Header="序号" />
 
                                    <DataGridTemplateColumn Width="130" Header="图片" >
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Source="{Binding EquipmentImg,Converter={StaticResource Base64ToImage}}" Margin="0 5"/>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
 
                                    <DataGridTextColumn Width="200" Binding="{Binding Name}" Header="名称" />
                                    <DataGridTextColumn Width="150" Binding="{Binding Ip}" Header="IP" />
                                    <DataGridTextColumn Width="100" Binding="{Binding Port}" Header="端口" />
                                    <DataGridTextColumn Width="230" Binding="{Binding CommunicateTypeName}" Header="通讯方式" />
 
                                    <!--#region 操作-->
                                    <DataGridTemplateColumn Header="{x:Static str:Resources.strOperation}" Width="*" >
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <!--修改-->
                                                    <Button x:Name="btnEdit" Content="修改" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnEdit_Click"/>
                                                    <!--删除-->
                                                    <Button x:Name="btnDelete" Content="删除" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnDelete_Click"/>
 
                                                    <!--方法-->
                                                    <Button x:Name="btnDeviceMethod" Content="方法" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnDeviceMethod_Click"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </ScrollViewer>
                    </Grid>
                </Border>
 
                <!--右侧:设备方法-->
                <Border Grid.Row="0" Grid.Column="1" Background="{DynamicResource lightGrayBrush}" CornerRadius="5" BorderThickness="0" Margin="10,0,0,0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="10"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="50"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
 
                        <!--搜索相关-->
                        <Grid Grid.Row="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="240"/>
                                <ColumnDefinition Width="400"/>
                            </Grid.ColumnDefinitions>
 
                            <!--搜索框-->
                            <ctrls:SearchTextBox x:Name="searchDeviceMethodName" Grid.Row="0" Grid.Column="0"
                                             Background="{DynamicResource middleGrayBrush}" Watermark="{x:Static str:Resources.strInputDeviceMethodName}" 
                                             VerticalAlignment="Center" FontSize="16" VerticalContentAlignment="Center" Height="30" Width="220" 
                                             HorizontalAlignment="Left" Margin="13,0,0,0"/>
 
                            <!--搜索按钮-->
                            <Button x:Name="btnSearchMethodName" Grid.Row="0" Grid.Column="1" Content="搜索" Width="80" Height="30" VerticalContentAlignment="Center"
                                    HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="20,0,0,0" FontSize="16" Style="{DynamicResource BlueButtonStyle}" 
                                    Background="{DynamicResource blueBrush}" Click="btnSearchMethodName_Click"/>
 
 
                            <!--添加方法-->
                            <Button x:Name="btnAddDeviceMethod" Grid.Row="0" Grid.Column="1" Content="{x:Static str:Resources.strAddDeviceMethod}" Width="80" Height="30" VerticalContentAlignment="Center"
                                    HorizontalAlignment="Left" VerticalAlignment="Center" Margin="150 0" FontSize="16" Style="{DynamicResource BlueButtonStyle}" 
                                    Background="{DynamicResource blueBrush}" Click="btnAddDeviceMethod_Click"/>
                        </Grid>
 
                        <Grid Grid.Row="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="50"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>
 
                            <!--方法中文名-->
                            <TextBlock Grid.Row="0" Grid.Column="0" Text="设备名称:" Width="80" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,0,0,0"
                               FontSize="16"/>
                            <TextBlock Grid.Row="0" Grid.Column="1" Name="tBoxDeviceName" FontSize="16" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
                        </Grid>
 
 
                        <!--分页-->
                        <page:PagerToolsControl Grid.Row="3" x:Name="pagerToolsDeviceMethod" VerticalAlignment="Bottom" Margin="15,0,0,0" 
                                                PageCntChanged="pagerToolsDeviceMethod_PageCntChanged" OnePageRowCntChanged="pagerToolsDeviceMethod_OnePageRowCntChanged" />
 
                        <!--DataGrid-->
                        <ScrollViewer Grid.Row="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" CanContentScroll="True">
                            <DataGrid  x:Name="dgDeviceMethodData" AutoGenerateColumns="False" BorderThickness="0" FontSize="16" 
                                  RowHeaderWidth="0" BorderBrush="LightGray" CanUserResizeColumns="True" CanUserResizeRows="False" Margin="20 20" Background="White"
                                  CanUserSortColumns="False" CanUserReorderColumns="False" CanUserAddRows="False" ColumnHeaderStyle="{DynamicResource dataGridColumnHeaderStyle}"
                                  GridLinesVisibility="None" IsReadOnly="True" RowStyle="{StaticResource dataGridRowStyle}" CellStyle="{StaticResource dataGridCellStyleDoubleClick}" Width="660">
 
                                <DataGrid.Columns>
                                    <DataGridTextColumn Width="80" Binding="{Binding SId}" Header="序号" />
                                    <DataGridTextColumn Width="180" Binding="{Binding Name}" Header="中文名称" />
                                    <DataGridTextColumn Width="180" Binding="{Binding ParameterName}" Header="英文名称" />
 
                                    <!--#region 操作-->
                                    <DataGridTemplateColumn Header="{x:Static str:Resources.strOperation}" Width="*" >
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <!--修改-->
                                                    <Button x:Name="btnMethodEdit" Content="修改" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnMethodEdit_Click"/>
                                                    <!--删除-->
                                                    <Button x:Name="btnMethodDelete" Content="删除" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnMethodDelete_Click"/>
                                                    <!--调试-->
                                                    <Button x:Name="btnMethodDebug" Content="调试" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnMethodDebug_Click"/>
                                                    <!--参数-->
                                                    <Button x:Name="btnMethodParamter" Content="参数" Width="45" Height="25" Style="{DynamicResource LinkButton}"
                                                            Tag="{Binding Id}" Foreground="{DynamicResource blueBrush}" Click="btnMethodParamter_Click"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                </DataGrid.Columns>
                            </DataGrid>
                        </ScrollViewer>
                        
                    </Grid>
                </Border>
            </Grid>
        </Border>
    </Grid>
</UserControl>