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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
<mahapps:MetroWindow x:Class="Tango.LogViewer.UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:Tango.LogViewer.UI"
xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
mc:Ignorable="d"
Title="Tango Log Viewer" WindowState="Maximized" ShowTitleBar="True" ShowCloseButton="True" DataContext="{StaticResource MainViewVM}" AllowDrop="True" Drop="FileWindow_Drop" Foreground="Gainsboro">
<Window.Resources>
<converters:EnumToDescriptionConverter x:Key="EnumToDescriptionConverter"></converters:EnumToDescriptionConverter>
<converters:BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter"/>
<converters:BooleanInverseConverter x:Key="BooleanInverseConverter" />
<SolidColorBrush x:Key="GrayBrush5" Color="#464646"/>
<SolidColorBrush x:Key="BorderGrayBrush" Color="#464646"/>
<SolidColorBrush x:Key="SelectedItemBrush" Color="#007ACC"/>
<Style x:Key="LogDataGridCellStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.VerticalAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Bottom" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsFocused" Value="False" />
<Condition Property="DataGridCell.IsSelected" Value="True" />
</MultiTrigger.Conditions>
<MultiTrigger.Setters>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
</MultiTrigger.Setters>
</MultiTrigger>
</Style.Triggers>
</Style>
<Style x:Key="LogDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
<Setter Property="Cursor" Value="Hand"></Setter>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
<Setter Property="Background" Value="#3F3F49"></Setter>
<Setter Property="Foreground" Value="Gainsboro" />
<Setter Property="FontWeight" Value="SemiBold"></Setter>
<Setter Property="Cursor" Value="Arrow"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding LogObject}" Value="External Bridge">
<Setter Property="Foreground" Value="#28A805" />
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="EmLogDataGridRowStyle" TargetType="DataGridRow" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
<Setter Property="Cursor" Value="Hand"></Setter>
</Trigger>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}" />
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<DataTrigger Binding="{Binding LogObject}" Value="External Bridge">
<Setter Property="Foreground" Value="#28A805" />
</DataTrigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="LogIconStyle">
<fa:ImageAwesome Height="16" Width="14" Margin="0 0 0 0" VerticalAlignment="Top">
<fa:ImageAwesome.Style>
<Style TargetType="fa:ImageAwesome">
<Setter Property="Icon" Value="ExclamationTriangle"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Category}" Value="Info">
<Setter Property="Icon" Value="InfoCircle"></Setter>
<Setter Property="Foreground" Value="Gainsboro"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Warning">
<Setter Property="Icon" Value="ExclamationTriangle"></Setter>
<Setter Property="Foreground" Value="DarkOrange"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Error">
<Setter Property="Icon" Value="ExclamationTriangle"></Setter>
<Setter Property="Foreground" Value="Red"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Critical">
<Setter Property="Icon" Value="Bell"></Setter>
<Setter Property="Foreground" Value="Red"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Category}" Value="Debug">
<Setter Property="Icon" Value="Bug"></Setter>
<Setter Property="Foreground" Value="Gray"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding CallerMethodName}" Value="OnStartup">
<Setter Property="Icon" Value="ClockOutline"></Setter>
<Setter Property="Foreground" Value="{StaticResource SelectedItemBrush}"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</fa:ImageAwesome.Style>
</fa:ImageAwesome>
</DataTemplate>
<Style x:Key="DataGridTextColumnElementStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="5" />
<Setter Property="Padding" Value="5" />
</Style>
</Window.Resources>
<Grid IsEnabled="{Binding Loading,Converter={StaticResource BooleanInverseConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="28"/>
<RowDefinition Height="5"/>
</Grid.RowDefinitions>
<Menu Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="10,0,0,0" BorderBrush="Transparent" Background="Transparent">
<MenuItem Header="File" Background="Transparent">
<MenuItem Header="Open" Command="{Binding OpeFileLogCommand}"/>
<MenuItem Header="Exit" Click="Exit_MenuItem_Click" />
</MenuItem>
</Menu>
<Grid Grid.Row="1" Margin="0 20 0 20">
<DockPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="10 0 0 0">
<TextBlock FontSize="10">Start Time:</TextBlock>
<Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" CornerRadius="5" >
<mahapps:TimePicker x:Name="startTimePicker" SelectedTime="{Binding StartSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="{Binding Culture}" BorderBrush="{StaticResource BorderGrayBrush}" BorderThickness="0" Margin="1" Foreground="Gainsboro" />
</Border>
</StackPanel>
<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Margin="20 0 0 0">
<TextBlock FontSize="10">End Time:</TextBlock>
<Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" CornerRadius="5" >
<mahapps:TimePicker x:Name="enddatePicker" SelectedTime="{Binding EndSelectedTime}" Width="160" VerticalAlignment="Center" FontSize="16" IsClockVisible="False" Culture="{Binding Culture}" PickerVisibility="HourMinute" BorderBrush="{StaticResource BorderGrayBrush}" BorderThickness="0" Margin="1" Foreground="Gainsboro"/>
</Border>
</StackPanel>
<Border BorderThickness="1" BorderBrush="{StaticResource BorderGrayBrush}" VerticalAlignment="Center" Padding="10 7" CornerRadius="5" Margin="30 10 0 0">
<StackPanel>
<ItemsControl VerticalAlignment="Center" ItemsSource="{Binding SelectedLogCategories}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="10 0 0 0">
<CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" BorderBrush="{StaticResource BorderGrayBrush}"></CheckBox>
<TextBlock Text="{Binding Data}" Margin="5 0 0 0" VerticalAlignment="Center"></TextBlock>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20 10 30 0">
<fa:ImageAwesome Icon="Search" Width="24" Height="24" Foreground="#7A7A7A"/>
<TextBox VerticalAlignment="Center" Margin="10 0 0 0" Width="300" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged, Delay=1000}" />
</StackPanel>
</DockPanel>
</Grid>
<Grid Grid.Row="2" >
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock FontSize="14" Grid.Row="0" FontFamily="Segoe UI">Log</TextBlock>
<StackPanel Orientation="Horizontal" Margin="0" Grid.Row="0" Grid.Column="2">
<TextBlock FontSize="14" Margin="10 0 0 0" FontFamily="Segoe UI">Message</TextBlock>
<CheckBox x:Name="WrapMessgeTextCheckBox" VerticalAlignment="Center" BorderBrush="{StaticResource BorderGrayBrush}" Margin="30 -5 0 0"></CheckBox>
<TextBlock Text="Wrap message text" Margin="5 -5 0 0" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BooleanToVisibilityInverseConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}" Margin="0 0 10 0">
<DataGrid x:Name="ActionGrid" HorizontalScrollBarVisibility="Disabled" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding LogsViewSource}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"
CellStyle="{StaticResource LogDataGridCellStyle}" RowStyle="{StaticResource LogDataGridRowStyle}" Foreground="Gainsboro">
<DataGrid.Resources>
<Style BasedOn="{StaticResource MetroDataGridColumnHeader}" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="Gainsboro" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn Header="" CellTemplate="{StaticResource LogIconStyle}"/>
<DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat=' HH:mm:ss.ff '}" Foreground="Gainsboro"/>
<DataGridTextColumn Header="FILE" Binding="{Binding RelativeCallerFile}" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
<DataGridTextColumn Header="METHOD" Binding="{Binding CallerMethodName}" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
<DataGridTextColumn Header="LINE" Binding="{Binding CallerLineNumber}" />
<DataGridTemplateColumn Header="MESSAGE" Width="1*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid VerticalAlignment="Center" Margin="0 5 0 5">
<Border Height="Auto" BorderThickness="0" >
<TextBlock Text="{Binding Message}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" ></TextBlock>
</Border>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
<StackPanel Orientation="Vertical" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding Loading,Converter={StaticResource BoolToVisibilityConverter}}">
<mahapps:ProgressRing Foreground="LightGray" Width="80" Height="80"></mahapps:ProgressRing>
<TextBlock Text="Loading..." FontStyle="Italic" Margin="0 40 0 0" FontSize="18" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<Border Visibility="{Binding IsEmbeddedLog, Converter={StaticResource BoolToVisibilityConverter}}" Grid.Column="0" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}" Margin="0 0 10 0">
<DataGrid x:Name="embededGrid" HorizontalScrollBarVisibility="Disabled" Background="Transparent" RenderOptions.EdgeMode="Aliased" RenderOptions.BitmapScalingMode="LowQuality" MaxWidth="{Binding RelativeSource={RelativeSource AncestorType=Grid},Path=ActualWidth}" AutoGenerateColumns="False" SelectionMode="Single" ItemsSource="{Binding LogsViewSource}" SelectedItem="{Binding SelectedLog}" RowHeight="40" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="True" IsReadOnly="True"
CellStyle="{StaticResource LogDataGridCellStyle}" RowStyle="{StaticResource EmLogDataGridRowStyle}" Foreground="Gainsboro">
<DataGrid.Resources>
<Style BasedOn="{StaticResource MetroDataGridColumnHeader}" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="Gainsboro" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTemplateColumn Header="ICON" CellTemplate="{StaticResource LogIconStyle}"/>
<DataGridTextColumn Header="DATE TIME" Binding="{Binding TimeStamp,StringFormat=' HH:mm:ss.ff '}" Foreground="Gainsboro"/>
<DataGridTextColumn Header="FILE" Binding="{Binding DebugLogResponse.FileName}" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
<DataGridTextColumn Header="LINE" Binding="{Binding DebugLogResponse.LineNumber}" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
<DataGridTextColumn Header="MODULE" Binding="{Binding DebugLogResponse.ModuleId}" ElementStyle="{StaticResource DataGridTextColumnElementStyle}"/>
<DataGridTextColumn Header="FILTER" Binding="{Binding DebugLogResponse.Filter}" />
<DataGridTemplateColumn Header="MESSAGE" Width="1*" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid VerticalAlignment="Center" Margin="0 5 0 5">
<Border Height="Auto" BorderThickness="0" >
<TextBlock Text="{Binding MessagePlusRepeated}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" ></TextBlock>
</Border>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Border>
<Border Margin="10 0 0 0" Grid.Column="2" Grid.Row="1" BorderThickness="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{StaticResource BorderGrayBrush}">
<TextBox BorderThickness="0" Text="{Binding Message}" IsReadOnly="True" AcceptsReturn="False" VerticalScrollBarVisibility="Auto" Foreground="Gainsboro">
<TextBox.Style>
<Style TargetType="TextBox" BasedOn="{StaticResource MetroTextBox}">
<Setter Property="TextWrapping" Value="NoWrap"></Setter>
<Setter Property="HorizontalScrollBarVisibility" Value="Auto"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=WrapMessgeTextCheckBox, Path=IsChecked}" Value="True">
<Setter Property="TextWrapping" Value="Wrap"></Setter>
<Setter Property="HorizontalScrollBarVisibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Border>
<GridSplitter Grid.Column="1" Grid.Row="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext" HorizontalAlignment="Center" VerticalAlignment="Stretch" Width="4" Background="{StaticResource BorderGrayBrush}"/>
</Grid>
</Grid>
<StatusBar Grid.Row="3" Grid.ColumnSpan="2" Background="Transparent">
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="1">
<TextBlock Text="{Binding FileName}"></TextBlock>
</StatusBarItem>
<Separator Grid.Column="2" Visibility="{Binding IsSet, Converter={StaticResource BoolToVisibilityConverter}}"/>
<StatusBarItem Grid.Column="3" Visibility="{Binding IsSet, Converter={StaticResource BoolToVisibilityConverter}}">
<TextBlock>
<Run Text="Set: "></Run>
<Run Text="{Binding CountOfSet}"></Run>
</TextBlock>
</StatusBarItem>
</StatusBar>
</Grid>
</mahapps:MetroWindow>
|