当前位置: 首页>>代码示例>>C#>>正文


C# MediaLibrary.GetPictureFromToken方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Media.MediaLibrary.GetPictureFromToken方法的典型用法代码示例。如果您正苦于以下问题:C# MediaLibrary.GetPictureFromToken方法的具体用法?C# MediaLibrary.GetPictureFromToken怎么用?C# MediaLibrary.GetPictureFromToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Media.MediaLibrary的用法示例。


在下文中一共展示了MediaLibrary.GetPictureFromToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnNavigatedTo

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            imageDetails.Text = "";

            IDictionary<string, string> queryStrings =
               NavigationContext.QueryString;

            string token = null;
            string source = null;
            if (queryStrings.ContainsKey("token"))
            {
                token = queryStrings["token"];
                source = "Photos_Extra_Viewer";
            }
            else if (queryStrings.ContainsKey("FileId"))
            {
                token = queryStrings["FileId"];
                source = "Photos_Extra_Share";
            }

            if (!string.IsNullOrEmpty(token))
            {
                MediaLibrary mediaLib = new MediaLibrary();
                Picture picture = mediaLib.GetPictureFromToken(token);
                currentImage = ImageUtil.GetBitmap(picture.GetImage());
                photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
                imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}",
                    source, picture.Name, token);
            }

            imageDetails.Text += "\nUri: " + e.Uri.ToString();
        }
开发者ID:whrxiao,项目名称:Windows-Phone-7-In-Action,代码行数:32,代码来源:MainPage.xaml.cs

示例2: OnNavigatedTo

      // Sample code for building a localized ApplicationBar
      //private void BuildLocalizedApplicationBar()
      //{
      //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
      //    ApplicationBar = new ApplicationBar();

      //    // Create a new button and set the text value to the localized string from AppResources.
      //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
      //    appBarButton.Text = AppResources.AppBarButtonText;
      //    ApplicationBar.Buttons.Add(appBarButton);

      //    // Create a new menu item with the localized string from AppResources.
      //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
      //    ApplicationBar.MenuItems.Add(appBarMenuItem);
      //}

      protected override void OnNavigatedTo(NavigationEventArgs e)
      {
         if (State.ContainsKey("customCamera"))
         {
            State.Remove("customCamera");
            InitializeCamera();
         }

         IDictionary<string, string> queryStrings =  NavigationContext.QueryString;
         
         string action = null;
         if (queryStrings.ContainsKey("Action"))
            action = queryStrings["Action"];
         
         string token = null;
         if (queryStrings.ContainsKey("FileId"))
            token = queryStrings["FileId"];
          
         if (!string.IsNullOrEmpty(token))
         {
            MediaLibrary mediaLib = new MediaLibrary();
            Picture picture = mediaLib.GetPictureFromToken(token);
            currentImage = PictureDecoder.DecodeJpeg(picture.GetImage());
            photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
            imageDetails.Text = string.Format("Image from {0} action.\nPicture name:\n{1}\nMedia library token:\n{2}", action, picture.GetPath(), token);
         }
      }
开发者ID:timothybinkley,项目名称:Windows-Phone-8-In-Action,代码行数:43,代码来源:MainPage.xaml.cs

示例3: OnNavigatedTo

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // Get a dictionary of query string keys and values.
            IDictionary<string, string> queryStrings = this.NavigationContext.QueryString;

            // Check whether the app has been started by the photo edit picker of the Windows Phone System
            // More information about the photo edit picker here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202966(v=vs.105).aspx
            if (queryStrings.ContainsKey("FileId") && imageAlreadyLoaded == false)
            {
                imageAlreadyLoaded = true;

                // Retrieve the photo from the media library using the FileID passed to the app.
                MediaLibrary library = new MediaLibrary();
                Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]);

                // Create a BitmapImage object and add set it as the PreviewImage
                BitmapImage bitmapFromPhoto = new BitmapImage();
                bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage());

                SetPreviewImage(bitmapFromPhoto);
            }

            // Every time we navigate to the MainPage we check if a filter has been selected on the FilterView page
            // If so, we apply this filter to the PreviewImage
            if (FilterSelectorView.SelectedFilter != null)
            {
                await ApplyFilter(FilterSelectorView.SelectedFilter, PreviewPicture);
            }            
        }
开发者ID:robinmanuelthiel,项目名称:Instagram-In-One-Hour,代码行数:29,代码来源:MainPage.xaml.cs

示例4: OnNavigatedTo

        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 whether the "FileId" key is present.
            if (queryStrings.ContainsKey("FileId"))
            {
                // Retrieve the photo from the media library using the FileID passed to the app.
                MediaLibrary library = new MediaLibrary();
                Picture photoFromLibrary = library.GetPictureFromToken(queryStrings["FileId"]);

                // Create a BitmapImage object and add set it as the image control source.
                // To retrieve a full-resolution image, use the GetImage() method instead.
                BitmapImage bitmapFromPhoto = new BitmapImage();
                bitmapFromPhoto.SetSource(photoFromLibrary.GetPreviewImage());
                image1.Source = bitmapFromPhoto;
            }
        }
开发者ID:seb2020,项目名称:CloudWave,代码行数:19,代码来源:PhotoShare.xaml.cs

示例5: OnNavigatedTo

 /// <summary>
 /// Called when this MainPage becomes the active page in a frame.
 /// </summary>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (!bmp.IsLoaded)
     {
         Stream stream;
         var query = this.NavigationContext.QueryString;
         if (query.ContainsKey("token"))
         {
             MediaLibrary lib = new MediaLibrary();
             Picture pic = lib.GetPictureFromToken(query["token"]);
             stream = pic.GetImage();
         }
         else
         {
             Uri uri = new Uri("Images/lenna.jpg", UriKind.Relative);
             stream = Application.GetResourceStream(uri).Stream;
         }
         bmp.Load(stream);
     }
     base.OnNavigatedTo(e);
 }
开发者ID:SSheldon,项目名称:Imagister,代码行数:24,代码来源:MainPage.xaml.cs

示例6: OnActivate

        protected override void OnActivate()
        {
            var library = new MediaLibrary();
            var photoFromLibrary = library.GetPictureFromToken(FileId);

            var image = photoFromLibrary.GetImage();
            var buffer = LerTudo(image);
            dadosDaMulta.ExibirImagem(image, true);
            
            fileInfo = new HttpUpload.FileInfo
            {
                FileName = photoFromLibrary.Name,
                ContentType = "image/jpeg",
                Buffer = buffer,
                ParamName = "multa[foto]"
            };

            dadosDaMulta.PropertyChanged += (sender, e) => { if (e.PropertyName == "IsValid") NotifyOfPropertyChange("CanShare"); };

            base.OnActivate();
        }
开发者ID:giggio,项目名称:multassociais-windowsapps,代码行数:21,代码来源:PhotoShareViewModel.cs

示例7: OnNavigatedTo

        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 whether the "token" key is present.
            if (queryStrings.ContainsKey("token"))
            {

                // Retrieve the picture from the media library using the token passed to the application.
                MediaLibrary library = new MediaLibrary();
                Picture picture = library.GetPictureFromToken(queryStrings["token"]);

                // Create a WriteableBitmap object and add it to the Image control Source property.
                BitmapImage bitmap = new BitmapImage();
                bitmap.CreateOptions = BitmapCreateOptions.None;
                bitmap.SetSource(picture.GetImage());

               // WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);
                Image_ToBeUploaded.Source = bitmap;
            }
        }
开发者ID:rkrishnasanka,项目名称:Dubizzle,代码行数:22,代码来源:NewAd.xaml.cs

示例8: OnNavigatedTo

 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     if (NavigationContext.QueryString.ContainsKey("token"))
     { 
         var library = new MediaLibrary();
         Picture picture = library.GetPictureFromToken(NavigationContext.QueryString["token"]);
         BitmapImage img = new BitmapImage() { CreateOptions = BitmapCreateOptions.None};
         img.SetSource(picture.GetImage());
         image.Source = img;
         NavigationContext.QueryString.Remove("token");
     }
     else if (NavigationContext.QueryString.ContainsKey("Photo"))
     {
         if (bool.Parse(NavigationContext.QueryString["Photo"]))
             image.Source = new BitmapImage(new Uri(instance.CurrentImage, UriKind.RelativeOrAbsolute));
         else
         {
             task.Show();
             NavigationContext.QueryString.Remove("Photo");
         }
     }
     base.OnNavigatedTo(e);
 }
开发者ID:nsamala,项目名称:LeMeme,代码行数:23,代码来源:BuildMemeView.xaml.cs

示例9: TryInitPhoto

        private void TryInitPhoto()
        {
            // Get a dictionary of query string keys and values.
            IDictionary<string, string> queryStrings = Page.NavigationContext.QueryString;

            // Ensure that there is at least one key in the query string, and check whether the "FileId" key is present.
            if (queryStrings.ContainsKey(FileId))
            {
                string fileId = queryStrings[FileId];
                MediaLibrary library = new MediaLibrary();
                Picture photoFromLibrary = library.GetPictureFromToken(fileId);
                InitImaging(null, fileId);
            }
        }
开发者ID:jbruchanov,项目名称:ZumpaReader-WinPhone,代码行数:14,代码来源:PostPageViewModel.cs

示例10: FromLibraryImage

        public void FromLibraryImage(string token)
        {
            System.Diagnostics.Debug.Assert(token != null);

            using (var library = new MediaLibrary())
            {
                using (var picture = library.GetPictureFromToken(token))
                {
                    var libraryPath = picture.GetPath();

                    if (LibraryPath != libraryPath)
                    {
                        LibraryPath = libraryPath;
                        LocalPath = Mapping.MatchLibraryPathWithLocalPath(libraryPath);

                        if (LocalPath != null)
                        {
                            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                            {
                                Image = store.OpenFile(LocalPath, FileMode.Open);
                            }
                        }
                        else
                        {
                            Image = picture.GetImage();
                        }

                        OriginalPath = Mapping.MatchPathWithOriginalPath(libraryPath);

                        if (OriginalPath != null)
                        {
                            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                            {
                                Original = store.OpenFile(OriginalPath, FileMode.Open);
                            }
                        }
                        else
                        {
                            Original = null;
                        }

                        OriginalLibraryPath = null;
                    }
                }
            }
        }
开发者ID:morefun0302,项目名称:photo-inspector,代码行数:46,代码来源:PhotoModel.cs

示例11: OnNavigatedTo

        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();
        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);
        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (State.ContainsKey("customCamera"))
            {
                State.Remove("customCamera");
                InitializeCamera();
            }

            IDictionary<string, string> queryStrings = NavigationContext.QueryString;

            string fileId = null;
            string source = null;
            // Photos_Extra_Viewer is deprecated
            //if (queryStrings.ContainsKey("token"))
            //{
            //    token = queryStrings["token"];
            //    source = "Photos_Extra_Viewer";
            //}
            //else
            if (queryStrings.ContainsKey("Action") && queryStrings.ContainsKey("FileId"))
            {

                fileId = queryStrings["FileId"];
                source = queryStrings["Action"];
            }

            if (!string.IsNullOrEmpty(fileId))
            {
                MediaLibrary mediaLib = new MediaLibrary();
                Picture picture = mediaLib.GetPictureFromToken(fileId);

                currentImage = PictureDecoder.DecodeJpeg(picture.GetImage());
                photoContainer.Fill = new ImageBrush { ImageSource = currentImage };
                imageDetails.Text = string.Format("Image from {0}.\nPicture name:\n{1}\nMedia library token:\n{2}",
                    source, picture.Name, fileId);
            }
        }
开发者ID:amrzagloul,项目名称:Windows-Phone-8-In-Action,代码行数:50,代码来源:MainPage.xaml.cs

示例12: FromToken

 public async Task FromToken(string token)
 {
     using (var library = new MediaLibrary())
     {
         using (var picture = library.GetPictureFromToken(token))
         {
             await FromLibraryPath(picture.GetPath());
         }
     }
 }
开发者ID:morefun0302,项目名称:photo-inspector,代码行数:10,代码来源:PhotoModel.cs

示例13: GetPictureByToken

        public static Picture GetPictureByToken(string token)
        {
            var library = new MediaLibrary();
            var photoFromLibrary = library.GetPictureFromToken(token);

            return photoFromLibrary;
        }
开发者ID:NPadrutt,项目名称:Places,代码行数:7,代码来源:Utilities.cs

示例14: ImageManipulator

        public ImageManipulator(string token, Image helper, int bsize)
        {
            // Retrieve the picture from the media library using the token passed to the application.
            MediaLibrary library = new MediaLibrary();
            Picture picture = library.GetPictureFromToken(token);

            InitFromStream(picture.GetImage(), helper);
            this.Radius = (int)((finalImage.PixelWidth * bsize) / helper.Width);
        }
开发者ID:ahmetalpbalkan,项目名称:colorify,代码行数:9,代码来源:ImageManipulator.cs

示例15: OnNavigatedTo

        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 whether the "token" key is present.
            if (queryStrings.ContainsKey("token"))
            {
                // Retrieve the picture from the media library using the token passed to the application.
                MediaLibrary library = new MediaLibrary();
                Picture picture = library.GetPictureFromToken(queryStrings["token"]);
                StartLoadingImage(picture.GetImage());
            }
        }
开发者ID:ahmetalpbalkan,项目名称:colorify,代码行数:14,代码来源:MainPage.xaml.cs


注:本文中的Microsoft.Xna.Framework.Media.MediaLibrary.GetPictureFromToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。