Console.xaml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <wpf:ThemableWindow x:Class="PRSDesktop.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:PRSDesktop"
  7. xmlns:wpf="clr-namespace:InABox.Wpf;assembly=InABox.Wpf"
  8. mc:Ignorable="d"
  9. Title="Console" Height="450" Width="800" Loaded="Window_Loaded" Closing="Window_Closing">
  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. </Grid.RowDefinitions>
  86. <DockPanel Grid.Row="0" Margin="5,5,5,0">
  87. <Label Content="Search" VerticalContentAlignment="Center" />
  88. <TextBox x:Name="Search" Margin="5,0,0,0" DockPanel.Dock="Left" Background="LightYellow"
  89. VerticalContentAlignment="Center" TextChanged="Search_TextChanged" />
  90. </DockPanel>
  91. <Border BorderBrush="Gray" Grid.Row="1" BorderThickness="0.75" Margin="5" Padding="2" Background="LightYellow">
  92. <ItemsControl x:Name="Log" ItemsSource="{Binding}" Style="{StaticResource LogViewerStyle}" />
  93. </Border>
  94. </Grid>
  95. </wpf:ThemableWindow>