<!--
LogDashboardCtrl.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:MetroContentControl x:Class="Raytheon.LogDashboard.View.LogDashboardCtrl"
      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 LogDashboard, Source={StaticResource LogDashLocator}}"
      mc:Ignorable="d" 
      Loaded="MetroContentControl_Loaded"                         
      >

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

    <mah:MetroContentControl.InputBindings>
        <KeyBinding Command="{Binding Path=SearchLogCommand}" CommandParameter="{StaticResource False}" Modifiers="Control" Key="F"/>
        <KeyBinding Command="{Binding Path=SearchLogCommand}" CommandParameter="{StaticResource True}" Modifiers="Control+Shift" Key="F"/>
        <KeyBinding Command="{Binding Path=FindNextCommand}" Modifiers="Control" Key="N"/>
        <KeyBinding Command="{Binding Path=FindPreviousCommand}" Modifiers="Control" Key="P"/>
        <KeyBinding Command="{Binding Path=ClearSearchResultCommand}" Modifiers="Control" Key="C"/>
        <KeyBinding Command="{Binding Path=ExportCommand}" Modifiers="Control" Key="S"/>
        <KeyBinding Command="{Binding Path=CleanCommand}" Modifiers="Control" Key="R"/>
        <KeyBinding Command="{Binding Path=GoToTimestampCommand}" Modifiers="Control" Key="T"/>
        <KeyBinding Command="{Binding Path=SetTimeIntervalCommand}" Modifiers="Control+Shift" Key="T"/>
    </mah:MetroContentControl.InputBindings>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.8*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition Height="0.85*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="225"/>
        </Grid.RowDefinitions>

        <Grid Grid.ColumnSpan="3" Margin="5">
            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="3" HorizontalAlignment="Left">
                <Button Style="{StaticResource ImportButtonStyleCircle}" Command="{Binding Path=ImportCommand}"/>
                <Button Style="{StaticResource ExportButtonStyleCircle}" Command="{Binding Path=ExportCommand}"/>
            </StackPanel>

            <StackPanel Orientation="Horizontal" Grid.ColumnSpan="3" HorizontalAlignment="Center">
                <Button Style="{StaticResource StartPauseNetworkReceiverButtonStyle}"/>
                <Button Style="{StaticResource StartPauseFileReceiverButtonStyle}" Visibility="{Binding Path=FileWatchers.Count, Converter={StaticResource CountToVisibilityConverter}}"/>
                <Button Style="{StaticResource ScrollToTop}" Click="OnScrollToTopButtonClick"/>
                <Button Style="{StaticResource AutoScrollToBottom}" Click="OnAutoScrollToBottomButtonClick" x:Name="AutoScrollButton"/>
                <Button Style="{StaticResource ScrollToBottom}" Click="OnScrollToBottomButtonClick"/>

                <Button Padding="2" HorizontalAlignment="Right"
                                    Style="{StaticResource CircleImageButtonStyle}"
                                    ToolTip="Clear / Reset All (Ctrl+R)" 
                                    Command="{Binding ElementName=LogsListView, Path=DataContext.CleanCommand}" 
                                    IsEnabled="{Binding ElementName=LogsListView, Path= DataContext.CleanIsEnabled}" 
                                    Margin="10,0">
                    <Image Source="{StaticResource CleanWhiteImage}"/>
                </Button>


            </StackPanel>

            <Button Style="{StaticResource SettingsButtonStyle}" Command="{Binding Path=OpenSettingsCommand}"/>
        </Grid>


        <Separator Grid.Row="0" Grid.ColumnSpan="3" Grid.Column="0" VerticalAlignment="Bottom" Margin="0"/>

        <Grid Grid.Row="1" Grid.Column="2" Grid.RowSpan="3">
            <Button Style="{StaticResource TreeButtonStyle}" Command="{Binding Path=OpenTreeCommand}" />
        </Grid>

        <GridSplitter Grid.Column="1" Width="2" Grid.Row="1" Grid.RowSpan="3" 
                      ResizeBehavior="PreviousAndNext"
                      ResizeDirection="Columns" 
                      Background="Gray"
                      VerticalAlignment="Stretch" 
                      HorizontalAlignment="Center"/>

        <GridSplitter Grid.Column="0" Grid.ColumnSpan="2" Height="3" Grid.Row="2" 
                      ResizeBehavior="PreviousAndNext"
                      ResizeDirection="Rows" 
                      Background="Gray"
                      HorizontalAlignment="Stretch"/>

        <ListView Grid.Column="0" Grid.Row="1" 
                  ItemsSource="{Binding Path=Logs, IsAsync=True}" 
                  SelectedValue="{Binding Path=SelectedLog}" 
                  x:Name="LogsListView" 
                  ScrollViewer.CanContentScroll="True" 
                  ScrollViewer.VerticalScrollBarVisibility="Auto" 
                  DragOver="LogsListView_OnDragOver" 
                  Drop="LogsListView_OnDrop" 
                  AllowDrop="True"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                  ScrollViewer.ScrollChanged="LogsListView_OnScrollChanged" 
                  ItemContainerStyle="{StaticResource LogItemStyle}" 
                  SelectionChanged="OnSelectionChanged" 
                  VirtualizingStackPanel.IsVirtualizing="True" 
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                  IsEnabled="{Binding Path=IsEnableLogList}" 
                  GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Vertical"/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.View>
                <GridView>
                    
                    <GridViewColumn Width="{Binding Path=ColorReceiverColumnWidth}" 
                                    HeaderContainerStyle="{StaticResource FixedWithHeaderContainerStyle}" 
                                    CellTemplate="{StaticResource ReceiverColorColumnDataTemplate}" />
                    
                    <GridViewColumn CellTemplate="{StaticResource LogLevelImagesDataTemplate}" 
                                    Width="90" 
                                    HeaderContainerStyle="{StaticResource LogLevelHeaderTemplate}"/>
                    
                    <GridViewColumn Header="Time" 
                                    Width="Auto"
                                    DisplayMemberBinding="{Binding Time, Converter={StaticResource DataConverter}}" 
                                    HeaderContainerStyle="{StaticResource BaseGridViewColumnHeaderStyle}"/>

                    <GridViewColumn Header="Thread" 
                                    Width="{Binding Path=ThreadColumnWidth}" 
                                    DisplayMemberBinding="{Binding Thread}" 
                                    HeaderContainerStyle="{StaticResource BaseGridViewColumnHeaderStyle}">
                    </GridViewColumn>

                    <GridViewColumn Header="Source" 
                                    Width="{Binding SourceColumnWidth}" 
                                    DisplayMemberBinding="{Binding Address}" 
                                    HeaderContainerStyle="{StaticResource IpGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Logger" 
                                    Width="Auto" 
                                    DisplayMemberBinding="{Binding Logger, Converter={StaticResource LoggerDisplayConverter}}" 
                                    HeaderContainerStyle="{StaticResource BaseGridViewColumnHeaderStyle}"/>
                    
                    <GridViewColumn Header="Message"
                                    CellTemplate="{StaticResource LogMessageDataTemplate}" 
                                    Width="1200"
                                    HeaderContainerStyle="{StaticResource MessageHeaderTemplate}"/>
                </GridView>
            </ListView.View>
            <ListView.InputBindings>
                <KeyBinding Key="W" Modifiers="Control" Command="{Binding Path=FindNextWarningCommand}"/>
                <KeyBinding Key="E" Modifiers="Control" Command="{Binding Path=FindNextErrorCommand}"/>
            </ListView.InputBindings>
        </ListView>

        <mah:ProgressRing Grid.Column="0" Grid.Row="1" Height="50" Width="50"
                     VerticalAlignment="Center" HorizontalAlignment="Center"
                     Visibility="{Binding Path=IsVisibleLoader, Converter={StaticResource BooleanToVisibility}}"/>

        <ProgressBar  Grid.Column="0" Grid.Row="1" Height="10" 
                      VerticalAlignment="Bottom" Value="{Binding ProcessBarValue}" 
                      Background="{Binding SelectedColorTheme.Color}"
                      Foreground="{Binding SelectedColorTheme.Color}"
                      Visibility="{Binding IsVisibleProcessBar, Converter={StaticResource BooleanToVisibility}}" Maximum="100"/>


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

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

                <StackPanel VerticalAlignment="Center">
                    <TextBlock Text="Message" />

                    <Button Grid.Row="0" Grid.Column="0"
                            ToolTip="Copy" 
                            Command="{Binding Path=CopyMessageCommand}" 
                            Style="{StaticResource CircleImageButtonStyle}">
                        <Image Source="{StaticResource CopyDrawingImage}"/>

                    </Button>
                </StackPanel>

                <TextBox x:Name="LoggerTextBox" Grid.Row="0" 
                         Text="{Binding Path=SelectedLog.Message}" 
                         Grid.Column="1" 
                         VerticalAlignment="Stretch" TextWrapping="Wrap" Margin="10,0,20,0" 
                         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,0">
                    <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="Logger" />
                    <TextBox Grid.Column="1" 
                             Text="{Binding Path=SelectedLog.Logger}" 
                             Height="35" 
                             Margin="6,0,10,0"
                             BorderThickness="1" 
                             VerticalContentAlignment="Center" 
                             HorizontalAlignment="Stretch" 
                             Padding="5,0" 
                             IsReadOnly="True"/>

                    <TextBlock Grid.Column="2" Text="Time" HorizontalAlignment="Left"/>
                    <TextBox Text="{Binding Path=SelectedLog.Time, StringFormat={}{0:MM/dd/yyyy HH:mm:ss.fff}}" 
                             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="Thread" HorizontalAlignment="Right"/>
                    <TextBox Text="{Binding Path=SelectedLog.Thread}" 
                             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="Port" HorizontalAlignment="Right"/>
                    <TextBox Text="{Binding Path=SelectedLog.Port}" 
                             Grid.Column="7" 
                             Height="35" 
                             Margin="10,0" 
                             Width="80"
                             BorderThickness="1" 
                             VerticalContentAlignment="Center" 
                             HorizontalAlignment="Right" 
                             Padding="5,0" 
                             IsReadOnly="True"/>
                </Grid>
            </Grid>
        </GroupBox>
    </Grid>

</mah:MetroContentControl>
