<Window
    x:Class="v2rayN.Desktop.Views.DNSSettingWindow"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:v2rayN.Desktop.Views"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
    xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
    Title="{x:Static resx:ResUI.menuDNSSetting}"
    Width="900"
    Height="600"
    x:DataType="vms:DNSSettingViewModel"
    ShowInTaskbar="False"
    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"
                Content="{x:Static resx:ResUI.TbConfirm}"
                IsDefault="True" />
            <Button
                x:Name="btnCancel"
                Width="100"
                Margin="{StaticResource MarginLr8}"
                Content="{x:Static resx:ResUI.TbCancel}"
                IsCancel="True" />
        </StackPanel>

        <TabControl HorizontalContentAlignment="Stretch">
            <TabItem Header="{x:Static resx:ResUI.ThBasicDNSSettings}">
                <ScrollViewer VerticalScrollBarVisibility="Visible">
                    <Grid
                        x:Name="gridBasicDNSSettings"
                        Margin="{StaticResource Margin8}"
                        ColumnDefinitions="Auto,Auto,*"
                        RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto">

                        <TextBlock
                            x:Name="txtBasicDNSSettingsInvalid"
                            Grid.Row="0"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbCustomDNSEnabledPageInvalid}" />

                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbDomesticDNS}" />
                        <ComboBox
                            x:Name="cmbDirectDNS"
                            Grid.Row="1"
                            Grid.Column="1"
                            Width="300"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            IsEditable="True" />
                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbDomesticDNSTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbRemoteDNS}" />
                        <ComboBox
                            x:Name="cmbRemoteDNS"
                            Grid.Row="2"
                            Grid.Column="1"
                            Width="300"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            IsEditable="True" />
                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbRemoteDNSTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbBootstrapDNS}" />
                        <ComboBox
                            x:Name="cmbBootstrapDNS"
                            Grid.Row="3"
                            Grid.Column="1"
                            Width="300"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            IsEditable="True" />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbBootstrapDNSTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbDirectResolveStrategy}" />
                        <ComboBox
                            x:Name="cmbDirectDNSStrategy"
                            Grid.Row="5"
                            Grid.Column="1"
                            Width="200"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            PlaceholderText="Default" />
                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbDirectResolveStrategyTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbRemoteResolveStrategy}" />
                        <ComboBox
                            x:Name="cmbRemoteDNSStrategy"
                            Grid.Row="6"
                            Grid.Column="1"
                            Width="200"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            PlaceholderText="Default" />
                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbRemoteResolveStrategyTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="7"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbParallelQuery}" />
                        <ToggleSwitch
                            x:Name="togParallelQuery"
                            Grid.Row="7"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />

                        <TextBlock
                            Grid.Row="8"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbServeStale}" />
                        <ToggleSwitch
                            x:Name="togServeStale"
                            Grid.Row="8"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />
                    </Grid>
                </ScrollViewer>
            </TabItem>

            <TabItem Header="{x:Static resx:ResUI.ThAdvancedDNSSettings}">
                <ScrollViewer VerticalScrollBarVisibility="Visible">
                    <Grid
                        x:Name="gridAdvancedDNSSettings"
                        Margin="{StaticResource Margin8}"
                        ColumnDefinitions="Auto,Auto,*"
                        RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,*">

                        <TextBlock
                            x:Name="txtAdvancedDNSSettingsInvalid"
                            Grid.Row="0"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbCustomDNSEnabledPageInvalid}" />

                        <TextBlock
                            Grid.Row="1"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbSettingsUseSystemHosts}" />
                        <ToggleSwitch
                            x:Name="togUseSystemHosts"
                            Grid.Row="1"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />

                        <TextBlock
                            Grid.Row="2"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbAddCommonDNSHosts}" />
                        <ToggleSwitch
                            x:Name="togAddCommonHosts"
                            Grid.Row="2"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />

                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbFakeIP}" />
                        <ToggleSwitch
                            x:Name="togFakeIP"
                            Grid.Row="3"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />
                        <TextBlock
                            Grid.Row="3"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbFakeIPTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="4"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbBlockSVCBHTTPSQueries}" />
                        <ToggleSwitch
                            x:Name="togBlockBindingQuery"
                            Grid.Row="4"
                            Grid.Column="1"
                            Margin="{StaticResource Margin4}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center" />
                        <TextBlock
                            Grid.Row="4"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbBlockSVCBHTTPSQueriesTips}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="0"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbValidateDirectExpectedIPs}" />
                        <ComboBox
                            x:Name="cmbDirectExpectedIPs"
                            Grid.Row="5"
                            Grid.Column="1"
                            Width="200"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            IsEditable="True" />
                        <TextBlock
                            Grid.Row="5"
                            Grid.Column="2"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbValidateDirectExpectedIPsDesc}"
                            TextWrapping="Wrap" />

                        <TextBlock
                            Grid.Row="6"
                            Grid.Column="0"
                            Grid.ColumnSpan="3"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Center"
                            Text="{x:Static resx:ResUI.TbDNSHostsConfig}" />

                        <TextBox
                            x:Name="txtHosts"
                            Grid.Row="7"
                            Grid.Column="0"
                            Grid.ColumnSpan="3"
                            Margin="{StaticResource Margin4}"
                            VerticalAlignment="Stretch"
                            BorderThickness="1"
                            Classes="TextArea"
                            TextWrapping="Wrap"
                            Watermark="{x:Static resx:ResUI.TbDNSHostsConfig}" />
                    </Grid>
                </ScrollViewer>
            </TabItem>

            <TabItem Header="{x:Static resx:ResUI.TbCustomDnsRay}">
                <DockPanel Margin="{StaticResource Margin8}">
                    <Grid DockPanel.Dock="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbCustomDNSEnable}" />
                            <ToggleSwitch
                                x:Name="togRayCustomDNSEnableCompatible"
                                Margin="{StaticResource Margin4}"
                                HorizontalAlignment="Left" />
                        </StackPanel>

                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsRemoteDNS}" />

                            <TextBlock Margin="{StaticResource Margin4}" VerticalAlignment="Center">
                                <HyperlinkButton Classes="WithIcon" Click="linkDnsObjectDoc_Click">
                                    <TextBlock Text="{x:Static resx:ResUI.TbDnsObjectDoc}" />
                                </HyperlinkButton>
                            </TextBlock>
                            <Button
                                x:Name="btnImportDefConfig4V2rayCompatible"
                                Margin="{StaticResource Margin4}"
                                Content="{x:Static resx:ResUI.TbSettingDnsImportDefConfig}" />
                        </StackPanel>
                    </Grid>

                    <WrapPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsUseSystemHosts}" />
                            <ToggleSwitch
                                x:Name="togUseSystemHostsCompatible"
                                Margin="{StaticResource Margin4}"
                                HorizontalAlignment="Left" />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Freedom}" />
                            <ComboBox
                                x:Name="cmbdomainStrategy4FreedomCompatible"
                                Width="150"
                                Margin="{StaticResource Margin4}" />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsDomainDNSAddress}" />
                            <ComboBox
                                x:Name="cmbdomainDNSAddressCompatible"
                                Width="150"
                                Margin="{StaticResource Margin4}"
                                IsEditable="True" />
                        </StackPanel>
                    </WrapPanel>

                    <Grid Margin="{StaticResource Margin4}" ColumnDefinitions="*,10,*">

                        <HeaderedContentControl
                            Grid.Column="0"
                            BorderBrush="Gray"
                            BorderThickness="1"
                            Header="HTTP/SOCKS">
                            <local:JsonEditor Name="txtnormalDNSCompatible" VerticalAlignment="Stretch" />
                        </HeaderedContentControl>

                        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />

                        <HeaderedContentControl
                            Grid.Column="2"
                            BorderBrush="Gray"
                            BorderThickness="1"
                            Header="{x:Static resx:ResUI.TbSettingsTunMode}">
                            <local:JsonEditor Name="txttunDNSCompatible" VerticalAlignment="Stretch" />
                        </HeaderedContentControl>
                    </Grid>
                </DockPanel>
            </TabItem>

            <TabItem Header="{x:Static resx:ResUI.TbCustomDnsSingbox}">
                <DockPanel Margin="{StaticResource Margin8}">
                    <Grid DockPanel.Dock="Top">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbCustomDNSEnable}" />
                            <ToggleSwitch
                                x:Name="togSBCustomDNSEnableCompatible"
                                Margin="{StaticResource Margin4}"
                                HorizontalAlignment="Left" />
                        </StackPanel>

                        <StackPanel Grid.Row="1" Orientation="Horizontal">
                            <TextBlock Margin="{StaticResource Margin4}" VerticalAlignment="Center">
                                <HyperlinkButton Classes="WithIcon" Click="linkDnsSingboxObjectDoc_Click">
                                    <TextBlock Text="{x:Static resx:ResUI.TbDnsSingboxObjectDoc}" />
                                </HyperlinkButton>
                            </TextBlock>
                            <Button
                                x:Name="btnImportDefConfig4SingboxCompatible"
                                Margin="{StaticResource Margin4}"
                                Content="{x:Static resx:ResUI.TbSettingDnsImportDefConfig}" />
                        </StackPanel>
                    </Grid>

                    <WrapPanel DockPanel.Dock="Bottom" Orientation="Horizontal">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsDomainStrategy4Out}" />
                            <ComboBox
                                x:Name="cmbdomainStrategy4OutCompatible"
                                Width="150"
                                Margin="{StaticResource Margin4}" />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock
                                Margin="{StaticResource Margin4}"
                                VerticalAlignment="Center"
                                Text="{x:Static resx:ResUI.TbSettingsDomainDNSAddress}" />
                            <ComboBox
                                x:Name="cmbdomainDNSAddress2Compatible"
                                Width="150"
                                Margin="{StaticResource Margin4}"
                                IsEditable="True" />
                        </StackPanel>
                    </WrapPanel>

                    <Grid Margin="{StaticResource Margin4}" ColumnDefinitions="*,10,*">

                        <HeaderedContentControl
                            Grid.Column="0"
                            BorderBrush="Gray"
                            BorderThickness="1"
                            Header="HTTP/SOCKS">
                            <local:JsonEditor Name="txtnormalDNS2Compatible" VerticalAlignment="Stretch" />
                        </HeaderedContentControl>

                        <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />

                        <HeaderedContentControl
                            Grid.Column="2"
                            BorderBrush="Gray"
                            BorderThickness="1"
                            Header="{x:Static resx:ResUI.TbSettingsTunMode}">
                            <local:JsonEditor Name="txttunDNS2Compatible" VerticalAlignment="Stretch" />
                        </HeaderedContentControl>

                    </Grid>
                </DockPanel>
            </TabItem>
        </TabControl>
    </DockPanel>
</Window>
