<reactiveui:ReactiveWindow
    x:Class="v2rayN.Views.MainWindow"
    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:conv="clr-namespace:v2rayN.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:v2rayN.Views"
    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:tb="http://www.hardcodet.net/taskbar"
    xmlns:vms="clr-namespace:v2rayN.ViewModels"
    Title="v2rayN"
    Width="900"
    Height="700"
    MinWidth="800"
    MinHeight="600"
    x:TypeArguments="vms:MainWindowViewModel"
    Background="{DynamicResource MaterialDesignPaper}"
    FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
    ShowInTaskbar="True"
    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>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Popupbox.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
            <conv:DelayColorConverter x:Key="DelayColorConverter" />
        </ResourceDictionary>
    </Window.Resources>

    <materialDesign:DialogHost
        Identifier="RootDialog"
        SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}"
        Style="{StaticResource MaterialDesignEmbeddedDialogHost}">
        <Grid>
            <DockPanel>
                <ToolBarTray DockPanel.Dock="Top">
                    <ToolBar
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        ClipToBounds="True"
                        Style="{StaticResource MaterialDesignToolBar}">
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="Server" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuServers}" />
                                    </StackPanel>
                                </MenuItem.Header>
                                <MenuItem
                                    x:Name="menuAddCustomServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddCustomServer}" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuAddVmessServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddVmessServer}" />
                                <MenuItem
                                    x:Name="menuAddVlessServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddVlessServer}" />
                                <MenuItem
                                    x:Name="menuAddShadowsocksServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddShadowsocksServer}" />
                                <MenuItem
                                    x:Name="menuAddSocksServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddSocksServer}" />
                                <MenuItem
                                    x:Name="menuAddTrojanServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddTrojanServer}" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuAddServerViaClipboard"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
                                <MenuItem
                                    x:Name="menuAddServerViaScan"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuAddServerViaScan}" />

                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="BookClockOutline" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuSubscription}" />
                                    </StackPanel>
                                </MenuItem.Header>
                                <MenuItem
                                    x:Name="menuSubSetting"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSubSetting}" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuSubUpdate"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSubUpdate}" />
                                <MenuItem
                                    x:Name="menuSubUpdateViaProxy"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
                                <MenuItem
                                    x:Name="menuSubGroupUpdate"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSubGroupUpdate}" />
                                <MenuItem
                                    x:Name="menuSubGroupUpdateViaProxy"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSubGroupUpdateViaProxy}" />
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="SettingsOutline" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuSetting}" />
                                    </StackPanel>
                                </MenuItem.Header>
                                <MenuItem
                                    x:Name="menuOptionSetting"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuOptionSetting}" />
                                <MenuItem
                                    x:Name="menuRoutingSetting"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRoutingSetting}" />
                                <MenuItem
                                    x:Name="menuGlobalHotkeySetting"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuGlobalHotkeySetting}" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuSettingsSetUWP"
                                    Height="{StaticResource MenuItemHeight}"
                                    Click="menuSettingsSetUWP_Click"
                                    Header="{x:Static resx:ResUI.TbSettingsSetUWP}" />
                                <MenuItem
                                    x:Name="menuClearServerStatistics"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuClearServerStatistics}" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuImportOldGuiConfig"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuImportOldGuiConfig}" />
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem x:Name="menuReload" Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="Reload" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuReload}" />
                                    </StackPanel>
                                </MenuItem.Header>
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="Update" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuCheckUpdate}" />
                                    </StackPanel>
                                </MenuItem.Header>
                                <MenuItem
                                    x:Name="menuCheckUpdateN"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="v2rayN" />
                                <MenuItem
                                    x:Name="menuCheckUpdateV2flyCore"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="V2fly v5 Core" />
                                <MenuItem
                                    x:Name="menuCheckUpdateSagerNetCore"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="SagerNet Core" />
                                <MenuItem
                                    x:Name="menuCheckUpdateXrayCore"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="Xray Core" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuCheckUpdateClashCore"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="Clash Core" />
                                <MenuItem
                                    x:Name="menuCheckUpdateClashMetaCore"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="Clash.Meta Core" />
                                <Separator Margin="-40,5" />
                                <MenuItem
                                    x:Name="menuCheckUpdateGeo"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="Geo files" />
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem x:Name="menuHelp" Padding="8,0">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="HelpCircleOutline" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuHelp}" />
                                    </StackPanel>
                                </MenuItem.Header>
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem
                                x:Name="menuPromotion"
                                Padding="8,0"
                                Click="menuPromotion_Click">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="VolumeHigh" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuPromotion}" />
                                    </StackPanel>
                                </MenuItem.Header>
                            </MenuItem>
                        </Menu>
                        <Separator />
                        <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
                            <MenuItem
                                x:Name="menuClose"
                                Padding="8,0"
                                Click="menuClose_Click">
                                <MenuItem.Header>
                                    <StackPanel Orientation="Horizontal">
                                        <materialDesign:PackIcon Margin="0,0,8,0" Kind="Minimize" />
                                        <TextBlock Text="{x:Static resx:ResUI.menuClose}" />
                                    </StackPanel>
                                </MenuItem.Header>
                            </MenuItem>
                        </Menu>

                        <materialDesign:PopupBox
                            Padding="8,0"
                            HorizontalAlignment="Right"
                            Style="{StaticResource MaterialDesignToolForegroundPopupBox}">
                            <StackPanel Margin="8">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock
                                        VerticalAlignment="Center"
                                        Style="{StaticResource ToolbarTextBlock}"
                                        Text="{x:Static resx:ResUI.TbSettingsColorMode}" />
                                    <ToggleButton x:Name="togDarkMode" Margin="8" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock
                                        VerticalAlignment="Center"
                                        Style="{StaticResource ToolbarTextBlock}"
                                        Text="{x:Static resx:ResUI.TbSettingsColor}" />
                                    <ComboBox
                                        x:Name="cmbSwatches"
                                        Width="100"
                                        Margin="8"
                                        DisplayMemberPath="Name"
                                        Style="{StaticResource DefComboBox}" />
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock
                                        VerticalAlignment="Center"
                                        Style="{StaticResource ToolbarTextBlock}"
                                        Text="{x:Static resx:ResUI.TbSettingsLanguage}" />
                                    <ComboBox
                                        x:Name="cmbCurrentLanguage"
                                        Width="100"
                                        Margin="8"
                                        materialDesign:HintAssist.Hint="Language"
                                        Style="{StaticResource DefComboBox}" />
                                </StackPanel>
                            </StackPanel>
                        </materialDesign:PopupBox>
                    </ToolBar>
                </ToolBarTray>
                <ToolBarTray DockPanel.Dock="Top">
                    <ToolBar
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        ClipToBounds="True"
                        Style="{StaticResource MaterialDesignToolBar}">
                        <ListBox x:Name="lstGroup" Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding remarks}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <Button
                            x:Name="btnAddSub"
                            Width="30"
                            Height="30"
                            Margin="8,0"
                            Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
                            <materialDesign:PackIcon Kind="Plus" />
                        </Button>
                        <Separator />
                        <TextBox
                            x:Name="txtServerFilter"
                            Width="200"
                            Margin="8,0"
                            materialDesign:HintAssist.Hint="{x:Static resx:ResUI.MsgServerTitle}"
                            materialDesign:TextFieldAssist.HasClearButton="True" />
                    </ToolBar>
                </ToolBarTray>

                <materialDesign:ColorZone
                    Height="50"
                    DockPanel.Dock="Bottom"
                    Mode="Standard">
                    <DockPanel>
                        <StackPanel
                            Margin="8,0"
                            VerticalAlignment="Center"
                            DockPanel.Dock="Right">
                            <TextBlock x:Name="txtSpeedProxyDisplay" Style="{StaticResource StatusbarItem}" />
                            <Border Margin="2" />
                            <TextBlock x:Name="txtSpeedDirectDisplay" Style="{StaticResource StatusbarItem}" />
                        </StackPanel>

                        <StackPanel
                            Width="240"
                            Margin="8,0"
                            VerticalAlignment="Center"
                            DockPanel.Dock="Left">
                            <TextBlock x:Name="txtInboundDisplay" Style="{StaticResource StatusbarItem}" />
                            <Border Margin="2" />
                            <TextBlock x:Name="txtInboundLanDisplay" Style="{StaticResource StatusbarItem}" />
                        </StackPanel>

                        <StackPanel
                            x:Name="spEnableTun"
                            Width="auto"
                            Margin="8,0"
                            VerticalAlignment="Center"
                            DockPanel.Dock="Left">
                            <TextBlock Text="{x:Static resx:ResUI.TbEnableTunAs}" />
                            <ToggleButton
                                x:Name="togEnableTun"
                                Margin="4"
                                HorizontalAlignment="Left" />
                        </StackPanel>

                        <StackPanel
                            Margin="8,0"
                            VerticalAlignment="Center"
                            DockPanel.Dock="Left"
                            Orientation="Horizontal">
                            <ComboBox
                                x:Name="cmbSystemProxy"
                                Width="120"
                                Margin="8,0"
                                materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuSystemproxy}"
                                Style="{StaticResource MaterialDesignFloatingHintComboBox}">
                                <ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyClear}" />
                                <ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxySet}" />
                                <ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyNothing}" />
                                <ComboBoxItem Content="{x:Static resx:ResUI.menuSystemProxyPac}" />
                            </ComboBox>

                            <ComboBox
                                x:Name="cmbRoutings2"
                                Width="150"
                                Margin="8,0"
                                materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuRouting}"
                                DisplayMemberPath="remarks"
                                Style="{StaticResource MaterialDesignFloatingHintComboBox}" />
                        </StackPanel>

                        <StackPanel Margin="8,0" VerticalAlignment="Center">
                            <TextBlock
                                x:Name="txtRunningServerDisplay"
                                PreviewMouseDown="txtRunningInfoDisplay_MouseDoubleClick"
                                Style="{StaticResource StatusbarItem}" />
                            <Border Margin="2" />
                            <TextBlock
                                x:Name="txtRunningInfoDisplay"
                                PreviewMouseDown="txtRunningInfoDisplay_MouseDoubleClick"
                                Style="{StaticResource StatusbarItem}" />
                        </StackPanel>
                    </DockPanel>
                </materialDesign:ColorZone>

                <Grid x:Name="gridMain">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="1*" />
                    </Grid.RowDefinitions>
                    <DataGrid
                        x:Name="lstProfiles"
                        Grid.Row="0"
                        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"
                        Style="{StaticResource DefDataGrid}">
                        <DataGrid.InputBindings>
                            <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Ctrl+C" />
                            <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Ctrl+V" />
                            <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Delete" />
                            <KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Enter" />
                        </DataGrid.InputBindings>
                        <DataGrid.ContextMenu>
                            <ContextMenu Style="{StaticResource DefContextMenu}">
                                <MenuItem
                                    x:Name="menuEditServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuEditServer}" />
                                <MenuItem
                                    x:Name="menuSetDefaultServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSetDefaultServer}" />
                                <MenuItem
                                    x:Name="menuRemoveServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRemoveServer}" />
                                <MenuItem
                                    x:Name="menuRemoveDuplicateServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRemoveDuplicateServer}" />
                                <MenuItem
                                    x:Name="menuCopyServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuCopyServer}" />
                                <MenuItem
                                    x:Name="menuShareServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuShareServer}" />
                                <Separator />
                                <MenuItem
                                    x:Name="menuMixedTestServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMixedTestServer}" />
                                <MenuItem
                                    x:Name="menuPingServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuPingServer}" />
                                <MenuItem
                                    x:Name="menuTcpingServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuTcpingServer}" />
                                <MenuItem
                                    x:Name="menuRealPingServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuRealPingServer}" />
                                <MenuItem
                                    x:Name="menuSpeedServer"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSpeedServer}" />
                                <MenuItem
                                    x:Name="menuSortServerResult"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuSortServerResult}" />
                                <Separator />
                                <MenuItem
                                    x:Name="menuMoveToGroup"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMoveToGroup}">
                                    <MenuItem Height="Auto">
                                        <MenuItem.Header>
                                            <DockPanel>
                                                <ComboBox
                                                    x:Name="cmbMoveToGroup"
                                                    Width="200"
                                                    materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuSubscription}"
                                                    DisplayMemberPath="remarks"
                                                    Style="{StaticResource MaterialDesignFilledComboBox}" />
                                            </DockPanel>
                                        </MenuItem.Header>
                                    </MenuItem>
                                </MenuItem>
                                <MenuItem
                                    x:Name="menuMoveTop"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMoveTop}" />
                                <MenuItem
                                    x:Name="menuMoveUp"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMoveUp}" />
                                <MenuItem
                                    x:Name="menuMoveDown"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMoveDown}" />
                                <MenuItem
                                    x:Name="menuMoveBottom"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuMoveBottom}" />
                                <MenuItem
                                    x:Name="menuSelectAll"
                                    Height="{StaticResource MenuItemHeight}"
                                    Click="menuSelectAll_Click"
                                    Header="{x:Static resx:ResUI.menuSelectAll}" />
                                <Separator />
                                <MenuItem
                                    x:Name="menuExport2ClientConfig"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuExport2ClientConfig}" />
                                <MenuItem
                                    x:Name="menuExport2ServerConfig"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuExport2ServerConfig}" />
                                <MenuItem
                                    x:Name="menuExport2ShareUrl"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuExport2ShareUrl}" />
                                <MenuItem
                                    x:Name="menuExport2SubContent"
                                    Height="{StaticResource MenuItemHeight}"
                                    Header="{x:Static resx:ResUI.menuExport2SubContent}" />
                            </ContextMenu>
                        </DataGrid.ContextMenu>
                        <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>
                        </DataGrid.Resources>
                        <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>

                            <materialDesign:DataGridTextColumn
                                Width="80"
                                Binding="{Binding configType}"
                                Header="{x:Static resx:ResUI.LvServiceType}" />
                            <DataGridTextColumn
                                Width="150"
                                Binding="{Binding remarks}"
                                Header="{x:Static resx:ResUI.LvAlias}" />
                            <DataGridTextColumn
                                Width="120"
                                Binding="{Binding address}"
                                Header="{x:Static resx:ResUI.LvAddress}" />
                            <DataGridTextColumn
                                Width="60"
                                Binding="{Binding port}"
                                Header="{x:Static resx:ResUI.LvPort}" />
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding security}"
                                Header="{x:Static resx:ResUI.LvEncryptionMethod}" />
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding network}"
                                Header="{x:Static resx:ResUI.LvTransportProtocol}" />
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding streamSecurity}"
                                Header="{x:Static resx:ResUI.LvTLS}" />
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding subRemarks}"
                                Header="{x:Static resx:ResUI.LvSubscription}" />
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding delayVal}"
                                Header="{x:Static resx:ResUI.LvTestDelay}">
                                <DataGridTextColumn.ElementStyle>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="HorizontalAlignment" Value="Right" />
                                        <Setter Property="Foreground" Value="{Binding delay, Converter={StaticResource DelayColorConverter}}" />
                                    </Style>
                                </DataGridTextColumn.ElementStyle>
                            </DataGridTextColumn>
                            <DataGridTextColumn
                                Width="100"
                                Binding="{Binding speedVal}"
                                Header="{x:Static resx:ResUI.LvTestSpeed}">
                                <DataGridTextColumn.ElementStyle>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="HorizontalAlignment" Value="Right" />
                                    </Style>
                                </DataGridTextColumn.ElementStyle>
                            </DataGridTextColumn>

                            <DataGridTextColumn
                                x:Name="colTodayUp"
                                Width="100"
                                Binding="{Binding todayUp}"
                                Header="{x:Static resx:ResUI.LvTodayUploadDataAmount}" />
                            <DataGridTextColumn
                                x:Name="colTodayDown"
                                Width="100"
                                Binding="{Binding todayDown}"
                                Header="{x:Static resx:ResUI.LvTodayDownloadDataAmount}" />
                            <DataGridTextColumn
                                x:Name="colTotalUp"
                                Width="100"
                                Binding="{Binding totalUp}"
                                Header="{x:Static resx:ResUI.LvTotalUploadDataAmount}" />
                            <DataGridTextColumn
                                x:Name="colTotalDown"
                                Width="100"
                                Binding="{Binding totalDown}"
                                Header="{x:Static resx:ResUI.LvTotalDownloadDataAmount}" />

                        </DataGrid.Columns>
                    </DataGrid>
                    <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" />
                    <local:MsgView Grid.Row="2" />
                </Grid>

            </DockPanel>
            <tb:TaskbarIcon
                x:Name="tbNotify"
                IconSource="/v2rayN.ico"
                NoLeftClickDelay="True">
                <tb:TaskbarIcon.ContextMenu>
                    <ContextMenu Style="{StaticResource DefContextMenu}">
                        <MenuItem x:Name="menuSystemProxyClear" Height="{StaticResource MenuItemHeight}">
                            <MenuItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon
                                        x:Name="menuSystemProxyClear2"
                                        Margin="0,0,8,0"
                                        Kind="Check" />
                                    <TextBlock Text="{x:Static resx:ResUI.menuSystemProxyClear}" />
                                </StackPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <MenuItem x:Name="menuSystemProxySet" Height="{StaticResource MenuItemHeight}">
                            <MenuItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon
                                        x:Name="menuSystemProxySet2"
                                        Margin="0,0,8,0"
                                        Kind="Check" />
                                    <TextBlock Text="{x:Static resx:ResUI.menuSystemProxySet}" />
                                </StackPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <MenuItem x:Name="menuSystemProxyNothing" Height="{StaticResource MenuItemHeight}">
                            <MenuItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon
                                        x:Name="menuSystemProxyNothing2"
                                        Margin="0,0,8,0"
                                        Kind="Check" />
                                    <TextBlock Text="{x:Static resx:ResUI.menuSystemProxyNothing}" />
                                </StackPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <MenuItem x:Name="menuSystemProxyPac" Height="{StaticResource MenuItemHeight}">
                            <MenuItem.Header>
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon
                                        x:Name="menuSystemProxyPac2"
                                        Margin="0,0,8,0"
                                        Kind="Check" />
                                    <TextBlock Text="{x:Static resx:ResUI.menuSystemProxyPac}" />
                                </StackPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <Separator />
                        <MenuItem x:Name="menuRoutings" Height="Auto">
                            <MenuItem.Header>
                                <DockPanel>
                                    <ComboBox
                                        x:Name="cmbRoutings"
                                        MaxWidth="300"
                                        materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuRouting}"
                                        DisplayMemberPath="remarks"
                                        Style="{StaticResource MaterialDesignFilledComboBox}" />
                                </DockPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <MenuItem Height="Auto">
                            <MenuItem.Header>
                                <DockPanel>
                                    <ComboBox
                                        x:Name="cmbServers"
                                        MaxWidth="300"
                                        materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuServers}"
                                        DisplayMemberPath="Text"
                                        Style="{StaticResource MaterialDesignFilledComboBox}" />
                                </DockPanel>
                            </MenuItem.Header>
                        </MenuItem>
                        <Separator />
                        <MenuItem
                            x:Name="menuAddServerViaClipboard2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
                        <MenuItem
                            x:Name="menuAddServerViaScan2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuAddServerViaScan}" />
                        <MenuItem
                            x:Name="menuSubUpdate2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuSubUpdate}" />
                        <MenuItem
                            x:Name="menuSubUpdateViaProxy2"
                            Height="{StaticResource MenuItemHeight}"
                            Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
                        <Separator />
                        <MenuItem
                            x:Name="menuExit"
                            Height="{StaticResource MenuItemHeight}"
                            Click="menuExit_Click"
                            Header="{x:Static resx:ResUI.menuExit}" />
                    </ContextMenu>
                </tb:TaskbarIcon.ContextMenu>
            </tb:TaskbarIcon>
            <materialDesign:Snackbar x:Name="MainSnackbar" MessageQueue="{materialDesign:MessageQueue}" />
        </Grid>

    </materialDesign:DialogHost>
</reactiveui:ReactiveWindow>
