<?xml version="1.0" encoding="UTF-8"?>
<!--
    This file is part of QTTabBar, a shell extension for Microsoft
    Windows Explorer.
    Copyright (C) 2007-2021  Quizo, Paul Accisano

    QTTabBar is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QTTabBar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QTTabBar.  If not, see <http://www.gnu.org/licenses/>.
-->

<qt:OptionsDialogTab
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:qt="clr-namespace:QTTabBarLib"
    x:Class="QTTabBarLib.Options12_Plugins"
    x:ClassModifier="internal">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="OptionsDialogResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <DockPanel
        Margin="14,5,10,16">
        <StackPanel
            DockPanel.Dock="Top"
            Margin="0,0,0,4"
            Orientation="Horizontal">
            <Image
                Source="{Binding Source={x:Static qt:Resources_Image.imgTabPlugin}, Converter={StaticResource BitmapToImageSourceConverter}}"
                Style="{StaticResource PageHeaderImageStyle}"/>
            <Label
                Content="{qt:Resx Key=Options_Page12_Plugins, Index=0}"
                FontSize="13"
                VerticalAlignment="Bottom"/>
        </StackPanel>
		<StackPanel
             DockPanel.Dock="Top"
            Margin="0,0,0,4"
            Orientation="Horizontal">
		<Button x:Name="btnBrowsePlugin"
            Click="btnBrowsePlugin_Click"
            Content="{qt:Resx Key=Options_Page12_Plugins, Index=1}"
            Height="22"
            Margin="0,0,10,0"
            Width="100"/>
        <Button x:Name="btnEnablePlugin"
            Click="btnEnablePlugin_Click"
            Content="{qt:Resx Key=Options_Page12_Plugins, Index=10}"
            Height="22"
            Margin="0,0,10,0"
            Width="100"/>
        <Button x:Name="btnDisablePlugin"
            Click="btnDisablePlugin_Click"
            Content="{qt:Resx Key=Options_Page12_Plugins, Index=11}"
            Height="22"
            Margin="0,10"
            Width="120"/>
        </StackPanel>
        
        <qt:RestrictDesiredSize MinHeight="200">
            <ListBox x:Name="lstPluginView"
                HorizontalContentAlignment="Stretch"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                <ListBox.Resources>
                    <SolidColorBrush 
                        x:Key="{x:Static SystemColors.HighlightBrushKey}" 
                        Color="White"/>
                    <SolidColorBrush 
                        x:Key="{x:Static SystemColors.HighlightTextBrushKey}"
                        Color="Black"/>
                    <SolidColorBrush 
                        x:Key="{x:Static SystemColors.ControlBrushKey}"
                        Color="White"/>
                </ListBox.Resources>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="{x:Type ListBoxItem}">
                        <Setter Property="BorderBrush" Value="DarkGray"/>
                        <Setter Property="BorderThickness" Value="0,0,0,1"/>
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                        <Setter Property="Padding" Value="0"/>                        
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <!-- Background -->
                            <Rectangle>
                                <Rectangle.Fill>
                                    <SolidColorBrush Color="{Binding Path=BackgroundColor}"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <!-- Barber Pole -->
                            <Rectangle>
                                <Rectangle.Fill>
                                    <LinearGradientBrush
                                        EndPoint="0,150"
                                        StartPoint="0,0"
                                        MappingMode="Absolute">
                                        <GradientStop Color="{Binding Path=StatusColor}" Offset="0"/>
                                        <GradientStop Color="Transparent" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.Fill>
                                <Rectangle.OpacityMask>
                                    <LinearGradientBrush
                                        EndPoint="28,28"
                                        MappingMode="Absolute"
                                        SpreadMethod="Repeat"
                                        StartPoint="0,0">
                                        <GradientStop Color="#24000000" Offset="0"/>
                                        <GradientStop Color="#24000000" Offset="0.5"/>
                                        <GradientStop Color="#10000000" Offset="0.5"/>
                                        <GradientStop Color="#10000000" Offset="1"/>
                                    </LinearGradientBrush>
                                </Rectangle.OpacityMask>
                            </Rectangle>
                            <DockPanel Background="Transparent" Margin="0,10">
                                <!-- Status Message block -->
                                <StackPanel
                                    Orientation="Horizontal"
                                    DockPanel.Dock="Top"
                                    Margin="48,0,0,0"
                                    Visibility="{Binding Path=StatusVisibility}">
                                    <!-- Status Message -->
                                    <TextBlock
                                        FontWeight="Bold"
                                        Margin="0,0,10,0"
                                        Text="{qt:Resx Key=Options_Page12_Plugins}">
                                        <TextBlock.Foreground>
                                            <SolidColorBrush Color="{Binding Path=StatusColor}"/>
                                        </TextBlock.Foreground>
                                        <TextBlock.Style>
                                            <Style TargetType="{x:Type TextBlock}">
                                                <Setter Property="qt:Resx.Index" Value="{Binding Path=StatusTextIdx}"/>
                                                <Setter Property="qt:Resx.Param" Value="{Binding Path=Name}"/>
                                            </Style>
                                        </TextBlock.Style>
                                    </TextBlock>
                                    <!-- Undo link -->
                                    <TextBlock
                                        Cursor="Hand"
                                        FontWeight="Bold"
                                        MouseUp="txtUndo_MouseUp"
                                        TextDecorations="Underline"
                                        Text="{qt:Resx Key=DialogButtons, Index=13}">
                                        <TextBlock.Style>
                                            <Style TargetType="{x:Type TextBlock}">
                                                <Setter Property="Foreground" Value="RoyalBlue"/>
                                                <Style.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter Property="Foreground" Value="DodgerBlue"/>
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </TextBlock.Style>
                                    </TextBlock>
                                </StackPanel>
                                <DockPanel
                                    Background="Transparent"
                                    Visibility="{Binding Path=MainBodyVisibility}">
                                    <DockPanel.Resources>
                                        <Style TargetType="{x:Type TextBlock}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=Enabled}" Value="False">
                                                    <Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </DockPanel.Resources>
                                    <!-- Icon -->
                                    <Grid
                                        DockPanel.Dock="Left"
                                        VerticalAlignment="Top"
                                        Width="48"
                                        Height="48">
                                        <Image
                                            Opacity="{Binding Path=IconOpacity}"
                                            VerticalAlignment="Center"
                                            HorizontalAlignment="Center"
                                            Stretch="None"
                                            RenderOptions.BitmapScalingMode="NearestNeighbor"
                                            Source="{Binding Path=Icon, Converter={StaticResource BitmapToImageSourceConverter}}"/>
                                    </Grid>
                                    <!-- Title and Author -->
                                    <StackPanel 
                                        DockPanel.Dock="Top"
                                        Orientation="Horizontal">
                                        <TextBlock 
                                            Text="{Binding Path=Title}"
                                            FontSize="15"
                                            FontWeight="ExtraBold"
                                            Margin="2"
                                            VerticalAlignment="Bottom"/>
                                        <TextBlock 
                                            Text="{qt:Resx Key=Options_Page12_Plugins, Index=2}"
                                            FontSize="15"
                                            FontWeight="ExtraBold"
                                            Margin="8,2"
                                            VerticalAlignment="Bottom"
                                            Visibility="{Binding Path=ShowDisabledTitle, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <TextBlock
                                            Text="{qt:Resx Key=Options_Page12_Plugins, Index=3}"
                                            Margin="10,2"
                                            VerticalAlignment="Bottom">
                                            <TextBlock.Style>
                                                <Style TargetType="{x:Type TextBlock}">
                                                    <!-- If I set this directly, it doesn't work.  No idea why... -->
                                                    <Setter Property="qt:Resx.Param" Value="{Binding Path=Author}"/>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </StackPanel>
                                    <!-- Buttons -->
                                    <StackPanel
                                        VerticalAlignment="Bottom"
                                        Orientation="Horizontal"
                                        DockPanel.Dock="Right">
                                        <StackPanel.Resources>
                                            <Style TargetType="{x:Type Button}">
                                                <Setter Property="DockPanel.Dock" Value="Right"/>
                                                <Setter Property="Height" Value="22"/>
                                                <Setter Property="Width" Value="70"/>
                                                <Setter Property="Margin" Value="3,0"/>
                                            </Style>
                                        </StackPanel.Resources>
                                        <Button x:Name="btnPluginOptions"
                                            Click="btnPluginOptions_Click"
                                            Content="{qt:Resx Key=DialogButtons, Index=10}"
                                            Visibility="{Binding Path=HasOptions, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <Button x:Name="btnPluginDisable"
                                            Click="btnPluginEnableDisable_Click"
                                            Content="{qt:Resx Key=DialogButtons, Index=12}"
                                            Visibility="{Binding Path=ShowDisableButton, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <Button x:Name="btnPluginEnable"
                                            Click="btnPluginEnableDisable_Click"
                                            Content="{qt:Resx Key=DialogButtons, Index=11}"
                                            Visibility="{Binding Path=ShowEnableButton, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                                        <Button x:Name="btnPluginRemove"
                                            Click="btnPluginRemove_Click"
                                            Content="{qt:Resx Key=DialogButtons, Index=9}"/>
                                    </StackPanel>
                                    <!-- Description -->
                                    <TextBlock 
                                        Text="{Binding Path=Desc}"
                                        Margin="2"
                                        HorizontalAlignment="Left"
                                        TextWrapping="Wrap"
                                        TextTrimming="CharacterEllipsis"
                                        MaxHeight="50"/>
                                </DockPanel>
                            </DockPanel>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </qt:RestrictDesiredSize>
    </DockPanel>
</qt:OptionsDialogTab>
