MainWindow.xaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <Window x:Class="NetworkTool.Client.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. mc:Ignorable="d"
  7. Title="NetworkTool"
  8. Height="680"
  9. Width="860"
  10. MinHeight="640"
  11. MinWidth="760"
  12. WindowStartupLocation="CenterScreen">
  13. <Window.Resources>
  14. <Style x:Key="DiscoveryListViewStyle" TargetType="ListView">
  15. <Setter Property="Background" Value="White" />
  16. <Setter Property="BorderBrush" Value="#E5E7EB" />
  17. <Setter Property="BorderThickness" Value="1" />
  18. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  19. <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
  20. <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
  21. </Style>
  22. <Style x:Key="DiscoveryColumnHeaderStyle" TargetType="GridViewColumnHeader">
  23. <Setter Property="Height" Value="36" />
  24. <Setter Property="Padding" Value="12,0" />
  25. <Setter Property="HorizontalContentAlignment" Value="Center" />
  26. <Setter Property="VerticalContentAlignment" Value="Center" />
  27. <Setter Property="Background" Value="#F3F4F6" />
  28. <Setter Property="Foreground" Value="#374151" />
  29. <Setter Property="FontWeight" Value="SemiBold" />
  30. <Setter Property="BorderBrush" Value="#E5E7EB" />
  31. <Setter Property="BorderThickness" Value="0,0,1,1" />
  32. </Style>
  33. <Style x:Key="DiscoveryListViewItemStyle" TargetType="ListViewItem">
  34. <Setter Property="Height" Value="36" />
  35. <Setter Property="Padding" Value="0" />
  36. <Setter Property="HorizontalContentAlignment" Value="Stretch" />
  37. <Setter Property="VerticalContentAlignment" Value="Center" />
  38. <Setter Property="Template">
  39. <Setter.Value>
  40. <ControlTemplate TargetType="ListViewItem">
  41. <Border x:Name="RowBorder"
  42. Background="Transparent"
  43. BorderBrush="#EEF2F7"
  44. BorderThickness="0,0,0,1"
  45. SnapsToDevicePixels="True">
  46. <GridViewRowPresenter Margin="0"
  47. VerticalAlignment="Center"
  48. Content="{TemplateBinding Content}"
  49. Columns="{Binding View.Columns, RelativeSource={RelativeSource AncestorType=ListView}}" />
  50. </Border>
  51. <ControlTemplate.Triggers>
  52. <Trigger Property="IsMouseOver" Value="True">
  53. <Setter TargetName="RowBorder" Property="Background" Value="#F9FAFB" />
  54. </Trigger>
  55. <Trigger Property="IsSelected" Value="True">
  56. <Setter TargetName="RowBorder" Property="Background" Value="#DBEAFE" />
  57. <Setter Property="Foreground" Value="#111827" />
  58. </Trigger>
  59. <MultiTrigger>
  60. <MultiTrigger.Conditions>
  61. <Condition Property="IsSelected" Value="True" />
  62. <Condition Property="Selector.IsSelectionActive" Value="False" />
  63. </MultiTrigger.Conditions>
  64. <Setter TargetName="RowBorder" Property="Background" Value="#DBEAFE" />
  65. <Setter Property="Foreground" Value="#111827" />
  66. </MultiTrigger>
  67. </ControlTemplate.Triggers>
  68. </ControlTemplate>
  69. </Setter.Value>
  70. </Setter>
  71. </Style>
  72. <Style x:Key="DiscoveryCellTextStyle" TargetType="TextBlock">
  73. <Setter Property="Padding" Value="8,0" />
  74. <Setter Property="VerticalAlignment" Value="Center" />
  75. <Setter Property="TextTrimming" Value="CharacterEllipsis" />
  76. </Style>
  77. </Window.Resources>
  78. <Grid Background="#F5F7FB">
  79. <Border Margin="24"
  80. Padding="24"
  81. Background="White"
  82. CornerRadius="12">
  83. <Grid>
  84. <Grid.RowDefinitions>
  85. <RowDefinition Height="Auto" />
  86. <RowDefinition Height="*" />
  87. </Grid.RowDefinitions>
  88. <TextBlock FontSize="20"
  89. FontWeight="SemiBold"
  90. Foreground="#111827"
  91. Text="设备发现与连接" />
  92. <Grid Grid.Row="1" Margin="0,20,0,0">
  93. <Grid.RowDefinitions>
  94. <RowDefinition Height="Auto" />
  95. <RowDefinition Height="*" />
  96. </Grid.RowDefinitions>
  97. <Border Padding="16" Background="#F9FAFB" CornerRadius="10">
  98. <StackPanel>
  99. <TextBlock FontSize="13" FontWeight="SemiBold" Foreground="#111827" Text="本机网卡" />
  100. <TextBlock Margin="0,12,0,0"
  101. FontSize="13"
  102. Foreground="#374151"
  103. Text="本机有线网卡" />
  104. <Grid Margin="0,8,0,0">
  105. <Grid.ColumnDefinitions>
  106. <ColumnDefinition Width="*" />
  107. <ColumnDefinition Width="Auto" />
  108. </Grid.ColumnDefinitions>
  109. <ComboBox x:Name="AdapterComboBox"
  110. MinHeight="36"
  111. VerticalContentAlignment="Center"
  112. SelectionChanged="AdapterComboBox_OnSelectionChanged">
  113. <ComboBox.ItemTemplate>
  114. <DataTemplate>
  115. <Grid>
  116. <Grid.ColumnDefinitions>
  117. <ColumnDefinition Width="Auto" />
  118. <ColumnDefinition Width="Auto" />
  119. </Grid.ColumnDefinitions>
  120. <TextBlock Grid.Column="0"
  121. Text="{Binding Name}"
  122. TextTrimming="CharacterEllipsis" />
  123. <TextBlock Grid.Column="1"
  124. Margin="12,0,0,0"
  125. Text="{Binding IPv4Display}" />
  126. </Grid>
  127. </DataTemplate>
  128. </ComboBox.ItemTemplate>
  129. </ComboBox>
  130. <Button x:Name="RefreshAdaptersButton"
  131. Grid.Column="1"
  132. Margin="8,0,0,0"
  133. MinHeight="36"
  134. Padding="14,0"
  135. Click="RefreshAdaptersButton_OnClick"
  136. Content="刷新" />
  137. </Grid>
  138. </StackPanel>
  139. </Border>
  140. <Border Grid.Row="1" Margin="0,16,0,0" Padding="16" Background="#F9FAFB" CornerRadius="10">
  141. <Grid>
  142. <Grid.RowDefinitions>
  143. <RowDefinition Height="Auto" />
  144. <RowDefinition Height="Auto" />
  145. <RowDefinition Height="*" />
  146. </Grid.RowDefinitions>
  147. <Grid>
  148. <Grid.ColumnDefinitions>
  149. <ColumnDefinition Width="*" />
  150. <ColumnDefinition Width="Auto" />
  151. </Grid.ColumnDefinitions>
  152. <TextBlock VerticalAlignment="Center"
  153. FontSize="13"
  154. FontWeight="SemiBold"
  155. Foreground="#111827"
  156. Text="发现设备(双击连接)" />
  157. <Button x:Name="SearchDevicesButton"
  158. Grid.Column="1"
  159. MinHeight="32"
  160. Padding="14,0"
  161. Click="SearchDevicesButton_OnClick"
  162. Content="重新搜索设备" />
  163. </Grid>
  164. <TextBlock x:Name="DiscoveryStateTextBlock"
  165. Grid.Row="1"
  166. Margin="0,10,0,0"
  167. Foreground="#4B5563"
  168. Text="选择网卡后会自动搜索设备。"
  169. TextWrapping="Wrap" />
  170. <ListView x:Name="DiscoveredDevicesListView"
  171. Grid.Row="2"
  172. Margin="0,12,0,0"
  173. MinHeight="220"
  174. Style="{StaticResource DiscoveryListViewStyle}"
  175. ItemContainerStyle="{StaticResource DiscoveryListViewItemStyle}"
  176. MouseDoubleClick="DiscoveredDevicesListView_OnMouseDoubleClick"
  177. SizeChanged="DiscoveredDevicesListView_OnSizeChanged">
  178. <ListView.View>
  179. <GridView ColumnHeaderContainerStyle="{StaticResource DiscoveryColumnHeaderStyle}">
  180. <GridViewColumn x:Name="DeviceIpColumn" Width="150" Header="IP">
  181. <GridViewColumn.CellTemplate>
  182. <DataTemplate>
  183. <TextBlock Style="{StaticResource DiscoveryCellTextStyle}" Text="{Binding Lan2Ip}" />
  184. </DataTemplate>
  185. </GridViewColumn.CellTemplate>
  186. </GridViewColumn>
  187. <GridViewColumn x:Name="DeviceHostnameColumn" Width="220" Header="主机名">
  188. <GridViewColumn.CellTemplate>
  189. <DataTemplate>
  190. <TextBlock Style="{StaticResource DiscoveryCellTextStyle}" Text="{Binding Hostname}" />
  191. </DataTemplate>
  192. </GridViewColumn.CellTemplate>
  193. </GridViewColumn>
  194. <GridViewColumn x:Name="DeviceMacColumn" Width="220" Header="MAC">
  195. <GridViewColumn.CellTemplate>
  196. <DataTemplate>
  197. <TextBlock Style="{StaticResource DiscoveryCellTextStyle}" Text="{Binding Mac}" />
  198. </DataTemplate>
  199. </GridViewColumn.CellTemplate>
  200. </GridViewColumn>
  201. </GridView>
  202. </ListView.View>
  203. </ListView>
  204. </Grid>
  205. </Border>
  206. </Grid>
  207. </Grid>
  208. </Border>
  209. <Border x:Name="StatusMessageBorder"
  210. Visibility="Collapsed"
  211. Panel.ZIndex="100"
  212. HorizontalAlignment="Center"
  213. VerticalAlignment="Top"
  214. Margin="24,16,24,0"
  215. MaxWidth="760"
  216. Padding="14,10"
  217. Background="#111827"
  218. CornerRadius="10">
  219. <TextBlock x:Name="StatusTextBlock"
  220. FontSize="13"
  221. Foreground="White"
  222. TextWrapping="Wrap"
  223. Text="" />
  224. </Border>
  225. </Grid>
  226. </Window>