コード例 #1
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);
        }
コード例 #2
0
        public virtual void UpdateActiveStateFromSelection()
        {
            if (this.AdornerList == null)
            {
                return;
            }
            Hashtable hashtable = new Hashtable();

            foreach (Adorner adorner in this.AdornerList)
            {
                PathPointAdorner   pathPointAdorner   = adorner as PathPointAdorner;
                PathSegmentAdorner pathSegmentAdorner = adorner as PathSegmentAdorner;
                if (pathPointAdorner != null)
                {
                    hashtable[(object)(PathPoint)pathPointAdorner] = (object)pathPointAdorner;
                    pathPointAdorner.IsActive = false;
                }
                else if (pathSegmentAdorner != null)
                {
                    hashtable[(object)(PathSegment)pathSegmentAdorner] = (object)pathSegmentAdorner;
                    pathSegmentAdorner.IsActive = false;
                }
            }
            foreach (PathPart pathPart in (IEnumerable <PathPart>) this.PathPartSelectionSet.GetSelectionByElement((SceneElement)this.Element))
            {
                PathPartAdorner pathPartAdorner = (PathPartAdorner)hashtable[(object)pathPart];
                if (pathPartAdorner != null)
                {
                    pathPartAdorner.IsActive = true;
                }
            }
            this.InvalidateRender();
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
 public void SetActive(PathPartAdorner pathPartAdorner, bool isActive)
 {
     if (pathPartAdorner.IsActive == isActive)
     {
         return;
     }
     pathPartAdorner.IsActive = isActive;
     this.InvalidateRender();
 }
コード例 #8
0
        protected override bool OnButtonDown(Point pointerPosition)
        {
            this.pathPartAdorner       = (PathPartAdorner)this.ActiveAdorner;
            this.isConstrainingAxes    = this.IsShiftDown;
            this.startRootPoint        = pointerPosition;
            this.currentEditingElement = this.pathPartAdorner.Element;
            bool               isShiftDown        = this.IsShiftDown;
            int                num                = this.IsAltDown ? true : false;
            bool               isControlDown      = this.IsControlDown;
            PathPointAdorner   pathPointAdorner   = this.pathPartAdorner as PathPointAdorner;
            PathTangentAdorner pathTangentAdorner = this.pathPartAdorner as PathTangentAdorner;
            PathSegmentAdorner pathSegmentAdorner = this.pathPartAdorner as PathSegmentAdorner;

            this.pathEditorTargets.Clear();
            if (pathTangentAdorner != null)
            {
                pathTangentAdorner.PathAdornerSet.SetActive((PathPartAdorner)pathTangentAdorner, true);
                this.isEnforcingSmoothness = this.ShouldEnforceSmoothness(pathTangentAdorner);
            }
            else
            {
                PathPartSelectionSet partSelectionSet = this.ActiveSceneViewModel.PathPartSelectionSet;
                PathPart             pathPart         = (PathPart)null;
                if (pathPointAdorner != null)
                {
                    pathPart = (PathPart)(PathPoint)pathPointAdorner;
                }
                else if (pathSegmentAdorner != null)
                {
                    pathPart = (PathPart)(PathSegment)pathSegmentAdorner;
                }
                if (isShiftDown)
                {
                    partSelectionSet.ExtendSelection(pathPart);
                }
                else if (isControlDown && this.ToolBehaviorContext.ActiveTool is ISelectionTool)
                {
                    partSelectionSet.ToggleSelection(pathPart);
                    if (!partSelectionSet.IsSelected(pathPart))
                    {
                        this.currentEditingElement = (BaseFrameworkElement)null;
                    }
                }
                else if (!partSelectionSet.IsSelected(pathPart))
                {
                    partSelectionSet.Clear();
                    partSelectionSet.ExtendSelection(pathPart);
                }
                if (partSelectionSet.IsSelected(pathPart) && pathSegmentAdorner != null)
                {
                    this.ComputeSegmentParameter();
                }
            }
            this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null);
            return(true);
        }
コード例 #9
0
 public void DeactivateAll()
 {
     foreach (Adorner adorner in this.AdornerList)
     {
         PathPartAdorner pathPartAdorner = adorner as PathPartAdorner;
         if (pathPartAdorner != null)
         {
             pathPartAdorner.IsActive = false;
         }
     }
     this.InvalidateRender();
 }
コード例 #10
0
        protected override bool OnHoverOverAdorner(IAdorner adorner)
        {
            PathPartAdorner adorner1 = adorner as PathPartAdorner;

            if (adorner1 == null)
            {
                return(base.OnHoverOverAdorner(adorner));
            }
            this.Cursor = this.GetAction(adorner1).HoverCursor;
            this.PreviewInsertionPoint = (ISceneInsertionPoint)null;
            return(true);
        }
コード例 #11
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);
        }