public Matrix GetCompleteInverseBrushTransformMatrix(bool includeTransformFromElementToBrushCoordinates) { return(BrushAdorner.GetCompleteInverseBrushTransformMatrix(this.BaseElement, this.PlatformBrush, includeTransformFromElementToBrushCoordinates)); }
private void UpdateTranslation(bool scrollNow) { SceneView activeView = this.ActiveView; SceneViewModel viewModel = activeView.ViewModel; Vector delta = this.dragCurrentPosition - this.dragStartPosition; if (this.isConstraining) { delta = this.ConstrainDeltaToAxis(delta); } if (delta == this.lastMove || this.IsAltDown) { return; } this.EnsureEditTransaction(); Vector vector1 = delta - this.lastMove; SceneElement primarySelection = viewModel.ElementSelectionSet.PrimarySelection; if (primarySelection == null) { return; } PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection); if (propertyReference == null) { return; } object computedValue = primarySelection.GetComputedValue(propertyReference); if (computedValue != null && !PlatformTypes.IsInstance(computedValue, PlatformTypes.SolidColorBrush, (ITypeResolver)primarySelection.ProjectContext)) { Vector vector2 = vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true); if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool) { ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.StartPointProperty); ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.EndPointProperty); Point point1 = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2); Point point2 = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2); this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point1); this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point2); } else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool) { ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.CenterProperty); ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.GradientOriginProperty); Point point1 = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2); Point point2 = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2); this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point1); this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point2); } else { this.TranslateBrushPosition(vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, false), primarySelection); } } activeView.EnsureVisible(this.dragStartPosition + delta, scrollNow); this.lastMove = delta; this.UpdateEditTransaction(); }
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(); }