Exemplo n.º 1
0
        public void AddScreenshot(AppScreenshot screenshot)
        {
            _developerService.SaveScreenshotAsync(screenshot);
            MobileScreenshots.Add(screenshot);

            // notify ui
            this.OnPropertyChanged(nameof(HasMobileScreenshot));
        }
Exemplo n.º 2
0
        public async Task RemoveScreenshot(AppScreenshot screenshot)
        {
            if (MobileScreenshots.Count == 1)
            {
                await _alertMessageService.ShowAsync(_resourceLoader.GetString("AcquireTheMinimumNumberOfScreenshot"), null, DialogCommands.CloseDialogCommand);

                return;
            }

            await _developerService.RemoveScreenshotAsync(screenshot);

            MobileScreenshots.Remove(screenshot);

            // notify ui
            this.OnPropertyChanged(nameof(HasMobileScreenshot));
        }
Exemplo n.º 3
0
        private const long MaxMobileScreenshotSize     = MaxMobileScreenshotSizeUnit * 1024; // 300 KB
        private async void SendMobileScreenshot_Click(object sender, RoutedEventArgs e)
        {
            var appScreenshotPageViewModel = (IAppScreenshotsPageViewModel)this.DataContext;

            var open = new FileOpenPicker
            {
                SuggestedStartLocation = PickerLocationId.PicturesLibrary,
                ViewMode = PickerViewMode.Thumbnail
            };

            // Filter to include a sample subset of file types
            open.FileTypeFilter.Clear();
            open.FileTypeFilter.Add(".png");
            open.FileTypeFilter.Add(".jpg");
            open.FileTypeFilter.Add(".jpeg");

            var file = await open.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            var fileProperties = await file.GetBasicPropertiesAsync();

            if (fileProperties.Size > MaxMobileScreenshotSize)
            {
                await
                _alertMessageService.ShowAsync(
                    string.Format(_resourceLoader.GetString("MobileScreenshotSizeExceedsTheAllowableLimit"),
                                  MaxMobileScreenshotSizeUnit), null, DialogCommands.CloseDialogCommand);

                return;
            }

            //var x = await fileProperties.RetrievePropertiesAsync(new string[] {"Height", "Width"});


            using (var fileStream = await file.OpenAsync(FileAccessMode.Read))
            {
                var bitmapImage = new BitmapImage();
                await bitmapImage.SetSourceAsync(fileStream);

                // load original image
                var sourceBitmapImage = new BitmapImage {
                    DecodePixelType = DecodePixelType.Physical
                };
                fileStream.Seek(0);
                await sourceBitmapImage.SetSourceAsync(fileStream);

                var sourceImageHeight = sourceBitmapImage.PixelHeight;
                var originalWidth     = sourceBitmapImage.PixelWidth;

                // create thubmnail image
                const int thumbnailHeight = 400;
                var       thumbnailWidth  = thumbnailHeight * originalWidth / sourceImageHeight;

                var thumbnailBitmapImage = new BitmapImage
                {
                    DecodePixelHeight = thumbnailHeight,
                    DecodePixelWidth  = thumbnailWidth,
                    DecodePixelType   = DecodePixelType.Physical
                };

                fileStream.Seek(0);
                await thumbnailBitmapImage.SetSourceAsync(fileStream);


                var screenshot = new AppScreenshot();

                var appSpecification = appScreenshotPageViewModel.AppDetail.AppSpecification;
                screenshot.AppGuid   = appSpecification.Guid;
                screenshot.AppId     = appSpecification.AppId;
                screenshot.FileName  = Guid.NewGuid() + Path.GetExtension(file.Name);
                screenshot.Thumbnail = thumbnailBitmapImage;
                screenshot.SourceImageStorageFile = file;
                screenshot.ScreenshotSize         = Logic.DeveloperService.ScreenshotSize.Original;
                screenshot.ScreenshotType         = Logic.DeveloperService.ScreenshotType.Mobile;

                appScreenshotPageViewModel.AddScreenshot(screenshot);
            }
        }
 public async static Task <ScreenshotDataContract> ToAppScreenshotDataContract(this AppScreenshot screenshot)
 {
     return(new ScreenshotDataContract()
     {
         Id = screenshot.Id,
         AppId = screenshot.AppId,
         AppGuid = screenshot.AppGuid,
         FileName = screenshot.FileName,
         ScreenshotSize = screenshot.ScreenshotSize,
         ScreenshotType = screenshot.ScreenshotType,
         ImageSource = await screenshot.SourceImageStorageFile.AsByteArrayAsync(),
     });
 }
Exemplo n.º 5
0
 public async Task RemoveScreenshotAsync(AppScreenshot screenshot)
 {
     await _developerService.RemoveScreenshotAsync(await screenshot.ToAppScreenshotDataContract());
 }