<!--
LogImportTemplateDialog.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.LogImportTemplateDialog"
        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 LogImportTemplate, Source={StaticResource LogDashLocator}}"
        Title="Log Import Template" 
        Topmost="True" 
        mc:Ignorable="d"
        Height="430" 
        Width="700" 
        Closing="LogImportTemplateDialog_OnClosing">

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

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

        <RadioButton Margin="10,10" 
                     ToolTip="Try to detect a template for parsing the log file automatically. 100% result is not guaranteed." 
                     Content="Automatically" 
                     IsChecked="{Binding Path=IsAutomaticDetectTemplateSelected}"/>
        
        <RadioButton Grid.Row="1" Margin="10,0" 
                     Content="Select from existing templates" 
                     IsChecked="{Binding Path=IsPopularTemplateSelected}"/>

        <ComboBox Grid.Row="2" Margin="10,0,10,5" 
                  Grid.ColumnSpan="2" 
                  ItemsSource="{Binding Path=PopularTemplates}" 
                  SelectedValue="{Binding Path=SelectedPopularTemplate}" 
                  SelectedValuePath="Value" 
                  DisplayMemberPath="Key"/>

        <RadioButton Grid.Row="3" 
                     Margin="10,0" 
                     Content="From layout string" 
                     IsChecked="{Binding Path=IsLayoutStringTemplateSelected}" 
                     VerticalAlignment="Center" />

        <TextBox Grid.Row="4" Grid.ColumnSpan="2" Margin="10,0,10,5" HorizontalAlignment="Stretch" 
                 Text="{Binding TemplateString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

        <RadioButton Grid.Row="5" Margin="10,0" Content="Or create your own template" 
                     IsChecked="{Binding Path=IsUserTemplateSelected}" 
                     VerticalAlignment="Center" />

        <Button Grid.Row="6" 
                Width="Auto" 
                Content="Add" Visibility="{Binding Path=ClearContainsIsVisible, Converter={StaticResource BooleanToVisibility}}"
                Command="{Binding Path=AddTemplateItemCommand}" Margin="10,5,0,0" 
                HorizontalAlignment="Left"/>

        <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="1">
            <Label Content="{Binding Separator, StringFormat={}{0}:}" VerticalAlignment="Center"/>
            <TextBox Text="{Binding Path=TemplateSeparator, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Center" Width="30" VerticalContentAlignment="Center"/>
        </StackPanel>

        <StackPanel Grid.Row="7" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="10,0,10,5" Height="80">
            <ItemsControl x:Name="TemplateLogItemsIC" ItemsSource="{Binding Path=TemplateLogItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" >
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <Label Content="${" VerticalContentAlignment="Center" Padding="0"/>
                                <ComboBox x:Name="ComboBox" Margin="5" ItemsSource="{Binding Path=TemplateItems}" SelectedItem="{Binding Path=SelectedTemplateParameter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="30" VerticalContentAlignment="Center">
                                    <ComboBox.GroupStyle>
                                        <GroupStyle>
                                            <GroupStyle.HeaderTemplate>
                                                <DataTemplate>
                                                    <TextBlock Text="{Binding Name}" Margin="10,0,0,0"/>
                                                </DataTemplate>
                                            </GroupStyle.HeaderTemplate>
                                        </GroupStyle>
                                    </ComboBox.GroupStyle>
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Parameter}"/>
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                                <Label Content="}" VerticalContentAlignment="Center" Padding="0"/>
                                <Label Padding="0" FontStyle="Normal" FontSize="18" VerticalContentAlignment="Center" Content="{Binding ElementName=TemplateLogItemsIC,  Path=DataContext.TemplateSeparator, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                            </StackPanel>

                            <Button Padding="0" 
                                    Width="60" Content="Remove" 
                                    Margin="1" Height="30" 
                                    ToolTip="Remove Template Item"
                                    Command="{Binding ElementName=TemplateLogItemsIC, Path=DataContext.RemoveTemplateItemCommand}" CommandParameter="{Binding}"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
       
        <CheckBox Grid.Row="9" Grid.ColumnSpan="2" Margin="10,0,10,10" Content="Add New Logs When Changing File" IsChecked="{Binding Path=NeedUpdateFile}"/>
        
        <Button Grid.Row="10" Grid.Column="0" HorizontalAlignment="Left" Margin="10,0" Width="180"
                Content="Save" Command="{Binding Path=SaveTemplateSettingsCommand}"/>
        
        <WrapPanel Grid.Row="10" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="10,0">
            <Button Command="{Binding OkCommand}" MinWidth="100" Height="30" Margin="0,0,10,0" Content="OK"/>
            <Button IsCancel="True" MinWidth="100" Content="Cancel"/>
        </WrapPanel>
    </Grid>
</mah:MetroWindow>
