<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="AppControlManager.Pages.Deployment"
    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:controls="using:CommunityToolkit.WinUI.Controls"
    xmlns:tk7controls="using:CommunityToolkit.WinUI.UI.Controls"
    xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:animatedvisuals="using:AnimatedVisuals"
    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="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <Grid.Resources>
                <Style x:Key="GridCardStyle" TargetType="Border">
                    <Style.Setters>
                        <Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
                        <Setter Property="CornerRadius" Value="{StaticResource OverlayCornerRadius}" />
                    </Style.Setters>
                </Style>

            </Grid.Resources>

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

                <TextBlock
                    TextWrapping="WrapWholeWords"
                    Style="{StaticResource BodyTextBlockStyle}">
                    <Span>
                        Deploy <Bold>any type </Bold> of <Run Foreground="{ThemeResource SystemAccentColor}">App Control</Run> Policy.
                    </Span>
                </TextBlock>

                <HyperlinkButton Content="Guide" NavigateUri="https://github.com/HotCakeX/Harden-Windows-Security/wiki/Deploy-App-Control-Policy" />

            </controls:WrapPanel>


            <InfoBar
                x:Name="StatusInfoBar"
                IsOpen="False"
                Visibility="Collapsed"
                Severity="Informational"
                Grid.Row="1">
                <InfoBar.Content>
                    <ProgressBar Margin="0,0,0,15" Visibility="Collapsed" x:Name="MainProgressRing" Value="0" IsIndeterminate="True" Minimum="0" Maximum="100"/>
                </InfoBar.Content>
            </InfoBar>


            <StackPanel HorizontalAlignment="Stretch"
             Spacing="{StaticResource SettingsCardSpacing}" Grid.Row="2" Margin="0,40,0,0">

                <win:StackPanel.ChildrenTransitions>
                    <win:EntranceThemeTransition FromVerticalOffset="50" />
                    <win:RepositionThemeTransition IsStaggeringEnabled="False" />
                </win:StackPanel.ChildrenTransitions>

                <controls:SettingsCard
                Description="Browse for XML policy file(s) to deploy unsigned on the system"
                Header="Select unsigned XML policy file(s)"
                HeaderIcon="{ui:FontIcon Glyph=&#xE82D;}" IsClickEnabled="False" IsActionIconVisible="False">

                    <controls:WrapPanel HorizontalSpacing="15" VerticalSpacing="15">

                        <Button x:Name="BrowseForXMLPolicyFilesButton" Click="BrowseForXMLPolicyFilesButton_Click">
                            <Button.Content>
                                <controls:WrapPanel Orientation="Horizontal">

                                    <AnimatedIcon x:Name="UnsignedXMLFilesLightAnimatedIcon" Height="20" Margin="0,0,5,0" Width="20">
                                        <AnimatedIcon.Source>
                                            <animatedvisuals:Light/>
                                        </AnimatedIcon.Source>
                                    </AnimatedIcon>

                                    <TextBlock Text="Browse" />

                                </controls:WrapPanel>
                            </Button.Content>

                            <Button.Flyout>
                                <Flyout x:Name="BrowseForXMLPolicyFilesButton_Flyout">

                                    <controls:WrapPanel Orientation="Vertical" HorizontalSpacing="15" VerticalSpacing="15">

                                        <Button Content="Clear" Click="BrowseForXMLPolicyFilesButton_Flyout_Clear_Click" />

                                        <TextBlock Text="View the XML files you selected." TextWrapping="WrapWholeWords" />

                                        <TextBox x:Name="BrowseForXMLPolicyFilesButton_SelectedFilesTextBox"
                                            TextWrapping="Wrap" AcceptsReturn="True" IsSpellCheckEnabled="False"
                                            SelectionHighlightColor="Pink" MinWidth="400" IsReadOnly="True" />

                                    </controls:WrapPanel>

                                </Flyout>
                            </Button.Flyout>

                        </Button>

                        <Button HorizontalAlignment="Center" x:Name="DeployUnsignedXMLButton"
                        HorizontalContentAlignment="Center" Click="DeployUnsignedXMLButton_Click">
                            <Button.Content>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                        <FontIcon Glyph="&#xE8B6;" Margin="0,0,8,0" />
                                        <TextBlock Text="Deploy"/>
                                    </StackPanel>
                                </StackPanel>
                            </Button.Content>

                        </Button>

                        <TeachingTip x:Name="DeployUnsignedXMLButtonTeachingTip"
                            Target="{x:Bind DeployUnsignedXMLButton}"
                            Title="No File was selected"
                            Subtitle="You need to select unsigned XML files to deploy first.">
                        </TeachingTip>

                    </controls:WrapPanel>

                </controls:SettingsCard>



                <controls:SettingsCard
            Description="Browse for XML policy file(s) to Sign and deploy on the system"
            Header="Select signed XML policy file(s)"
            HeaderIcon="{ui:FontIcon Glyph=&#xEF3F;}" IsClickEnabled="False" IsActionIconVisible="False">

                    <controls:WrapPanel HorizontalSpacing="15" VerticalSpacing="15">

                        <Button x:Name="BrowseForSignedXMLPolicyFilesButton" Click="BrowseForSignedXMLPolicyFilesButton_Click">
                            <Button.Content>
                                <controls:WrapPanel Orientation="Horizontal">

                                    <AnimatedIcon x:Name="SignedXMLFilesLightAnimatedIcon" Visibility="Collapsed" Height="20" Margin="0,0,5,0" Width="20">
                                        <AnimatedIcon.Source>
                                            <animatedvisuals:Light/>
                                        </AnimatedIcon.Source>
                                    </AnimatedIcon>

                                    <TextBlock Text="Browse" />

                                </controls:WrapPanel>
                            </Button.Content>

                            <Button.Flyout>
                                <Flyout x:Name="BrowseForSignedXMLPolicyFilesButton_Flyout">

                                    <controls:WrapPanel Orientation="Vertical" HorizontalSpacing="15" VerticalSpacing="15">

                                        <Button Content="Clear" Click="BrowseForSignedXMLPolicyFilesButton_Flyout_Clear_Click" />

                                        <TextBlock Text="View the XML files you selected." TextWrapping="WrapWholeWords" />

                                        <TextBox x:Name="BrowseForSignedXMLPolicyFilesButton_SelectedFilesTextBox"
                    TextWrapping="Wrap" AcceptsReturn="True" IsSpellCheckEnabled="False"
                    SelectionHighlightColor="Pink" MinWidth="400" IsReadOnly="True" />

                                    </controls:WrapPanel>

                                </Flyout>
                            </Button.Flyout>

                        </Button>

                        <Button HorizontalAlignment="Center" x:Name="DeploySignedXMLButton"
                                HorizontalContentAlignment="Center" Click="DeploySignedXMLButton_Click">
                            <Button.Content>
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                        <FontIcon Glyph="&#xE8B6;" Margin="0,0,8,0" />
                                        <TextBlock x:Name="DeploySignedXMLButtonContentTextBlock" Text="Deploy"/>
                                    </StackPanel>
                                </StackPanel>
                            </Button.Content>

                        </Button>

                        <TeachingTip x:Name="DeploySignedXMLButtonTeachingTip"
    Target="{x:Bind DeploySignedXMLButton}"
    Title="No File was selected"
    Subtitle="You need to select Signed XML files to deploy first.">
                        </TeachingTip>

                    </controls:WrapPanel>

                </controls:SettingsCard>




                <controls:SettingsCard 
                    Description="Browse for CIP Binary file(s) to deploy on the system"
                    Header="Select CIP Binary file(s)"
                    HeaderIcon="{ui:FontIcon Glyph=&#xEF3E;}" IsClickEnabled="False" IsActionIconVisible="False" >

                    <controls:WrapPanel HorizontalSpacing="15" VerticalSpacing="15">

                        <Button x:Name="BrowseForCIPBinaryFilesButton" Content="Browse" Click="BrowseForCIPBinaryFilesButton_Click">

                            <Button.Flyout>
                                <Flyout x:Name="BrowseForCIPBinaryFilesButton_Flyout">

                                    <controls:WrapPanel Orientation="Vertical" HorizontalSpacing="15" VerticalSpacing="15">

                                        <Button Content="Clear" Click="BrowseForCIPBinaryFilesButton_Flyout_Clear_Click" />

                                        <TextBlock Text="View the CIP files you selected." TextWrapping="WrapWholeWords" />

                                        <TextBox x:Name="BrowseForCIPBinaryFilesButton_SelectedFilesTextBox"
                                            TextWrapping="Wrap" AcceptsReturn="True" IsSpellCheckEnabled="False"
                                            SelectionHighlightColor="Pink" MinWidth="400" IsReadOnly="True" />

                                    </controls:WrapPanel>

                                </Flyout>
                            </Button.Flyout>

                        </Button>


                        <Button HorizontalAlignment="Center" x:Name="DeployCIPButton"
                            HorizontalContentAlignment="Center" Click="DeployCIPButton_Click">
                            <Button.Content>
                                <StackPanel Orientation="Horizontal">

                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
                                        <FontIcon Glyph="&#xE8B6;" Margin="0,0,8,0" />
                                        <TextBlock Text="Deploy"/>
                                    </StackPanel>

                                </StackPanel>
                            </Button.Content>

                        </Button>

                        <TeachingTip x:Name="DeployCIPButtonTeachingTip"
                            Target="{x:Bind DeployCIPButton}"
                            Title="No File was selected"
                            Subtitle="You need to select CIP files to deploy first.">
                        </TeachingTip>

                    </controls:WrapPanel>

                </controls:SettingsCard>

            </StackPanel>

        </Grid>
    </ScrollViewer>
</Page>
