LogView.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <UserControl
  2. x:Class="ShakerManger.View.LogView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:hc="https://handyorg.github.io/handycontrol"
  7. xmlns:local="clr-namespace:ShakerManger.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:model="clr-namespace:Shaker.Model;assembly=Shaker"
  10. xmlns:system="clr-namespace:System;assembly=mscorlib"
  11. xmlns:vm="clr-namespace:ShakerManger.ViewModel"
  12. d:DataContext="{d:DesignInstance {x:Type vm:LogMangerViewModel}}"
  13. d:DesignHeight="450"
  14. d:DesignWidth="800"
  15. DataContext="{Binding Source={StaticResource MainViewModel}, Path=Data.LogManger}"
  16. Foreground="{StaticResource LableBrush}"
  17. mc:Ignorable="d">
  18. <UserControl.Resources>
  19. <system:Double x:Key="fontsize">14</system:Double>
  20. </UserControl.Resources>
  21. <Grid>
  22. <Grid.RowDefinitions>
  23. <RowDefinition Height="66" />
  24. <RowDefinition Height="*" />
  25. </Grid.RowDefinitions>
  26. <UniformGrid Rows="1">
  27. <StackPanel Orientation="Horizontal">
  28. <TextBlock
  29. VerticalAlignment="Center"
  30. FontSize="{StaticResource fontsize}"
  31. Text="开始时间" />
  32. <hc:DateTimePicker
  33. Width="220"
  34. Height="46"
  35. Margin="10,0,0,0"
  36. Background="Transparent"
  37. DateTimeFormat="yyyy/MM/dd HH:mm:ss"
  38. FontSize="{StaticResource fontsize}"
  39. SelectedDateTime="{Binding StartTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  40. </StackPanel>
  41. <StackPanel Orientation="Horizontal">
  42. <TextBlock
  43. VerticalAlignment="Center"
  44. FontSize="{StaticResource fontsize}"
  45. Text="截至时间" />
  46. <hc:DateTimePicker
  47. Width="220"
  48. Height="46"
  49. Margin="10,0,0,0"
  50. Background="Transparent"
  51. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  52. DateTimeFormat="yyyy/MM/dd HH:mm:ss"
  53. FontSize="{StaticResource fontsize}"
  54. SelectedDateTime="{Binding EndTime, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  55. </StackPanel>
  56. <StackPanel Orientation="Horizontal">
  57. <TextBlock
  58. VerticalAlignment="Center"
  59. FontSize="{StaticResource fontsize}"
  60. Text="振动台" />
  61. <ComboBox
  62. Width="220"
  63. Height="46"
  64. Margin="10,0,0,0"
  65. Background="Transparent"
  66. DisplayMemberPath="Key"
  67. FontSize="{StaticResource fontsize}"
  68. ItemsSource="{Binding Shakers}"
  69. SelectedValue="{Binding SelectedShaker}"
  70. SelectedValuePath="Value"
  71. Style="{StaticResource ComboBoxStyle1}" />
  72. </StackPanel>
  73. <StackPanel Orientation="Horizontal">
  74. <TextBlock
  75. VerticalAlignment="Center"
  76. FontSize="{StaticResource fontsize}"
  77. Text="日志类型" />
  78. <ComboBox
  79. Width="220"
  80. Height="46"
  81. Margin="10,0,0,0"
  82. Background="Transparent"
  83. DisplayMemberPath="Description"
  84. FontSize="{StaticResource fontsize}"
  85. ItemsSource="{Binding LogType, Converter={StaticResource EnumToCollectionConverter}, Mode=OneTime}"
  86. SelectedValue="{Binding LogType}"
  87. SelectedValuePath="Value"
  88. Style="{StaticResource ComboBoxStyle1}" />
  89. </StackPanel>
  90. <StackPanel Orientation="Horizontal">
  91. <TextBlock
  92. VerticalAlignment="Center"
  93. FontSize="{StaticResource fontsize}"
  94. Text="关键字" />
  95. <hc:TextBox
  96. Width="220"
  97. Height="46"
  98. Margin="10,0,0,0"
  99. hc:InfoElement.Placeholder="输入关键字"
  100. Background="Transparent"
  101. CaretBrush="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Foreground}"
  102. FontSize="{StaticResource fontsize}"
  103. Text="{Binding Keyword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  104. <Button
  105. Margin="20,0,0,0"
  106. hc:IconElement.Geometry="{StaticResource SearchGeometry}"
  107. Command="{Binding SearchCommand}"
  108. IsEnabled="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=IsAnonymous, Converter={StaticResource Boolean2BooleanReConverter}}"
  109. Style="{StaticResource ImageButton}" />
  110. </StackPanel>
  111. </UniformGrid>
  112. <Border
  113. Grid.Row="1"
  114. Margin="10"
  115. BorderBrush="{StaticResource AuxiliaryBrush}"
  116. BorderThickness="1">
  117. <ListView
  118. FontSize="14"
  119. Foreground="{StaticResource LableBrush}"
  120. ItemsSource="{Binding Logs}">
  121. <ListView.Style>
  122. <Style TargetType="ListView">
  123. <Setter Property="Background" Value="White" />
  124. <Setter Property="BorderBrush" Value="Transparent" />
  125. <Setter Property="Padding" Value="0" />
  126. <Setter Property="Template">
  127. <Setter.Value>
  128. <ControlTemplate TargetType="{x:Type ListView}">
  129. <Grid Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=ActualHeight}">
  130. <Grid.RowDefinitions>
  131. <RowDefinition Height="36" />
  132. <RowDefinition Height="*" />
  133. <RowDefinition Height="24" />
  134. </Grid.RowDefinitions>
  135. <Grid Background="{StaticResource EmbellishBrush}">
  136. <Grid.ColumnDefinitions>
  137. <ColumnDefinition Width="220" />
  138. <ColumnDefinition Width="100" />
  139. <ColumnDefinition Width="140" />
  140. <ColumnDefinition />
  141. </Grid.ColumnDefinitions>
  142. <Border BorderBrush="{StaticResource AuxiliaryBrush}" BorderThickness="0,0,1,1">
  143. <TextBlock
  144. HorizontalAlignment="Center"
  145. VerticalAlignment="Center"
  146. Foreground="{StaticResource MainBrush}"
  147. Text="记录时间" />
  148. </Border>
  149. <Border
  150. Grid.Column="2"
  151. BorderBrush="{StaticResource AuxiliaryBrush}"
  152. BorderThickness="0,0,1,1">
  153. <TextBlock
  154. HorizontalAlignment="Center"
  155. VerticalAlignment="Center"
  156. Foreground="{StaticResource MainBrush}"
  157. Text="振动台" />
  158. </Border>
  159. <Border
  160. Grid.Column="1"
  161. BorderBrush="{StaticResource AuxiliaryBrush}"
  162. BorderThickness="0,0,1,1">
  163. <TextBlock
  164. HorizontalAlignment="Center"
  165. Foreground="{StaticResource MainBrush}"
  166. VerticalAlignment="Center"
  167. Text="用户" />
  168. </Border>
  169. <Border
  170. Grid.Column="3"
  171. BorderBrush="{StaticResource AuxiliaryBrush}"
  172. BorderThickness="0,0,0,1">
  173. <TextBlock
  174. Foreground="{StaticResource MainBrush}"
  175. HorizontalAlignment="Center"
  176. VerticalAlignment="Center"
  177. Text="日志" />
  178. </Border>
  179. </Grid>
  180. <ScrollViewer
  181. Grid.Row="1"
  182. HorizontalScrollBarVisibility="Hidden"
  183. VerticalScrollBarVisibility="Auto">
  184. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  185. </ScrollViewer>
  186. <Border Grid.Row="2" Background="{StaticResource AuxiliaryBrush}">
  187. <TextBlock
  188. Grid.Row="2"
  189. Foreground="{StaticResource LableBrush}"
  190. Margin="10,0,0,0"
  191. VerticalAlignment="Center"
  192. Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=DataContext.Logs.Count, StringFormat=记录条数:{0}}" />
  193. </Border>
  194. </Grid>
  195. </ControlTemplate>
  196. </Setter.Value>
  197. </Setter>
  198. <Setter Property="ItemTemplate">
  199. <Setter.Value>
  200. <DataTemplate>
  201. <Grid>
  202. <Grid.ColumnDefinitions>
  203. <ColumnDefinition Width="220" />
  204. <ColumnDefinition Width="100" />
  205. <ColumnDefinition Width="140" />
  206. <ColumnDefinition />
  207. </Grid.ColumnDefinitions>
  208. <Border
  209. Grid.Column="0"
  210. BorderBrush="{StaticResource AuxiliaryBrush}"
  211. BorderThickness="0,0,1,1">
  212. <TextBlock
  213. HorizontalAlignment="Center"
  214. VerticalAlignment="Center"
  215. Text="{Binding DateTime, StringFormat=yyyy/MM/dd HH:mm:ss.fff}" />
  216. </Border>
  217. <Border
  218. Grid.Column="1"
  219. BorderBrush="{StaticResource AuxiliaryBrush}"
  220. BorderThickness="0,0,1,1">
  221. <TextBlock
  222. HorizontalAlignment="Center"
  223. VerticalAlignment="Center"
  224. Text="{Binding UserID}" />
  225. </Border>
  226. <Border
  227. Grid.Column="2"
  228. BorderBrush="{StaticResource AuxiliaryBrush}"
  229. BorderThickness="0,0,1,1">
  230. <TextBlock
  231. HorizontalAlignment="Center"
  232. VerticalAlignment="Center"
  233. Text="{Binding ShakerID}" />
  234. </Border>
  235. <Border
  236. Grid.Column="3"
  237. BorderBrush="{StaticResource AuxiliaryBrush}"
  238. BorderThickness="0,0,0,1">
  239. <TextBlock
  240. x:Name="text"
  241. Margin="20,0,0,0"
  242. VerticalAlignment="Center"
  243. Text="{Binding Message}" />
  244. </Border>
  245. </Grid>
  246. <DataTemplate.Triggers>
  247. <DataTrigger Binding="{Binding Level}" Value="{x:Static model:LogType.Message}">
  248. <Setter TargetName="text" Property="Foreground" Value="{StaticResource LableBrush}" />
  249. </DataTrigger>
  250. <DataTrigger Binding="{Binding Level}" Value="{x:Static model:LogType.Warn}">
  251. <Setter TargetName="text" Property="Foreground" Value="{StaticResource LableBrush}" />
  252. </DataTrigger>
  253. <DataTrigger Binding="{Binding Level}" Value="{x:Static model:LogType.Error}">
  254. <Setter TargetName="text" Property="Foreground" Value="Red" />
  255. </DataTrigger>
  256. </DataTemplate.Triggers>
  257. </DataTemplate>
  258. </Setter.Value>
  259. </Setter>
  260. <Setter Property="ItemContainerStyle">
  261. <Setter.Value>
  262. <Style TargetType="ListViewItem">
  263. <Setter Property="MinHeight" Value="32" />
  264. <Setter Property="Background" Value="Transparent" />
  265. <Setter Property="BorderBrush" Value="Transparent" />
  266. <Setter Property="BorderThickness" Value="0" />
  267. <Setter Property="SnapsToDevicePixels" Value="True" />
  268. <Setter Property="OverridesDefaultStyle" Value="True" />
  269. <Setter Property="Cursor" Value="Hand" />
  270. <Setter Property="IsEnabled" Value="False" />
  271. <Setter Property="Template">
  272. <Setter.Value>
  273. <ControlTemplate TargetType="ListViewItem">
  274. <ContentPresenter />
  275. </ControlTemplate>
  276. </Setter.Value>
  277. </Setter>
  278. </Style>
  279. </Setter.Value>
  280. </Setter>
  281. </Style>
  282. </ListView.Style>
  283. </ListView>
  284. </Border>
  285. </Grid>
  286. </UserControl>