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

Adding pages on the fly to the radbook

9 Answers 155 Views
Book
This is a migrated thread and some comments may be shown as answers.
G S S
Top achievements
Rank 1
G S S asked on 18 Nov 2010, 01:59 AM
Hi,

Is it possible to setup a polling mechanism so that my RadBook implementation can poll a directory on the site, and if any new files are added to this dir, they can be added to the radbook?

I know a polling mechanism isn't RadBook-specific and can be coded, but can I add pages on the fly (HTML)?

Also, can I embed the Silverlight report viewer in the RadBook?

Thanks

9 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 18 Nov 2010, 02:49 PM
Hello G S S,

Adding pages (RadBookItem) is supported and is the same as adding an item in any other ItemsControl.
Also, using a report viewer in the book is a supported scenario. Here is an interesting article on the subject.

Using Telerik Report WCF Service (or how to display reports in RadBook)

Also, you can take a look at this integration example "RadBook and RadRichTextBox".

Regards,
Kiril Stanoev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
G S S
Top achievements
Rank 1
answered on 13 Feb 2011, 04:06 PM
Hi,

To add to my original question, what I want/need to do is bind 15-20 HTML paes into the RadBook. These pages are stored in the same directory, so I need to loop over each page and bind it, eg:

foreach (File file in Directory.GetDirectory(DirectoryPath))
{
  radBook1.BindToBook(file);
}

This is not valid C#, but is the pseudo code of what I need to do. Also (And this is a Silverlight-specific question). What would be the way to do this?

Thanks
0
Kiril Stanoev
Telerik team
answered on 16 Feb 2011, 05:59 PM
Hello G S S,

Please take a look at the attachments in this forum thread. I believe they will be useful to your scenario.

Best wishes,
Kiril Stanoev
the Telerik team
0
G S S
Top achievements
Rank 1
answered on 17 Feb 2011, 12:28 AM
Hi,

That's a good find, thank you! The only issue with that is:

              this.book.ItemsSource = bindingSource;

bindingSource has one property - Document - which is set to one HtmlDocument (in the code of where I got the snippet above from). However, I want to add >1 page to the items source. How can I do this? I'd expect to use a collection here?


Thanks     
0
Boby
Telerik team
answered on 22 Feb 2011, 09:55 AM
Hello G S S,
RadDocumentBindingSource is designed for showing one document in RadBook. If you have multiple documents, you can either merge them in one, or use custom DataTemplate for RadBook's pages containing RadRichTextBox bound to your HTML documents. For binding RadRichTextBox, take a look at this article.

Kind regards,
Boby
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
G S S
Top achievements
Rank 1
answered on 24 Feb 2011, 01:33 AM
Thanks for this help.

I have made a solution (Silverlight Application) which has a radbook and binds a single .docx. I've pretty much copied the example solution on the Silverlight Demos. My XAML is as follows:

<P><UserControl x:Class="CodeQualityBookApp.MainPage"<BR>    
xmlns="<A 
xmlns:x="<A 
xmlns:d="<A 
xmlns:mc="<A 
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents" 
mc:Ignorable="d"<BR>    d:DesignHeight="300" 
d:DesignWidth="400"></P>
<P>    
<UserControl.Resources><BR> <BR>        
<Controls:DocumentViewManager 
x:Name="viewManager"></Controls:DocumentViewManager></P>
<P><BR>        <Grid x:Name="LayoutRoot" 
Background="White"></P>
<P>     <telerik:RadBook Name="book" 
RightPageIndex="1"><BR>            
<telerik:RadBookItem><BR>                
<BR>            
</telerik:RadBookItem><BR>        
</telerik:RadBook><BR>    
</Grid><BR>       
</UserControl.Resources></UserControl></P>

 
The codebehind C# is:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Documents;
using Telerik.Windows.Documents.FormatProviders;
using Telerik.Windows.Documents.Layout;
using Telerik.Windows.Documents.Model;
  
namespace CodeQualityBookApp
{
    public partial class MainPage : UserControl
    {
  
        private RadDocumentBindingSource bindingSource = new RadDocumentBindingSource();
  
  
        public MainPage()
        {
            InitializeComponent();
             UserControl_Loaded(this, new RoutedEventArgs());
        }
  
  
  
        public void LoadDocument(Stream stream, string extension)
        {
  
            RadDocument doc;
  
            IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);
            if (provider != null)
            {
                doc = provider.Import(stream);
            }
  
            else
            {
                MessageBox.Show("Unknown format.");
                return;
            }
  
            doc.Measure(RadDocument.MAX_DOCUMENT_SIZE);
            doc.Arrange(new RectangleF(PointF.Empty, doc.DesiredSize));
  
            doc.LayoutMode = DocumentLayoutMode.Paged;
  
            doc.DefaultPageLayoutSettings.Width = 320 / 0.7F;
            doc.DefaultPageLayoutSettings.Height = 390 / 0.7F;
            doc.SectionDefaultPageMargin = new Padding(55);
            doc.Sections.First.PageMargin = new Padding(55);
  
            doc.UpdateLayout();
  
            this.book.RightPageIndex = 0;
          
  
            this.viewManager.Document = doc;
            bindingSource.Document = doc;
        }
  
            private Uri GetResourceUri(string resource)
        {
            AssemblyName assemblyName = new AssemblyName(this.GetType().Assembly.FullName);
            string resourcePath = "/" + assemblyName.Name + ";component/" + resource;
            Uri resourceUri = new Uri(resourcePath, UriKind.Relative);
  
            return resourceUri;
        }
  
  
  
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            using (Stream stream = Application.GetResourceStream(this.GetResourceUri("Build Server conventions.docx")).Stream)
            {
                this.LoadDocument(stream, ".docx");
            }
            this.book.ItemsSource = bindingSource;
        }
  
    }
}

The referenced file has been added to the project, and appears inside. When I view this page in my browser, the Silverlight loader indicator keeps spinning (with no progress %).


Thanks
0
Boby
Telerik team
answered on 01 Mar 2011, 01:00 PM
Hello G S S,

The behavior you observed is most probably because the application crashes when loading. You can try to debug it and check where the exception is thrown. Unfortunately we cannot determine the reason for this by the code provided.

Best wishes,
Boby
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
G S S
Top achievements
Rank 1
answered on 01 Mar 2011, 01:57 PM
Hi,

Thanks, I will do that. However, is the code below correct for what I am trying to do?


Thanks   
0
Ivailo Karamanolev
Telerik team
answered on 04 Mar 2011, 09:20 AM
Hello G S S,

There is nothing particularly wrong with your code/approach. If you keep experiencing issues, please try to debug the application and see what the exception or problem is. If that doesn't help either, we'll be able to assist you further if you send us a small demo project which exhibits this wrong behavior.

All the best,
Ivailo
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Book
Asked by
G S S
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
G S S
Top achievements
Rank 1
Boby
Telerik team
Ivailo Karamanolev
Telerik team
Share this question
or