當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。