public static void RotateSlide(Grid gSlideBox, int iTargetActualAngle) { MultiScaleImage multiScaleImage = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage; RotateTransform renderTransform = new RotateTransform(iTargetActualAngle); int acuteAngle = PublicMethods.GetAcuteAngle(iTargetActualAngle); float num = (float)Math.Sin(Math.PI / 180.0 * (double)acuteAngle); float num2 = (float)Math.Cos(Math.PI / 180.0 * (double)acuteAngle); float num3 = (0f - (float)(multiScaleImage.ActualWidth - gSlideBox.ActualWidth)) / 2f; float num4 = (0f - (float)(multiScaleImage.ActualHeight - gSlideBox.ActualHeight)) / 2f; multiScaleImage.RenderTransformOrigin = new Point(0.5, 0.5); multiScaleImage.RenderTransform = renderTransform; float num5 = (float)gSlideBox.ActualWidth; float num6 = (float)gSlideBox.ActualHeight; float num7 = num5 * num2 + num6 * num; float num8 = num5 * num + num6 * num2; float num9 = (0f - (num7 - num5)) / 2f; float num10 = (0f - (num8 - num6)) / 2f; multiScaleImage.Margin = new Thickness(num9, num10, num9, num10); Point pDeltaOffset = default(Point); if (multiScaleImage.Source != null) { pDeltaOffset.X = 0f - num3 + num9; pDeltaOffset.Y = 0f - num4 + num10; multiScaleImage.DeltaToPan(pDeltaOffset, false, 2); } }
public static void MagnifierZoomAboutPoint(Grid gMagnifierFlipBox, MultiScaleImage mSlide, Border bMagnifierBorder, Point pSlideBoxPixelPoint, float fScreenRatio) { MultiScaleImage multiScaleImage = gMagnifierFlipBox.FindName("mMagnifier") as MultiScaleImage; gMagnifierFlipBox.FindName("gMagnifierMarkBox"); if (mSlide.Source == null) { multiScaleImage.Visibility = Visibility.Collapsed; return; } multiScaleImage.Visibility = Visibility.Visible; if (multiScaleImage.Source != mSlide.Source) { multiScaleImage.Source = mSlide.Source; GetMagnifierMark(mSlide, gMagnifierFlipBox, fScreenRatio); } float num = mSlide.fTargetScale * 2f; if (multiScaleImage.OriginalScale != (double)num) { float num2 = float.Parse(multiScaleImage.DataContext.ToString()) * num; multiScaleImage.minScaleRelativeToMinSize = 1.0; multiScaleImage.OriginalScale = num; multiScaleImage.MaxScaleRelativeToMaxSize = 4f * num; float currentScale = multiScaleImage.GetCurrentScale(); multiScaleImage.ScaleCanvas(num2 / currentScale, new Point(bMagnifierBorder.Width / 2.0, bMagnifierBorder.Height / 2.0)); } Point slideBoxFlipValue = PublicMethods.GetSlideBoxFlipValue(PublicMethods.FindSlideBox(mSlide)); if (PublicMethods.GetElementFlipValue(gMagnifierFlipBox) != slideBoxFlipValue) { FlipTool.FlipElement(gMagnifierFlipBox, slideBoxFlipValue.X, slideBoxFlipValue.Y); } int elementActualAngle = PublicMethods.GetElementActualAngle(mSlide); if (PublicMethods.GetElementActualAngle(multiScaleImage) != elementActualAngle) { RotateMagnifier(multiScaleImage, elementActualAngle); } pSlideBoxPixelPoint = PublicMethods.FlipPoint(PublicMethods.FindSlideBox(mSlide), pSlideBoxPixelPoint); Point pPixelPoint = mSlide.BoxPixelToControlPixel(pSlideBoxPixelPoint); Point pNavigatorRatio = mSlide.ControlPixelToSlideRatio(pPixelPoint, false); Point pDeltaOffset = multiScaleImage.RatioOffsetToDeltaOffset(pNavigatorRatio); multiScaleImage.DeltaToPan(pDeltaOffset); Mark.UpdateAllMarks(gMagnifierFlipBox, fScreenRatio); }