Esempio n. 1
0
 /// <summary>
 /// Applies the computed scale to the image control.
 /// </summary>
 private static void ApplyScale(Image image, ImageZoomerSettings settings)
 {
     ((CompositeTransform)image.RenderTransform).ScaleX = settings.TotalImageScale;
      ((CompositeTransform)image.RenderTransform).ScaleY = settings.TotalImageScale;
 }
Esempio n. 2
0
        /// <summary>
        /// Checks that dragging by the given amount won't result in empty space around the image
        /// </summary>
        private static bool IsDragValid(double scaleDelta, Point translateDelta, Image image, ImageZoomerSettings settings, out bool bounce)
        {
            if (settings.ImagePosition.X + translateDelta.X < image.ActualWidth * 0.33 || settings.ImagePosition.Y + translateDelta.Y < image.ActualHeight * 0.33)
             {
            bounce = true;
            return true;
             }
             if ((image.ActualWidth * settings.TotalImageScale * scaleDelta) + (settings.ImagePosition.X + translateDelta.X) < image.ActualWidth * 1.33)
             {
            bounce = true;
            return true;
             }
             if ((image.ActualHeight * settings.TotalImageScale * scaleDelta) + (settings.ImagePosition.Y + translateDelta.Y) < image.ActualHeight * 1.33)
             {
            bounce = true;
            return true;
             }

             if ((image.ActualWidth * settings.TotalImageScale * scaleDelta) + (settings.ImagePosition.X + translateDelta.X) < image.ActualWidth)
             {
            bounce = false;
            return false;
             }
             if ((image.ActualHeight * settings.TotalImageScale * scaleDelta) + (settings.ImagePosition.Y + translateDelta.Y) < image.ActualHeight)
             {
            bounce = false;
            return false;
             }

             bounce = false;
             return true;
        }
Esempio n. 3
0
 private static void ApplyPosition(Image image, ImageZoomerSettings settings)
 {
     ((CompositeTransform)image.RenderTransform).TranslateX = settings.ImagePosition.X;
      ((CompositeTransform)image.RenderTransform).TranslateY = settings.ImagePosition.Y;
 }
Esempio n. 4
0
 /// <summary>
 /// Updates the scaling factor by multiplying the delta.
 /// </summary>
 private static void UpdateImageScale(double scaleFactor, Image image, ImageZoomerSettings settings)
 {
     settings.TotalImageScale *= scaleFactor;
      ApplyScale(image, settings);
 }
Esempio n. 5
0
        private static void UpdateImagePosition(Point delta, Image image, ImageZoomerSettings settings)
        {
            var newPosition = new Point(settings.ImagePosition.X + delta.X, settings.ImagePosition.Y + delta.Y);

             if (newPosition.X > 0) newPosition.X = 0;
             if (newPosition.Y > 0) newPosition.Y = 0;

             if ((image.ActualWidth * settings.TotalImageScale) + newPosition.X < image.ActualWidth)
            newPosition.X = image.ActualWidth - (image.ActualWidth * settings.TotalImageScale);

             if ((image.ActualHeight * settings.TotalImageScale) + newPosition.Y < image.ActualHeight)
            newPosition.Y = image.ActualHeight - (image.ActualHeight * settings.TotalImageScale);

             settings.ImagePosition = newPosition;

             ApplyPosition(image, settings);
        }
Esempio n. 6
0
 /// <summary>
 /// Resets the zoom to its original scale and position
 /// </summary>
 private static void ResetImagePosition(Image image, ImageZoomerSettings settings)
 {
     settings.TotalImageScale = 1;
      settings.ImagePosition = new Point(0, 0);
      ApplyScale(image, settings);
      ApplyPosition(image, settings);
 }
Esempio n. 7
0
 /// <summary>
 /// Tells if the scaling is inside the desired range
 /// </summary>
 private static bool IsScaleValid(double scaleDelta, ImageZoomerSettings settings)
 {
     return (settings.TotalImageScale * scaleDelta >= 1) && (settings.TotalImageScale * scaleDelta <= settings.MAX_IMAGE_ZOOM);
 }