Jeff Prosise's Blog

Page-Turn Framework Updated for Silverlight 2

I just returned home from the PDC after a marvelous few days in sunny L.A. Sunday's Silverlight precon was a blast, and if you attended, I hope you felt it was worth your time. I could have easily filled out two more days with Silverlight fun and games, but I tried to hit the high points in the time we had together.

I spent my time on the airplane to and from L.A. updating my page-turn framework for Silverlight 2. The original framework utilized Silverlight 1.0 and was introduced in the May 2008 issue of MSDN Magazine. The new version features the same basic API with a few tweaks and additions. For example, the PageTurn class now fires a PageTurned event each time a page turn is complete, making it easy to update the UI around the page-turn canvas each time the user flips a page. Here's a sample built around the new framework:

PageTurnDemo 

You can download the sample code here, or view the app online here. The page-turn framework is implemented in PageTurn.cs, and you can see how to use the framework by perusing Page.xaml and Page.xaml.cs. The XAML structure is the same as described in the aforementioned MSDN Magazine article.

I still need to do some cleaning-up in the code and would also like to add a few more features. But since the framework's in decent shape as is, and since I have promised publicly to update it for Silverlight 2, I didn't want to wait any longer to push the bits out there. If you have comments, questions, or suggestions (or, heaven forbid, find any bugs), be sure to let me know.

On Oct 29 2008 7:59 AMBy jprosise With 14 Comments

Comments (14)

  1. Hello Jeff: Great precon session; I actually liked it better than PDC itself. Anyway, I cannot for the life of me remember the uri you gave for your web demos (something like webdemo1.aspx). Can you pass it along? Thanks again for the great session... -Dan

  2. Dan, you can download my PDC demos from http://www.wintellect.com/Downloads/PDC_2008_Demos.zip.

  3. Trevor STreeton

    Hi
    The demo I saw on was super. I downloaded it, unzipped it and tried to run it, but it never finishes loading.

  4. Harald Mejlholm

    Is it possible to modify the GoToSpread-method so that it turns the page in the same nice way, that it does when I do it manually?

  5. Yes, although it'll require some work. I intend to update the framework to take advantage of some SL3 features such as animation easing. Maybe when I update it I can add an "automatic paging" feature.

  6. At work, I was approached about putting our inhouse phone directory on our intranet web site. Ok, no prob. Then it was mentioned about how cool it would be if it actually looked like a book.

    Ok, I told them I didn't think this would be nontrivial, but I'd look around.

    Came across your pageturn stuff for silverlight. I see now that you've updated it, but I've been digging into your original stuff for a couple of weeks now.

    So, my question is could you give me a small sample javascript to load page 3 of your included booklette.

    I can create the images from a sql database and zip them up, but I just can't figure out how to go to a specific page.

    Thanks.

  7. Version 2 of the framework (the C# version) has a GoToSpread method for doing exactly that. You could either use version 2 or port that method to JavaScript. You really should use v2; it's nicer and cleaner!

  8. I blame it all on the cold medicine. Took a long look at the code again and figured out my error. So I've got it working now.

    Does version 2 work on Macs? I have downloaded it and have it running, but when I look thru the directories I see a dll. The mac I can test on has an older version of OS 10 that won't load silverlight. Still waiting to use somebody's newer mac for testing version 2.

  9. This is a great framework, thanks for that.

    Little optimization if you have a lot of pages:

    If you have a lot of pages (>40 double pages) the cpu uses is quite high on page turn. I have changed the framework so that only the visible pages and one before and after are visible. The other pages are always collapsed. The cpu usage is then a lot better.

    So if you plan to use this framewrok for a lot of pages this may help you.

  10. Excelent framework. I am new in all this things, i'm trying to add new pages but i can't. I already added 2 extra canvas in the XAML and modified the the .cs, but when i run it, there is a error in the InitializeComponent(). I hope you could help me. Best Regards

Leave a Comment