protected override void OnDrag(MouseDevice mouseDevice, double zoom)
        {
            Point  point  = PathFigureUtilities.GetPoint(this.PathEditContext.GetPathFigure(this.Path), this.PathEditContext.PartIndex);
            Point  point1 = this.geometryToDocument.Transform(point);
            Point  viewRootCoordinates = this.GetPointInViewRootCoordinates(mouseDevice, true);
            Vector vector = viewRootCoordinates - point1;
            Vector correspondingVector = ElementUtilities.GetCorrespondingVector(vector, this.geometryToDocument, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null);

            if (this.hasMoved || Tolerances.HaveMoved(point1, viewRootCoordinates, zoom))
            {
                this.hasMoved = true;
                PathGeometry       path               = this.Path;
                int                figureIndex        = this.PathEditContext.FigureIndex;
                int                partIndex          = this.PathEditContext.PartIndex;
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                PathFigureEditor   pathFigureEditor   = new PathFigureEditor(path.Figures[figureIndex]);
                if (partIndex > 0 || PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure))
                {
                    pathGeometryEditor.SetPoint(figureIndex, partIndex - 1, point - correspondingVector);
                }
                if (pathFigureEditor.GetLastIndexOfDownstreamSegment(partIndex) != partIndex)
                {
                    pathGeometryEditor.SetPoint(figureIndex, partIndex + 1, point + correspondingVector);
                }
                if (partIndex == PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - 1 && PathFigureUtilities.IsOpen(pathFigureEditor.PathFigure))
                {
                    this.LastTangent = vector;
                }
                this.PathEditorTarget.AddCriticalEdit();
            }
            base.OnDrag(mouseDevice, zoom);
        }
示例#2
0
        protected override bool OnDrag(Point dragStartPosition, Point dragCurrentPosition, bool scrollNow)
        {
            switch (this.ActiveAdorner.Kind)
            {
            case RadialGradientAdornerKind.GradientOriginPoint:
                this.actionString = StringTable.UndoUnitRadialGradientOrigin;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                }
                Point point = this.initialCenterInBrush;
                if (Tolerances.HaveMoved(dragCurrentPosition, this.initialCenterInDocument, this.ActiveView.Zoom))
                {
                    Point positionInBrush = this.ActiveAdorner.InverseTransformPoint(dragCurrentPosition * this.initialContextToElementMatrix, true) * this.brushToRootMatrix;
                    BrushTransformBehavior.OffsetDragPoint(ref positionInBrush, this.initialCenterInBrush * this.brushToRootMatrix, this.dragOffset, 0.0);
                    point = RoundingHelper.RoundPosition(positionInBrush * this.rootToBrushMatrix);
                }
                if (this.ActiveAdorner.GradientOriginPoint != point)
                {
                    this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point);
                    this.UpdateEditTransaction();
                    break;
                }
                break;

            case RadialGradientAdornerKind.RadiusPoint:
                this.actionString = StringTable.UndoUnitScaleRadialGradient;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                    this.radiusX = (double)this.GetBrushValue(RadialGradientBrushNode.RadiusXProperty);
                    this.radiusY = (double)this.GetBrushValue(RadialGradientBrushNode.RadiusYProperty);
                    if (Math.Abs(this.radiusX) < 0.01)
                    {
                        this.radiusX = 0.01;
                    }
                    if (Math.Abs(this.radiusY) < 0.01)
                    {
                        this.radiusY = 0.01;
                    }
                }
                Vector perpendicular;
                double num1 = GradientStopBehavior.VectorProjection(this.ActiveAdorner.BrushCenter * this.brushToRootMatrix, this.initialPointerPosition, dragCurrentPosition, 0.0, out perpendicular);
                double num2 = RoundingHelper.RoundLength(this.radiusX * num1);
                double num3 = RoundingHelper.RoundLength(this.radiusY * num1);
                this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)num2);
                this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)num3);
                this.UpdateEditTransaction();
                break;
            }
            this.ActiveView.EnsureVisible((IAdorner)this.ActiveAdorner, scrollNow);
            return(true);
        }
示例#3
0
        private void ScopeElement_MouseMove(object sender, MouseEventArgs args)
        {
            if (this.ActiveBehavior == null)
            {
                return;
            }
            if ((Keyboard.Modifiers & ModifierKeys.Alt) != ModifierKeys.None)
            {
                this.consumeAltKey = true;
            }
            Point position = args.GetPosition((IInputElement)this.scopeElement);

            if (position == this.lastDragPosition)
            {
                return;
            }
            this.lastDragPosition = position;
            FrameworkElement rootElement = this.RootElement;

            if (rootElement == null)
            {
                return;
            }
            GeneralTransform generalTransform = this.scopeElement.TransformToDescendant((Visual)rootElement);

            if (generalTransform == null)
            {
                return;
            }
            Point point = position * VectorUtilities.GetMatrixFromTransform(generalTransform);

            if (this.IsButtonDown && this.buttonDownHandled)
            {
                if (!this.IsDragging && !Tolerances.HaveMoved(this.dragStartPosition, point, this.view.Zoom))
                {
                    return;
                }
                this.isDragging          = true;
                this.dragCurrentPosition = point;
                args.Handled             = this.ActiveBehavior.HandleDrag(this.dragStartPosition, this.dragCurrentPosition);
            }
            else
            {
                args.Handled = this.ActiveBehavior.HandleHover(point);
            }
        }