protected override bool OnButtonDownOverNonAdorner(Point pointerPosition) { this.IsProjectedInsertionPoint = Adorner.NonAffineTransformInParentStack(this.ActiveSceneInsertionPoint.SceneElement); if (!this.IsProjectedInsertionPoint) { this.pointList.Clear(); this.pointList.Add(pointerPosition); this.vpFitter.Clear(); this.vpFitter.Add(pointerPosition, 0L); this.vpFitter.CurveTolerance = Tolerances.CurveFittingDistanceTolerance(this.ActiveView.Zoom) * Tolerances.CurveFittingDistanceTolerance(this.ActiveView.Zoom); } return(true); }
protected override void OnPreviewInsertionPointChanged() { base.OnPreviewInsertionPointChanged(); if (this.PreviewInsertionPoint == null) { if (this.ActiveSceneViewModel.ActiveSceneInsertionPoint == null) { this.IsProjectedInsertionPoint = false; } else { this.IsProjectedInsertionPoint = Adorner.NonAffineTransformInParentStack(this.ActiveSceneViewModel.ActiveSceneInsertionPoint.SceneElement); } } else { this.IsProjectedInsertionPoint = Adorner.NonAffineTransformInParentStack(this.PreviewInsertionPoint.SceneElement); } }
private void DrawFeedback(Point pointBegin, Point pointEnd) { Rect rect = new Rect(pointBegin, pointEnd); this.ToolBehaviorContext.SnappingEngine.UpdateTargetBounds(rect); DrawingContext drawingContext = this.OpenFeedback(); Pen thinPen = FeedbackHelper.GetThinPen(this.ActiveView.Zoom); System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(this.ActiveView, this.ActiveSceneInsertionPoint.SceneElement, rect, thinPen.Thickness, false); drawingContext.DrawGeometry((Brush)null, thinPen, rectangleGeometry); if (!Adorner.NonAffineTransformInParentStack(this.ActiveSceneInsertionPoint.SceneElement)) { Matrix computedTransformToRoot = this.ActiveView.GetComputedTransformToRoot(this.ActiveSceneInsertionPoint.SceneElement); double scale = 1.0 / this.ActiveView.Zoom; SizeAdorner.DrawDimension(drawingContext, ElementLayoutAdornerType.Right, computedTransformToRoot, computedTransformToRoot, thinPen, rect, scale); SizeAdorner.DrawDimension(drawingContext, ElementLayoutAdornerType.Bottom, computedTransformToRoot, computedTransformToRoot, thinPen, rect, scale); } this.CloseFeedback(); }
private void UpdateEditingElementTransform() { SceneView activeView = this.textSource.DesignerContext.ActiveView; Matrix matrix = new Matrix(); if (this.TextSource.Visual != null) { if (Adorner.NonAffineTransformInParentStack((SceneElement)this.TextSource)) { Rect actualBounds = activeView.GetActualBounds(this.TextSource.Visual); Point point = activeView.TransformPoint(this.TextSource.Visual, (IViewObject)activeView.HitTestRoot, new Point(actualBounds.Width / 2.0, actualBounds.Height / 2.0)); matrix.Translate(point.X - this.EditingElement.Width / 2.0, point.Y - this.EditingElement.Height / 2.0); } else { matrix = activeView.GetComputedTransformToRoot(this.TextSource.Visual); } } this.EditingElement.SetTransformMatrix(this.IsMatrixValidForTransform(matrix) ? matrix : Matrix.Identity); }
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 override void Draw(DrawingContext drawingContext, Matrix matrix) { if (!this.ShouldDraw) { return; } SceneElementSelectionSet elementSelectionSet = this.DesignerContext.ActiveSceneViewModel.ElementSelectionSet; AdornerLayer adornerLayer = this.DesignerContext.ActiveView.AdornerLayer; Tool adornerOwnerTool = this.DesignerContext.ToolManager.ActiveTool.AdornerOwnerTool; SceneView activeView = this.DesignerContext.ActiveView; Transform transform = activeView.Artboard.CalculateTransformFromContentToArtboard(); bool flag1 = this.ElementSet.AdornsMultipleElements && (adornerOwnerTool.GetSelectionAdornerUsages((SceneElement)null) & SelectionAdornerUsages.ShowBoundingBox) != SelectionAdornerUsages.None; bool flag2 = false; bool flag3 = true; Rect rectangle = new Rect(); foreach (SceneElement element in this.ElementSet.Elements) { IViewObject viewTargetElement = element.ViewTargetElement; if (!(element is Base3DElement) && !element.IsHiddenOrCollapsedOrAncestorHiddenOrCollapsed && (viewTargetElement != null && element.Visual != null)) { Rect actualBounds = this.DesignerContext.ActiveView.GetActualBounds(viewTargetElement); bool flag4 = element == this.ElementSet.PrimaryElement; if ((adornerOwnerTool.GetSelectionAdornerUsages(element) & SelectionAdornerUsages.ShowBoundingBox) != SelectionAdornerUsages.None && this.ElementSet.Elements.Count < 100 || flag4) { Pen pen = flag4 ? this.MediumPen : this.BorderPen; System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(this.DesignerContext.ActiveView, element, actualBounds, pen.Thickness, true); drawingContext.DrawGeometry((Brush)null, pen, rectangleGeometry); } if (flag1) { Rect rect1 = activeView.TransformBounds(element.Visual, (IViewObject)activeView.HitTestRoot, actualBounds); Rect rect2 = transform.TransformBounds(rect1); if (!flag2) { flag2 = Adorner.NonAffineTransformInParentStack(element); } if (flag3) { rectangle = rect2; flag3 = false; } else { rectangle.Union(rect2); } } } } if (!flag1) { return; } if (flag2) { rectangle.Inflate(this.MediumPen.Thickness / 2.0, this.MediumPen.Thickness / 2.0); drawingContext.DrawRectangle((Brush)null, this.MediumPen, rectangle); } else { System.Windows.Media.Geometry rectangleGeometry = Adorner.GetTransformedRectangleGeometry(this.ElementSet.ElementBounds, this.ElementSet.GetTransformMatrixToAdornerLayer(), this.MediumPen.Thickness); drawingContext.DrawGeometry((Brush)null, this.MediumPen, rectangleGeometry); } }
private void UpdateTranslation(bool scrollNow) { SceneView activeView = this.ActiveView; SceneViewModel viewModel = activeView.ViewModel; if (!this.HasMouseMovedAfterDown) { this.hasInitializedBrush = false; } SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection; if (primarySelection == null) { return; } PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection); if (propertyReference == null || Adorner.NonAffineTransformInParentStack(primarySelection)) { return; } this.EnsureEditTransaction(); if (!this.hasInitializedBrush) { if (!PlatformTypes.IsInstance(this.ActiveView.ElementSelectionSet.PrimarySelection.GetComputedValue(propertyReference), PlatformTypes.GradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { object lastUsed = BrushCategory.GetLastUsed(this.ActiveView.DesignerContext, this.ActiveView.Document.DocumentContext, BrushCategory.Gradient); this.ActiveView.ElementSelectionSet.PrimarySelection.SetValueAsWpf(propertyReference, lastUsed); this.UpdateEditTransaction(); } this.CopyPrimaryBrushToSelection(); this.hasInitializedBrush = true; } object computedValue = primarySelection.GetComputedValue(propertyReference); Matrix matrix = activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true); Point point1 = this.dragStartPosition * matrix; Point point2 = this.dragCurrentPosition * matrix; Point point3 = RoundingHelper.RoundPosition(point1); Point point4 = RoundingHelper.RoundPosition(point2); if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point3); this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point4); } else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext)) { this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point3); this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point3); if (this.IsShiftDown) { Vector vector = point4 - point3; this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)vector.Length); this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)vector.Length); } else { Point point5 = RoundingHelper.RoundPosition(new Point(Math.Abs(point3.X - point4.X), Math.Abs(point3.Y - point4.Y))); this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)point5.X); this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)point5.Y); } } activeView.EnsureVisible(this.dragStartPosition + this.dragCurrentPosition - this.dragStartPosition, scrollNow); this.UpdateEditTransaction(); }