Custom Style definition

4 posts, 0 answers
  1. Marcin
    Marcin avatar
    7 posts
    Member since:
    Aug 2014

    Posted 29 Sep Link to this post

    I've 2 questions:

    First one:

    I've a problem with custom Style definition. I want to edit some of built-in styles. At this moment I've got this code:

    StyleDefinition h1 = this.radRichTextEditor1.Document.StyleRepository.GetValueOrNull(RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(1));
    h1.SpanProperties.FontSize = ConstDocumentationParams.fontSizeH1;
    h1.SpanProperties.ForeColor = System.Drawing.ColorTranslator.FromHtml(ConstDocumentationParams.colorH1);
    h1.SpanProperties.FontStyle = ConstDocumentationParams.typeH1;
    h1.SpanProperties.FontWeight = Telerik.WinControls.RichTextEditor.UI.FontWeights.Normal;
    h1.SpanProperties.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily(ConstDocumentationParams.fontFamily);

     

    Everything works fine until I select text and click the heading edited by me. Text changes to old style, not new. How can I fix this problem?

     

    Second one:

    How can I insert programmatically some element whitch will be generated to html tag: "<h1>","<h2>" etc.

     

    Best regards

    Marcin

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 30 Sep Link to this post

    Hi Marcin,

    Thank you for writing.

    1. I was not able to reproduce this. This is why I have attached my test project. Could you please check it and let me know what I need to change in order to reproduce the undesired behavior?

    2. You can specify the paragraph's StyleName before inserting it. For example:
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    paragraph.StyleName = RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(1);
    Span span = new Span("Span declared in code-behind");
    paragraph.Inlines.Add(span);
    section.Blocks.Add(paragraph);
    radRichTextEditor1.Document.Sections.Add(section);

    I am looking forward to your reply.
     
    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marcin
    Marcin avatar
    7 posts
    Member since:
    Aug 2014

    Posted 30 Sep in reply to Dimitar Link to this post

    Dimitar, thank you for writing.

     

    In attachments You can find what I was talking about.

    My steps:

    1. write some text(in style from "Heading 1"

    2. select some of letters

    3. click on "heading 1"

    4. old style :(

     

    I have version: 2016_2_608 of winforms

     

    Best regards,

    Marcin 

  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 04 Oct Link to this post

    Hi Marcin,

    Thank you for writing.

    This is considered an issue which I have logged in our Feedback Portal. I have added a vote for it on your behalf as well. You can track its progress, subscribe for status changes and add your comment to it here. I have also updated your Telerik Points.

    To workaround this you need to set the styles of the linked style definition as well: 
    StyleDefinition h1 = this.radRichTextEditor1.Document.StyleRepository.GetValueOrNull(RadDocumentDefaultStyles.GetHeadingStyleNameByIndex(1));
    h1.SpanProperties.FontSize = 33;
    h1.SpanProperties.ForeColor = System.Drawing.ColorTranslator.FromHtml("#e83737");
      
    StyleDefinition h1Char = h1.LinkedStyle;
      
    h1.SpanProperties.FontWeight = Telerik.WinControls.RichTextEditor.UI.FontWeights.Normal;
    h1.SpanProperties.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily("Segoe Script");
      
    h1Char.SpanProperties.FontWeight = Telerik.WinControls.RichTextEditor.UI.FontWeights.Normal;
    h1Char.SpanProperties.FontFamily = new Telerik.WinControls.RichTextEditor.UI.FontFamily("Segoe Script");
      
    h1Char.SpanProperties.FontSize = 33;
    h1Char.SpanProperties.ForeColor = System.Drawing.ColorTranslator.FromHtml("#e83737");

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top