<reactiveui:ReactiveWindow
    x:Class="v2rayN.Views.RoutingSettingWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="clr-namespace:v2rayN.Converters"
    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:v2rayN.Resx"
    xmlns:vms="clr-namespace:v2rayN.ViewModels"
    Title="{x:Static resx:ResUI.menuRoutingSetting}"
    Width="900"
    Height="700"
    x:TypeArguments="vms:RoutingSettingViewModel"
    Background="{DynamicResource MaterialDesignPaper}"
    FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
    ResizeMode="NoResize"
    TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    TextOptions.TextFormattingMode="Display"
    TextOptions.TextRenderingMode="Auto"
    WindowStartupLocation="CenterScreen"
    mc:Ignorable="d">
    <Window.Resources>
        <ResourceDictionary>
            <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
        </ResourceDictionary>
    </Window.Resources>
    <DockPanel>
        <ToolBarTray DockPanel.Dock="Top">
            <ToolBar
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                ClipToBounds="True"
                Style="{StaticResource MaterialDesignToolBar}">
                <Menu Margin="0,8" Style="{StaticResource ToolbarMenu}">
                    <MenuItem x:Name="menuRoutingBasic" Padding="8,0">
                        <MenuItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <materialDesign:PackIcon Margin="0,0,8,0" Kind="Server" />
                                <TextBlock Text="{x:Static resx:ResUI.menuRoutingBasic}" />
                            </StackPanel>
                        </MenuItem.Header>
                        <MenuItem
                            x:Name="menuRoutingBasicImportRules"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuRoutingBasicImportRules}" />
                    </MenuItem>
                </Menu>
                <Separator />
                <Menu Margin="0,8" Style="{StaticResource ToolbarMenu}">
                    <MenuItem x:Name="menuRoutingAdvanced" Padding="8,0">
                        <MenuItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <materialDesign:PackIcon Margin="0,0,8,0" Kind="Routes" />
                                <TextBlock Text="{x:Static resx:ResUI.menuRoutingAdvanced}" />
                            </StackPanel>
                        </MenuItem.Header>
                        <MenuItem
                            x:Name="menuRoutingAdvancedAdd2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuRoutingAdvancedAdd}" />
                        <MenuItem
                            x:Name="menuRoutingAdvancedImportRules2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuRoutingAdvancedImportRules}" />
                    </MenuItem>
                </Menu>
                <Separator />
                <TextBlock
                    Margin="8,0,0,0"
                    VerticalAlignment="Center"
                    Style="{StaticResource ToolbarTextBlock}"
                    Text="{x:Static resx:ResUI.TbenableRoutingAdvanced}" />
                <ToggleButton
                    x:Name="togenableRoutingAdvanced"
                    Margin="8,0,0,0"
                    HorizontalAlignment="Left" />
                <Separator />
                <TextBlock
                    Margin="8,0,0,0"
                    VerticalAlignment="Center"
                    Style="{StaticResource ToolbarTextBlock}">
                    <Hyperlink Click="linkdomainStrategy_Click">
                        <TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy}" />
                    </Hyperlink>
                </TextBlock>
                <ComboBox
                    x:Name="cmbdomainStrategy"
                    Width="110"
                    Margin="8,0,0,0"
                    Style="{StaticResource DefComboBox}" />
                <Separator />
                <TextBlock
                    Margin="8,0,0,0"
                    VerticalAlignment="Center"
                    Style="{StaticResource ToolbarTextBlock}"
                    Text="{x:Static resx:ResUI.TbdomainMatcher}" />
                <ComboBox
                    x:Name="cmbdomainMatcher"
                    Width="80"
                    Margin="8,0,0,0"
                    Style="{StaticResource DefComboBox}" />

            </ToolBar>
        </ToolBarTray>

        <Grid
            Margin="16"
            HorizontalAlignment="Center"
            DockPanel.Dock="Bottom">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="600" />
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="100" />
            </Grid.ColumnDefinitions>
            <StackPanel
                Grid.Column="0"
                HorizontalAlignment="Left"
                VerticalAlignment="Center">
                <TextBlock Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.TbRoutingTips}" />
            </StackPanel>
            <Button
                x:Name="btnSave"
                Grid.Column="1"
                Margin="4"
                Content="{x:Static resx:ResUI.TbConfirm}"
                Cursor="Hand"
                Style="{StaticResource DefButton}" />
            <Button
                x:Name="btnCancel"
                Grid.Column="2"
                Margin="4"
                Click="btnCancel_Click"
                Content="{x:Static resx:ResUI.TbCancel}"
                Cursor="Hand"
                IsCancel="true"
                Style="{StaticResource DefButton}" />
        </Grid>

        <DockPanel>
            <TabControl x:Name="tabAdvanced">
                <TabItem HorizontalAlignment="Left" Header="{x:Static resx:ResUI.TbRoutingTabRuleList}">
                    <DataGrid
                        x:Name="lstRoutings"
                        AutoGenerateColumns="False"
                        BorderThickness="1"
                        CanUserAddRows="False"
                        CanUserResizeRows="False"
                        CanUserSortColumns="False"
                        EnableRowVirtualization="True"
                        GridLinesVisibility="All"
                        HeadersVisibility="Column"
                        IsReadOnly="True"
                        Style="{StaticResource DefDataGrid}">
                        <DataGrid.ContextMenu>
                            <ContextMenu Style="{StaticResource DefContextMenu}">
                                <MenuItem
                                    x:Name="menuRoutingAdvancedAdd"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRoutingAdvancedAdd}" />
                                <MenuItem
                                    x:Name="menuRoutingAdvancedRemove"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRoutingAdvancedRemove}" />
                                <MenuItem
                                    x:Name="menuRoutingAdvancedSelectAll"
                                    Height="{StaticResource MenuItemHeight}"
                                    Click="menuRoutingAdvancedSelectAll_Click"
                                    Header="{x:Static resx:ResUI.menuSelectAll}" />
                                <MenuItem
                                    x:Name="menuRoutingAdvancedSetDefault"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRoutingAdvancedSetDefault}" />
                                <Separator />
                                <MenuItem
                                    x:Name="menuRoutingAdvancedImportRules"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRoutingAdvancedImportRules}" />
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Width="50">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Border
                                            Width="auto"
                                            Height="auto"
                                            Background="{DynamicResource PrimaryHueLightBrush}"
                                            Visibility="{Binding Path=isActive, Converter={StaticResource BoolToVisConverter}}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn
                                Width="200"
                                Binding="{Binding remarks}"
                                Header="{x:Static resx:ResUI.LvAlias}" />
                            <DataGridTextColumn
                                Width="70"
                                Binding="{Binding ruleNum}"
                                Header="{x:Static resx:ResUI.LvCount}" />
                            <DataGridTextColumn
                                Width="280"
                                Binding="{Binding url}"
                                Header="{x:Static resx:ResUI.LvUrl}" />
                            <DataGridTextColumn
                                Width="280"
                                Binding="{Binding customIcon}"
                                Header="{x:Static resx:ResUI.LvCustomIcon}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem>
            </TabControl>

            <TabControl x:Name="tabBasic">
                <TabItem Header="{x:Static resx:ResUI.TbRoutingTabProxy}">
                    <Grid Margin="{StaticResource SettingItemMargin}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <GroupBox
                            Grid.Column="0"
                            Header="Domain"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtProxyDomain"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
                        <GroupBox
                            Grid.Column="2"
                            Header="IP"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtProxyIP"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                    </Grid>
                </TabItem>

                <TabItem Header="{x:Static resx:ResUI.TbRoutingTabDirect}">
                    <Grid Margin="{StaticResource SettingItemMargin}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <GroupBox
                            Grid.Column="0"
                            Header="Domain"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtDirectDomain"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
                        <GroupBox
                            Grid.Column="2"
                            Header="IP"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtDirectIP"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                    </Grid>
                </TabItem>

                <TabItem Header="{x:Static resx:ResUI.TbRoutingTabBlock}">
                    <Grid Margin="{StaticResource SettingItemMargin}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1*" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <GroupBox
                            Grid.Column="0"
                            Header="Domain"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtBlockDomain"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
                        <GroupBox
                            Grid.Column="2"
                            Header="IP"
                            Style="{StaticResource MaterialDesignGroupBox}">
                            <TextBox
                                Name="txtBlockIP"
                                AcceptsReturn="True"
                                TextWrapping="Wrap"
                                VerticalScrollBarVisibility="Auto" />
                        </GroupBox>
                    </Grid>
                </TabItem>
            </TabControl>
        </DockPanel>
    </DockPanel>

</reactiveui:ReactiveWindow>
