<UserControl x:Class="MyPad.Views.Regions.OptionContentView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:p="http://prismlibrary.com/"
             xmlns:m="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:mi="http://metro.mahapps.com/winfx/xaml/iconpacks"
             xmlns:le="http://wpflocalizeextension.codeplex.com"
             xmlns:qc="http://QuickConverter.CodePlex.com/"
             xmlns:ge="clr-namespace:SourceChord.GridExtra;assembly=GridExtra.Wpf"
             xmlns:root="clr-namespace:MyPad"
             xmlns:behaviors="clr-namespace:MyPad.Views.Behaviors"
             xmlns:controls="clr-namespace:MyPad.Views.Controls"
             xmlns:markup="clr-namespace:MyPad.Views.Markup"
             mc:Ignorable="d" 
             p:ViewModelLocator.AutoWireViewModel="True"
             d:DesignHeight="450" d:DesignWidth="800"
             Cursor="{qc:Binding '$P ? Cursors.Wait : Cursors.Arrow', P={Binding IsPending.Value, Mode=TwoWay}}">

    <Grid Margin="20 -25 20 10" MaxWidth="{StaticResource Const.BreakPoint.XL}">
        <TabControl Padding="10 10 5 0" m:HeaderedControlHelper.HeaderFontWeight="Bold" Background="Transparent">
            <TabControl.Resources>
                <Style x:Key="TitleTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource Common.TextBlock}">
                    <Setter Property="FontSize" Value="{DynamicResource MahApps.Font.Size.Dialog.Message}"/>
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style x:Key="TitleSeparator" TargetType="{x:Type Border}">
                    <Setter Property="Background" Value="{DynamicResource MahApps.Brushes.Gray2}"/>
                    <Setter Property="Margin" Value="0 5 0 10"/>
                    <Setter Property="Height" Value="1"/>
                </Style>
                <Style x:Key="BlockMargin" TargetType="{x:Type Border}">
                    <Setter Property="Height" Value="15"/>
                </Style>
                <Style x:Key="ComboBoxTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource Common.TextBlock}"/>
                
                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource Common.TextBlock}">
                    <Setter Property="Margin" Value="5"/>
                    <Setter Property="VerticalAlignment" Value="Center"/>
                </Style>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource Common.Button}">
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource Common.RadioButton}">
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource Common.CheckBox}">
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource Common.TextBox}">
                    <Setter Property="Margin" Value="5"/>
                </Style>
                <Style TargetType="{x:Type m:NumericUpDown}" BasedOn="{StaticResource Common.NumericUpDown}">
                    <Setter Property="Margin" Value="30 0 0 5"/>
                    <Setter Property="MinWidth" Value="100"/>
                    <Setter Property="HorizontalAlignment" Value="Left"/>
                </Style>
                <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource Common.ComboBox}">
                    <Setter Property="Margin" Value="5"/>
                    <Setter Property="BorderThickness" Value="0 0 0 1"/>
                </Style>
                <Style TargetType="{x:Type DataGrid}" BasedOn="{StaticResource Common.DataGrid}">
                    <Setter Property="Margin" Value="5"/>
                </Style>
            </TabControl.Resources>

            <!-- ********** システム ********** -->
            <TabItem DataContext="{Binding Settings.System, Mode=OneWay}" Header="{le:Loc Label_System}">
                <ScrollViewer>
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{le:Loc Label_Appearance}" Style="{StaticResource TitleTextBlock}"/>
                            <Border ToolTip="{le:Loc Message_NotifyAppearanceWarning}" ToolTipService.InitialShowDelay="0" Background="Transparent" VerticalAlignment="Center" Margin="5 0 0 0" Padding="10 5">
                                <mi:Codicons Kind="Info"/>
                            </Border>
                        </StackPanel>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <StackPanel>
                            <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                                <DockPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="0 0 0 5">
                                    <Border Margin="5 0 5 5" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MahApps.Brushes.TextBox.Border}">
                                        <StackPanel>
                                            <TextBlock Text="{le:Loc Label_Theme}" Style="{DynamicResource MahApps.Styles.TextBlock.Watermark}" FontSize="{DynamicResource MahApps.Font.Size.FloatingWatermark}" Margin="5 5 0 0"/>
                                            <StackPanel Orientation="Horizontal" Margin="5 0">
                                                <RadioButton Content="{le:Loc Label_SyncAppTheme}" IsChecked="{qc:Binding Convert='(int)$P == 0', ConvertBack='$value ? 0 : DependencyProperty.UnsetValue', P={Binding Theme, Mode=TwoWay}}"/>
                                                <RadioButton Content="{le:Loc Label_Dark}"         IsChecked="{qc:Binding Convert='(int)$P == 1', ConvertBack='$value ? 1 : DependencyProperty.UnsetValue', P={Binding Theme, Mode=TwoWay}}"/>
                                                <RadioButton Content="{le:Loc Label_Light}"        IsChecked="{qc:Binding Convert='(int)$P == 2', ConvertBack='$value ? 2 : DependencyProperty.UnsetValue', P={Binding Theme, Mode=TwoWay}}"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </Border>
                                    <ComboBox ItemsSource="{x:Static root:Constants.ACCENT_COLORS}"
                                              SelectedValue="{Binding AccentColor, Mode=TwoWay}"
                                              SelectedValuePath="ColorScheme"
                                              m:TextBoxHelper.Watermark="{le:Loc Label_AccentColor}"
                                              m:TextBoxHelper.UseFloatingWatermark="True">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Horizontal">
                                                    <Ellipse Fill="{Binding ShowcaseBrush, Mode=OneWay}" Width="16" Height="16"/>
                                                    <TextBlock Text="{Binding ColorScheme, Mode=OneWay}" Margin="5 0 0 0"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </DockPanel>

                                <DockPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="0 0 0 5">
                                    <Border Margin="5 0 5 5" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MahApps.Brushes.TextBox.Border}">
                                        <StackPanel>
                                            <TextBlock Text="{le:Loc Label_Size}" Style="{DynamicResource MahApps.Styles.TextBlock.Watermark}" FontSize="{DynamicResource MahApps.Font.Size.FloatingWatermark}" Margin="5 5 0 0"/>
                                            <StackPanel Orientation="Horizontal" Margin="5 0">
                                                <RadioButton Content="{le:Loc Label_Small}"  IsChecked="{qc:Binding Convert='(int)$P == 0', ConvertBack='$value ? 0 : DependencyProperty.UnsetValue', P={Binding UISize, Mode=TwoWay}}"/>
                                                <RadioButton Content="{le:Loc Label_Medium}" IsChecked="{qc:Binding Convert='(int)$P == 1', ConvertBack='$value ? 1 : DependencyProperty.UnsetValue', P={Binding UISize, Mode=TwoWay}}"/>
                                                <RadioButton Content="{le:Loc Label_Large}"  IsChecked="{qc:Binding Convert='(int)$P == 2', ConvertBack='$value ? 2 : DependencyProperty.UnsetValue', P={Binding UISize, Mode=TwoWay}}"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </Border>
                                    <ComboBox ItemsSource="{x:Static root:Constants.FONT_FAMILIES}"
                                              SelectedValue="{Binding FontFamily, Mode=TwoWay}"
                                              m:TextBoxHelper.Watermark="{le:Loc Label_FontFamily}"
                                              m:TextBoxHelper.UseFloatingWatermark="True">
                                        <!-- 選択肢にフォントファミリを適用する -->
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Converter={markup:FontFamilyToNameConverter}}" FontFamily="{Binding}" Style="{StaticResource ComboBoxTextBlock}"/>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </DockPanel>
                            </ge:ResponsiveGrid>

                            <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                                <Border ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" ge:ResponsiveGrid.MD="4" Margin="0 0 0 5">
                                    <ComboBox ItemsSource="{x:Static root:Constants.CULTURES}"
                                              SelectedValue="{Binding Culture, Mode=TwoWay}"
                                              SelectedValuePath="Name"
                                              m:TextBoxHelper.Watermark="{le:Loc Label_Language}"
                                              m:TextBoxHelper.UseFloatingWatermark="True">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{qc:MultiBinding '$P0 + \' (\' + $P1 + \')\'', P0={Binding Description, Mode=OneWay}, P1={Binding Name, Mode=OneWay}}" Style="{StaticResource ComboBoxTextBlock}"/>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </Border>

                                <Border ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" ge:ResponsiveGrid.MD="4" Margin="0 0 0 5">
                                    <ComboBox ItemsSource="{qc:Binding 'new string[] { string.Empty }.Concat($P.Keys)', P={Binding DataContext.SyntaxService.Definitions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Mode=OneWay}}"
                                              SelectedValue="{qc:Binding Convert='$P ?? string.Empty', ConvertBack='string.IsNullOrEmpty($value) ? null : $value', P={Binding SyntaxDefinitionName, Mode=TwoWay}}"
                                              m:TextBoxHelper.Watermark="{le:Loc Label_SyntaxColoring}"
                                              m:TextBoxHelper.UseFloatingWatermark="True">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{qc:Binding 'string.IsNullOrEmpty($P) ? \'Plain Text\' : $P', P={Binding Mode=OneWay}}" Style="{StaticResource ComboBoxTextBlock}"/>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </Border>

                                <StackPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" ge:ResponsiveGrid.MD="4" Margin="0 0 0 5">
                                    <ComboBox ItemsSource="{x:Static root:Constants.ENCODINGS}"
                                              SelectedValue="{Binding Encoding, Mode=TwoWay}"
                                              m:TextBoxHelper.Watermark="{le:Loc Label_Encoding}"
                                              m:TextBoxHelper.UseFloatingWatermark="True">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{qc:MultiBinding '$P0 + \' - \' + $P1', P0={Binding CodePage, Mode=OneWay}, P1={Binding EncodingName, Mode=OneWay}}" Style="{StaticResource ComboBoxTextBlock}"/>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                    <CheckBox IsChecked="{Binding AutoDetectEncoding, Mode=TwoWay}" Content="{le:Loc LabelText_AutoDetectByDefault}" Margin="10 0"/>
                                </StackPanel>
                            </ge:ResponsiveGrid>
                        </StackPanel>

                        <Border Style="{StaticResource BlockMargin}"/>

                        <TextBlock Text="{le:Loc Label_Behavior}" Style="{StaticResource TitleTextBlock}"/>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                            <StackPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="5">
                                <CheckBox IsChecked="{Binding SaveWindowPlacement, Mode=TwoWay}"   Content="{le:Loc LabelText_SaveWindowPlacement}"/>
                                <CheckBox IsChecked="{Binding UseOverlayDialog, Mode=TwoWay}"      Content="{le:Loc LabelText_UseOverlayDialog}"/>
                                <CheckBox IsChecked="{Binding UseToastNotifications, Mode=TwoWay}" Content="{le:Loc LabelText_UseToastNotifications}"/>
                                <CheckBox IsChecked="{Binding ShowFullName, Mode=TwoWay}"          Content="{le:Loc LabelText_ShowFullName}"/>
                                <CheckBox IsChecked="{Binding ShowFileIcon, Mode=TwoWay}"          Content="{le:Loc LabelText_ShowFileIcon}"/>
                                <CheckBox IsChecked="{Binding ShowSingleTab, Mode=TwoWay}"         Content="{le:Loc LabelText_ShowSingleTab}"/>
                            </StackPanel>

                            <StackPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="5">
                                <CheckBox IsChecked="{Binding EnableNotifyIcon, Mode=TwoWay}"      Content="{le:Loc LabelText_EnableNotifyIcon}"
                                          Checked="EnableNotifyIcon_CheckedChanged"
                                          Unchecked="EnableNotifyIcon_CheckedChanged"/>
                                <CheckBox IsChecked="{Binding EnableResident, Mode=TwoWay}"        Content="{le:Loc LabelText_EnableResident}"
                                          IsEnabled="{Binding EnableNotifyIcon, Mode=OneWay}"/>
                                <Border Height="10"/>
                                <CheckBox IsChecked="{Binding EnableAutoSave, Mode=TwoWay}"        Content="{le:Loc LabelText_EnableAutoSave}"/>
                                <m:NumericUpDown Value="{Binding AutoSaveInterval, Mode=TwoWay}" Minimum="1"
                                                 m:TextBoxHelper.Watermark="{le:Loc Label_AutoSaveInterval}"
                                                 m:TextBoxHelper.UseFloatingWatermark="True"/>
                            </StackPanel>
                        </ge:ResponsiveGrid>
                    </StackPanel>
                </ScrollViewer>
            </TabItem>

            <!-- ********** テキストエディタ ********** -->
            <TabItem DataContext="{Binding Settings.TextEditor, Mode=OneWay}" Header="{le:Loc Label_TextEditor}">
                <ScrollViewer>
                    <StackPanel>
                        <TextBlock Text="{le:Loc Label_Font}" Style="{StaticResource TitleTextBlock}"/>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                            <Border ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6">
                                <ComboBox ItemsSource="{x:Static root:Constants.FONT_FAMILIES}"
                                          SelectedValue="{Binding FontFamily, Mode=TwoWay}"
                                          m:TextBoxHelper.Watermark="{le:Loc Label_FontFamily}"
                                          m:TextBoxHelper.UseFloatingWatermark="True">
                                    <!-- 選択肢にフォントファミリを適用する -->
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Converter={markup:FontFamilyToNameConverter}}" FontFamily="{Binding}" Style="{StaticResource ComboBoxTextBlock}"/>
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                            </Border>

                            <Grid ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" ge:GridEx.ColumnDefinition="*, *, *">
                                <ComboBox Grid.Column="0"
                                          ItemsSource="{x:Static root:Constants.FONT_WEIGHTS}"
                                          SelectedValue="{Binding FontWeight, Mode=TwoWay}"
                                          m:TextBoxHelper.Watermark="{le:Loc Label_FontWeight}"
                                          m:TextBoxHelper.UseFloatingWatermark="True"
                                          FontFamily="{Binding FontFamily, Mode=OneWay}">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding}" FontWeight="{Binding}" Style="{StaticResource ComboBoxTextBlock}"/>
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                                <ComboBox Grid.Column="1"
                                          ItemsSource="{x:Static root:Constants.FONT_STYLES}"
                                          SelectedValue="{Binding FontStyle, Mode=TwoWay}"
                                          m:TextBoxHelper.Watermark="{le:Loc Label_FontStyle}"
                                          m:TextBoxHelper.UseFloatingWatermark="True"
                                          FontFamily="{Binding FontFamily, Mode=OneWay}">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding}" FontStyle="{Binding}" Style="{StaticResource ComboBoxTextBlock}"/>
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                                <ComboBox Grid.Column="2"
                                          ItemsSource="{x:Static root:Constants.FONT_SIZES}"
                                          SelectedValue="{Binding ActualFontSize, Mode=TwoWay}"
                                          m:TextBoxHelper.Watermark="{le:Loc Label_FontSize}"
                                          m:TextBoxHelper.UseFloatingWatermark="True"
                                          FontFamily="{Binding FontFamily, Mode=OneWay}"/>
                            </Grid>
                        </ge:ResponsiveGrid>

                        <Border Style="{StaticResource BlockMargin}"/>

                        <TextBlock Text="{le:Loc Label_Behavior}" Style="{StaticResource TitleTextBlock}"/>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                            <StackPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="5">
                                <CheckBox IsChecked="{Binding HighlightCurrentLine, Mode=TwoWay}"        Content="{le:Loc LabelText_HighlightCurrentLine}"/>
                                <CheckBox IsChecked="{Binding ShowSpaces, Mode=TwoWay}"                  Content="{le:Loc LabelText_ShowSpaces}"/>
                                <CheckBox IsChecked="{Binding ShowTabs, Mode=TwoWay}"                    Content="{le:Loc LabelText_ShowTabs}"/>
                                <CheckBox IsChecked="{Binding ShowBoxForControlCharacters, Mode=TwoWay}" Content="{le:Loc LabelText_ShowBoxForControlCharacters}"/>
                                <CheckBox IsChecked="{Binding ShowEndOfLine, Mode=TwoWay}"               Content="{le:Loc LabelText_ShowEndOfLine}"/>
                                <CheckBox IsChecked="{Binding ShowLineNumbers, Mode=TwoWay}"             Content="{le:Loc LabelText_ShowLineNumbers}"/>
                                <CheckBox IsChecked="{Binding ShowChangeMarker, Mode=TwoWay}"            Content="{le:Loc LabelText_ShowChangeMarker}"/>
                                <CheckBox IsChecked="{Binding HideCursorWhileTyping, Mode=TwoWay}"       Content="{le:Loc LabelText_HideCursorWhileTyping}"/>

                                <Border Height="10"/>

                                <CheckBox IsChecked="{Binding ShowColumnRuler, Mode=TwoWay}" Content="{le:Loc LabelText_ShowColumnRuler}"/>
                                <m:NumericUpDown Value="{Binding ColumnRulerPosition, Mode=TwoWay}" Minimum="1" Maximum="10000"
                                                 m:TextBoxHelper.Watermark="{le:Loc Label_ColumnRulerPosition}"
                                                 m:TextBoxHelper.UseFloatingWatermark="True"/>
                                <CheckBox IsChecked="{Binding WordWrap, Mode=TwoWay}"            Content="{le:Loc LabelText_EnableWordWrap}"/>
                                <CheckBox IsChecked="{Binding ConvertTabsToSpaces, Mode=TwoWay}" Content="{le:Loc LabelText_ConvertTabsToSpaces}"/>
                                <m:NumericUpDown Value="{Binding IndentationSize, Mode=TwoWay}" Minimum="1" Maximum="64"
                                                 m:TextBoxHelper.Watermark="{le:Loc Label_IndentationSize}"
                                                 m:TextBoxHelper.UseFloatingWatermark="True"/>
                            </StackPanel>

                            <StackPanel ge:ResponsiveGrid.XS="12" ge:ResponsiveGrid.SM="6" Margin="5">
                                <CheckBox IsChecked="{Binding EnableFoldings, Mode=TwoWay}"                          Content="{le:Loc LabelText_EnableFoldings}"/>
                                <CheckBox IsChecked="{Binding EnableAutoCompletion, Mode=TwoWay}"                    Content="{le:Loc LabelText_EnableAutoCompletion}"/>
                                <CheckBox IsChecked="{Binding EnableHalfWidth, Mode=TwoWay}"                         Content="{le:Loc LabelText_EnableHalfWidth}"/>
                                <CheckBox IsChecked="{Binding EnableSlashedZero, Mode=TwoWay}"                       Content="{le:Loc LabelText_EnableSlashedZero}"
                                          IsEnabled="{Binding EnableHalfWidth, Mode=OneWay}"/>
                                <CheckBox IsChecked="{Binding EnableVirtualSpace, Mode=TwoWay}"                      Content="{le:Loc LabelText_EnableVirtualSpace}"/>
                                <CheckBox IsChecked="{Binding EnableRectangularSelection, Mode=TwoWay}"              Content="{le:Loc LabelText_EnableRectangularSelection}"/>
                                <CheckBox IsChecked="{Binding EnableTextDragDrop, Mode=TwoWay}"                      Content="{le:Loc LabelText_EnableTextDragDrop}"/>
                                <CheckBox IsChecked="{Binding EnableImeSupport, Mode=TwoWay}"                        Content="{le:Loc LabelText_EnableImeSupport}"/>
                                <CheckBox IsChecked="{Binding EnableHyperlinks, Mode=TwoWay}"                        Content="{le:Loc LabelText_EnableHyperlinks}"/>
                                <CheckBox IsChecked="{Binding EnableEmailHyperlinks, Mode=TwoWay}"                   Content="{le:Loc LabelText_EnableEmailHyperlinks}"/>
                                <CheckBox IsChecked="{Binding RequireControlModifierForHyperlinkClick, Mode=TwoWay}" Content="{le:Loc LabelText_RequireControlModifierForHyperlinkClick}"/>
                                <CheckBox IsChecked="{Binding CutCopyWholeLine, Mode=TwoWay}"                        Content="{le:Loc LabelText_EnableCutCopyWholeLine}"/>
                                <CheckBox IsChecked="{Binding CutCopyHtmlFormat, Mode=TwoWay}"                       Content="{le:Loc LabelText_EnableCutCopyHtmlFormat}"/>
                                <CheckBox IsChecked="{Binding AllowToggleOverstrikeMode, Mode=TwoWay}"               Content="{le:Loc LabelText_AllowToggleOverstrikeMode}"/>
                                <CheckBox IsChecked="{Binding AllowScrollBelowDocument, Mode=TwoWay}"                Content="{le:Loc LabelText_AllowScrollBelowDocument}"/>
                            </StackPanel>
                        </ge:ResponsiveGrid>
                    </StackPanel>
                </ScrollViewer>
            </TabItem>

            <!-- ********** エクスプローラー ********** -->
            <TabItem DataContext="{Binding Settings.Misc, Mode=OneWay}" Header="{le:Loc Command_Explorer}">
                <DockPanel>
                    <TextBlock  DockPanel.Dock="Top" Text="{le:Loc LabelText_SetExplorerRoot}" Style="{StaticResource TitleTextBlock}"/>
                    <Border     DockPanel.Dock="Top" Style="{StaticResource TitleSeparator}"/>
                    <DataGrid ItemsSource="{Binding ExplorerRoots, Mode=OneWay}" LoadingRow="{qc:QuickEvent '$eventArgs.Row.Header = ($eventArgs.Row.GetIndex() + 1).ToString()'}"
                              AutoGenerateColumns="False" HeadersVisibility="All" RowHeaderWidth="50" ColumnWidth="*"
                              CanUserResizeRows="False" CanUserResizeColumns="False" CanUserSortColumns="False" CanUserAddRows="True" CanUserDeleteRows="True"
                              SelectionUnit="Cell" KeyboardNavigation.ControlTabNavigation="None">
                        <DataGrid.Resources>
                            <!-- 全選択ボタンを置き換える -->
                            <Style x:Key="{ComponentResourceKey ResourceId=MetroDataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type DataGrid}}" TargetType="{x:Type Button}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type Button}">
                                            <Border Background="Transparent" ToolTip="{le:Loc Command_Apply}">
                                                <Button Command="{Binding DataContext.RecreateExplorerCommand, Mode=OneTime, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Style="{DynamicResource Common.ChromelessButton}">
                                                    <StackPanel Orientation="Horizontal">
                                                        <mi:PackIconCodicons Kind="Files" Margin="0 0 5 0"/>
                                                        <mi:Unicons Kind="CornerUpLeftAlt"/>
                                                    </StackPanel>
                                                </Button>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                            <!-- テンプレートカラム用のセル -->
                            <Style x:Key="TemplateColumnDataGridCell" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource Common.DataGridCell}">
                                <Setter Property="IsTabStop" Value="False"/>
                            </Style>
                        </DataGrid.Resources>
                        <DataGrid.Columns>
                            <DataGridTextColumn Binding="{Binding Path, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Header="{le:Loc Label_Path}">
                                <DataGridTextColumn.EditingElementStyle>
                                    <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource Common.TextBox}">
                                        <Setter Property="BorderThickness" Value="0"/>
                                        <Setter Property="m:TextBoxHelper.SelectAllOnFocus" Value="True"/>
                                        <Setter Property="m:TextBoxHelper.ClearTextButton" Value="True"/>
                                        <Setter Property="m:TextBoxHelper.Watermark" Value="{qc:QuickValue 'Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)'}"/>
                                    </Style>
                                </DataGridTextColumn.EditingElementStyle>
                            </DataGridTextColumn>
                            <DataGridTemplateColumn Header="{le:Loc Label_IsEnabled}" IsReadOnly="True" Width="60" CellStyle="{StaticResource TemplateColumnDataGridCell}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <DataTemplate.Triggers>
                                            <!-- プレースホルダーには表示しない -->
                                            <DataTrigger Binding="{Binding}" Value="{x:Static controls:DataGridHelper.NewItemPlaceholder}">
                                                <Setter Property="Visibility" Value="Collapsed"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                        <CheckBox IsChecked="{Binding IsEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5 0 0 0"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn IsReadOnly="True" Width="30" CellStyle="{StaticResource TemplateColumnDataGridCell}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Command="{Binding DataContext.SelectDirectoryCommand, Mode=OneTime, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding Mode=OneWay}" ToolTip="{le:Loc Command_Select}" Style="{DynamicResource Common.ChromelessButton}">
                                            <mi:Codicons Kind="FolderOpened"/>
                                        </Button>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn IsReadOnly="True" Width="30" CellStyle="{StaticResource TemplateColumnDataGridCell}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <DataTemplate.Triggers>
                                            <!-- プレースホルダーには表示しない -->
                                            <DataTrigger Binding="{Binding}" Value="{x:Static controls:DataGridHelper.NewItemPlaceholder}">
                                                <Setter Property="Visibility" Value="Collapsed"/>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                        <Button Command="{Binding DataContext.RemoveDirectoryCommand, Mode=OneTime, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" CommandParameter="{Binding Mode=OneWay}" ToolTip="{le:Loc Command_Delete}" Style="{DynamicResource Common.ChromelessButton}">
                                            <mi:Material Kind="FolderRemove"/>
                                        </Button>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </DockPanel>
            </TabItem>

            <!-- ********** 構成ファイル ********** -->
            <TabItem Header="{le:Loc Label_ConfigFile}">
                <ScrollViewer>
                    <StackPanel>
                        <TextBlock Text="{le:Loc Label_SystemDirectory}" Style="{StaticResource TitleTextBlock}"/>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <Grid ge:GridEx.ColumnDefinition="Auto, *, 5, Auto, 5" ge:GridEx.RowDefinition="Auto, Auto, Auto">
                            <Grid.Resources>
                                <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource Common.TextBox}">
                                    <Setter Property="Margin" Value="5"/>
                                    <Setter Property="IsTabStop" Value="False"/>
                                    <Setter Property="IsReadOnly" Value="True"/>
                                    <Setter Property="m:TextBoxHelper.SelectAllOnFocus" Value="True"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsReadOnly" Value="True">
                                            <Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Gray5}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                                <Style x:Key="IconButton" TargetType="{x:Type Button}" BasedOn="{StaticResource Common.Button}">
                                    <Setter Property="Margin" Value="0 5"/>
                                    <Setter Property="Padding" Value="0"/>
                                    <Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
                                </Style>
                                <Style x:Key="IconDangerButton" TargetType="{x:Type Button}" BasedOn="{StaticResource Common.DangerButton}">
                                    <Setter Property="Margin" Value="0 5"/>
                                    <Setter Property="Padding" Value="0"/>
                                    <Setter Property="Width" Value="{Binding ActualHeight, RelativeSource={RelativeSource Self}}"/>
                                </Style>
                            </Grid.Resources>

                            <TextBlock Grid.Row="0" Grid.Column="0" Text="{le:Loc Label_ExecutionDirectory}"/>
                            <TextBox   Grid.Row="0" Grid.Column="1" Text="{Binding ProductInfo.Working, Mode=OneWay}"/>
                            <Button    Grid.Row="0" Grid.Column="3" ToolTip="{le:Loc Command_Open}" Style="{StaticResource IconButton}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <behaviors:ProcessStartAction FileName="explorer.exe" Arguments="{Binding ProductInfo.Working, Mode=OneWay}" ThrowException="False"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <mi:Codicons Kind="FolderOpened"/>
                            </Button>

                            <TextBlock Grid.Row="1" Grid.Column="0" Text="{le:Loc Label_TempDirectory}"/>
                            <TextBox   Grid.Row="1" Grid.Column="1" Text="{Binding ProductInfo.Temporary, Mode=OneWay}"/>
                            <Button    Grid.Row="1" Grid.Column="3" ToolTip="{le:Loc Command_Open}" Style="{StaticResource IconButton}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <behaviors:ProcessStartAction FileName="explorer.exe" Arguments="{Binding ProductInfo.Temporary, Mode=OneWay}" ThrowException="False"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                                <mi:Codicons Kind="FolderOpened"/>
                            </Button>

                            <TextBlock Grid.Row="2" Grid.Column="0" Text="{le:Loc Label_AppDataDirectory}"/>
                            <TextBox   Grid.Row="2" Grid.Column="1" Text="{Binding ProductInfo.Roaming, Mode=OneWay}"/>
                            <Button    Grid.Row="2" Grid.Column="3" Command="{Binding InitializeSyntaxCommand, Mode=OneTime}" ToolTip="{le:Loc Command_InitializeSyntax}" Style="{StaticResource IconDangerButton}">
                                <mi:VaadinIcons Kind="FileRefresh"/>
                            </Button>
                        </Grid>

                        <Border Style="{StaticResource BlockMargin}"/>

                        <TextBlock Text="{le:Loc Label_SystemSettings}" Style="{StaticResource TitleTextBlock}"/>
                        <Border Style="{StaticResource TitleSeparator}"/>
                        <ge:ResponsiveGrid BreakPoints="{DynamicResource Const.BreakPoints}">
                            <ge:ResponsiveGrid.Resources>
                                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource Common.Button}">
                                    <Setter Property="Margin" Value="5"/>
                                    <Setter Property="ge:ResponsiveGrid.XS" Value="12"/>
                                    <Setter Property="ge:ResponsiveGrid.SM" Value="6"/>
                                    <Setter Property="ge:ResponsiveGrid.MD" Value="4"/>
                                    <Style.Resources>
                                        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource Common.TextBlock}">
                                            <Setter Property="VerticalAlignment" Value="Center"/>
                                        </Style>
                                    </Style.Resources>
                                </Style>
                                <Style x:Key="This.DangerButton" TargetType="{x:Type Button}" BasedOn="{StaticResource Common.DangerButton}">
                                    <Setter Property="Margin" Value="5"/>
                                    <Setter Property="ge:ResponsiveGrid.XS" Value="12"/>
                                    <Setter Property="ge:ResponsiveGrid.SM" Value="6"/>
                                    <Setter Property="ge:ResponsiveGrid.MD" Value="4"/>
                                    <Style.Resources>
                                        <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource Common.TextBlock}">
                                            <Setter Property="VerticalAlignment" Value="Center"/>
                                        </Style>
                                    </Style.Resources>
                                </Style>
                            </ge:ResponsiveGrid.Resources>

                            <Button Command="{Binding ImportSettingsFileCommand, Mode=OneTime}">
                                <StackPanel Orientation="Horizontal">
                                    <mi:PackIconFontisto Kind="Import" VerticalAlignment="Center" Margin="0 0 5 0"/>
                                    <TextBlock Text="{le:Loc Command_ImportSettings}"/>
                                </StackPanel>
                            </Button>
                            <Button Command="{Binding ExportSettingsFileCommand, Mode=OneTime}">
                                <StackPanel Orientation="Horizontal">
                                    <mi:PackIconFontisto Kind="Export" VerticalAlignment="Center" Margin="0 0 5 0"/>
                                    <TextBlock Text="{le:Loc Command_ExportSettings}"/>
                                </StackPanel>
                            </Button>
                            <Button Command="{Binding InitializeSettingsCommand, Mode=OneTime}" Style="{StaticResource This.DangerButton}">
                                <StackPanel Orientation="Horizontal">
                                    <mi:PackIconMaterial Kind="CogRefresh" VerticalAlignment="Center" Margin="0 0 5 0"/>
                                    <TextBlock Text="{le:Loc Command_InitializeSettings}"/>
                                </StackPanel>
                            </Button>
                        </ge:ResponsiveGrid>
                    </StackPanel>
                </ScrollViewer>
            </TabItem>
        </TabControl>

        <Border d:IsHidden="True" Style="{StaticResource Common.Overlay}" Visibility="{qc:Binding '$P ? Visibility.Visible : Visibility.Collapsed', P={Binding IsPending.Value, Mode=OneWay}}">
            <StackPanel Margin="5 0" HorizontalAlignment="Stretch" VerticalAlignment="Center">
                <TextBlock Text="{le:Loc Text_Working}" HorizontalAlignment="Center" TextAlignment="Center"/>
                <Border Height="10"/>
                <m:ProgressRing/>
            </StackPanel>
        </Border>
    </Grid>

</UserControl>
