Giter Site home page Giter Site logo

Comments (4)

whistyun avatar whistyun commented on June 16, 2024

For now, Sasabune*** style only works on MarkdownScrollViewer.
And It don't references FlowDocument properties but MarkdownScrollViewer properties.

Markdown engine = new();
FlowDocument document = engine.Transform("# Heading1\n## Heading2\n### Heading3\n#### Heading3\nfoo bar text\n|head1|head2|\n|-|-|\n|body1|body2|");
document.Style = MarkdownStyle.SasabuneStandard;

// MarkdownScrollViewer MSV = new();
MSV.Document = document;
MSV.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
MSV.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

image

from mdxaml.

LauraKami avatar LauraKami commented on June 16, 2024

2022-11-22 15_38_56-Clipboard

as soon, I have style, Header 1 2 3 don't work anymore for me,
only R0C0 with no style ( style in Xaml, but don't work header is not red or blue ).

2022-11-22 15_46_07-WpfAppMdDemo2 - Microsoft Visual Studio

`
Markdown engine = new();

        //string markdownTxt = "";
        string markdownTxt = "# Heading1\n## Heading2\n### Heading3\n#### Heading3\nfoo bar text\n|head1|head2|\n|-|-|\n|body1|body2|";
        //string markdownTxt = System.IO.File.ReadAllText("example.md");
        FlowDocument document1 = engine.Transform("# Heading1\n## Heading2\n# 1-R0C0 Style XAML\n" + markdownTxt);
        FlowDocument document2 = engine.Transform("# Heading1\n## Heading2\n# 2-R1C0 Sasabune\n" + markdownTxt);
        FlowDocument document3 = engine.Transform("# Heading1\n## Heading2\n# 3-R0C1 SasabuneCompact\n" + markdownTxt);
        FlowDocument document4 = engine.Transform("# Heading1\n## Heading2\n# 4-R1C1 SasabuneStandard\n" + markdownTxt);


        // Document.Style = MarkdownStyle.Sasabune;  ( style in xaml )
        MSV_R0C0.Document = document1;
        MSV_R0C0.Document.Background = new SolidColorBrush( Color.FromArgb(255, 0, 0, 0)); // a,r,g,b
        MSV_R0C0.Document.Foreground = new SolidColorBrush( Color.FromArgb(255, 255, 255,255));


        
        document2.Style = MarkdownStyle.Sasabune;
        MSV_R1C0.Document = document2;
        MSV_R1C0.Document.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
        MSV_R1C0.Document.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

        document3.Style = MarkdownStyle.SasabuneCompact;
        MSV_R0C1.Document = document3;
        MSV_R0C1.Document.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
        MSV_R0C1.Document.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

        document4.Style = MarkdownStyle.SasabuneStandard;
        MSV_R1C1.Document = document4;
        MSV_R1C1.Document.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
        MSV_R1C1.Document.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

`

`
xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
Loaded="Window_Loaded">

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50*"/>
        <RowDefinition Height="50*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50*"/>
        <ColumnDefinition Width="50*"/>
    </Grid.ColumnDefinitions>
    <Grid.Resources>
        <Style x:Key="MdStyle" TargetType="FlowDocument">
            <Style.Resources>
                <Style TargetType="Paragraph">
                    <Style.Triggers>
                        <Trigger Property="Tag" Value="Heading1">
                            <Setter Property="FontSize"   Value="42" />
                            <Setter Property="Foreground" Value="Red" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                        <Trigger Property="Tag" Value="Heading2">
                            <Setter Property="FontSize"   Value="20" />
                            <Setter Property="Foreground" Value="Blue" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Style.Resources>
        </Style>

    </Grid.Resources>
    <mdxam:MarkdownScrollViewer 
        x:Name="MSV_R0C0"
        Grid.Row="0" Grid.Column="0"
        MarkdownStyle="{StaticResource ResourceKey=MdStyle}"
        xml:space="preserve">
            # Heading R0C0

            ## Heading 2

            content
    </mdxam:MarkdownScrollViewer>
    <mdxam:MarkdownScrollViewer 
        x:Name="MSV_R1C0"
        Grid.Row="1" Grid.Column="0"
        
        xml:space="preserve">
            # Heading R1C0

            ## Heading 2

            content
    </mdxam:MarkdownScrollViewer>
    <mdxam:MarkdownScrollViewer 
        x:Name="MSV_R0C1"
        Grid.Row="0" Grid.Column="1"
        xml:space="preserve">
            # Heading R0C1

            ## Heading 2

            content
    </mdxam:MarkdownScrollViewer>
    <mdxam:MarkdownScrollViewer 
        x:Name="MSV_R1C1"
        Grid.Row="1" Grid.Column="1"
        xml:space="preserve">
            # Heading R1C1

            ## Heading 2

            content
    </mdxam:MarkdownScrollViewer>
</Grid>
`

2022-11-22 15_43_10-WpfAppMdDemo2 - Microsoft Visual Studio

from mdxaml.

whistyun avatar whistyun commented on June 16, 2024

Please modify your code as the bellow.

MSV_R0C0.Document = document1;
MSV_R0C0.Background = new SolidColorBrush( Color.FromArgb(255, 0, 0, 0)); // a,r,g,b
MSV_R0C0.Foreground = new SolidColorBrush( Color.FromArgb(255, 255, 255,255));

document2.Style = MarkdownStyle.Sasabune;
MSV_R1C0.Document = document2;
MSV_R1C0.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
MSV_R1C0.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

document3.Style = MarkdownStyle.SasabuneCompact;
MSV_R0C1.Document = document3;
MSV_R0C1.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
MSV_R0C1.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

document4.Style = MarkdownStyle.SasabuneStandard;
MSV_R1C1.Document = document4;
MSV_R1C1.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
MSV_R1C1.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));

Sasabune***(Sasabune, SasabuneCompact and SasabuneStandard) refers only to the direct properties of MarkdownScrollViewer.

from mdxaml.

LauraKami avatar LauraKami commented on June 16, 2024

merci @whistyun
Yes it's work fine, sorry I don't see in your first post, the subtle difference between set at document level vs set at Viewer level.
Have a good day.
Laura

from mdxaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.