<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.Resources>
<Style TargetType="Image">
<Setter Property="Margin" Value="-12,-36,0,0"/>
</Style>
</Grid.Resources>
<phone:Panorama x:Name="photoFlow1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="530">
</phone:Panorama>
</Grid>

private void AddPanoramaItem(LongMoreViewModel ItemNumber)
{
for (int i = 0; i < ItemNumber.Apps.Count; i++)
{
PanoramaItem Navitation = new PanoramaItem();
Image nimage = new Image();
nimage.RenderTransform = new CompositeTransform();
nimage.ManipulationDelta += Navitation_ManipulationDelta;
nimage.DoubleTap += Navitation_DoubleTap;

AppRecommend mde = ItemNumber.Apps[i] as AppRecommend;
nimage.Source= new BitmapImage(new Uri(mde.Name, UriKind.Absolute));
nimage.Stretch = System.Windows.Media.Stretch.Fill;
Navitation.Content = nimage;
photoFlow1.Items.Add(Navitation);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////

private void Navitation_ManipulationDelta(object sender, System.Windows.Input.ManipulationDeltaEventArgs e)
{
Image grid = sender as Image;
if (grid == null)
return;
bool oldIsPinch = isPinching;
isPinching = e.PinchManipulation != null;

if (oldIsPinch == false && isPinching == false)
{
this.OnDragDelta(sender, e);
}
else if (oldIsPinch == false && isPinching == true)
{
this.OnPinchStarted(sender, e);
}
else if (oldIsPinch == true && isPinching == true)
{
this.OnPinchDelta(sender, e);
}
else if (oldIsPinch == true && isPinching == false)
{
this.OnPinchCompleted(sender, e);
}
}
private void OnDragDelta(object sender, ManipulationDeltaEventArgs e)
{
FrameworkElement framework = sender as FrameworkElement;
CompositeTransform compositeTransform = framework.RenderTransform as CompositeTransform;
if (compositeTransform.ScaleX == 1.0 && compositeTransform.ScaleY == 1.0)
return;
Point point = TransChanged(compositeTransform).Transform(e.DeltaManipulation.Translation);
compositeTransform.TranslateX += point.X;
compositeTransform.TranslateY += point.Y;
}
private GeneralTransform TransChanged(CompositeTransform trans)
{
CompositeTransform compositeTransform = new CompositeTransform();
compositeTransform.Rotation = trans.Rotation;
compositeTransform.ScaleX = trans.ScaleX;
compositeTransform.ScaleY = trans.ScaleY;
compositeTransform.CenterX = trans.CenterX;
compositeTransform.CenterY = trans.CenterY;
compositeTransform.TranslateX = 0.0;
compositeTransform.TranslateY = 0.0;
return (GeneralTransform)compositeTransform;
}
private void OnPinchStarted(object sender, ManipulationDeltaEventArgs e)
{
this.isPinching = true;
foreach (PanoramaItem item in photoFlow1.Items)
{
PanoramaItem pItem = photoFlow1.SelectedItem as PanoramaItem;
if (!item.Equals(pItem))
item.Visibility = Visibility.Collapsed;
}
}
private void OnPinchDelta(object sender, ManipulationDeltaEventArgs e)
{
FrameworkElement framework = sender as FrameworkElement;
CompositeTransform compositeTransform = framework.RenderTransform as CompositeTransform;
double scaleX = compositeTransform.ScaleX;
double deltaScale1 = e.PinchManipulation.DeltaScale;
double scaleY = compositeTransform.ScaleY;
double deltaScale2 = e.PinchManipulation.DeltaScale;
double num1 = compositeTransform.ScaleX * deltaScale1;
double num2 = compositeTransform.ScaleY * deltaScale2;
if (num2 > (double)this.maxScale || num1 > (double)this.maxScale)
{
compositeTransform.ScaleX = (double)this.maxScale;
compositeTransform.ScaleY = (double)this.maxScale;
}
else
{
compositeTransform.ScaleX = num1;
compositeTransform.ScaleY = num2;
}
}
private void OnPinchCompleted(object sender, ManipulationDeltaEventArgs e)
{
this.isPinching = false;
}
private void Navitation_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
{
FrameworkElement framework = sender as FrameworkElement;
CompositeTransform compositeTransform = framework.RenderTransform as CompositeTransform;
compositeTransform.ScaleX = compositeTransform.ScaleY = 1;
compositeTransform.CenterX = framework.Width / 2;
compositeTransform.CenterY = framework.Height / 2;

foreach (PanoramaItem item in photoFlow1.Items)
{
PanoramaItem pItem = photoFlow1.SelectedItem as PanoramaItem;
if (!item.Equals(pItem))
item.Visibility = Visibility.Visible;
}
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

<!--<phone:Panorama x:Name="photoFlow1" ItemsSource="{Binding Apps}" Margin="-12,0,-48,0">
<phone:Panorama.HeaderTemplate>
<DataTemplate>
<ContentControl Content="" FontSize="1"/>
</DataTemplate>
</phone:Panorama.HeaderTemplate>
<phone:Panorama.ItemTemplate>
<DataTemplate>
<Image Stretch="None" x:Name="Navitation" local:CCImage.Source="{Binding Name}"
ManipulationDelta="Navitation_ManipulationDelta" DoubleTap="Navitation_DoubleTap">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image>
</DataTemplate>
</phone:Panorama.ItemTemplate>
</phone:Panorama>-->

public class LongMoreViewModel : BaseViewModel
{
public LongMoreViewModel()
{
Apps = new ObservableCollection<object>();
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/9418d78e-41d3-4010-b752-08a22f56a1bd?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/be2dac62-de4a-44bb-87bf-1f2b41d56df1?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/e0117eea-1cff-4c4b-835f-d00ebf4abe26?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/cb572d91-f0c1-4bdc-92b6-0b510801cf33?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/a6fa5c5d-f7a1-4c21-a5f8-0040383263ee?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/ac5a04d3-9a4a-4d40-9e7b-fa2db58b4e05?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/dcedb633-a6f7-4113-9211-598e30e38cca?imageType=ws_screenshot_large&rotation=0" });
Apps.Add(new AppRecommend() { Name = "http://cdn.marketplaceimages.windowsphone.com/v8/images/aa048089-c5de-426f-b313-462a2996c0b9?imageType=ws_screenshot_large&rotation=0" });
}
public IList<object> Apps { get; set; }
private BitmapImage imageSource;
/// <summary>
/// 获取或设置当前分享天气的图片.
/// </summary>
public BitmapImage ImageSource
{
get
{
return imageSource;
}
set
{
if (value != imageSource)
{
imageSource = value;
NotifyPropertyChanged("ImageSource");
}
}
}
}
public class AppRecommend
{
public string Name { get; set; }

public override bool Equals(object obj)
{
if ((obj != null) && (obj.GetType() == typeof(PanoramaItem)))
{
var thePanoItem = (PanoramaItem)obj;

return base.Equals(thePanoItem.Header);
}
else
{
return base.Equals(obj);
}
}

public override int GetHashCode()
{
return base.GetHashCode();
}
}

wp8 入门到精通 Gallery的更多相关文章

  1. wp8 入门到精通 虚拟标示符 设备ID

    //获得设备虚拟标示符 wp8 public string GetWindowsLiveAnonymousID() { object anid = new object(); string anony ...

  2. wp8 入门到精通 仿美拍评论黑白列表思路

    static bool isbool = false; private void BindGameDelete() { Tile tile = new Tile(); List<Color> ...

  3. wp8 入门到精通 生命周期

  4. wp8 入门到精通 定时更新瓷贴

    public class ScheduledAgent : ScheduledTaskAgent { static ScheduledAgent() { Deployment.Current.Disp ...

  5. wp8 入门到精通 ImageCompress 图片压缩

    //实例化选择器 PhotoChooserTask photoChooserTask = new PhotoChooserTask(); BitmapImage bimg; int newPixelW ...

  6. wp8 入门到精通 MultiMsgPrompt

    List<NotifyMsg> arraymsg = new List<NotifyMsg>(); List<NotifyInfo> ArrayNotifyInfo ...

  7. wp8 入门到精通 数据库更新字段(一)

    public class UserInfoDB : BaseDB { public UserInfoDB() : base(@"Data Source=isostore:\MakeLove\ ...

  8. wp8 入门到精通 启动系统分享照片任务

    PhotoChooserTask photoChooserTask = new PhotoChooserTask(); photoChooserTask.Completed += photoChoos ...

  9. wp8 入门到精通 Utilities类 本地存储+异步

    public class CCSetting { public async static void AddOrUpdateValue<T>(string key, T value) { t ...

随机推荐

  1. WebRTC

    WebRTC,名称源自网页实时通信(Web Real-Time Communication)的缩写,是一个支持网页浏览器进行实时语音对话或视频对话的技术,是谷歌2010年以6820万美元收购Globa ...

  2. jq鼠标隐藏显示的方法

    <div style="width:300px; float:left;">        <div onmouseover="testOnmouseO ...

  3. 新建samba配置步骤

    Linux系统默认已经安装了Samba,但是没有安装Samba服务: 1,先查看安装情况:rpm -qa|grep samba 根据系统的安装情况选择下载或者通过光驱安装所缺的rpm包. 我的安装情况 ...

  4. 迁移mysql数据到oracle上

    转自:http://www.cnblogs.com/Warmsunshine/p/4651283.html 我是生成的文件里面的master.sql里面的sql,一个一个拷出来的. 迁移mysql数据 ...

  5. wxPython+Boa Constructor环境配置

    配置之前先完成eclipse + Pydev的配置环境.详见http://www.cnblogs.com/dflower/archive/2010/05/13/1734522.html 1. 安装 w ...

  6. MongoDB 3.0 新特性【转】

    本文来自:http://www.open-open.com/lib/view/open1427078982824.html#_label3 更多信息见官网: http://docs.mongodb.o ...

  7. [转]Android How to Download and Make Volley.jar

    原文来自:http://tips.androidhive.info/2015/08/android-how-to-download-and-make-volley-jar/   1 Comment . ...

  8. Ubuntu 配置 Tomcat

    系统环境:Ubuntu 10.10(linux-kernel 2.6.35-22) 安装版本:apache-tomcat-7.0.29.tar.gz(官方网址:Apache Tomcat) 安装步骤: ...

  9. 【leetcode】Number of Islands(middle)

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  10. 【hadoop2.6.0】利用JAVA API 实现数据上传

    原本的目的是想模拟一个流的上传过程,就是一边生成数据,一边存储数据,因为能用上HADOOP通常情况下原本数据的大小就大到本地硬盘存不下.这一般是通过把数据先一部分一部分的缓冲到本地的某个文件夹下,hd ...