您的位置:首页 > 其它

一起学Windows phone 7开发(四. DeepZoom)

2010-08-05 12:14 423 查看
DeepZoom 是silverlight的特色功能之一,也同样被加到了windows phone 7中来。这个功能现在应该算是phone7 Ui的主要功能了吧。因为phone7的很多Ui就是DeepZoom开发的,另外在MIX10大会有展出的漫画阅读软件也是由DeepZoom开发的,由此也可以看的出这个功能在phone7上的重要性。

一.要开发DeepZoom首先需要 DeepZoom Composer这个在expression下的工具来生成deepzoom图集。


二.新建windows phone application,在xaml设计窗口加入以下语句:

<MultiScaleImage x:Name="msi" Width="486" Height="652" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-6,0,0,0" />

在Phone7中只能用MultiScaleImage来展示DeepZoom图集。

三.将DeepZoom Composer生成的图集加入到工程中。

四.加入如下代码,以显示图集:

this.msi.ImageOpenSucceeded += new RoutedEventHandler(msi_ImageOpenSucceeded);

void msi_ImageOpenSucceeded(object sender, RoutedEventArgs e)

{

Point point = this.msi.ViewportOrigin;

msi.ViewportWidth = 1;

msi.ViewportOrigin = new Point(0, -0.3);

}

this.msi.Source = new DeepZoomImageTileSource(new Uri("Assets /dzc_output.xml", UriKind.Relative));

五.要让图集移动,缩放,还需要加入MouseMove,LButtonDown,LbuttonUp的响应。

private void Zoom(double zoomnew, Point p)

{

if (zoomnew < 0.5)

zoomnew = 0.5;

msi.ZoomAboutLogicalPoint(zoomnew / zoom, p.X, p.Y);

zoom = zoomnew;

}

好了,运行一下吧,看看是不很有趣!看看效果吧。









内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: