Console.xaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <wpf:ThemableWindow x:Class="PRSServer.Console"
  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. xmlns:local="clr-namespace:PRSServer"
  7. xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
  8. mc:Ignorable="d"
  9. Title="Console" Height="800" Width="1200" Closing="Window_Closing" Loaded="Console_Loaded">
  10. <Window.Resources>
  11. <Style TargetType="ItemsControl" x:Key="LogViewerStyle">
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate>
  15. <ScrollViewer CanContentScroll="True">
  16. <ItemsPresenter />
  17. </ScrollViewer>
  18. </ControlTemplate>
  19. </Setter.Value>
  20. </Setter>
  21. <Setter Property="ItemsPanel">
  22. <Setter.Value>
  23. <ItemsPanelTemplate>
  24. <VirtualizingStackPanel IsItemsHost="True" />
  25. </ItemsPanelTemplate>
  26. </Setter.Value>
  27. </Setter>
  28. </Style>
  29. <DataTemplate DataType="{x:Type local:LogEntry}">
  30. <Grid IsSharedSizeScope="True">
  31. <Grid.ColumnDefinitions>
  32. <ColumnDefinition SharedSizeGroup="Date" Width="120" />
  33. <ColumnDefinition SharedSizeGroup="Type" Width="60" />
  34. <ColumnDefinition SharedSizeGroup="User" Width="120" />
  35. <ColumnDefinition />
  36. </Grid.ColumnDefinitions>
  37. <TextBlock Text="{Binding DateTime}" Grid.Column="0" FontFamily="Courier New"
  38. Margin="5,0,5,0" />
  39. <TextBlock Text="{Binding Type}" Grid.Column="1" FontFamily="Courier New"
  40. Margin="5,0,5,0" />
  41. <TextBlock Text="{Binding User}" Grid.Column="2" FontFamily="Courier New"
  42. Margin="0,0,2,0" />
  43. <TextBlock Text="{Binding Message}" Grid.Column="3" FontFamily="Courier New"
  44. TextWrapping="Wrap" />
  45. </Grid>
  46. </DataTemplate>
  47. <DataTemplate DataType="{x:Type local:CollapsibleLogEntry}">
  48. <Grid IsSharedSizeScope="True">
  49. <Grid.ColumnDefinitions>
  50. <ColumnDefinition SharedSizeGroup="Date" Width="120" />
  51. <ColumnDefinition SharedSizeGroup="Type" Width="60" />
  52. <ColumnDefinition SharedSizeGroup="User" Width="120" />
  53. <ColumnDefinition />
  54. </Grid.ColumnDefinitions>
  55. <Grid.RowDefinitions>
  56. <RowDefinition Height="Auto" />
  57. <RowDefinition />
  58. </Grid.RowDefinitions>
  59. <TextBlock Text="{Binding DateTime}" Grid.Column="0" FontFamily="Courier New"
  60. Margin="5,0,5,0" />
  61. <TextBlock Text="{Binding Type}" Grid.Column="1" FontFamily="Courier New"
  62. Margin="5,0,5,0" />
  63. <TextBlock Text="{Binding User}" Grid.Column="2" FontFamily="Courier New"
  64. Margin="0,0,2,0" />
  65. <TextBlock Text="{Binding Message}" Grid.Column="3" FontFamily="Courier New"
  66. TextWrapping="Wrap" />
  67. <ToggleButton x:Name="Expander" Grid.Row="1" Grid.Column="0"
  68. VerticalAlignment="Top" Content="+" HorizontalAlignment="Right" />
  69. <ItemsControl ItemsSource="{Binding Contents}" Style="{StaticResource LogViewerStyle}"
  70. Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
  71. x:Name="Contents" Visibility="Collapsed" />
  72. </Grid>
  73. <DataTemplate.Triggers>
  74. <Trigger SourceName="Expander" Property="IsChecked" Value="True">
  75. <Setter TargetName="Contents" Property="Visibility" Value="Visible" />
  76. <Setter TargetName="Expander" Property="Content" Value="-" />
  77. </Trigger>
  78. </DataTemplate.Triggers>
  79. </DataTemplate>
  80. </Window.Resources>
  81. <Grid>
  82. <Grid.RowDefinitions>
  83. <RowDefinition Height="Auto" />
  84. <RowDefinition Height="*" />
  85. <RowDefinition Height="Auto" />
  86. </Grid.RowDefinitions>
  87. <Grid>
  88. <Grid.RowDefinitions>
  89. <RowDefinition Height="Auto" />
  90. </Grid.RowDefinitions>
  91. <Grid.ColumnDefinitions>
  92. <ColumnDefinition Width="Auto" />
  93. <ColumnDefinition />
  94. <ColumnDefinition Width="Auto" />
  95. <ColumnDefinition Width="Auto" />
  96. <ColumnDefinition Width="Auto" />
  97. </Grid.ColumnDefinitions>
  98. <Label Content="Search" VerticalContentAlignment="Center" HorizontalAlignment="Left" />
  99. <TextBox x:Name="Search" Margin="5,0,0,0" DockPanel.Dock="Right" Background="LightYellow"
  100. VerticalContentAlignment="Center" PreviewKeyDown="Search_KeyDown" TextChanged="Search_TextChanged"
  101. HorizontalAlignment="Stretch" Grid.Column="1" />
  102. <CheckBox x:Name="UseRegEx" Content="Use Regular Expressions" HorizontalAlignment="Right"
  103. VerticalAlignment="Center" Visibility="Visible" Margin="5,0,5,0" Grid.Column="2"
  104. Checked="UseRegEx_Checked" Unchecked="UseRegEx_Unchecked" />
  105. <CheckBox x:Name="ShowImportant" Content="Show only Important" HorizontalAlignment="Right"
  106. VerticalAlignment="Center" Visibility="Visible" Margin="5,0,5,0" Grid.Column="3"
  107. Checked="ShowImportant_Checked" Unchecked="ShowImportant_Unchecked"/>
  108. <Button x:Name="LoadLog" Grid.Column="4" Content="Load Log File" Padding="4,1,4,1" Margin="5,5,5,5"
  109. Click="LoadLog_Click" />
  110. <Button x:Name="CloseLog" Grid.Column="4" Content="Close Log File" Padding="4,1,4,1" Margin="5,5,5,5"
  111. Click="CloseLog_Click" Visibility="Collapsed" />
  112. </Grid>
  113. <Border x:Name="LogBorder" BorderBrush="Gray" Grid.Row="1" BorderThickness="0.75" Margin="5" Padding="2" Background="WhiteSmoke">
  114. <ItemsControl x:Name="Log" ItemsSource="{Binding}" Style="{StaticResource LogViewerStyle}">
  115. <ItemsControl.Template>
  116. <ControlTemplate>
  117. <ScrollViewer CanContentScroll="True">
  118. <ItemsPresenter />
  119. </ScrollViewer>
  120. </ControlTemplate>
  121. </ItemsControl.Template>
  122. </ItemsControl>
  123. </Border>
  124. <Label x:Name="Error" Content="" Grid.Row="2" HorizontalAlignment="Right" Visibility="Collapsed" />
  125. </Grid>
  126. </wpf:ThemableWindow>