<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="AppControlManager.Pages.Settings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppControlManager.Pages"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ui="using:CommunityToolkit.WinUI"
    xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:controls="using:CommunityToolkit.WinUI.Controls"
    mc:Ignorable="d">
    <Page.Resources>
        <!--  These styles can be referenced to create a consistent SettingsPage layout  -->
        <!--  Spacing between cards  -->
        <x:Double x:Key="SettingsCardSpacing">4</x:Double>
        <!--  Style (inc. the correct spacing) of a section header  -->
        <Style x:Key="SettingsSectionHeaderTextBlockStyle"
               BasedOn="{StaticResource BodyStrongTextBlockStyle}"
               TargetType="TextBlock">
            <Style.Setters>
                <Setter Property="Margin" Value="1,30,0,6" />
            </Style.Setters>
        </Style>
    </Page.Resources>

    <ScrollViewer>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <controls:WrapPanel Grid.Row="0" VerticalSpacing="4" HorizontalSpacing="4" Orientation="Horizontal" Margin="6,10,6,10">

                <TextBlock
TextWrapping="WrapWholeWords"
Style="{StaticResource BodyTextBlockStyle}">

<Span>
    Customize your app settings here. Your preferences will be
        <Run Foreground="{ThemeResource SystemAccentColor}">saved</Run>
    so they're ready for you every time you start the AppControl Manager.
</Span>
                </TextBlock>

            </controls:WrapPanel>


            <StackPanel HorizontalAlignment="Stretch"
                        Spacing="{StaticResource SettingsCardSpacing}" Grid.Row="1">
                <win:StackPanel.ChildrenTransitions>
                    <win:EntranceThemeTransition FromVerticalOffset="50" />
                    <win:RepositionThemeTransition IsStaggeringEnabled="False" />
                </win:StackPanel.ChildrenTransitions>
                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
                           Text="User Configurations" />
                <controls:SettingsExpander Description="The following are the contents of the User Configurations JSON file"
                                           Header="User Configs"
                                           HeaderIcon="{ui:FontIcon Glyph=&#xE71D;}">
                    <Button Content="Get Configuration"  Click="GetConfigurationButton_Click"
                            Style="{StaticResource AccentButtonStyle}" />
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard ContentAlignment="Left">
                            <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                                <!-- Signed Policy Path -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Signed Policy Path:" x:Name="SignedPolicyPathTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="SignedPolicyPath"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="SignedPolicyPath"/>
                                        <AppBarButton Icon="Folder" Label="Browse" Click="BrowseButton_Click" Tag="SignedPolicyPath"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Unsigned Policy Path -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Unsigned Policy Path:" x:Name="UnsignedPolicyPathTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="UnsignedPolicyPath"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="UnsignedPolicyPath"/>
                                        <AppBarButton Icon="Folder" Label="Browse" Click="BrowseButton_Click" Tag="UnsignedPolicyPath"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Sign Tool Custom Path -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Sign Tool Custom Path:" x:Name="SignToolCustomPathTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="SignToolCustomPath"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="SignToolCustomPath"/>
                                        <AppBarButton Icon="Folder" Label="Browse" Click="BrowseButton_Click" Tag="SignToolCustomPath"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Certificate Common Name -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">

                                    <AutoSuggestBox x:Name="CertificateCommonNameAutoSuggestBox"
                                        Header="Certificate Common Name:"
                                        QueryIcon="Find"
                                        GotFocus="CertificateCommonNameAutoSuggestBox_GotFocus"
                                        TextChanged="CertificateCNAutoSuggestBox_TextChanged"
                                        PlaceholderText="Find Certificate Common Names"
                                        MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>

                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="CertificateCommonName"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="CertificateCommonName"/>
                                        <AppBarButton Icon="Refresh" Label="Refresh" Click="CertificateCommonNameSuggestionsRefresh_Click" Tag="CertificateCommonName" ToolTipService.ToolTip="Fetches the latest certificate common names from the User's personal certificate store"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Certificate Path -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Certificate Path:" x:Name="CertificatePathTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="CertificatePath"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="CertificatePath"/>
                                        <AppBarButton Icon="Folder" Label="Browse" Click="BrowseButton_Click" Tag="CertificatePath"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Strict Kernel Policy GUID -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Strict Kernel Policy GUID:" x:Name="StrictKernelPolicyGUIDTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="StrictKernelPolicyGUID"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="StrictKernelPolicyGUID"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Strict Kernel No Flight Roots Policy GUID -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Strict Kernel No Flight Roots Policy GUID:" x:Name="StrictKernelNoFlightRootsPolicyGUIDTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="StrictKernelNoFlightRootsPolicyGUID"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="StrictKernelNoFlightRootsPolicyGUID"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Strict Kernel Mode Policy Time of Deployment -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Strict Kernel Mode Policy Time of Deployment (YYYY-MM-DD):" x:Name="StrictKernelModePolicyTimeTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="StrictKernelModePolicyTime"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="StrictKernelModePolicyTime"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                                <!-- Last Update Check -->
                                <controls:WrapPanel Orientation="Horizontal" Margin="0,0,0,10">
                                    <TextBox Header="Last Update Check (YYYY-MM-DD):" x:Name="LastUpdateCheckTextBox" MinWidth="300" Margin="0,0,10,0" VerticalAlignment="Center"/>
                                    <CommandBar Background="Transparent" IsOpen="False" DefaultLabelPosition="Right" VerticalAlignment="Center" Margin="0,25,0,0">
                                        <AppBarButton Icon="Save" Label="Save" Click="EditButton_Click" Tag="LastUpdateCheck"/>
                                        <AppBarButton Icon="Clear" Label="Clear" Click="ClearButton_Click" Tag="LastUpdateCheck"/>
                                    </CommandBar>
                                </controls:WrapPanel>
                            </StackPanel>
                        </controls:SettingsCard>
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>

                <!--  'Appearance' section  -->
                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="Appearance" />
                <controls:SettingsExpander IsExpanded="True" Header="Make AppControl Manager Look the Way You Want" HeaderIcon="{ui:FontIcon Glyph=&#xE790;}">

                    <controls:SettingsExpander.ItemsHeader>
                        <InfoBar x:Name="LackOfAnimationsNoticeInfoBar"
                            Title="Windows Animations are Disabled"
                            Message="For an improved experience with DataGrids in AppControl Manager, consider enabling 'Always Show Scrollbars' in Windows Settings -> Accessibility -> Visual Effects."
                            BorderThickness="0"
                            CornerRadius="0"
                            IsIconVisible="True"
                            IsOpen="False"
                            IsClosable="False"
                            Severity="Warning">
                            <InfoBar.ActionButton>
                                <HyperlinkButton Content="Learn more about this issue on GitHub" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/issues/415" />
                            </InfoBar.ActionButton>
                        </InfoBar>

                    </controls:SettingsExpander.ItemsHeader>

                    <controls:SettingsExpander.Items>

                        <controls:SettingsCard Description="Mostly suitable when using MicaAlt as the background." Header="Darker Background" HeaderIcon="{ui:FontIcon Glyph=&#xF0E8;}">
                            <ToggleSwitch x:Name="NavigationViewBackgroundToggle" ToolTipService.ToolTip="It will remove the extra light shadow from the background, giving an overal darker look to the AppControl Manager's appearance."/>
                        </controls:SettingsCard>

                        <controls:SettingsCard Description="Customize the App Background Style" Header="Background Style" HeaderIcon="{ui:FontIcon Glyph=&#xEF1F;}">
                            <ComboBox x:Name="BackgroundComboBox" ToolTipService.ToolTip="This is the backdrop of the AppControl Manager. The changes you notice will be visible in the background.">
                                <ComboBoxItem>MicaAlt</ComboBoxItem>
                                <ComboBoxItem>Mica</ComboBoxItem>
                                <ComboBoxItem>Acrylic</ComboBoxItem>
                            </ComboBox>

                        </controls:SettingsCard>

                        <controls:SettingsCard Description="Customize the Theme" Header="Theme" HeaderIcon="{ui:FontIcon Glyph=&#xE706;}">
                            <ComboBox x:Name="ThemeComboBox" ToolTipService.ToolTip="Select a theme for the AppControl Manager">
                                <ComboBoxItem>Use System Setting</ComboBoxItem>
                                <ComboBoxItem>Dark</ComboBoxItem>
                                <ComboBoxItem>Light</ComboBoxItem>
                            </ComboBox>
                        </controls:SettingsCard>

                        <controls:SettingsCard Description="Choose a style for the main navigation icons" Header="Icons Style" HeaderIcon="{ui:FontIcon Glyph=&#xE8D3;}">
                            <ComboBox x:Name="IconsStyleComboBox" ToolTipService.ToolTip="Pick a style for the main navigation's icons.">
                                <ComboBoxItem>Animated</ComboBoxItem>
                                <ComboBoxItem>Windows Accent</ComboBoxItem>
                                <ComboBoxItem>Monochromatic</ComboBoxItem>
                            </ComboBox>
                        </controls:SettingsCard>

                        <controls:SettingsCard Description="Customize the Navigation Menu location" Header="Navigation Menu" HeaderIcon="{ui:FontIcon Glyph=&#xE90C;}">
                            <ComboBox SelectedIndex="0" x:Name="NavigationMenuLocation" ToolTipService.ToolTip="Select a location for the navigation menu">
                                <ComboBoxItem>Left</ComboBoxItem>
                                <ComboBoxItem>Top</ComboBoxItem>
                            </ComboBox>
                        </controls:SettingsCard>

                    </controls:SettingsExpander.Items>

                </controls:SettingsExpander>


                <!--  'Sound' section  -->
                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
           Text="Sound" />
                <controls:SettingsCard Description="Hear audio feedback when using different elements of the AppControl Manager" Header="Sound" HeaderIcon="{ui:FontIcon Glyph=&#xEC4F;}">
                    <ToggleSwitch x:Name="SoundToggleSwitch" />
                </controls:SettingsCard>


                <!--  'About' section  -->
                <TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"
                           Text="About" />
                <controls:SettingsExpander x:Name="CopyRightSettingsExpander"
                                           Header="AppControl Manager"
                                           IsExpanded="True"
                                           HeaderIcon="{ui:BitmapIcon Source=ms-appx:///Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png}">
                    <TextBlock x:Name="VersionTextBlock" win:IsTextSelectionEnabled="True"
                               Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
                    <controls:SettingsExpander.Items>
                        <controls:SettingsCard HorizontalContentAlignment="Left"
                                               ContentAlignment="Left">
                            <StackPanel Margin="-12,0,0,0"
                                        Orientation="Vertical">
                                <HyperlinkButton Content="GitHub repository" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security" />
                                <HyperlinkButton Content="AppControl Manager Documentation" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/wiki/AppControl-Manager" />
                                <HyperlinkButton Content="SpyNetGirl website" NavigateUri="https://spynetgirl.github.io/" />
                                <HyperlinkButton Content="YouTube Channel" NavigateUri="https://www.youtube.com/@hotcakex" />
                                <HyperlinkButton Content="X" NavigateUri="https://x.com/CyberCakeX" />
                            </StackPanel>
                        </controls:SettingsCard>
                    </controls:SettingsExpander.Items>
                </controls:SettingsExpander>

                <controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10" VerticalSpacing="10" Margin="0,8,0,0">
                    <HyperlinkButton Content="Send feedback" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/issues/new/choose" />
                    <HyperlinkButton Content="Icons8 website for all of the Icons used in this app" NavigateUri="https://icons8.com" />
                    <HyperlinkButton Content="Source Code" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/tree/main/AppControl%20Manager" />
                </controls:WrapPanel>

            </StackPanel>

        </Grid>

    </ScrollViewer>

</Page>
