示例#1
0
        private static void rotationDegreesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImagePanelView view = (ImagePanelView)d;

            if (view.ImageScaleMode != ScaleMode.UNSCALED)
            {
                view.setScaleMode();
            }
            else
            {
                view.setLayoutTransform();
            }
        }
示例#2
0
        private static async void locationChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImagePanelView view = (ImagePanelView)d;

            // cancel previously running load requests
            if (view.ImageLoadingTask != null && !view.ImageLoadingTask.IsCompleted)
            {
                view.TokenSource.Cancel();
                try
                {
                    await view.ImageLoadingTask;
                }
                catch (Exception)
                {
                }
            }

            view.TokenSource = new CancellationTokenSource();
            view.Token       = view.TokenSource.Token;

            String location = (String)e.NewValue;

            try
            {
                view.IsLoading = true;
                //view.ImageLoadingTask = Task<BitmapSource>.Factory.StartNew(() => loadImage(location, view.Token), view.Token);
                view.ImageLoadingTask = Task <BitmapImage> .Factory.StartNew(() => ImageUtils.loadImage(location, view.Token), view.Token);

                await view.ImageLoadingTask;

                view.pictureBox.Source = view.ImageLoadingTask.Result;
                view.scrollViewer.ScrollToHorizontalOffset(0);
                view.scrollViewer.ScrollToVerticalOffset(0);
                view.setScaleMode();
            }
            catch (OperationCanceledException)
            {
                Logger.Log.Info("Cancelled loading image:" + (String)location);
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Error loading image:" + (String)location, ex);
                MessageBox.Show("Error loading image: " + location + "\n\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                view.IsLoading = false;
            }
        }
示例#3
0
        private static void isLoadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImagePanelView view = (ImagePanelView)d;

            bool isLoading = (bool)e.NewValue;

            if (isLoading)
            {
                view.scrollViewer.Visibility          = Visibility.Hidden;
                view.loadingView.VisibilityAndAnimate = Visibility.Visible;
            }
            else
            {
                view.scrollViewer.Visibility          = Visibility.Visible;
                view.loadingView.VisibilityAndAnimate = Visibility.Collapsed;
            }
        }
示例#4
0
        private static void scaleModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImagePanelView view = (ImagePanelView)d;

            view.setScaleMode();
        }
示例#5
0
        private static void flipYChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ImagePanelView view = (ImagePanelView)d;

            view.setLayoutTransform();
        }