Archive for October 4th, 2009

Using Seadragon with ASP.NET MVC

Seadragon is one of the new controls in the AJAX Control Toolkit. It gives you all the goodness of Deep Zoom using only JavaScript. The control toolkit is designed to work with Web Forms, but the underlying Seadragon API is easy to use from anywhere.

If you want to see what Seadragon and DeepZoom can do, then check out some of the gigapixel images on SeaDragon.com (JavaScript), or browse my photos of Stockholm on DeepZoomPix (it uses Silverlight). Bonus points if you find the picture of Ayende with his head in the center of an ice sculpture.

Once you’ve put together your own image using Deep Zoom Composer, then all you need to use with MVC is the Seadragon Ajax Library hosted on Live Labs.  Start with just a <div> in a view.  Assuming you have the traditional MVC setup with a master page, it’s as simple as this:

<asp:Content ContentPlaceHolderID="MainContent" runat="server">

    <h2>Seadragon</h2>
    <div id="container"></div>

</asp:Content>

On my master pages I usually have a ContentPlaceHolder inside the <head> tag to inject script. With that in place, here is one way to get the Seadragon API loaded and bootstrap the viewer:

<asp:Content ContentPlaceHolderID="Scripts" runat="server">
        <script type="text/javascript" 
                src="http://seadragon.com/ajax/0.8/seadragon-min.js">
        </script>
        
        <script type="text/javascript">
            function init() {
                var viewer = new Seadragon.Viewer("container");
                viewer.openDzi("/Content/sample.xml");
            }

            Seadragon.Utils.addEvent(window, "load", init);
        </script>
</asp:Content>

In openDzi, pass the path to the .xml or .dzi file you create with Deep Zoom Composer, and the library will take care of the rest. Of course, you’ll need to put all the rest of the files and folders the composer creates on your server, too. The viewer allows you to subscribe to events, create overlays, and add your own controls that respond to user input.

The last piece you’ll need is some styling for the div:

<style type="text/css">
    #container
    {
        width: 500px;
        height: 400px;
        background-color: black;
        border: 1px solid black;
        color: white;   /* for error messages, etc. */
    }
</style>

Impressive results with very little work!


MilkChart: Graph/Chart Library For MooTools

MilkChart is an outstanding set of MooTools classes that create robust charts from your static data. Chart types include column, bar, line, scatter, and pie. MilkChart uses the HTML5 <canvas> tag and is only supported on browsers other than IE.

Implementation is very easy; requires arguments in the form of HTML TABLE by passing its ID or key/value set of options. You can easily customize it via several options including height, width, fonts, colors, etc.

Developed by Brett Dixon; MilkChart is available for download Apache License 2.0.  You can find further information, demos & download on MilkChart Project Website.

Similar Posts:


  • Sponsored Links

  •  

  • .

    Copyright © 1996-2010 Answer My Query. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress