<pfui:VsDialogWindow
    x:Class="NuGet.Dialog.PackageManagerWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:shared="clr-namespace:Microsoft.VisualStudio.ExtensionsExplorer.UI;assembly=Microsoft.VisualStudio.ExtensionsExplorer.UI"
    xmlns:resources="clr-namespace:NuGet.Dialog;assembly=NuGet.DialogServices"
    xmlns:dialogServices="clr-namespace:NuGet.Dialog;assembly=NuGet.DialogServices"
    xmlns:dialogCommands="clr-namespace:NuGet.Dialog.PackageManagerUI;assembly=NuGet.DialogServices"
    xmlns:local="clr-namespace:NuGet.Dialog"
    xmlns:resx="clr-namespace:NuGet.VisualStudio.Resources;assembly=NuGet.VisualStudio"
    xmlns:pfui="clr-namespace:NuGet.VisualStudio;assembly=NuGet.VisualStudio"
    xmlns:vsfx="clr-namespace:NuGet.VisualStudio;assembly=NuGet.VisualStudio" 
    Background="{DynamicResource {x:Static vsfx:VsBrushes.EnvironmentBackgroundGradientKey}}"
    WindowStartupLocation="CenterOwner"
    HasHelpButton="True" 
    HasMaximizeButton="False"
    HasMinimizeButton="False"
    ResizeMode="CanResize"
    ShowInTaskbar="False"
    SnapsToDevicePixels="True"
    Width="900"
    Height="600"
    MinWidth="800" 
    MinHeight="450"
    dialogServices:WindowSizePersistenceHelper.WindowToken="MainWindow"
    Loaded="OnDialogWindowLoaded"
    Closing="OnDialogWindowClosing"
    Closed="OnDialogWindowClosed"
    AutomationProperties.AutomationId="NuGetMainWindow"
    >
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="CommonStyles.xaml" />
                <ResourceDictionary Source="TemplateStyles.xaml" />
                <ResourceDictionary Source="OnlineProviderTemplates.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Window.CommandBindings>
        <CommandBinding 
            Command="{x:Static dialogCommands:PackageManagerWindowCommands.PackageOperationCommand}"
            CanExecute="CanExecuteCommandOnPackage"
            Executed="ExecutedPackageCommand" />
        
        <CommandBinding
            Command="ApplicationCommands.Close"
            CanExecute="CanExecuteClose"
            Executed="ExecutedClose" />
        
        <CommandBinding 
            Command="{x:Static dialogCommands:PackageManagerWindowCommands.ShowOptionsPage}"
            CanExecute="CanExecuteClose"
            Executed="ExecutedShowOptionsPage" />
        
        <CommandBinding 
            Command="{x:Static dialogCommands:PackageManagerWindowCommands.OpenExternalLink}"
            Executed="ExecuteOpenLicenseLink" />
        
        <CommandBinding
            Command="{x:Static dialogCommands:PackageManagerWindowCommands.FocusOnSearchBox}"
            Executed="ExecuteSetFocusOnSearchBox" />
    </Window.CommandBindings>

    <Window.InputBindings>
        <KeyBinding Command="{x:Static dialogCommands:PackageManagerWindowCommands.FocusOnSearchBox}" Gesture="CTRL+E" />
    </Window.InputBindings>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Border Background="{DynamicResource {x:Static vsfx:VsBrushes.NewProjectBackgroundKey}}" Padding="0,0,0,4" Grid.Row="1">
            <shared:VSExtensionsExplorerCtl
                x:Name="explorer"
                ActiveView="MediumIcons"
                HorizontalAlignment="Stretch"
                SnapsToDevicePixels="True"
                ListViewIsVirtualizing="True"
                IsFxComboVisible="True"
                IsMediumIconsViewButtonVisible="False"
                IsSmallIconsViewButtonVisible="False"
                IsLargeIconsViewButtonVisible="False"
                CategorySelectionChanged="OnCategorySelectionChanged"
                ProviderSelectionChanged="OnProviderSelectionChanged"
                Grid.IsSharedSizeScope="True" />
        </Border>

        <Border 
            x:Name="DisclaimerText"
            Grid.Row="1"
            Width="220"
            Background="{DynamicResource {x:Static dialogServices:UIResources.ContentBackgroundBrushKey}}"
            HorizontalAlignment="Left"
            VerticalAlignment="Bottom"
            BorderBrush="{DynamicResource {x:Static vsfx:VsBrushes.NewProjectBackgroundKey}}" 
            BorderThickness="0,2,0,0"
            Padding="8">
            <TextBlock 
                Foreground="{DynamicResource {x:Static vsfx:VsBrushes.WindowTextKey}}"
                Text="{x:Static resx:VsResources.Dialog_DisclaimerText}" 
                TextWrapping="Wrap" />
        </Border>

        <Grid x:Name="BottomBar" Grid.Row="2" MinHeight="50">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Button
                AutomationProperties.AutomationId="SettingsButton"
                Grid.Column="0"
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Margin="12"
                MinWidth="75" 
                MinHeight="23"
                Padding="4,0,4,0"
                Command="{x:Static dialogCommands:PackageManagerWindowCommands.ShowOptionsPage}" 
                Content="{x:Static resources:Resources.Dialog_Settings}" />

            <Button 
                AutomationProperties.AutomationId="CloseButton"
                Grid.Column="2"
                HorizontalAlignment="Right"
                VerticalAlignment="Center"
                Margin="12"
                MinWidth="75" 
                MinHeight="23" 
                Padding="4,0,4,0"
                Command="ApplicationCommands.Close"
                Content="{x:Static resources:Resources.Dialog_Close}" 
                IsCancel="True" />
        </Grid>
    </Grid>
</pfui:VsDialogWindow>