9月30日的AjaxControlToolkit 30930里增加了两个新的控件:AsyncFileUpload和Seadragon,上次大略的写了下AsyncFileUpload,这次就简单的写写Seadragon吧,不过Seadragon还是不是很明白。有什么问题望高手指出。
随着AjaxControlToolkit 30930加入了Seadragon控件,我们现在可以在本地实现这种类似DeepZoom的图片效果了,而且由于采用的是AJAX方式,所以不需要客户端安装任何插件(DeepZoom就必须Silverlight),废话不少了,下面就来简单说下Seadragon的使用吧。
要使用SeaDragon首先要准备图片,SeaDragon的SourceUrl要求是个xml或dzi文件,这里我们用Deep Zoom Composer来制作xml文件吧。
我们首先打开Deep Zoom Composer,然后导入图片
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_6.png"></a>
然后排列下图片,排成我们喜欢的样子(当然只要一张图片也可以)
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_8.png"></a>
当然还有其他的一些功能,比如加菜单,链接之类的,不过有的好像在导出AJAX的时候不大好用,导出成Silverlight的时候好使。
最后就是导出了,选择导出成SeaDragon AJAX
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_10.png"></a>
导出的进度条:
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_12.png"></a>
导出完成,打开看看生成了些啥吧
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_14.png"></a>
要用的就是上面的这两个
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_16.png"></a>
将文件dzc_output.xml和文件夹dzc_output_files拷贝到我们Web的目录下,然后就该画网页了。
首先新建个ASP.NET页面,拖进去个ScriptManager,然后再拖进来个Seadragon,看看效果
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_18.png"></a>
下面切换到代码视图,我们来完善Seadragon的属性。
最后看下效果:
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_22.png"></a>
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_24.png"></a>
<a href="http://images.cnblogs.com/cnblogs_com/sun8134/WindowsLiveWriter/AjaxControlToolkitSeaDragon_C9D8/image_26.png"></a>
上代码,其实很简单:
恩。差不多就这些吧,没啥技术含量,最后贴下SeaDragon的属性吧:
animationTime - The amount of time in seconds that animations should last. Default is 1.5.
blendTime - The amount of time in seconds that new tiles take to blend from transparent to opaque. Default is 0.5.
alwaysBlend - Whether tiles should always blend in and out, not just when they're first loaded. Default is false.
autoHideControls - Whether controls should get automatically hidden when the user's mouse is off the viewer and the image has stopped animating. Default is true.
immediateRender - Whether the most appropriate tiles should always be rendered first, before any lower-res tiles are rendered. This loses the "sharpening" effect and instead creates a very visible "tiling" effect. Default is false.
minZoomDimension - The minimum size (in screen pixels) of either dimension that can result from zooming out. Default is 16.
maxZoomPixelRatio - The maximum pixel ratio (screen pixel to content pixel) that can result from zooming in. Default is 4.
visibilityRatio - The minimum portion of the viewport that must show visible content in both dimensions. Default is 0.1.
springStiffness - Determines how sharply the springs used for animations move. Default is 5.0.
imageLoaderLimit - The maximum number of concurrent image downloads that can be performed by each viewer. Default is 2.
clickTimeThreshold - The maximum number of milliseconds that can pass between a mousedown and a mouseup for the action to still be considered a "quick" click. Default is 200.
clickDistThreshold - The maximum number of pixels the mouse can move between a mousedown and a mouseup for the action to still be considered a "quick" click. Default is 5.
zoomPerClick - The factor by which images should zoom when clicked on. Default is 2.
zoomPerSecond - The factor by which images should zoom over each second when the zoom buttons are held down. Default is 2.
sourceUrl - The path for all UI images. This can be absolute or relative. If relative, it must be relative to the HTML page. A change to this value will only affect new viewers. Default is "img/".
showNavigationControl - Whether navigation buttons should be shown.
其实,SeaDragon里还能嵌套其他的一些东西,比如Menu,不过捣鼓的还不大明白,还望大家指点。
最后附上example里嵌套Menu的一段代码吧:
</ajaxToolkit:Seadragon>
本文转自 sun8134 博客园博客,原文链接: http://www.cnblogs.com/sun8134/archive/2009/11/05/1596636.html ,如需转载请自行联系原作者