コード例 #1
0
 private void AddScreenShot(Bitmap screenshot)
 {
     Contract.Requires(screenshot != null);
     var shot = Container.GetExportedValue<ISSScreenShotViewModel>();
     if (shot.IsNotNull())
     {
         shot.Header = ScreenshotName;
         shot.SetScreenShot(screenshot);
         ScreenShots.Add(shot);
         SelectedScreenShot = shot;
     }
 }
コード例 #2
0
        public void GetScreenShots()
        {
            try
            {
                PictureAlbumCollection allAlbums = _mediaLibrary.RootPictureAlbum.Albums;
                ScreenShots.Clear();

                foreach (var album in allAlbums)
                {
                    if (album.Name.ToUpper().Contains("SCREENSHOT"))
                    {
                        PictureCollection screenShots = album.Pictures;

                        foreach (var picture in screenShots)
                        {
                            Stream picToDisplay = picture.GetImage();

                            BitmapImage bmImage = new BitmapImage();
                            bmImage.SetSource(picToDisplay);

                            var imageToShow = new Image
                            {
                                Source = PictureDecoder.DecodeJpeg(picToDisplay, picture.Width, picture.Height)
                            };


                            ScreenShots.Add(new ScreenShot(picture.Name, new Uri(MediaLibraryExtensions.GetPath(picture), UriKind.Absolute), imageToShow));
                        }
                    }
                }

                if (ScreenShots.Count() >= 1)
                {
                    SelectedScreenShot = ScreenShots[ScreenShots.Count - 1];
                }
                else
                {
                    NoScreenShotVisibility = Visibility.Visible;
                }
            }
            catch (Exception ex)
            {
            }
        }