Пример #1
0
        protected override bool OnHoverOverAdorner(IAdorner adorner)
        {
            if (this.action == null && !this.IsAltDown)
            {
                this.PopSelf();
                return(true);
            }
            PathPartAdorner pathPartAdorner = adorner as PathPartAdorner;

            if (pathPartAdorner == null)
            {
                return(base.OnHoverOverAdorner(adorner));
            }
            PenAction penAction = this.GetAction(pathPartAdorner);

            if (penAction == null)
            {
                if (this.action != null)
                {
                    penAction = this.action;
                }
                else
                {
                    this.PopSelf();
                    return(true);
                }
            }
            this.Cursor = penAction.HoverCursor;
            return(true);
        }
Пример #2
0
        protected override bool OnButtonDownOverAdorner(IAdorner adorner)
        {
            if (this.action != null)
            {
                this.action.End();
                this.action = (PenAction)null;
            }
            if (!this.ToolBehaviorContext.SnappingEngine.IsStarted)
            {
                this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            }
            PathPartAdorner pathPartAdorner = adorner as PathPartAdorner;

            if (pathPartAdorner == null)
            {
                return(base.OnButtonDownOverAdorner(adorner));
            }
            this.action = this.GetAction(pathPartAdorner);
            if (this.action != null)
            {
                this.action.Begin(new PathEditContext(pathPartAdorner.FigureIndex, pathPartAdorner.PartIndex), this.MouseDevice);
                if (!this.affectedAdornerSets.Contains(pathPartAdorner.PathAdornerSet))
                {
                    this.affectedAdornerSets.Add(pathPartAdorner.PathAdornerSet);
                }
                this.isConstrainingAxes = this.IsShiftDown;
                this.UpdateCursor();
            }
            return(true);
        }
Пример #3
0
        protected override bool OnButtonDownOverAdorner(IAdorner adorner)
        {
            this.EndAction();
            if (!this.ToolBehaviorContext.SnappingEngine.IsStarted)
            {
                this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            }
            PathPartAdorner pathPartAdorner = adorner as PathPartAdorner;

            if (pathPartAdorner == null)
            {
                return(base.OnButtonDownOverAdorner(adorner));
            }
            PenAction    action       = this.GetAction(pathPartAdorner);
            SceneElement sceneElement = (SceneElement)this.EditingElement;

            this.pathEditorTarget = pathPartAdorner.PathAdornerSet.PathEditorTarget;
            if (this.pathEditorTarget != null)
            {
                this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
            }
            if (sceneElement != null)
            {
                this.ActiveSceneViewModel.DefaultView.AdornerLayer.InvalidateAdornerVisuals(sceneElement);
            }
            this.BeginAction(action, pathPartAdorner);
            return(true);
        }
Пример #4
0
        private PenAction GetAction(PathPartAdorner pathPartAdorner)
        {
            PenAction        penAction        = (PenAction)null;
            PathEditorTarget pathEditorTarget = pathPartAdorner.PathAdornerSet.PathEditorTarget;
            PathFigure       pathFigure       = pathEditorTarget.PathGeometry.Figures[pathPartAdorner.FigureIndex];

            for (int index1 = 0; index1 < pathFigure.Segments.Count; ++index1)
            {
                System.Windows.Media.PathSegment segment = pathFigure.Segments[index1];
                for (int index2 = 0; index2 < PathSegmentUtilities.GetPointCount(segment); ++index2)
                {
                    if (PathSegmentUtilities.GetPointKind(segment, index2) == PathPointKind.Arc)
                    {
                        return((PenAction)null);
                    }
                }
            }
            if (pathPartAdorner is PathPointAdorner)
            {
                penAction = (PenAction) new ConvertPointAction(pathEditorTarget, this.ActiveSceneViewModel);
            }
            else if (pathPartAdorner is PathTangentAdorner || pathPartAdorner is PenTangentAdorner)
            {
                penAction = (PenAction) new TangentDragAction(pathEditorTarget, this.ActiveSceneViewModel, pathPartAdorner is PenTangentAdorner);
            }
            else if (pathPartAdorner is PathSegmentAdorner)
            {
                penAction = (PenAction) new ConvertSegmentAction(pathEditorTarget, this.ActiveSceneViewModel);
            }
            return(penAction);
        }
Пример #5
0
        private void BeginAction(PenAction action, PathPartAdorner pathPartAdorner)
        {
            if (action == null)
            {
                return;
            }
            if (this.IsActive && action is StartAction)
            {
                this.FinalizePath(this.EditingElement);
            }
            PathEditContext pathEditContext = this.pathEditContext;

            if (pathPartAdorner != null)
            {
                pathEditContext = new PathEditContext(pathPartAdorner.FigureIndex, pathPartAdorner.PartIndex);
            }
            this.action             = action;
            this.Cursor             = action.DragCursor;
            this.isConstrainingAxes = this.IsShiftDown;
            action.Begin(pathEditContext, this.MouseDevice);
            this.pathEditorTarget = action.PathEditorTarget;
            this.pathEditContext  = action.PathEditContext;
            if (this.pathEditorTarget != null)
            {
                this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
            }
            if (!action.SetPathActive || this.pathEditorTarget == null || this.pathEditContext == null || this.EditingElement != null && !this.EditingElement.IsViewObjectValid)
            {
                return;
            }
            ((PenTool)this.Tool).ActivePathEditInformation = new ActivePathEditInformation(this.pathEditorTarget, this.pathEditContext.FigureIndex);
        }
Пример #6
0
 protected override bool OnButtonDownOverNonAdorner(Point pointerPosition)
 {
     if (this.action != null)
     {
         this.action.End();
         this.action = (PenAction)null;
     }
     this.UpdateCursor();
     return(true);
 }
Пример #7
0
        private PenAction GetAction(PathPartAdorner adorner)
        {
            PenAction          penAction          = (PenAction)null;
            PathSegmentAdorner pathSegmentAdorner = adorner as PathSegmentAdorner;
            PathEditorTarget   pathEditorTarget   = (PathEditorTarget)null;

            if (adorner != null)
            {
                pathEditorTarget = adorner.PathAdornerSet.PathEditorTarget;
            }
            if (pathSegmentAdorner != null)
            {
                penAction = (PenAction) new InsertAction(pathEditorTarget, this.ActiveSceneViewModel);
            }
            else
            {
                PathPointAdorner pathPointAdorner = adorner as PathPointAdorner;
                if (pathPointAdorner != null)
                {
                    penAction = (PenAction) new DeletePointAction(pathEditorTarget, this.ActiveSceneViewModel);
                    PathFigure figure1 = pathEditorTarget.PathGeometry.Figures[pathPointAdorner.FigureIndex];
                    if (PathFigureUtilities.IsOpen(figure1) && !PathFigureUtilities.IsIsolatedPoint(figure1))
                    {
                        bool       flag1   = pathPointAdorner.PointIndex == 0;
                        bool       flag2   = pathPointAdorner.PointIndex == PathFigureUtilities.PointCount(figure1) - 1;
                        bool       flag3   = pathPointAdorner.PathAdornerSet.PathEditorTarget == this.pathEditorTarget;
                        bool       flag4   = this.pathEditContext != null && pathPointAdorner.FigureIndex == this.pathEditContext.FigureIndex;
                        bool       flag5   = this.pathEditorTarget != null && pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == this.pathEditorTarget.PathEditMode;
                        bool       flag6   = pathPointAdorner.PathAdornerSet.PathEditorTarget.PathEditMode == PathEditMode.ScenePath;
                        PathFigure figure2 = this.pathEditContext == null || this.pathEditorTarget == null ? (PathFigure)null : this.pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry);
                        bool       flag7   = figure2 != null && PathFigureUtilities.IsOpen(figure2);
                        bool       flag8   = (flag3 && !flag4 || flag5 && flag6) && flag7;
                        if (flag1)
                        {
                            penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new CloseAction(pathEditorTarget, this.ActiveSceneViewModel);
                        }
                        else if (flag2)
                        {
                            penAction = !flag3 || !flag4 ? (!flag8 ? (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel) : (PenAction) new JoinAction(pathEditorTarget, this.ActiveSceneViewModel, this.pathEditorTarget, this.pathEditContext)) : (PenAction) new AdjustAction(pathEditorTarget, this.ActiveSceneViewModel);
                        }
                    }
                    if (PathFigureUtilities.IsIsolatedPoint(figure1) && this.pathEditContext == null)
                    {
                        penAction = (PenAction) new ExtendAction(pathEditorTarget, this.ActiveSceneViewModel);
                    }
                }
            }
            if (penAction == null)
            {
                penAction = !this.IsActive || this.pathEditorTarget == null || (this.pathEditorTarget.PathGeometry.Figures.Count <= 0 || this.pathEditorTarget.PathGeometry.Figures[this.pathEditorTarget.PathGeometry.Figures.Count - 1].IsClosed) ? (PenAction) new StartAction(this, (PathEditorTarget)null, this.ActiveSceneViewModel) : (PenAction) new AppendAction(this.pathEditorTarget, this.ActiveSceneViewModel);
            }
            return(penAction);
        }
Пример #8
0
 private bool AllDone()
 {
     this.ToolBehaviorContext.SnappingEngine.Stop();
     if (this.action != null)
     {
         this.action.End();
     }
     this.action = (PenAction)null;
     if (this.IsAltDown)
     {
         this.UpdateCursor();
     }
     else
     {
         this.PopSelf();
     }
     return(true);
 }
Пример #9
0
 private void EndAction()
 {
     if (this.action == null)
     {
         return;
     }
     this.action.End();
     this.pathEditorTarget = this.action.PathEditorTarget;
     this.pathEditContext  = this.action.PathEditContext;
     if (this.pathEditorTarget != null)
     {
         this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement;
     }
     if (this.action.SetPathActive && this.pathEditorTarget != null && this.pathEditContext != null && (this.EditingElement == null || this.EditingElement.IsViewObjectValid))
     {
         ((PenTool)this.Tool).ActivePathEditInformation = new ActivePathEditInformation(this.pathEditorTarget, this.pathEditContext.FigureIndex);
     }
     this.action = (PenAction)null;
 }