zoukankan      html  css  js  c++  java
  • [Windows Phone 7]开发分享图片的插件(2)

    在WP7的picture hub中,选中一张图片,查看图片时,点击“…”菜单,点share…时,会出现一个菜单(这个菜单中就是可以对选中的图片进行分享或者处理的应用列表)
    下面介绍如何实现这个一键分享功能:
    1.创建share picker xml文件
    2.获取和处理图片
    在你的应用程序中新建一个叫“E0F0E49A-3EB1-4970-B780-45DA41EC7C28.xml”的XML文件
    注意:请把文件的 Copy to Output Directory的属性设置成Copy always.
    这样你的应用就会出现在share...中了,但是如何处理选中的图片了,实际上,从share...中启动你的应用时,图片会通过导航参数“FileId”传递给你的应用程序.
    得到该图片示例如下:
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        // Get a dictionary of query string keys and values.
        IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;
    
        // Ensure that there is at least one key in the query string, and check 
        // if the "FileId" key is present.
        if (queryStrings.ContainsKey("FileId"))
        {
            // Retrieve the picture from the local Zune Media database using the FileID
            // passed to the application.
            MediaLibrary library = new MediaLibrary();
            Picture picture = library.GetPictureFromToken(queryStrings["FileId"]);
    
            // Create a WriteableBitmap object and add it to the Image control Source property.
            BitmapImage bitmap = new BitmapImage();
            bitmap.SetSource(picture.GetImage());
            WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);
            retrievePic.Source = picLibraryImage;
        }
    }
  • 相关阅读:
    UVa10050 Hartals
    UVa540 Team Queue
    UVa 11234 Expressions (二叉树重建&由叶往根的层次遍历)
    stl lower_bound upper_bound binary_search equal_range
    【windows】使用键盘代替鼠标的快捷键
    【Linux】xshell连接中断后就无法连接虚拟机中的Linux
    【Linux命令】ls命令
    【DB2】NULLS LAST与NULLS FIRST
    【PPT】PPT倒计时动画的制作方法 5.4.3.2.1...
    【Datastage】函数大全
  • 原文地址:https://www.cnblogs.com/ssqjd/p/1970431.html
Copyright © 2011-2022 走看看