示例#1
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);
        }
示例#2
0
        private HashSet <SceneElement> PathPartDelete(SceneEditTransaction editTransaction)
        {
            HashSet <SceneElement> hashSet          = new HashSet <SceneElement>();
            PathPartSelectionSet   partSelectionSet = this.SceneViewModel.PathPartSelectionSet;
            Dictionary <PathEditMode, List <PathEditorTarget> > dictionary = new Dictionary <PathEditMode, List <PathEditorTarget> >();

            dictionary[PathEditMode.ClippingPath] = new List <PathEditorTarget>();
            dictionary[PathEditMode.ScenePath]    = new List <PathEditorTarget>();
            dictionary[PathEditMode.MotionPath]   = new List <PathEditorTarget>();
            Tool activeTool = this.SceneViewModel.DesignerContext.ToolManager.ActiveTool;

            if (activeTool != null)
            {
                foreach (PathPart pathPart in partSelectionSet.Selection)
                {
                    BaseFrameworkElement frameworkElement = pathPart.SceneElement as BaseFrameworkElement;
                    if (frameworkElement != null)
                    {
                        PathEditorTarget pathEditorTarget = activeTool.GetPathEditorTarget((Base2DElement)frameworkElement, pathPart.PathEditMode);
                        if (pathEditorTarget != null && !dictionary[pathPart.PathEditMode].Contains(pathEditorTarget))
                        {
                            dictionary[pathPart.PathEditMode].Add(pathEditorTarget);
                            hashSet.Add((SceneElement)frameworkElement);
                        }
                    }
                }
            }
            List <PathEditorTarget> list1 = new List <PathEditorTarget>();
            List <PathEditorTarget> list2 = new List <PathEditorTarget>();

            foreach (KeyValuePair <PathEditMode, List <PathEditorTarget> > keyValuePair in dictionary)
            {
                foreach (PathEditorTarget pathEditorTarget in keyValuePair.Value)
                {
                    pathEditorTarget.BeginEditing();
                    int count1 = pathEditorTarget.PathGeometry.Figures.Count;
                    ICollection <PathPart> selectionByElement = partSelectionSet.GetSelectionByElement((SceneElement)pathEditorTarget.EditingElement, keyValuePair.Key);
                    new DeleteCommand.SelectedComponentsRemover(pathEditorTarget).Execute(selectionByElement);
                    pathEditorTarget.EndEditing(false);
                    pathEditorTarget.PostDeleteAction();
                    if (keyValuePair.Key == PathEditMode.ScenePath)
                    {
                        if (!PathGeometryUtilities.IsEmpty(pathEditorTarget.PathGeometry))
                        {
                            PathElement pathElement = (PathElement)pathEditorTarget.EditingElement;
                            int         count2      = pathElement.PathGeometry.Figures.Count;
                            if (count1 == 1 && count2 > 1)
                            {
                                ISceneNodeCollection <SceneNode> collectionContainer = pathElement.GetCollectionContainer();
                                if (!collectionContainer.FixedCapacity.HasValue || collectionContainer.FixedCapacity.Value >= collectionContainer.Count - 1 + count2)
                                {
                                    list2.Add(pathEditorTarget);
                                }
                            }
                        }
                        else
                        {
                            list1.Add(pathEditorTarget);
                        }
                    }
                    pathEditorTarget.AddCriticalEdit();
                }
            }
            List <SceneElement> list3 = new List <SceneElement>();

            foreach (PathEditorTarget pathEditorTarget in list2)
            {
                PathElement pathElement1 = (PathElement)pathEditorTarget.EditingElement;
                using (this.SceneView.AdornerLayer.SuspendUpdates())
                {
                    this.SceneView.UpdateLayout();
                    foreach (PathElement pathElement2 in PathCommandHelper.ReleaseCompoundPaths(pathElement1, editTransaction))
                    {
                        list3.Add((SceneElement)pathElement2);
                    }
                }
            }
            foreach (PathEditorTarget pathEditorTarget in list1)
            {
                pathEditorTarget.RemovePath();
            }
            partSelectionSet.Clear();
            this.SceneViewModel.ElementSelectionSet.ExtendSelection((ICollection <SceneElement>)list3);
            foreach (SceneElement sceneElement in list3)
            {
                hashSet.Add(sceneElement);
            }
            return(hashSet);
        }