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); }
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); }
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); }
private void MovePathParts(PathPartSelectionSet pathPartSelectionSet, BaseFrameworkElement sceneElement, PathEditMode pathEditMode, Vector deltaOffset) { ICollection <PathPart> selectionByElement = pathPartSelectionSet.GetSelectionByElement((SceneElement)sceneElement, pathEditMode); Tool activeTool = this.ActiveSceneViewModel.DesignerContext.ToolManager.ActiveTool; if (selectionByElement.Count <= 0 || activeTool == null) { return; } PathEditorTarget pathEditorTarget = activeTool.GetPathEditorTarget((Base2DElement)sceneElement, pathEditMode); if (pathEditorTarget == null) { return; } this.EnsureEditTransaction(); pathEditorTarget.BeginEditing(); if (!this.pathEditorTargets.ContainsKey(pathEditorTarget)) { this.pathEditorTargets.Add(pathEditorTarget, true); } Matrix transformToAncestor = pathEditorTarget.GetTransformToAncestor((IViewObject)this.ActiveView.HitTestRoot); Vector correspondingVector = ElementUtilities.GetCorrespondingVector(deltaOffset, transformToAncestor); PathEditBehavior.TranslateSelection(pathEditorTarget, selectionByElement, correspondingVector); this.ActiveView.AdornerLayer.InvalidateAdornerVisuals((SceneElement)pathEditorTarget.EditingElement); }
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); }
private void Invalidate() { Tool activeTool = this.sceneElement.ViewModel.DesignerContext.ToolManager.ActiveTool; if (activeTool == null) { return; } PathEditorTarget pathEditorTarget = activeTool.GetPathEditorTarget((Base2DElement)this.sceneElement, this.pathEditMode); pathEditorTarget.UpdateCachedPath(); pathEditorTarget.AddCriticalEdit(); }
public PathEditorTarget GetPathEditorTarget(Base2DElement element, PathEditMode pathEditMode) { if (element == null) { return((PathEditorTarget)null); } List <PathEditorTarget> list; if (this.map.TryGetValue(element, out list)) { foreach (PathEditorTarget pathEditorTarget in list) { if (pathEditorTarget.PathEditMode == pathEditMode) { pathEditorTarget.RefreshSubscription(); return(pathEditorTarget); } } } else { list = new List <PathEditorTarget>(); this.map.Add(element, list); } PathEditorTarget pathEditorTarget1 = (PathEditorTarget)null; if (pathEditMode == PathEditMode.ScenePath) { PathElement pathElement = element as PathElement; if (pathElement == null) { return((PathEditorTarget)null); } ReferenceStep property = PlatformTypeHelper.GetProperty((ITypeResolver)element.ProjectContext, (ITypeId)element.Type, MemberType.Property, "Data"); if (property == null || !property.ShouldSerialize) { return((PathEditorTarget)null); } pathEditorTarget1 = (PathEditorTarget) new ScenePathEditorTarget(pathElement); } else if (pathEditMode == PathEditMode.MotionPath) { pathEditorTarget1 = (PathEditorTarget) new MotionPathEditorTarget(element); } else if (pathEditMode == PathEditMode.ClippingPath) { pathEditorTarget1 = (PathEditorTarget) new ClippingPathEditorTarget(element); } list.Add(pathEditorTarget1); return(pathEditorTarget1); }
protected override void OnDetach() { this.ActiveSceneViewModel.EarlySceneUpdatePhase -= new SceneUpdatePhaseEventHandler(this.ActiveSceneViewModel_EarlySceneUpdatePhase); if (this.IsActive && this.action != null) { this.EndAction(); } if (this.EditingElement != null) { this.FinalizePath(this.EditingElement); } this.pathEditorTarget = (PathEditorTarget)null; this.pathEditContext = (PathEditContext)null; base.OnDetach(); }
public IAdornerSet CreateAdornerSet(ToolBehaviorContext toolContext, SceneElement adornedElement) { BaseFrameworkElement adornedElement1 = adornedElement as BaseFrameworkElement; if (adornedElement1 == null) { return((IAdornerSet)null); } PathEditorTarget pathEditorTarget = this.pathEditorTargetMap.GetPathEditorTarget((Base2DElement)adornedElement1, this.pathEditMode); if (pathEditorTarget == null) { return((IAdornerSet)null); } return((IAdornerSet) new PenAdornerSet(toolContext, adornedElement1, pathEditorTarget)); }
public IEnumerable <PathEditorTarget> GetAllPathEditorTargets(SceneElement element) { Base2DElement base2DElement = element as Base2DElement; if (base2DElement != null) { PathEditorTarget target = this.GetPathEditorTarget(base2DElement, PathEditMode.ScenePath); if (target != null) { yield return(target); } target = this.GetPathEditorTarget(base2DElement, PathEditMode.ClippingPath); if (target != null) { yield return(target); } } }
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; }
public IAdornerSet CreateAdornerSet(ToolBehaviorContext toolContext, SceneElement adornedElement) { BaseFrameworkElement adornedElement1 = adornedElement as BaseFrameworkElement; if (adornedElement1 == null) { return((IAdornerSet)null); } if (this.pathEditMode == PathEditMode.ClippingPath && RectangleGeometryAdornerSetCreatorBase.ShouldApplyRectangleGeometryAdornerTo(adornedElement)) { return((IAdornerSet)null); } PathEditorTarget pathEditorTarget = this.pathEditorTargetMap.GetPathEditorTarget((Base2DElement)adornedElement1, this.pathEditMode); if (pathEditorTarget == null) { return((IAdornerSet)null); } return((IAdornerSet) new PathAdornerSet(toolContext, adornedElement1, pathEditorTarget)); }
protected override bool OnButtonDownOverNonAdorner(Point pointerPosition) { this.IsProjectedInsertionPoint = Adorner.NonAffineTransformInParentStack(this.ActiveSceneInsertionPoint.SceneElement); if ((this.action ?? this.GetAction((PathPartAdorner)null)) is StartAction && this.IsProjectedInsertionPoint) { return(true); } this.EndAction(); if (!this.ToolBehaviorContext.SnappingEngine.IsStarted) { this.ToolBehaviorContext.SnappingEngine.Start(this.ToolBehaviorContext, (BaseFrameworkElement)null, (IList <BaseFrameworkElement>)null); } FrameworkElement frameworkElement = this.MouseDevice.DirectlyOver as FrameworkElement; if (frameworkElement == null || frameworkElement.Parent == null) { return(true); } ActivePathEditInformation pathEditInformation = ((PenTool)this.Tool).ActivePathEditInformation; if (pathEditInformation != null) { this.pathEditorTarget = pathEditInformation.ActivePathEditorTarget; this.pathEditContext = new PathEditContext(pathEditInformation.ActiveFigureIndex, 0); } else { this.pathEditorTarget = (PathEditorTarget)null; } if (this.pathEditorTarget != null) { this.EditingElement = (BaseFrameworkElement)this.pathEditorTarget.EditingElement; this.pathEditorTarget.UpdateCachedPath(); } this.BeginAction(this.GetAction((PathPartAdorner)null), (PathPartAdorner)null); return(true); }
public PathEditBehavior(ToolBehaviorContext toolContext, PathEditorTarget pathEditorTarget) : base(toolContext) { this.pathEditorTarget = pathEditorTarget; }
public TangentUpdateAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
public CloseAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
public TangentDragAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel, bool adjustLastTangent) : base(pathEditorTarget, viewModel) { this.adjustLastTangent = adjustLastTangent; }
public RedefineTangentAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
protected void RemovePath() { this.pathEditorTarget.RemovePath(); this.pathEditorTarget = (PathEditorTarget)null; this.pathEditContext = (PathEditContext)null; }
public ExtendAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
public JoinAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel, PathEditorTarget oldPathEditorTarget, PathEditContext oldPathEditContext) : base(pathEditorTarget, viewModel) { this.oldPathEditorTarget = oldPathEditorTarget; this.oldPathEditContext = oldPathEditContext; }
protected PenAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) { this.viewModel = viewModel; this.pathEditorTarget = pathEditorTarget; this.axisConstraint = new AxisConstraint(); }
public PathAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement, PathEditorTarget pathEditorTarget) : base(toolContext, (SceneElement)adornedElement) { this.pathEditorTarget = pathEditorTarget; this.pathEditorTarget.MatrixChanged += new EventHandler(this.PathEditorTarget_MatrixChanged); }
public DeletePointAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
internal static void TranslateSelection(PathEditorTarget pathEditorTarget, ICollection <PathPart> pathParts, Vector offset) { List <BitArray> list = new List <BitArray>(pathEditorTarget.PathGeometry.Figures.Count); for (int index = 0; index < pathEditorTarget.PathGeometry.Figures.Count; ++index) { list.Add(new BitArray(PathFigureUtilities.PointCount(pathEditorTarget.PathGeometry.Figures[index]), false)); } foreach (PathPart pathPart in (IEnumerable <PathPart>)pathParts) { PathPoint pathPoint = pathPart as PathPoint; if ((PathPart)pathPoint != (PathPart)null) { if (pathPoint.PartIndex < list[pathPoint.FigureIndex].Count) { list[pathPoint.FigureIndex][pathPoint.PartIndex] = true; } } else { PathSegment pathSegment = pathPart as PathSegment; if ((PathPart)pathSegment != (PathPart)null) { list[pathSegment.FigureIndex][pathSegment.PartIndex] = true; PathFigure pathFigure = pathEditorTarget.PathGeometry.Figures[pathPart.FigureIndex]; if (pathFigure.IsClosed && pathPart.PartIndex == 0) { int num1 = PathFigureUtilities.PointCount(pathFigure); int num2 = 1; if (PathFigureUtilities.IsCloseSegmentDegenerate(pathFigure)) { num2 = PathSegmentUtilities.GetPointCount(pathFigure.Segments[pathFigure.Segments.Count - 1]); } list[pathSegment.FigureIndex][num1 - num2] = true; } else { int segmentIndex; int segmentPointIndex; PathFigureUtilities.GetSegmentFromPointIndex(pathFigure, pathPart.PartIndex, out segmentIndex, out segmentPointIndex); int pointCount = PathSegmentUtilities.GetPointCount(pathFigure.Segments[segmentIndex]); int index = pathSegment.PartIndex - pointCount; if (index >= 0) { list[pathSegment.FigureIndex][index] = true; } } } } } for (int figureIndex = 0; figureIndex < pathEditorTarget.PathGeometry.Figures.Count; ++figureIndex) { BitArray bitArray = list[figureIndex]; PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditorTarget.PathGeometry.Figures[figureIndex], pathEditorTarget.PathDiffChangeList, figureIndex); int num = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure); for (int index = 0; index < num; ++index) { if (bitArray[index]) { pathFigureEditor.MovePoint(index, offset + pathFigureEditor.GetPoint(index)); } } } }
public AdjustAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
public ConvertPointAction(PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { }
public PenAdornerSet(ToolBehaviorContext toolContext, BaseFrameworkElement adornedElement, PathEditorTarget pathEditorTarget) : base(toolContext, adornedElement, pathEditorTarget) { }
public StartAction(PenCreateBehavior penCreateBehavior, PathEditorTarget pathEditorTarget, SceneViewModel viewModel) : base(pathEditorTarget, viewModel) { this.penCreateBehavior = penCreateBehavior; }