Feeds:
文章
评论

Archive for 2009年11月

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>

  • Read Full Post »

    (转)死了都要try !

    #region转贴-如有侵权-敬请见谅-justfun
    //***********仅献给在奋斗在中国编程长征路上的战友们!*************//
    //*******感觉挺好玩的,转一下***********//
    /**//*
    作词 作曲 演唱 某某程序员
    copy by 包子
    
    
    死了都要try!
    不catch我不痛快!
    程序毁灭throw还在!
    把每天,
    当作是程序来更改,
    一改一天,
    累到泪水都掉下来,
    不理会,
    老板是好还是坏,
    只要有工资,
    来还贷.
    改,
    不是需求做的太坏,
    那是sb客户想要什么,
    自己都不明白.
    忍受现在,
    自己一生的还不完的贷,
    很多模块,
    不能完成,
    我还得改.
    死了都要try!
    不catch我不痛快!
    程序毁灭throw还在
    */
    
    
    #endregion

    Read Full Post »