IBlockElement Split() example

2 posts, 0 answers
  1. Sandeep
    Sandeep avatar
    10 posts
    Member since:
    Nov 2014

    Posted 02 Dec 2014 Link to this post


    Can i get some example of the usage of the IBlockElement Split() function.

  2. Deyan
    Deyan avatar
    157 posts

    Posted 02 Dec 2014 Link to this post

    Hello Sandeep,

    Thank you for contacting us.

    The IBlockElement interface is designed to be used in the following scenario:
    • Measure some block element in a desired size.
    • Draw the element in the desired size and position.
    • Split the element when there is any pending content that needs to be drawn.
    The following code snippet shows how to split some long text and draw its parts one below the other. The code uses Block class which implements the IBlockElement interface.
    RadFixedDocument document = new RadFixedDocument();
    FixedContentEditor editor = new FixedContentEditor(document.Pages.AddPage());
    editor.GraphicProperties.IsFilled = false;
    editor.GraphicProperties.IsStroked = true;
    Block block = new Block();
    block.InsertText("Some long text that will be split!");
    double splitWidth = 50;
    double height = 10;
    bool hasPendingContent;
        Size desiredSize = block.Measure(new Size(splitWidth, 0));
        Rect rectangle = new Rect(10, height, splitWidth, desiredSize.Height);
        block.Draw(editor, rectangle);
        height += 10 + rectangle.Height;
        hasPendingContent = block.HasPendingContent;
        if (hasPendingContent)
            block = block.Split();
    while (hasPendingContent);

    I hope this is helpful.

    the Telerik team

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top