<UserControl x:Class="Vulnerator.View.UI.SettingsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:Converters="clr-namespace:Vulnerator.View.Converter"
             xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
             xmlns:LiveCharts="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
             xmlns:Validation="clr-namespace:Vulnerator.View.Validation"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dat="clr-namespace:System.Windows.Data;assembly=PresentationFramework"
             xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:local="clr-namespace:Vulnerator.View.UI"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:v="clr-namespace:Vulnerator.View"
             xmlns:vh="clr-namespace:Vulnerator.View.ViewHelper"
             xmlns:vm="clr-namespace:Vulnerator.ViewModel"
             HorizontalAlignment="Stretch"
             VerticalAlignment="Stretch"
             d:DesignWidth="800"
             DataContext="{Binding Settings, Source={StaticResource Locator}}"
             mc:Ignorable="d">
    <UserControl.Resources />
    <Grid Background="{DynamicResource WindowBackgroundBrush}">
        <ScrollViewer Margin="5,0,5,5"
                      HorizontalScrollBarVisibility="Disabled"
                      VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <StackPanel HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch">
                        <Label Grid.Column="0"
                               Style="{StaticResource SecondLevelHeaderStyle}">
                            <TextBlock Text="User Information"
                                       TextTrimming="CharacterEllipsis" />
                        </Label>
                        <TextBox Margin="5,0,5,5"
                                 Controls:TextBoxHelper.ButtonContent="{IconPacks:Material Kind=CloseBoxOutline}"
                                 Controls:TextBoxHelper.Watermark="Active User(Read Only)"
                                 vh:DependencyProperties.FloatingWatermark="Active User (Read Only)"
                                 IsReadOnly="True"
                                 Style="{StaticResource HeaderedTextBoxStyle}"
                                 Text="{Binding Source={StaticResource Settings}, Path=Default.ActiveUser}" />
                        <TextBox Margin="5,0,5,5"
                                 Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                 Controls:TextBoxHelper.ClearTextButton="True"
                                 Controls:TextBoxHelper.Watermark="Name (First &amp; Last)"
                                 vh:DependencyProperties.FloatingWatermark="Name"
                                 Style="{StaticResource HeaderedTextBoxStyle}"
                                 Text="{Binding Source={StaticResource Settings}, Path=Default.Name}" />
                        <TextBox Margin="5,0,5,5"
                                 Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                 Controls:TextBoxHelper.ClearTextButton="True"
                                 Controls:TextBoxHelper.Watermark="Phone Number (Digits Only - e.g. 0123456789)"
                                 vh:DependencyProperties.FloatingWatermark="Phone Number"
                                 Style="{StaticResource HeaderedTextBoxStyle}">
                            <Binding Mode="TwoWay"
                                     Source="{StaticResource Settings}"
                                     UpdateSourceTrigger="PropertyChanged"
                                     Path="Default.Phone">
                                <Binding.ValidationRules>
                                    <Validation:PhoneNumberValidationRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox>

                        <TextBox Margin="5,0,5,5"
                                 Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                 Controls:TextBoxHelper.ClearTextButton="True"
                                 Controls:TextBoxHelper.Watermark="eMASS Email (you@example.com)"
                                 vh:DependencyProperties.FloatingWatermark="eMASS Email"
                                 Style="{StaticResource HeaderedTextBoxStyle}">
                            <Binding Mode="TwoWay"
                                     Source="{StaticResource Settings}"
                                     UpdateSourceTrigger="PropertyChanged"
                                     Path="Default.Email">
                                <Binding.ValidationRules>
                                    <Validation:EmailValidationRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </TextBox>
                        <TextBox Margin="5,0,5,5"
                                 Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                 Controls:TextBoxHelper.ClearTextButton="True"
                                 Controls:TextBoxHelper.Watermark="Organization (e.g. NAVAIR)"
                                 vh:DependencyProperties.FloatingWatermark="Organization"
                                 Style="{StaticResource HeaderedTextBoxStyle}"
                                 Text="{Binding Source={StaticResource Settings}, Path=Default.Organization}" />
                        <Label Grid.Column="0"
                               Style="{StaticResource SecondLevelHeaderStyle}">
                            <TextBlock Text="Database File"
                                       TextTrimming="CharacterEllipsis" />
                        </Label>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox Margin="5,0,5,5"
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Center"
                                     Controls:TextBoxHelper.Watermark="Database File"
                                     IsReadOnly="True"
                                     Style="{StaticResource NonHeaderedTextBoxStyle}"
                                     Text="{Binding Source={StaticResource Settings}, Path=Default.Database}" />
                            <Button Grid.Column="1"
                                    Margin="5,0,5,5"
                                    Command="{Binding BrowseForDatabaseCommand}"
                                    Content="{IconPacks:FontAwesomeLight Kind=FileSearch}"
                                    ToolTip="Search" />
                            <Button Grid.Column="2"
                                    Margin="5,0,5,5"
                                    Command="{Binding CreateDatabaseCommand}"
                                    Content="{IconPacks:FontAwesomeLight Kind=FilePlus}"
                                    ToolTip="Create" />
                        </Grid>
                        <Grid Grid.Column="0"
                              Visibility="Collapsed">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Label Grid.Column="0"
                                   Style="{StaticResource SecondLevelHeaderStyle}">
                                <TextBlock Text="Update STIG Library"
                                           TextTrimming="CharacterEllipsis" />
                            </Label>
                            <Label Grid.Column="2"
                                   VerticalAlignment="Bottom">
                                <TextBlock Text="Last Update:"
                                           TextTrimming="CharacterEllipsis" />
                            </Label>
                            <Label Grid.Column="3"
                                   VerticalAlignment="Bottom">
                                <TextBlock Text="{Binding Source={StaticResource Settings}, Path=Default.StigLibraryIngestDate}"
                                           TextTrimming="CharacterEllipsis" />
                            </Label>
                        </Grid>
                        <Grid Visibility="Collapsed">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox x:Name="uploadStigLibraryTextbox"
                                     Margin="5,0,5,5"
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Center"
                                     Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                     Controls:TextBoxHelper.ClearTextButton="True"
                                     Controls:TextBoxHelper.Watermark="STIG Library or Single STIG (ZIP File)"
                                     Style="{StaticResource NonHeaderedTextBoxStyle}"
                                     Text="{Binding StigLibraryLocation, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <Button Grid.Column="1"
                                    Margin="5,0,5,5"
                                    Command="{Binding SelectStigLibraryCommand}"
                                    Content="{IconPacks:FontAwesomeLight Kind=FileSearch}"
                                    ToolTip="Search" />
                            <Button Grid.Column="2"
                                    Margin="5,0,5,5"
                                    Command="{Binding IngestStigLibraryCommand}"
                                    Content="{IconPacks:FontAwesomeLight Kind=FileImport}"
                                    ToolTip="Upload" />
                        </Grid>
                        <!--<Label Grid.Column="0" Style="{StaticResource SecondLevelHeaderStyle}">
                        <TextBlock Text="Build Ansible Tower Report Files" TextTrimming="CharacterEllipsis" />
                    </Label>
                    <Button
                        MaxWidth="150"
                        Margin="5,0,5,5"
                        HorizontalAlignment="Left"
                        Command="{Binding BuildAnsibleTowerReportsCommand}"
                        Content="Build Reports" />-->
                        <TextBox Margin="5,0,5,5"
                                 Background="LightPink"
                                 Style="{StaticResource ErrorTextBox}"
                                 Text="Please select a STIG Library for ingestion."
                                 TextAlignment="Center"
                                 TextWrapping="Wrap"
                                 Visibility="{Binding NoLibraryVisibility}" />
                        <TextBox Margin="5,0,5,5"
                                 Background="LightPink"
                                 Style="{StaticResource ErrorTextBox}"
                                 Text="STIG Library ingestion error - see log for details."
                                 TextAlignment="Center"
                                 TextWrapping="Wrap"
                                 Visibility="{Binding IngestionErrorVisibility}" />
                        <TextBox Margin="5,0,5,5"
                                 Style="{StaticResource SuccessTextBox}"
                                 Text="STIG Library successfully ingested."
                                 TextAlignment="Center"
                                 TextWrapping="Wrap"
                                 Visibility="{Binding IngestionSuccessVisibility}" />
                        <Grid Visibility="{Binding ProgressVisibility, FallbackValue=Collapsed}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <ProgressBar Width="{Binding ActualWidth, ElementName=uploadStigLibraryTextbox}"
                                         Margin="5,0,5,5"
                                         Maximum="{Binding ProgressBarMax}"
                                         Minimum="0"
                                         Value="{Binding ProgressBarValue}" />
                            <Grid Grid.Column="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0"
                                           Text="{Binding ProgressBarValue}"
                                           TextAlignment="Center" />
                                <TextBlock Grid.Column="1"
                                           Text="/"
                                           TextAlignment="Center" />
                                <TextBlock Grid.Column="2"
                                           Text="{Binding ProgressBarMax}"
                                           TextAlignment="Center" />
                            </Grid>
                        </Grid>

                        <Expander Margin="5,0"
                                  Background="Red"
                                  BorderBrush="Red"
                                  ExpandDirection="Down"
                                  Style="{StaticResource CustomExpander}"
                                  Visibility="Collapsed">
                            <Expander.Header>
                                <Label Foreground="White">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <IconPacks:PackIconFontAwesomeLight Grid.Column="0"
                                                                            Margin="5,0"
                                                                            HorizontalAlignment="Center"
                                                                            VerticalAlignment="Center"
                                                                            Kind="ExclamationTriangle" />
                                        <TextBlock Grid.Column="1"
                                                   Text="Danger Zone"
                                                   TextTrimming="CharacterEllipsis" />
                                    </Grid>
                                </Label>
                            </Expander.Header>
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Vulnerabilities" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all vulnerability data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Mitigations" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all mitigation data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Contacts" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all contact data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Organizations" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all organization data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button x:Name="purgeAccreditationsButton"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Accreditations" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all accreditation data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Projects" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all user-defined project data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Hardware" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all hardware data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition />
                                    </Grid.ColumnDefinitions>
                                    <Button Width="{Binding ElementName=purgeAccreditationsButton, Path=ActualWidth}"
                                            Margin="5,0,5,5"
                                            VerticalAlignment="Center"
                                            Content="Purge Software" />
                                    <Label Grid.Column="1">
                                        <TextBlock Text="Warning: This will permanently erase all software data"
                                                   TextWrapping="Wrap" />
                                    </Label>
                                </Grid>
                            </StackPanel>
                        </Expander>
                    </StackPanel>
                    <StackPanel Grid.Column="1"
                                HorizontalAlignment="Stretch"
                                VerticalAlignment="Stretch"
                                Visibility="Collapsed">
                        <Grid HorizontalAlignment="Stretch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Label Style="{StaticResource SecondLevelHeaderStyle}">
                                <TextBlock Text="Overlay Management"
                                           TextTrimming="CharacterEllipsis"
                                           TextWrapping="NoWrap" />
                            </Label>
                            <Button Grid.Column="2"
                                    Margin="5,0,5,5"
                                    Content="{IconPacks:FontAwesomeLight Kind=PlusSquare}"
                                    ToolTip="Add Overlay" />
                            <Button Grid.Column="3"
                                    Margin="5,0,5,5"
                                    Content="{IconPacks:FontAwesomeLight Kind=MinusSquare}"
                                    ToolTip="Remove Overlay(s)" />
                        </Grid>
                        <DataGrid MinHeight="100"
                                  Margin="5,0,5,5"
                                  BorderThickness="1"
                                  CanUserAddRows="True"
                                  HeadersVisibility="None"
                                  Style="{StaticResource GreyBorderedDataGridStyle}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn />
                                <DataGridTextColumn />
                            </DataGrid.Columns>
                        </DataGrid>
                        <Label Style="{StaticResource SecondLevelHeaderStyle}">
                            <TextBlock Text="Organization Management"
                                       TextTrimming="CharacterEllipsis" />
                        </Label>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <TextBox Grid.Column="0"
                                     Margin="5,0,5,5"
                                     VerticalAlignment="Center"
                                     Controls:TextBoxHelper.ButtonContent="{IconPacks:FontAwesomeLight Kind=TimesSquare}"
                                     Controls:TextBoxHelper.ClearTextButton="True"
                                     Controls:TextBoxHelper.Watermark="Enter a new organization name"
                                     Style="{StaticResource NonHeaderedTextBoxStyle}" />
                            <Button Grid.Column="1"
                                    Margin="5,0,5,5"
                                    Content="{IconPacks:FontAwesomeLight Kind=PlusSquare}"
                                    ToolTip="Add Organization" />
                            <Button Grid.Column="2"
                                    Margin="5,0,5,5"
                                    Content="{IconPacks:FontAwesomeLight Kind=MinusSquare}"
                                    ToolTip="Remove Organization(s)" />
                        </Grid>
                        <DataGrid MinHeight="100"
                                  Margin="5,0,5,5"
                                  BorderThickness="1"
                                  CanUserAddRows="True"
                                  HeadersVisibility="None"
                                  Style="{StaticResource GreyBorderedDataGridStyle}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn />
                                <DataGridTextColumn />
                            </DataGrid.Columns>
                        </DataGrid>
                    </StackPanel>
                </Grid>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
