public PathDiff(Base2DElement targetElement, IPropertyId pathProperty, PathDiffChangeList changeList) { this.targetElement = targetElement; this.platformMetadata = targetElement.Platform.Metadata; this.pathProperty = this.platformMetadata.ResolveProperty(pathProperty) as ReferenceStep; this.changeList = changeList; }
public static void ExplicitlyChangeLayoutRounding(SceneNode targetNode, PropertyReference filteredProperty) { Base2DElement base2Delement = targetNode as Base2DElement; if (base2Delement == null || !LayoutRoundingHelper.IsUseLayoutRoundingProperty(targetNode, (IProperty)filteredProperty.LastStep)) { return; } LayoutRoundingHelper.SetAutoLayoutRounding((SceneElement)base2Delement, false); }
public static Matrix GetBrushMatrix(Base2DElement element, object brush, IPropertyId matrixProperty) { Transform transform = BrushAdorner.GetBrushPropertyAsWpf(element, brush, matrixProperty) as Transform; if (transform != null) { return(transform.Value); } return(Matrix.Identity); }
public void Stop() { if (this.snapLineRenderer.IsAttached) { this.snapLineRenderer.Detach(); } this.toolContext = (ToolBehaviorContext)null; this.targetElement = (SceneElement)null; this.container = (Base2DElement)null; this.snapLines.Clear(); }
protected virtual double GetNativeHeight(SceneElement element) { double val2 = double.PositiveInfinity; Base2DElement context = element.Parent as Base2DElement; if (context != null && context.IsViewObjectValid) { val2 = context.GetComputedBounds(context).Height; } return(Math.Min(100.0, val2)); }
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); }
public ClippingPathEditorTarget(Base2DElement editingElement) : base(editingElement.ViewModel, Base2DElement.ClipProperty, (SceneNode)editingElement) { this.editingElement = editingElement; IPropertyId propertyKey = (IPropertyId)editingElement.ProjectContext.ResolveProperty(Base2DElement.ClipProperty); this.basisSubscription = new SceneNodeSubscription <PathElement, PathGeometry>(); this.basisSubscription.Path = new SearchPath(new SearchStep[1] { new SearchStep(new SearchAxis(propertyKey)) }); this.basisSubscription.InsertBasisNode((SceneNode)editingElement); this.basisSubscription.PathNodeInserted += new SceneNodeSubscription <PathElement, PathGeometry> .PathNodeInsertedListener(((PathEditorTarget)this).OnBasisSubscriptionPathNodeInserted); this.basisSubscription.PathNodeRemoved += new SceneNodeSubscription <PathElement, PathGeometry> .PathNodeRemovedListener(this.OnBasisSubscriptionPathNodeRemoved); this.UpdateCachedPath(); }
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 bool TrySetAutoSizeProperty(IPropertyId layoutProperty, object value, IPropertyId alignmentProperty, object autoAlignmentValue, Func <Thickness, Size, double, Thickness> adjustMarginFunction) { if (this.property.Reference.FirstStep.Equals((object)layoutProperty)) { string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1] { (object)this.property.PropertyName }); if (this.property.SceneNodeObjectSet.Document.IsEditable) { using (SceneEditTransaction editTransaction = this.property.SceneNodeObjectSet.ViewModel.CreateEditTransaction(description, false, SceneEditTransactionType.NestedInAutoClosing)) { foreach (SceneNode sceneNode in this.property.SceneNodeObjectSet.Objects) { Base2DElement base2Delement = sceneNode as Base2DElement; if (base2Delement != null) { bool flag1 = base2Delement.GetComputedValueAsWpf(alignmentProperty).Equals(autoAlignmentValue); bool flag2 = value is double; bool flag3 = base2Delement.Parent == null || base2Delement.Parent is FrameworkTemplateElement; if (!flag1 || !flag2 || (!base2Delement.IsViewObjectValid || flag3)) { base2Delement.SetValue(this.property.Reference, value); } else if (base2Delement.Visual != null) { Thickness thickness1 = (Thickness)base2Delement.GetComputedValueAsWpf(BaseFrameworkElement.MarginProperty); Thickness thickness2 = adjustMarginFunction(thickness1, ((IViewVisual)base2Delement.Visual).RenderSize, (double)value); base2Delement.SetValueAsWpf(BaseFrameworkElement.MarginProperty, (object)thickness2); } } else { sceneNode.SetValue(this.property.Reference, value); } } editTransaction.Commit(); } this.property.SceneNodeObjectSet.TransactionContext.UpdateTransaction(); return(true); } } return(false); }
public static Matrix GetCompleteBrushTransformMatrix(Base2DElement element, object brush, bool includeTransformFromElementToBrushCoordinates) { Matrix matrix1 = Matrix.Identity; if (brush != null && element != null) { Rect computedTightBounds = element.GetComputedTightBounds(); Matrix matrix2 = BrushAdorner.GetBrushMatrix(element, brush, BrushNode.RelativeTransformProperty); if (PlatformTypes.IsInstance(brush, PlatformTypes.GradientBrush, (ITypeResolver)element.ProjectContext)) { if ((BrushMappingMode)BrushAdorner.GetBrushPropertyAsWpf(element, brush, GradientBrushNode.MappingModeProperty) == BrushMappingMode.Absolute) { if (includeTransformFromElementToBrushCoordinates) { Matrix identity = Matrix.Identity; identity.Translate(-computedTightBounds.X, -computedTightBounds.Y); double scaleX = computedTightBounds.Width == 0.0 ? 1.0 : 1.0 / computedTightBounds.Width; double scaleY = computedTightBounds.Height == 0.0 ? 1.0 : 1.0 / computedTightBounds.Height; identity.Scale(scaleX, scaleY); matrix2 = identity * matrix2; } } else if (BrushAdorner.IsAdorningFillProperty((SceneElement)element)) { matrix2 *= BrushAdorner.GetStrokeTransform((SceneElement)element); } } if (PlatformTypes.IsInstance(brush, PlatformTypes.TileBrush, (ITypeResolver)element.ProjectContext) && BrushAdorner.IsAdorningFillProperty((SceneElement)element)) { matrix2 *= BrushAdorner.GetStrokeTransform((SceneElement)element); } Matrix matrix3 = new Matrix(computedTightBounds.Width, 0.0, 0.0, computedTightBounds.Height, computedTightBounds.X, computedTightBounds.Y); matrix1 = matrix2 * matrix3 * BrushAdorner.GetBrushMatrix(element, brush, BrushNode.TransformProperty); } return(matrix1); }
public MotionPathEditorTarget(Base2DElement editingElement) : base(editingElement.ViewModel) { this.editingElement = editingElement; this.UpdateCachedPath(); }
public void Start(ToolBehaviorContext toolContext, BaseFrameworkElement targetElement, IList <BaseFrameworkElement> ignoredElements) { if (this.IsStarted) { this.Stop(); } this.toolContext = toolContext; if (this.toolContext.View.ViewModel.UsingEffectDesigner) { return; } this.container = (Base2DElement)null; this.targetElement = (SceneElement)targetElement; if (targetElement == null) { ISceneInsertionPoint sceneInsertionPoint = this.toolContext.View.ViewModel.ActiveSceneInsertionPoint; if (sceneInsertionPoint != null) { this.container = sceneInsertionPoint.SceneElement as Base2DElement; } } else if (!this.IsTransformed((SceneElement)targetElement)) { this.container = targetElement.ParentElement as Base2DElement; } ILayoutDesigner layoutDesigner = targetElement == null?this.toolContext.View.ViewModel.GetLayoutDesignerForParent((SceneElement)this.container, true) : this.toolContext.View.ViewModel.GetLayoutDesignerForChild(this.targetElement, true); BaseFrameworkElement parent = this.container as BaseFrameworkElement; bool leftRight = layoutDesigner.GetWidthConstraintMode(parent, targetElement) != LayoutConstraintMode.CanvasLike; bool topBottom = layoutDesigner.GetHeightConstraintMode(parent, targetElement) != LayoutConstraintMode.CanvasLike; if (!leftRight && !topBottom) { this.container = (Base2DElement)null; } if (this.container == null) { return; } this.snapLineRenderer.Attach(toolContext, (SceneElement)this.container); Rect actualBounds = this.toolContext.View.GetActualBounds(this.container.ViewObject); this.AddSnapLines(actualBounds, true, leftRight, topBottom); GridElement gridElement = this.container as GridElement; if (gridElement != null) { double x = 0.0; foreach (ColumnDefinitionNode columnDefinitionNode in (IEnumerable <ColumnDefinitionNode>)gridElement.ColumnDefinitions) { x += columnDefinitionNode.ComputedWidth; Point p1 = new Point(x, actualBounds.Top); Point p2 = new Point(x, actualBounds.Bottom); this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Vertical, SnapLineLocation.Minimum, true)); this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Vertical, SnapLineLocation.Maximum, true)); } double y = 0.0; foreach (RowDefinitionNode rowDefinitionNode in (IEnumerable <RowDefinitionNode>)gridElement.RowDefinitions) { y += rowDefinitionNode.ComputedHeight; Point p1 = new Point(actualBounds.Left, y); Point p2 = new Point(actualBounds.Right, y); this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Horizontal, SnapLineLocation.Minimum, true)); this.snapLines.Add(new SnapLine(p1, p2, SnapLineOrientation.Horizontal, SnapLineLocation.Maximum, true)); } } if (!(this.container is PanelElement)) { return; } foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)((PanelElement)this.container).Children) { BaseFrameworkElement frameworkElement = sceneNode as BaseFrameworkElement; if (frameworkElement != null && frameworkElement != targetElement && frameworkElement.IsViewObjectValid && ((ignoredElements == null || !ignoredElements.Contains(frameworkElement)) && !this.IsTransformed((SceneElement)frameworkElement))) { Rect actualBoundsInParent = this.toolContext.View.GetActualBoundsInParent(frameworkElement.ViewObject); this.AddSnapLines(actualBoundsInParent, false, leftRight, topBottom); double baseline = this.toolContext.View.GetBaseline((SceneNode)frameworkElement); if (!double.IsNaN(baseline)) { this.snapLines.Add(new SnapLine(new Point(actualBoundsInParent.Left, actualBoundsInParent.Top + baseline), new Point(actualBoundsInParent.Right, actualBoundsInParent.Top + baseline), SnapLineOrientation.Horizontal, SnapLineLocation.Baseline, false)); } } } }
protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice) { BaseFrameworkElement frameworkElement = this.oldPathEditorTarget.EditingElement.GetCommonAncestor((SceneNode)this.EditingElement) as BaseFrameworkElement; Base2DElement editingElement = this.oldPathEditorTarget.EditingElement; Base2DElement base2Delement = (Base2DElement)this.EditingElement; if (frameworkElement != base2Delement && !base2Delement.GetComputedTransformToElement((SceneElement)frameworkElement).HasInverse) { this.End(); } else { int figureIndex1 = pathEditContext.FigureIndex; int num1 = PathFigureUtilities.PointCount(this.oldPathEditContext.GetPathFigure(this.oldPathEditorTarget.PathGeometry)); if (editingElement != base2Delement) { this.PathEditorTarget.EndEditing(false); figureIndex1 += this.oldPathEditorTarget.PathGeometry.Figures.Count; List <PathElement> otherElements = new List <PathElement>(); PathElement mainElement = (PathElement)editingElement; PathElement pathElement = (PathElement)base2Delement; otherElements.Add(pathElement); PathCommandHelper.MakeCompoundPath(mainElement, otherElements, this.EditTransaction); this.UpdateEditTransaction(); this.PathEditorTarget = this.oldPathEditorTarget; } this.PathEditorTarget.BeginEditing(); PathGeometryEditor geometryEditor = this.PathEditorTarget.CreateGeometryEditor(); if (pathEditContext.PartIndex != 0) { geometryEditor.CreatePathFigureEditor(figureIndex1).Reverse(); } geometryEditor.JoinFigure(this.oldPathEditContext.FigureIndex, figureIndex1); int figureIndex2 = this.oldPathEditContext.FigureIndex; if (pathEditContext.FigureIndex < this.oldPathEditContext.FigureIndex && editingElement == base2Delement) { --figureIndex2; } this.UpdateEditTransaction(); this.View.UpdateLayout(); PathFigureEditor pathFigureEditor = geometryEditor.CreatePathFigureEditor(figureIndex2); int downstreamSegment1 = pathFigureEditor.GetLastIndexOfDownstreamSegment(num1 - 1); if (pathFigureEditor.GetPointKind(downstreamSegment1) == PathPointKind.Cubic) { Vector lastTangent = this.oldPathEditorTarget.LastTangent; pathFigureEditor.SetPoint(downstreamSegment1 - 2, pathFigureEditor.GetPoint(downstreamSegment1 - 2) + lastTangent); } this.PathEditorTarget.EndEditing(false); int downstreamSegment2 = pathFigureEditor.GetLastIndexOfDownstreamSegment(num1 - 1); this.PathEditContext = new PathEditContext(figureIndex2, downstreamSegment2); int num2 = PathFigureUtilities.PointCount(pathFigureEditor.PathFigure); if (pathFigureEditor.GetPointKind(num2 - 1) == PathPointKind.Cubic) { this.LastTangent = pathFigureEditor.GetPoint(num2 - 1) - pathFigureEditor.GetPoint(num2 - 2); } else { this.LastTangent = new Vector(0.0, 0.0); } this.UpdateEditTransaction(); this.zeroTangents = false; this.PathEditorTarget.BeginEditing(); base.OnBegin(this.PathEditContext, mouseDevice); } }
public static Matrix GetCompleteInverseBrushTransformMatrix(Base2DElement element, object brush, bool includeTransformFromElementToBrushCoordinates) { return(ElementUtilities.GetInverseMatrix(BrushAdorner.GetCompleteBrushTransformMatrix(element, brush, includeTransformFromElementToBrushCoordinates))); }
public static object GetBrushPropertyAsWpf(Base2DElement element, object brush, IPropertyId key) { ReferenceStep referenceStep = (ReferenceStep)element.Platform.Metadata.ResolveProperty(key); return(element.ViewModel.DefaultView.ConvertToWpfValue(referenceStep.GetCurrentValue(brush))); }