<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
                    xmlns:controls="clr-namespace:Reloaded.WPF.Controls;assembly=Reloaded.WPF"
                    xmlns:hc="https://handyorg.github.io/handycontrol">

    <!-- For IntelliSense: Uncomment only when editing. -->
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="pack://siteoforigin:,,,/Theme/Default/Root.xaml" />
        <controls:SharedResourceDictionary Source="pack://siteoforigin:,,,/Theme/Default/R-II/Settings.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- Document styles -->
    <Style TargetType="{x:Type FlowDocument}" x:Key="{x:Static markdig:Styles.DocumentStyleKey}">
        <Setter Property="ScrollViewer.Visibility" Value="Hidden"/>
        <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
        <Setter Property="Foreground" Value="{StaticResource TextColorBrush}"/>
        <Setter Property="LineHeight" Value="{DynamicResource FontSizeSmaller}"/>
        <Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
    </Style>
 
    <Style TargetType="{x:Type Paragraph}" x:Key="{x:Static markdig:Styles.Heading1StyleKey}">
        <Setter Property="FontSize" Value="{DynamicResource FontSizeLargest}" />
        <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
    </Style>

    <Style TargetType="{x:Type Paragraph}" x:Key="{x:Static markdig:Styles.Heading2StyleKey}">
        <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
        <Setter Property="FontSize" Value="{DynamicResource FontSizeLarger}" />
    </Style>

    <Style TargetType="{x:Type Paragraph}" x:Key="{x:Static markdig:Styles.Heading3StyleKey}">
        <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
        <Setter Property="FontSize" Value="{DynamicResource FontSizeRegular}" />
    </Style>

    <Style TargetType="{x:Type Paragraph}" x:Key="{x:Static markdig:Styles.Heading4StyleKey}">
        <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
        <Setter Property="FontSize" Value="{DynamicResource FontSizeSmall}" />
    </Style>

    <Style TargetType="{x:Type Hyperlink}" x:Key="{x:Static markdig:Styles.HyperlinkStyleKey}">
        <Setter Property="Foreground" Value="{DynamicResource AccentColorLightestBrush}"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{DynamicResource AccentColorLighterBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type Image}" x:Key="{x:Static markdig:Styles.ImageStyleKey}">
        <Setter Property="MaxHeight" Value="{Binding RelativeSource={RelativeSource Self}, Path=Source.(BitmapSource.PixelHeight)}" />
        <Setter Property="MaxWidth" Value="{Binding RelativeSource={RelativeSource Self}, Path=Source.(BitmapSource.PixelWidth)}" />
    </Style>

    <Style TargetType="{x:Type Paragraph}" x:Key="{x:Static markdig:Styles.CodeBlockStyleKey}">
        <Setter Property="Background" Value="Transparent"/>    
    </Style>

    <Style TargetType="{x:Type Run}" x:Key="{x:Static markdig:Styles.CodeStyleKey}">
        <Setter Property="Background" Value="Transparent"/>
    </Style>

    <Style TargetType="{x:Type Section}" x:Key="{x:Static markdig:Styles.QuoteBlockStyleKey}">
        <Setter Property="BorderBrush" Value="{DynamicResource BorderColorBrush}" />
        <Setter Property="BorderThickness" Value="{DynamicResource MarkdownBlockQuoteThickness}" />
        <Setter Property="Foreground" Value="{DynamicResource MarkdownBlockQuoteTextColor}" />
        <Setter Property="Padding" Value="{DynamicResource MarkdownBlockQuotePadding}" />
    </Style>

    <Style TargetType="{x:Type Table}" x:Key="{x:Static markdig:Styles.TableStyleKey}">
        <Setter Property="CellSpacing" Value="{DynamicResource MarkdownCellPadding}"/>
    </Style>

    <Style TargetType="{x:Type TableCell}" x:Key="{x:Static markdig:Styles.TableCellStyleKey}"/>
    <Style TargetType="{x:Type TableRow}" x:Key="{x:Static markdig:Styles.TableHeaderStyleKey}"/>

    <Style TargetType="{x:Type CheckBox}" x:Key="{x:Static markdig:Styles.TaskListStyleKey}">
        <Setter Property="Margin" Value="0,0,0,-2" />
    </Style>

    <Style TargetType="{x:Type Line}" x:Key="{x:Static markdig:Styles.ThematicBreakStyleKey}">
        <Setter Property="Stretch" Value="Fill" />
        <Setter Property="Stroke" Value="{DynamicResource BorderColorBrush}" />
    </Style>

    <Style TargetType="{x:Type Span}" x:Key="{x:Static markdig:Styles.SubscriptStyleKey}">
        <Setter Property="Typography.Variants" Value="Subscript" />
    </Style>

    <Style TargetType="{x:Type Span}" x:Key="{x:Static markdig:Styles.SuperscriptStyleKey}">
        <Setter Property="Typography.Variants" Value="Superscript" />
    </Style>

    <Style TargetType="{x:Type Span}" x:Key="{x:Static markdig:Styles.StrikeThroughStyleKey}">
        <Setter Property="TextBlock.TextDecorations" Value="Strikethrough" />
    </Style>

    <Style TargetType="{x:Type Span}" x:Key="{x:Static markdig:Styles.InsertedStyleKey}">
        <Setter Property="TextBlock.TextDecorations" Value="Underline" />
    </Style>

    <Style TargetType="markdig:MarkdownViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="markdig:MarkdownViewer">
                    <FlowDocumentScrollViewer Document="{TemplateBinding Document}"
                                              ScrollViewer.VerticalScrollBarVisibility="Hidden"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="FlowDocumentScrollViewerWithoutToolbar" TargetType="{x:Type FlowDocumentScrollViewer}">
        <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type FlowDocumentScrollViewer}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            CornerRadius="{Binding (hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" 
                            Background="{TemplateBinding Background}"
                            Margin="{TemplateBinding Padding}">
                        <ScrollViewer x:Name="PART_ContentHost" CanContentScroll="True" 
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- MarkdownViewer Text Only Template-->
    <Style x:Key="FlowDocumentScrollViewerTextOnlyStyle" TargetType="{x:Type FlowDocumentScrollViewer}">
        <Style.Resources>
            <Style TargetType="{x:Type FlowDocument}" x:Key="{x:Static markdig:Styles.DocumentStyleKey}">
                <Setter Property="ScrollViewer.Visibility" Value="Hidden"/>
                <Setter Property="FontFamily" Value="{DynamicResource FontRegular}" />
                <Setter Property="Foreground" Value="{StaticResource TextColorBrush}"/>
                <Setter Property="LineHeight" Value="{DynamicResource FontSizeSmaller}"/>
            </Style>
        </Style.Resources>

        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
        <Setter Property="SelectionBrush" Value="{DynamicResource AccentColorBrushDark}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type FlowDocumentScrollViewer}">
                    <ScrollViewer x:Name="PART_ContentHost" 
                                  IsHitTestVisible="True" 
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MarkdownViewerTextOnly" TargetType="markdig:MarkdownViewer">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="markdig:MarkdownViewer">
                    <FlowDocumentScrollViewer Document="{TemplateBinding Document}"
                                              Background="Transparent"
                                              HorizontalScrollBarVisibility="Disabled"
                                              Focusable="False"
                                              Style="{DynamicResource FlowDocumentScrollViewerTextOnlyStyle}">
                        
                    </FlowDocumentScrollViewer>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>