示例#1
0
        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);
        }
示例#2
0
        public static void UpdateViewRect(Grid gSlideBox, bool bScaleChanged, bool animate = false, float fDurationTime = 0f, EasingFunctionBase easing = null)
        {
            MultiScaleImage mSlide       = gSlideBox.FindName("mMultiScaleImage") as MultiScaleImage;
            ZoomableCanvas  zcCycleGrid  = gSlideBox.FindName("zcGrid") as ZoomableCanvas;
            Border          border       = gSlideBox.FindName("bGridBox") as Border;
            float           fTargetScale = mSlide.fTargetScale;

            if (zcCycleGrid.Children.Count == 0)
            {
                return;
            }
            System.Windows.Point point = mSlide.SlideRatioToBoxPixel(new System.Windows.Point(0.0, 0.0));
            int elementActualAngle     = PublicMethods.GetElementActualAngle(mSlide);

            if (!animate)
            {
                zcCycleGrid.ApplyAnimationClock(ZoomableCanvas.ScaleProperty, null);
                border.ApplyAnimationClock(FrameworkElement.MarginProperty, null);
                border.Margin     = new Thickness(point.X, point.Y, 0.0, 0.0);
                zcCycleGrid.Scale = fTargetScale;
                if (bScaleChanged)
                {
                    foreach (System.Windows.Shapes.Rectangle child in zcCycleGrid.Children)
                    {
                        child.StrokeThickness = 1f / fTargetScale;
                    }
                }
            }
            else
            {
                border.BeginAnimation(FrameworkElement.MarginProperty, new ThicknessAnimation(new Thickness(point.X, point.Y, 0.0, 0.0), TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                if (bScaleChanged)
                {
                    DoubleAnimation doubleAnimation = new DoubleAnimation(fTargetScale, TimeSpan.FromMilliseconds(fDurationTime))
                    {
                        EasingFunction = easing
                    };
                    int i = 0;
                    doubleAnimation.CurrentTimeInvalidated += delegate
                    {
                        Task.Factory.StartNew(delegate
                        {
                            i++;
                            if (i % 3 == 0)
                            {
                                float fCurrentScale = 0f;
                                zcCycleGrid.Dispatcher.BeginInvoke((Action) delegate
                                {
                                    fCurrentScale = mSlide.GetCurrentScale();
                                    foreach (System.Windows.Shapes.Rectangle child2 in zcCycleGrid.Children)
                                    {
                                        child2.StrokeThickness = 1f / fCurrentScale;
                                    }
                                }, DispatcherPriority.Loaded);
                            }
                        }, TaskCreationOptions.AttachedToParent);
                    };
                    zcCycleGrid.BeginAnimation(ZoomableCanvas.ScaleProperty, doubleAnimation, HandoffBehavior.Compose);
                }
            }
            System.Windows.Point point3 = border.RenderTransformOrigin = new System.Windows.Point(0.0, 0.0);
            border.RenderTransform = new RotateTransform(elementActualAngle);
        }
示例#3
0
        public static bool ResetZoomTool(MultiScaleImage mSlide, StackPanel sZoomTool, Canvas cChoicesBox, Line lBGLine, Line lValueLine, int iDefaultAngle, float fScreenRatio, ResourceDictionary rdDirectory)
        {
            Grid grid = mSlide.Parent as Grid;

            if (mSlide.Source == null)
            {
                sZoomTool.Visibility = Visibility.Collapsed;
                return(false);
            }
            sZoomTool.Visibility = Visibility.Visible;
            listChoice           = new List <int>
            {
                1,
                2,
                4,
                10
            };
            if (cChoicesBox.Children.Count > 4)
            {
                cChoicesBox.Children.RemoveRange(4, cChoicesBox.Children.Count - 1);
            }
            double dMaxActualZoom = mSlide.Source.sbcCurrentSlide.dMaxActualZoom;

            if (dMaxActualZoom >= 120.0)
            {
                iMaxSetZoom = 160;
                listChoice.AddRange(new List <int>
                {
                    20,
                    40,
                    80,
                    120,
                    160
                });
            }
            else if (dMaxActualZoom >= 80.0)
            {
                iMaxSetZoom = 120;
                listChoice.AddRange(new List <int>
                {
                    20,
                    40,
                    80,
                    120
                });
            }
            else if (dMaxActualZoom >= 40.0)
            {
                iMaxSetZoom = 80;
                listChoice.AddRange(new List <int>
                {
                    20,
                    40,
                    80
                });
            }
            else if (dMaxActualZoom >= 20.0)
            {
                iMaxSetZoom = 40;
                listChoice.AddRange(new List <int>
                {
                    20,
                    40
                });
            }
            else
            {
                iMaxSetZoom = 20;
                listChoice.Add(20);
            }
            float num  = (float)grid.ActualWidth;
            float num2 = (float)grid.ActualHeight;

            if (iDefaultAngle / 90 % 2 == 1)
            {
                num  = (float)grid.ActualHeight;
                num2 = (float)grid.ActualWidth;
            }
            float num3 = (float)Math.Min((double)num / mSlide.Source.ImageSize.Width, (double)num2 / mSlide.Source.ImageSize.Height);

            mSlide.OriginalScale             = num3;
            mSlide.MaxScaleRelativeToMaxSize = (double)iMaxSetZoom / mSlide.Source.sbcCurrentSlide.dMaxActualZoom / (double)fScreenRatio;
            float fScale = (float)mSlide.minScaleRelativeToMinSize * num3;

            fMinSetZoom        = ScaleToZoom(mSlide, fScale, fScreenRatio);
            fTotalHeight       = GetTopValue(iMaxSetZoom) + 10f;
            cChoicesBox.Height = fTotalHeight;
            lBGLine.Y2         = fTotalHeight;
            lValueLine.Y1      = fTotalHeight;
            foreach (int item in listChoice)
            {
                Label label = new Label();
                label.Margin = new Thickness(-35.0, fTotalHeight - GetTopValue(item) - 18f, 0.0, 0.0);
                label.SetValue(FrameworkElement.StyleProperty, rdDirectory["ZoomToolChoices"]);
                label.Content = item;
                Line line = new Line();
                line.Stroke          = new SolidColorBrush(Color.FromRgb(byte.MaxValue, 0, 0));
                line.StrokeThickness = 1.0;
                line.X1 = 5.0;
                line.X2 = 15.0;
                line.Y1 = fTotalHeight - GetTopValue(item) - 5f;
                line.Y2 = fTotalHeight - GetTopValue(item) - 5f;
                cChoicesBox.Children.Add(label);
                cChoicesBox.Children.Add(line);
            }
            float currentScale = mSlide.GetCurrentScale();

            ScaleToZoom(mSlide, currentScale, fScreenRatio);
            return(true);
        }