AjaxControlToolkit--SeaDragon

介绍了如何使用AjaxControlToolkit中的Seadragon控件实现DeepZoom效果,包括图片准备、属性设置及嵌套Menu的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

9月30日的AjaxControlToolkit 30930里增加了两个新的控件:AsyncFileUpload和Seadragon,上次大略的写了下AsyncFileUpload,这次就简单的写写Seadragon吧,不过Seadragon还是不是很明白。有什么问题望高手指出。

 

Seadragon主要来源于Microsoft Live Libs,大家有兴趣的话可以去http://livelabs.com/seadragon/看看。

而且微软早已经推出了SeaDragon的在线服务(http://seadragon.com/),借助这个服务。大家可以把自己服务器上的图片用类似于DeepZoom的方式发布,不过在线总是有很多缺点,虽说现在是网络社会了,但中国的网速...很多时候实在不敢恭维....

随着AjaxControlToolkit 30930加入了Seadragon控件,我们现在可以在本地实现这种类似DeepZoom的图片效果了,而且由于采用的是AJAX方式,所以不需要客户端安装任何插件(DeepZoom就必须Silverlight),废话不少了,下面就来简单说下Seadragon的使用吧。

 

要使用SeaDragon首先要准备图片,SeaDragon的SourceUrl要求是个xml或dzi文件,这里我们用Deep Zoom Composer来制作xml文件吧。

Deep Zoom Composer下载:http://www.microsoft.com/downloads/details.aspx?FamilyID=457b17b7-52bf-4bda-87a3-fa8a4673f8bf&DisplayLang=en

 

我们首先打开Deep Zoom Composer,然后导入图片

image

然后排列下图片,排成我们喜欢的样子(当然只要一张图片也可以)

image

当然还有其他的一些功能,比如加菜单,链接之类的,不过有的好像在导出AJAX的时候不大好用,导出成Silverlight的时候好使。

 

最后就是导出了,选择导出成SeaDragon AJAX

image

导出的进度条:

image

导出完成,打开看看生成了些啥吧

image

要用的就是上面的这两个

image

将文件dzc_output.xml和文件夹dzc_output_files拷贝到我们Web的目录下,然后就该画网页了。

 

首先新建个ASP.NET页面,拖进去个ScriptManager,然后再拖进来个Seadragon,看看效果

image

下面切换到代码视图,我们来完善Seadragon的属性。

        <cc1:Seadragon ID="Seadragon1" runat="server" AnimationTime="0.5" 
            Height="450px" SourceUrl="~/images/dzc_output.xml" Width="600px">
        </cc1:Seadragon>

 

最后看下效果:

image

image

image

上代码,其实很简单:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="seadragon.aspx.cs" Inherits="seadragon" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
      function pageLoad() {
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <cc1:Seadragon ID="Seadragon1" runat="server" AnimationTime="0.5" 
            Height="450px" SourceUrl="~/images/dzc_output.xml" Width="600px">
        </cc1:Seadragon>
    </div>
    </form>
</body>
</html>

恩。差不多就这些吧,没啥技术含量,最后贴下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 ID="Seadragon2"
  runat="server"
  CssClass="seadragon"
  SourceUrl="dzc_output.xml">
  <ControlsCollection>
    <ajaxToolkit:SeadragonControl runat="server"
      Anchor="TOP_RIGHT">
      <asp:Menu runat="server">
        <Items>
          <asp:MenuItem Text="Menu" Value="Menu" />
          <asp:MenuItem Text="Control" Value="Control" />
          <asp:MenuItem Text="Over" Value="Over" />
          <asp:MenuItem Text="Seadragon" Value="Seadragon" />
        </Items>
      </asp:Menu>
    </ajaxToolkit:SeadragonControl>
  </ControlsCollection>
  <OverlaysCollection>
    <ajaxToolkit:SeadragonScalableOverlayrunat="server"
      Rect-Height="0.24"
      Rect-Width="0.26" 
      CssClass="overlay" 
      Rect-Point-X="0.14" 
      Rect-Point-Y="0.06"     
    </ajaxToolkit:SeadragonScalableOverlay>
  </OverlaysCollection>

</ajaxToolkit:Seadragon>



本文转自 sun8134 博客园博客,原文链接: http://www.cnblogs.com/sun8134/archive/2009/11/05/1596636.html ,如需转载请自行联系原作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值