This is a migrated thread and some comments may be shown as answers.

bug on UpdateLayout()?

3 Answers 108 Views
Book
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 23 Aug 2011, 03:07 PM

Hi, there.
I think RadBook is a great component for document viewer.
The problem is that I need to change the Width and Height of the viewer and the contents need to reformat the pages to fit in.
I tested code based on "RadBookIntegration" sample by adding the follwoing code.

       private void RadButtonIncrease_Click(object senderRoutedEventArgs e)
        {
            RadDocument doc = this.viewManager.Document;
            doc.DefaultPageLayoutSettings.Width += 50;
            doc.DefaultPageLayoutSettings.Height += 50;
            doc.UpdateLayout();
        }
        private void RadButtonDecrease_Click(object senderRoutedEventArgs e)
        {
            RadDocument doc = this.viewManager.Document;
            doc.DefaultPageLayoutSettings.Width -= 50;
            doc.DefaultPageLayoutSettings.Height -= 50;
            doc.UpdateLayout();
        }

I believe UpdateLayout should reformat the contents but the result is not what I expected;  page numbers and contents gets duplicated.
Can you please tell me what I'm doing wrong?

Thanks for your help.

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 26 Aug 2011, 03:23 PM
Hi Chris ,

Unfortunately, changing the page layout settings after the document has been shown in the Book is not supported. What you can do is create a copy of the document, set different values for Width and Height and then assign it to the book. Here is a sample implementation of that:

private void RadButtonIncrease_Click(object sender, RoutedEventArgs e)
{
    RadDocument doc = this.viewManager.Document.CreateDeepCopy() as RadDocument;
    if (doc.DefaultPageLayoutSettings.Width + 50 < this.book.Width)
    {
        doc.DefaultPageLayoutSettings.Width += 50;
    }
    if (doc.DefaultPageLayoutSettings.Height + 50 < this.book.Height)
    {
        doc.DefaultPageLayoutSettings.Height += 50;
    }
    doc.UpdateLayout();
    this.viewManager.Document = doc;
    bindingSource.Document = doc;
    this.book.UpdateLayout();
}
 
private void RadButtonDecrease_Click(object sender, RoutedEventArgs e)
{
    RadDocument doc = this.viewManager.Document.CreateDeepCopy() as RadDocument;
    if (doc.DefaultPageLayoutSettings.Width - 50 > this.book.Width)
    {
        doc.DefaultPageLayoutSettings.Width -= 50;
    }
    if (doc.DefaultPageLayoutSettings.Height - 50 > this.book.Height)
    {
        doc.DefaultPageLayoutSettings.Height -= 50;
    }
    doc.UpdateLayout();
    this.viewManager.Document = doc;
    bindingSource.Document = doc;
    this.book.UpdateLayout();
}

As you will probably notice, it may cause performance issues with bigger documents. We will consider making some changes to the RadBook and RadRichTextPageView controls in order to make such scenarios more straight-forward for implementation.

Greetings,
Iva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Chris
Top achievements
Rank 1
answered on 29 Aug 2011, 10:13 PM
Thanks for the info but let me ask you a question.
Is this consider as a bug? If it is, the name UpdateLayout somewhat misleading.
If it's not a bug, the name should change to something else.
Thanks.

  
0
Mike
Telerik team
answered on 02 Sep 2011, 08:03 AM
Hello Chris,

We will consider this limitation as a bug a try to resolve it for the next major release. Let us know if the workaround suits your app at this point.

All the best,
Mike
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Book
Asked by
Chris
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Chris
Top achievements
Rank 1
Mike
Telerik team
Share this question
or