Beispiel #1
0
        public void UpdateMeasureTool(MultiScaleImage mSlide, bool animate = false, float fDurationTime = 0f, EasingFunctionBase easing = null)
        {
            Grid  gSlideBox     = PublicMethods.FindSlideBox(mSlide);
            Point pNormalPoint  = mSlide.SlideRatioToBoxPixel(pStartRatio);
            Point pNormalPoint2 = mSlide.SlideRatioToBoxPixel(pOverRatio);

            pNormalPoint  = PublicMethods.FlipPoint(gSlideBox, pNormalPoint);
            pNormalPoint2 = PublicMethods.FlipPoint(gSlideBox, pNormalPoint2);
            if (!animate)
            {
                CloseMeasureToolAnimation();
                lMeasureLine.X1      = pNormalPoint.X;
                lMeasureLine.Y1      = pNormalPoint.Y;
                lMeasureLine.X2      = pNormalPoint2.X;
                lMeasureLine.Y2      = pNormalPoint2.Y;
                lMeasureValue.Margin = new Thickness((lMeasureLine.X2 - lMeasureLine.X1) / 2.0 + lMeasureLine.X1 - 30.0, (lMeasureLine.Y2 - lMeasureLine.Y1) / 2.0 + lMeasureLine.Y1 - 20.0, 0.0, 0.0);
            }
            else
            {
                lMeasureLine.BeginAnimation(Line.Y1Property, new DoubleAnimation(pNormalPoint.Y, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                lMeasureLine.BeginAnimation(Line.X2Property, new DoubleAnimation(pNormalPoint2.X, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                lMeasureLine.BeginAnimation(Line.Y2Property, new DoubleAnimation(pNormalPoint2.Y, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                }, HandoffBehavior.Compose);
                DoubleAnimation doubleAnimation = new DoubleAnimation(pNormalPoint.X, TimeSpan.FromMilliseconds(fDurationTime))
                {
                    EasingFunction = easing
                };
                doubleAnimation.CurrentTimeInvalidated += delegate
                {
                    CloseMeasureToolAnimation(4);
                    lMeasureValue.Margin = new Thickness((lMeasureLine.X2 - lMeasureLine.X1) / 2.0 + lMeasureLine.X1 - 30.0, (lMeasureLine.Y2 - lMeasureLine.Y1) / 2.0 + lMeasureLine.Y1 - 20.0, 0.0, 0.0);
                };
                lMeasureLine.BeginAnimation(Line.X1Property, doubleAnimation, HandoffBehavior.Compose);
            }
        }
Beispiel #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);
        }