<base:WindowBase
    x:Class="v2rayN.Views.ProfilesSelectWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="clr-namespace:v2rayN.Base"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:reactiveui="http://reactiveui.net"
    xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
    xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
    Title="{x:Static resx:ResUI.TbSelectProfile}"
    Width="800"
    Height="450"
    x:TypeArguments="vms:ProfilesSelectViewModel"
    Style="{StaticResource WindowGlobal}"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">

    <DockPanel Margin="{StaticResource Margin8}">
        <StackPanel
            Margin="{StaticResource Margin4}"
            HorizontalAlignment="Center"
            DockPanel.Dock="Bottom"
            Orientation="Horizontal">
            <Button
                x:Name="btnSave"
                Width="100"
                Click="BtnSave_Click"
                Content="{x:Static resx:ResUI.TbConfirm}"
                IsDefault="True"
                Style="{StaticResource DefButton}" />
            <Button
                x:Name="btnCancel"
                Width="100"
                Margin="{StaticResource MarginLeftRight8}"
                Content="{x:Static resx:ResUI.TbCancel}"
                IsCancel="true"
                Style="{StaticResource DefButton}" />
        </StackPanel>
        <Grid>
            <DockPanel>
                <WrapPanel Margin="{StaticResource Margin4}" DockPanel.Dock="Top">
                    <ListBox
                        x:Name="lstGroup"
                        MaxHeight="200"
                        AutomationProperties.Name="{x:Static resx:ResUI.menuSubscription}"
                        FontSize="{DynamicResource StdFontSize}"
                        ItemContainerStyle="{StaticResource MyChipListBoxItem}"
                        Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Remarks}" />
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                    <Button
                        x:Name="btnAutofitColumnWidth"
                        Width="30"
                        Height="30"
                        Margin="{StaticResource MarginLeftRight8}"
                        AutomationProperties.Name="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}"
                        Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
                        ToolTip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}">
                        <materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowSplitVertical" />
                    </Button>
                    <TextBox
                        x:Name="txtServerFilter"
                        Width="200"
                        Margin="{StaticResource MarginLeftRight4}"
                        VerticalContentAlignment="Center"
                        materialDesign:HintAssist.Hint="{x:Static resx:ResUI.MsgServerTitle}"
                        materialDesign:TextFieldAssist.HasClearButton="True"
                        AutomationProperties.Name="{x:Static resx:ResUI.MsgServerTitle}"
                        Style="{StaticResource DefTextBox}" />
                </WrapPanel>
                <DataGrid
                    x:Name="lstProfiles"
                    materialDesign:DataGridAssist.CellPadding="2,2"
                    AutoGenerateColumns="False"
                    BorderThickness="1"
                    CanUserAddRows="False"
                    CanUserResizeRows="False"
                    CanUserSortColumns="False"
                    EnableRowVirtualization="True"
                    Focusable="True"
                    GridLinesVisibility="All"
                    HeadersVisibility="All"
                    IsReadOnly="True"
                    RowHeaderWidth="40"
                    SelectionMode="Single"
                    Style="{StaticResource DefDataGrid}">
                    <DataGrid.InputBindings>
                        <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Enter" />
                    </DataGrid.InputBindings>
                    <DataGrid.Resources>
                        <Style BasedOn="{StaticResource MaterialDesignDataGridRow}" TargetType="DataGridRow">
                            <EventSetter Event="MouseDoubleClick" Handler="LstProfiles_MouseDoubleClick" />
                        </Style>
                        <Style BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}" TargetType="DataGridColumnHeader">
                            <EventSetter Event="Click" Handler="LstProfiles_ColumnHeader_Click" />
                        </Style>

                        <Style BasedOn="{StaticResource MaterialDesignDataGridCell}" TargetType="DataGridCell">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsActive}" Value="True">
                                    <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
                                    <Setter Property="Foreground" Value="Black" />
                                    <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Primary.Light}" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </DataGrid.Resources>
                    <DataGrid.Columns>
                        <base:MyDGTextColumn
                            Width="80"
                            Binding="{Binding ConfigType}"
                            ExName="ConfigType"
                            Header="{x:Static resx:ResUI.LvServiceType}" />
                        <base:MyDGTextColumn
                            Width="150"
                            Binding="{Binding Remarks}"
                            ExName="Remarks"
                            Header="{x:Static resx:ResUI.LvRemarks}" />
                        <base:MyDGTextColumn
                            Width="120"
                            Binding="{Binding Address}"
                            ExName="Address"
                            Header="{x:Static resx:ResUI.LvAddress}" />
                        <base:MyDGTextColumn
                            Width="60"
                            Binding="{Binding Port}"
                            ExName="Port"
                            Header="{x:Static resx:ResUI.LvPort}" />
                        <base:MyDGTextColumn
                            Width="100"
                            Binding="{Binding Network}"
                            ExName="Network"
                            Header="{x:Static resx:ResUI.LvTransportProtocol}" />
                        <base:MyDGTextColumn
                            Width="100"
                            Binding="{Binding StreamSecurity}"
                            ExName="StreamSecurity"
                            Header="{x:Static resx:ResUI.LvTLS}" />
                        <base:MyDGTextColumn
                            Width="100"
                            Binding="{Binding SubRemarks}"
                            ExName="SubRemarks"
                            Header="{x:Static resx:ResUI.LvSubscription}" />
                    </DataGrid.Columns>
                </DataGrid>
            </DockPanel>
        </Grid>
    </DockPanel>
</base:WindowBase>
