<controls:MetroWindow x:Class="LunarSF.SHomeWorkshop.LunarMarkdownEditor.LineLeaderTextSettingDialog"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:local="clr-namespace:LunarSF.SHomeWorkshop.LunarMarkdownEditor"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      mc:Ignorable="d"
                      Title="设置换行时要保留的前导字符串"
                      Icon="App.png"
                      BorderBrush="#FFBB6115"
                      BorderThickness="1"
                      GlowBrush="#FFBB6115"
                      FontFamily="Simsun"
                      FontSize="14"
                      TextOptions.TextFormattingMode="Display"
                      Padding="0"
                      Height="560"
                      Width="760">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Label Margin="10,10,10,0">A 类(原文)规则:</Label>

        <TextBox Name="tbxA"
                 AcceptsReturn="True"
                 AcceptsTab="False"
                 Grid.Row="1"
                 Margin="10"
                 HorizontalScrollBarVisibility="Auto"
                 VerticalScrollBarVisibility="Visible"></TextBox>

        <Rectangle Grid.ColumnSpan="2"
                   Grid.Row="2"
                   Fill="#FF9B7B56" />

        <TextBlock TextWrapping="Wrap"
                   Grid.Row="2"
                   Margin="10"
                   Foreground="White">  这种比较自由,不需要以 $ 开头。</TextBlock>

        <Label Margin="10,10,10,0"
               Grid.Column="1">B 类(替换)规则:</Label>

        <TextBox Name="tbxB"
                 AcceptsReturn="True"
                 AcceptsTab="False"
                 Grid.Row="1"
                 Grid.Column="1"
                 Margin="10"
                 HorizontalScrollBarVisibility="Auto"
                 VerticalScrollBarVisibility="Visible"></TextBox>

        <DockPanel Grid.ColumnSpan="2"
                   Grid.Row="3"
                   Margin="10"
                   LastChildFill="True">
            <TextBlock Margin="10,0,0,0"
                       VerticalAlignment="Center">内置替换文本首字符:</TextBlock>
            <TextBox Name="tbxReplaceTextFstChar"
                     AcceptsReturn="False"
                     AcceptsTab="False"
                     MaxLength="1"
                     Margin="0,0,10,0"
                     VerticalAlignment="Center"
                     Width="40">$</TextBox>
            <TextBlock Margin="10,0"
                       xml:space="preserve"
                       TextWrapping="Wrap"
                       VerticalAlignment="Center">  默认字符是 $ 。用于新行行首。
  例如:如果已经设置了一条 B 类规则“<Span Foreground="Green">^[$] {0,}经济[::] {0,}</Span>”。
  此时在一个内容为“<Span Foreground="Brown">$ 经济:小农经济</Span>”的文本行的末尾按下回车键,会将此行中的前导字符串“<Span Foreground="Red">$ 经济:</Span>”在新行头部替换为“<Span Foreground="Red"
                                                                                                                                 TextDecorations="underline"
                                                                                                                                 xml:space="preserve">$       </Span>”。
  但是,如果这个<Span FontWeight="Bold">内置替换文本首字符</Span>被改成了“<Span Foreground="Blue">&amp;</Span>”,则新行头部“<Span Foreground="Red">$ 经济:</Span>”会被替换为“<Span Foreground="Blue"
                                                                                                                                                  TextDecorations="underline"
                                                                                                                                                  xml:space="preserve">&amp;       </Span>”。</TextBlock>

        </DockPanel>

        <TextBlock TextWrapping="Wrap"
                   Margin="10"
                   Grid.Row="2"
                   Grid.Column="1"
                   Foreground="White">  这种一般应以下面设置的<Span Foreground="Yellow"
                                                         FontWeight="Bold">内置替换文本首字符</Span>(默认是 $)开头,此时新行以 $+空格 的形式出现的。</TextBlock>

        <Expander Grid.Row="4"
                  Style="{x:Null}"
                  Margin="10"
                  Header="其它说明"
                  Grid.ColumnSpan="2"
                  IsExpanded="False">
            <TextBlock TextWrapping="Wrap"
                       Margin="10">
  有时候,我们希望在按下 Enter(回车)键时,能让新行自动添加当前行头部某些文本(例如五个空格啥的),这样每个新行都可以自动对齐,省去重复输入的麻烦。
            <LineBreak />
  这个对话框中,我们可以自行添加正则表达式来书写一些匹配规则。这些规则分为 A 类规则与 B 类规则。A 类规则是原文本规则,即不加修改地将匹配的原文字符串添加到新行头部;B 类规则是替换规则,会将当前行头部匹配规则的文本转换成相应字符长度的“$+半角空格串”的形式添加到新行的头部。
            <LineBreak />
  为什么要加个美元符号($)呢?这是因为四个以上连续空格会被视为代码块的标记,所以必须另找一个字符开头。
            <LineBreak />
  注意:A 类(原文)规则优先。也就是说,如果两种规则的正则表达式相同,则会优先保留原文本添加到新行头部。
            </TextBlock>
        </Expander>

        <DockPanel Grid.Row="5"
                   Background="#FF9B7B56"
                   Height="64"
                   Grid.ColumnSpan="2"
                   LastChildFill="False">
            <Button DockPanel.Dock="Right"
                    Style="{StaticResource ResourceKey=SquareButtonStyle}"
                    Height="28"
                    Margin="10"
                    BorderThickness="1"
                    FontWeight="Normal"
                    VerticalAlignment="Center"
                    Padding="20,4"
                    Name="btnCancel"
                    Click="btnCancel_Click">取消(_C)</Button>
            <Button DockPanel.Dock="right"
                    Style="{StaticResource ResourceKey=SquareButtonStyle}"
                    Height="28"
                    Margin="10"
                    BorderThickness="1"
                    FontWeight="Normal"
                    Name="btnOK"
                    VerticalAlignment="Center"
                    Padding="20,4"
                    Click="btnOK_Click">保存(_S)</Button>
        </DockPanel>
    </Grid>
</controls:MetroWindow>