一.要开发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;
}
好了,运行一下吧,看看是不很有趣!看看效果吧。