<?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"
    xmlns:r="clr-namespace:Ricciolo.Controls;assembly=Ricciolo.Controls.TreeListView"
    x:Class="QTTabBarLib.Options09_Groups"
    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.imgTabGroups}, Converter={StaticResource BitmapToImageSourceConverter}}"
                Style="{StaticResource PageHeaderImageStyle}"/>
            <Label
                Content="{qt:Resx Key=Options_Page09_Groups, Index=0}"
                FontSize="13"
                VerticalAlignment="Bottom"/>
        </StackPanel>
        <TextBlock 
            Text="{qt:Resx Key=Options_Page09_Groups, Index=1}" 
            TextWrapping="Wrap"
            DockPanel.Dock="Top"
            Margin="5,10,5,5"/>
        <Grid
            DockPanel.Dock="Top"
            Margin="0,5,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnGroupsMoveNodeUp"
                Content="&#9650;"
                Height="23"
                Margin="4"
                Width="28"
                Click="btnGroupsMoveNodeUpDown_Click" />
            <Button x:Name="btnGroupsMoveNodeDown"
                Content="&#9660;"
                Grid.Column="1"
                Height="23"
                Margin="4"
                Width="28"
                Click="btnGroupsMoveNodeUpDown_Click" />
            <Button x:Name="btnGroupsAddGroup" 
                Content="{qt:Resx Key=Options_Page09_Groups, Index=2}"
                Grid.Column="3"
                Height="23"
                Margin="4"
                Width="120"
                Click="btnGroupsAddGroup_Click" />
            <Button x:Name="btnGroupsAddFolder"
                Content="{qt:Resx Key=DialogButtons, Index=8}"
                Grid.Column="4"
                Height="23"
                Margin="4"
                Width="70"
                Click="btnGroupsAddFolder_Click" />
            <Button x:Name="btnGroupsRemoveNode"
                Content="{qt:Resx Key=DialogButtons, Index=9}"
                Grid.Column="5"
                Height="23"
                Margin="4"
                Width="70"
                Click="btnGroupsRemoveNode_Click" />
        </Grid>
        <qt:RestrictDesiredSize MinHeight="200">
            <r:TreeListView x:Name="tvwGroups"
                MouseDown="tvwGroups_MouseDown"
                PreviewKeyDown="tvwGroups_PreviewKeyDown">
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                        <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}" />
                    </Style>
                </TreeView.ItemContainerStyle>
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate ItemsSource="{Binding Path=Folders}"/>
                </TreeView.ItemTemplate>
                <r:TreeListView.Columns>
                    <GridViewColumn Header="{qt:Resx Key=Options_Page09_Groups, Index=3}" Width="300">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel
                                    Orientation="Horizontal"
                                    VerticalAlignment="Center">
                                    <Image
                                        Source="{Binding Path=Icon, Converter={StaticResource BitmapToImageSourceConverter}}"
                                        Width="16"
                                        Height="16"
                                        Stretch="Fill"
                                        Margin="0,0,2,0"/>
                                    <qt:EditableHeader x:Name="ehrName"
                                        Container="{Binding RelativeSource={RelativeSource AncestorType={x:Type r:TreeListViewItem}}}"
                                        IsEditing="{Binding Path=IsEditing}"
                                        Margin="0"/>
                                </StackPanel>
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry">
                                        <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=Name}"/>
                                    </DataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="FolderEntry"/>
                                            <Condition Binding="{Binding Path=IsVirtualFolder}" Value="False"/>
                                        </MultiDataTrigger.Conditions>
                                        <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=Path}"/>
                                    </MultiDataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="FolderEntry"/>
                                            <Condition Binding="{Binding Path=IsVirtualFolder}" Value="True"/>
                                        </MultiDataTrigger.Conditions>
                                        <Setter TargetName="ehrName" Property="Text" Value="{Binding Path=DisplayText, Mode=OneWay}"/>
                                        <Setter TargetName="ehrName" Property="ReadOnly" Value="True"/>
                                    </MultiDataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="{qt:Resx Key=Options_Page09_Groups, Index=4}" Width="60">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox x:Name="chkStartup"
                                    IsChecked="{Binding Path=Startup}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Visibility="Collapsed" />
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry">
                                        <Setter TargetName="chkStartup" Property="Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="{qt:Resx Key=Options_Page09_Groups, Index=5}" Width="100">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock x:Name="txtHotkey"
                                    Text="{Binding Path=HotkeyString}"
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    Visibility="Collapsed" />
                                <DataTemplate.Triggers>
                                    <DataTrigger Binding="{Binding Converter={StaticResource ObjectToClassNameConverter}}" Value="GroupEntry">
                                        <Setter TargetName="txtHotkey" Property="Visibility" Value="Visible"/>
                                    </DataTrigger>
                                </DataTemplate.Triggers>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </r:TreeListView.Columns>
            </r:TreeListView>
        </qt:RestrictDesiredSize>
    </DockPanel>
</qt:OptionsDialogTab>
