Ejemplo n.º 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "PNG|*.png",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Multiselect      = false,
                Title            = "Open Image",
                CheckPathExists  = true,
                CheckFileExists  = true
            };

            var urlString = string.Empty;

            if (openFileDialog.ShowDialog() == true)
            {
                RevealedImage = null;
                urlString     = openFileDialog.FileName;

                SelectPhotoButton.IsEnabled = false;
                RevealButton.IsEnabled      = false;

                if (InitialImageLoad)
                {
                    ThumbText.Visibility = Visibility.Collapsed;
                }
                else
                {
                    await ImagePreview.HideUsingLinearAnimationAsync();
                }

                await ThumbLoading.ShowUsingLinearAnimationAsync();

                var availableToProcess = await ProcessImageAsync(urlString);

                await ThumbLoading.HideUsingLinearAnimationAsync();

                if (!availableToProcess)
                {
                    await ImagePreview.ShowUsingLinearAnimationAsync();

                    RevealButton.IsEnabled = true;
                }

                SelectPhotoButton.IsEnabled = true;

                if (InitialImageLoad)
                {
                    InitialImageLoad = false;
                }
                if (!RevealButton.IsVisible && !availableToProcess)
                {
                    RevealButton.ShowUsingLinearAnimation();
                }
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter           = "Jpeg Photos|*.jpg;*.jpeg",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Multiselect      = false,
                Title            = "Open Image",
                CheckPathExists  = true,
                CheckFileExists  = true
            };

            var urlString = string.Empty;

            if (openFileDialog.ShowDialog() == true)
            {
                urlString = openFileDialog.FileName;

                SelectPhotoButton.IsEnabled = false;
                NextPageButton.IsEnabled    = false;

                if (initialImageLoad)
                {
                    ThumbText.Visibility = Visibility.Collapsed;
                }
                else
                {
                    await ImagePreview.HideUsingLinearAnimationAsync();
                }

                await ThumbLoading.ShowUsingLinearAnimationAsync();

                await ProcessImageAsync(urlString);

                await ThumbLoading.HideUsingLinearAnimationAsync();

                await ImagePreview.ShowUsingLinearAnimationAsync();

                SelectPhotoButton.IsEnabled = true;
                NextPageButton.IsEnabled    = true;

                if (initialImageLoad)
                {
                    initialImageLoad = false;
                    NextPageButton.ShowUsingLinearAnimation();
                }
            }
        }