<!--
SearchResult.xaml
12/4/2023

RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.

THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S. GOVERNMENT

UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.

WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE
EXPORT OR DISCLOSURE TO NON-U.S. PERSONS, WHEREVER LOCATED, IS RESTRICTED
BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R. SECTION
120-130) OR THE EXPORT ADMINISTRATION REGULATIONS (EAR) (15 C.F.R. SECTION
730-774). THIS DOCUMENT CANNOT BE EXPORTED (E.G., PROVIDED TO A SUPPLIER
OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S. PERSON, WHEREVER
LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS
BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S. GOVERNMENT
APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL
PENALTIES.

DOD 5220.22-M, INDUSTRIAL SECURITY MANUAL, CHAPTER 5, SECTION 1 THROUGH 9 :
FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN OR DOD 5200.1-R,
INFORMATION SECURITY PROGRAM, CHAPTER 6. FOR UNCLASSIFIED, LIMITED DOCUMENTS
DESTROY BY ANY  METHOD THAT WILL PREVENT DISCLOSURE OF CONTENTS OR
RECONSTRUCTION OF THE DOCUMENT.
POC: Alex Kravchenko (1118268)
-->
<mah:MetroWindow x:Class="Raytheon.LogDashboard.View.SearchResult"
        xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
        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"
        DataContext="{Binding SearchResult, Source={StaticResource LogDashLocator}}"
        mc:Ignorable="d"
        Title="Log Dashboard Search Result" 
        Height="600" 
        Width="1024">

    <mah:MetroWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Styles/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </mah:MetroWindow.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.65*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="0.35*"/>
        </Grid.RowDefinitions>
        <ListView x:Name="FoundResultListView"  ItemsSource="{Binding Path=SearchResult, IsAsync=True}"
                  ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" SelectedValue="{Binding Path=SelectedLog}"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled" VirtualizingStackPanel.IsVirtualizing="True" 
                  VirtualizingStackPanel.VirtualizationMode="Recycling" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler" >
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Level" Width="Auto" 
                                    CellTemplate="{StaticResource LogLevelImagesDataTemplate}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Time" Width="Auto" 
                                    DisplayMemberBinding="{Binding Time, StringFormat={}{0:MM/dd/yyyy HH:mm:ss.fff}}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Thread" 
                                    Width="Auto" 
                                    DisplayMemberBinding="{Binding Thread}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="IP" 
                                    Width="115" 
                                    DisplayMemberBinding="{Binding Address}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Logger" 
                                    Width="120" 
                                    DisplayMemberBinding="{Binding Logger, Converter={StaticResource LoggerDisplayConverter}}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Message" 
                                    Width="1500" 
                                    CellTemplate="{StaticResource LogMessageDataTemplate}" 
                                    HeaderContainerStyle="{StaticResource SearchGridViewColumnHeaderStyle}"/>
                </GridView>
            </ListView.View>
            <ListView.ContextMenu>
                <ContextMenu Style="{StaticResource BaseContextMenu}">
                    <MenuItem Header="Go to this log message" ToolTip="Go to this log message in main Log Viewer window" Margin="0" Click="ShowMessageInMainWindowClick"/>
                </ContextMenu>
            </ListView.ContextMenu>
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <EventSetter Event="MouseDoubleClick" Handler="ListViewItem_MouseDoubleClick"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Level}" Value="Warn">
                            <Setter Property="Foreground" Value="Orange"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Level}" Value="Error">
                            <Setter Property="Foreground" Value="Red"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Level}" Value="Fatal">
                            <Setter Property="Foreground" Value="DarkRed"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Level}" Value="Info">
                            <Setter Property="Foreground" Value="Green"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Level}" Value="Debug">
                            <Setter Property="Foreground" Value="Black"></Setter>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Level}" Value="Trace">
                            <Setter Property="Foreground" Value="Gray"></Setter>
                        </DataTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" Value="0.5"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <GridSplitter Grid.Column="0" Height="3" Grid.Row="1" ResizeDirection="Rows" Background="Gray"
                      HorizontalAlignment="Stretch"/>

        <GroupBox Grid.Row="2" Padding="0,5">
            <GroupBox.HeaderTemplate>
                <DataTemplate>
                    <Grid Height="25" Margin="10,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="Message Details" FontSize="16" Foreground="LightGray"/>
                        <TextBlock Grid.Column="1" Text="Fount Logs:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,5,0" Foreground="LightGray"/>
                        <TextBlock Grid.Column="2" Text="{Binding Path=DataContext.SearchResult.Count, RelativeSource={RelativeSource AncestorType=mah:MetroWindow}}" 
                                   HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0" Foreground="LightGray"/>
                    </Grid>
                </DataTemplate>
            </GroupBox.HeaderTemplate>

            <Grid Margin="10">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="60"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="{Binding Message, StringFormat={}{0}:}" FontSize="14"  VerticalAlignment="Top" Margin="0,5,0,0"/>
                <Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Bottom" ToolTip="Copy" Command="{Binding Path=CopyMessageCommand}" Margin="0,5">
                    <Image Source="{StaticResource CopyDrawingImage}"/>
                </Button>
                <TextBox x:Name="LoggerTextBox" 
                         Grid.Row="0" 
                         Text="{Binding Path=SelectedLog.Message}" 
                         FontSize="14" Grid.Column="1" 
                         VerticalAlignment="Stretch" 
                         TextWrapping="Wrap" Margin="10,0"
                         BorderThickness="1" 
                         VerticalContentAlignment="Top" 
                         HorizontalAlignment="Stretch" Padding="5,0" Height="Auto" IsReadOnly="True" VerticalScrollBarVisibility="Auto"/>


                <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="20,10,10,10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <TextBlock Text="{Binding Logger, StringFormat={}{0}:}" FontSize="14"  VerticalAlignment="Center"/>
                    <TextBox Text="{Binding Path=SelectedLog.Logger}" FontSize="14" Grid.Column="1" Height="35" Margin="23,0,10,0"
                             BorderThickness="1" VerticalContentAlignment="Center" HorizontalAlignment="Stretch" Padding="5,0" IsReadOnly="True"/>

                    <TextBlock Grid.Column="2" Text="{Binding Time, StringFormat={}{0}:}" FontSize="14"  VerticalAlignment="Center" HorizontalAlignment="Left"/>
                    <TextBox Text="{Binding Path=SelectedLog.Time, StringFormat={}{0:MM/dd/yyyy HH:mm:ss.fff}}" FontSize="14" Grid.Column="3" Height="35" Margin="10,0" Width="180"
                             BorderThickness="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="5,0" IsReadOnly="True"/>

                    <TextBlock Grid.Column="4" Text="{Binding Thread, StringFormat={}{0}:}" FontSize="14"  VerticalAlignment="Center" HorizontalAlignment="Right"/>
                    <TextBox Text="{Binding Path=SelectedLog.Thread}" FontSize="14" Grid.Column="5" Height="35" Margin="10,0" Width="80"
                             BorderThickness="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" Padding="5,0" IsReadOnly="True"/>

                    <TextBlock Grid.Column="6" Text="{Binding Port, StringFormat={}{0}:}" FontSize="14"  VerticalAlignment="Center" HorizontalAlignment="Right"/>
                    <TextBox Text="{Binding Path=SelectedLog.Port}" FontSize="14" Grid.Column="7" Height="35" Margin="10,0,0,0" Width="80"
                             BorderThickness="1" VerticalContentAlignment="Center" HorizontalAlignment="Right" Padding="5,0" IsReadOnly="True"/>
                </Grid>
            </Grid>
        </GroupBox>
    </Grid>
</mah:MetroWindow>

