Exemple #1
0
        public async void Apply()
        {
            var bytes = await SelectedImage.AsBytes();

            parent.ChangeImage(bytes);
            navigationService.GoBack();
        }
Exemple #2
0
        public async void SelectImage(EditCountdownViewModel viewModel)
        {
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".bmp");

            var file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            var image = await SelectedImage.FromFile(file);

            if (!image.IsValid)
            {
                return;
            }

            if (image.IsSquare)
            {
                var imageData = await image.AsBytes();

                viewModel.ChangeImage(imageData);
                return;
            }

            var cropViewModel = new CropImageViewModel(viewModel)
            {
                SelectedImage = image
            };

            Frame.Navigate(typeof(CropImagePage), cropViewModel);
        }