public override void SetSize(Rect sourceRect, BaseFrameworkElement target, ILayoutDesigner targetLayoutDesigner) { Rect childRect = targetLayoutDesigner.GetChildRect(target); childRect.Height = sourceRect.Height; targetLayoutDesigner.SetChildRect(target, childRect, false, true); }
private void SetGridHeightCore(GridElement grid, double height) { BaseFrameworkElement sizeElement = this.GetSizeElement((BaseFrameworkElement)grid); if (sizeElement.ViewModel.RootNode == sizeElement) { if (!double.IsNaN(sizeElement.Height)) { sizeElement.Height = height; } else { if (double.IsNaN((double)sizeElement.GetLocalOrDefaultValue(DesignTimeProperties.DesignHeightProperty))) { return; } sizeElement.SetValue(DesignTimeProperties.DesignHeightProperty, (object)height); } } else { ILayoutDesigner designerForChild = sizeElement.ViewModel.GetLayoutDesignerForChild((SceneElement)sizeElement, true); Rect rect = designerForChild.GetChildRect(sizeElement); rect = new Rect(rect.Left, rect.Top, rect.Width, height); designerForChild.SetChildRect(sizeElement, rect, false, true); } }
protected override void CreateAdorners() { BaseFrameworkElement child = this.Element as BaseFrameworkElement; BaseFrameworkElement frameworkElement = this.Element.ParentElement as BaseFrameworkElement; if (child == null || frameworkElement == null || !frameworkElement.IsAttached) { return; } ILayoutDesigner designerForChild = this.ViewModel.GetLayoutDesignerForChild(this.Element, true); if ((designerForChild.GetWidthConstraintMode(child) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike) { this.AddAdorner((Adorner) new ElementLayoutLineAdorner((AdornerSet)this, ElementLayoutAdornerType.Left)); this.AddAdorner((Adorner) new ElementLayoutLineAdorner((AdornerSet)this, ElementLayoutAdornerType.Right)); this.AddAdorner((Adorner) new ElementLayoutLockAdorner((AdornerSet)this, ElementLayoutAdornerType.Left)); this.AddAdorner((Adorner) new ElementLayoutLockAdorner((AdornerSet)this, ElementLayoutAdornerType.Right)); } if ((designerForChild.GetHeightConstraintMode(child) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike) { return; } this.AddAdorner((Adorner) new ElementLayoutLineAdorner((AdornerSet)this, ElementLayoutAdornerType.Top)); this.AddAdorner((Adorner) new ElementLayoutLineAdorner((AdornerSet)this, ElementLayoutAdornerType.Bottom)); this.AddAdorner((Adorner) new ElementLayoutLockAdorner((AdornerSet)this, ElementLayoutAdornerType.Top)); this.AddAdorner((Adorner) new ElementLayoutLockAdorner((AdornerSet)this, ElementLayoutAdornerType.Bottom)); }
public static void AdjustPathForAnimations(PathElement pathElement, SceneEditTransaction editTransaction) { using (pathElement.ViewModel.ForceBaseValue()) { System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)pathElement.GetLocalOrDefaultValueAsWpf(PathElement.DataProperty); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.AddGeometry(geometry1); Rect bounds = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry.Bounds, pathElement, false); PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform); Rect maxAnimatedExtent = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, propertyReference); double num1 = Math.Min(0.0, maxAnimatedExtent.Left); double num2 = Math.Min(0.0, maxAnimatedExtent.Top); Vector vector = new Vector(-num1, -num2); ILayoutDesigner designerForChild = pathElement.ViewModel.GetLayoutDesignerForChild((SceneElement)pathElement, true); editTransaction.Update(); Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)pathElement); childRect.X += num1; childRect.Y += num2; childRect.Width = Math.Max(maxAnimatedExtent.Width, childRect.Width); childRect.Height = Math.Max(maxAnimatedExtent.Height, childRect.Height); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, childRect); Transform transform = (Transform) new TranslateTransform(vector.X, vector.Y); PathGeometry geometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry, transform); if (!pathElement.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2); } pathElement.PathGeometry = geometry2; PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, propertyReference, transform); pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1)); } }
public override void Execute() { BaseFrameworkElement selectedElement = this.SelectedElement; SceneViewModel sceneViewModel1 = this.SceneViewModel; bool flag1 = true; BaseFrameworkElement frameworkElement = selectedElement; int num1 = flag1 ? true : false; ILayoutDesigner designerForChild = sceneViewModel1.GetLayoutDesignerForChild((SceneElement)frameworkElement, num1 != 0); SceneNode parent = selectedElement.Parent; IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement); ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild); int index = collectionForProperty.IndexOf((SceneNode)selectedElement); if (!BehaviorHelper.EnsureBlendSDKLibraryAssemblyReferenced(this.SceneViewModel, "Microsoft.Expression.Controls") || !ProjectContext.GetProjectContext(selectedElement.ProjectContext).IsTypeSupported(ProjectNeutralTypes.PathListBox)) { return; } using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { SceneViewModel sceneViewModel2 = this.SceneViewModel; bool flag2 = false; string unitMakeLayoutPath = StringTable.UndoUnitMakeLayoutPath; int num2 = flag2 ? true : false; using (SceneEditTransaction editTransaction = sceneViewModel2.CreateEditTransaction(unitMakeLayoutPath, num2 != 0)) { using (this.SceneViewModel.ForceBaseValue()) { using (this.SceneViewModel.DisableDrawIntoState()) { this.SceneViewModel.ElementSelectionSet.Clear(); Rect childRect = designerForChild.GetChildRect(selectedElement); selectedElement.EnsureNamed(); PathListBoxElement pathListBoxElement = (PathListBoxElement)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.PathListBox); LayoutPathNode layoutPathNode = (LayoutPathNode)this.SceneViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath); BindingSceneNode bindingSceneNode = (BindingSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Binding); bindingSceneNode.ElementName = selectedElement.Name; layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode); pathListBoxElement.LayoutPaths.Add((SceneNode)layoutPathNode); if (!collectionForProperty.FixedCapacity.HasValue || collectionForProperty.Count < collectionForProperty.FixedCapacity.Value) { collectionForProperty.Insert(index, (SceneNode)pathListBoxElement); } else { GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid); collectionForProperty[index] = (SceneNode)gridElement; gridElement.Children.Add((SceneNode)pathListBoxElement); gridElement.Children.Add((SceneNode)selectedElement); } editTransaction.Update(); designerForChild.SetChildRect((BaseFrameworkElement)pathListBoxElement, childRect); this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)pathListBoxElement); editTransaction.Commit(); } } } } }
public GridLayoutOperation(ILayoutDesigner designer, BaseFrameworkElement child) : base(designer, child) { this.parentGrid = child.ParentElement as GridElement; if (this.parentGrid == null) { throw new ArgumentException(ExceptionStringTable.LayoutBehaviorElementNotInGrid); } }
protected override void Initialize() { base.Initialize(); ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElement, true); this.initialRect = designerForChild.GetChildRect(this.BaseEditingElement); this.initialOverrides = designerForChild.ComputeOverrides(this.BaseEditingElement); this.transformHelper = PathElement.TryCreateTransformHelper(this.EditingElement, this.StartSize); }
public void UpdateTranslation(ILayoutDesigner layoutDesigner, Rect unionOfBounds) { if (this.element.ViewObject == null || this.Bounds.IsEmpty || this.Bounds.Width <= 0.0 && this.Bounds.Height <= 0.0) { return; } using (layoutDesigner.SuppressLayoutRounding) layoutDesigner.SetLayoutFromCache(this.element, this.cache, unionOfBounds); }
public LayoutOperation(ILayoutDesigner designer, BaseFrameworkElement child) { this.Designer = designer; this.Child = child; this.Settings = new LayoutSettings(); this.SettingsFromElement = LayoutUtilities.GetLayoutSettingsFromElement((SceneElement)child); this.ExplicitOverrides = LayoutUtilities.GetLayoutOverrides((SceneElement)child); this.WidthConstraintMode = designer.GetWidthConstraintMode(child); this.HeightConstraintMode = designer.GetHeightConstraintMode(child); }
protected void MoveDraggedElementsInContainer() { Point point1 = this.DragCurrentPosition; if (this.IsConstraining) { point1 = this.ConstrainPointToAxis(this.DragStartPosition, this.DragCurrentPosition); } Point point2 = this.ActiveView.TransformPoint((IViewObject)this.ActiveView.HitTestRoot, this.LayoutContainer.Visual, point1); Point point3 = this.ActiveView.TransformPoint((IViewObject)this.ActiveView.HitTestRoot, this.LayoutContainer.Visual, this.DragStartPosition); for (int index = 0; index < this.DraggedElements.Count; ++index) { BaseFrameworkElement child = this.DraggedElements[index]; if (child.IsViewObjectValid) { LayoutOverrides overridesToIgnore = LayoutOverrides.None; if (point1.X != this.DragStartPosition.X) { overridesToIgnore |= LayoutOverrides.CenterHorizontalAlignment; } if (point1.Y != this.DragStartPosition.Y) { overridesToIgnore |= LayoutOverrides.CenterVerticalAlignment; } if (this.Context.IsRecordingKeyframes) { Vector vector = point2 - point3; CanonicalTransform canonicalTransform = this.Context.BaseRenderTransforms[index]; double num1 = RoundingHelper.RoundLength(vector.X + canonicalTransform.TranslationX); double num2 = RoundingHelper.RoundLength(vector.Y + canonicalTransform.TranslationY); if (!object.Equals((object)canonicalTransform.TranslationX, (object)num1)) { child.SetValue(child.Platform.Metadata.CommonProperties.RenderTransformTranslationX, (object)num1); } if (!object.Equals((object)canonicalTransform.TranslationY, (object)num2)) { child.SetValue(child.Platform.Metadata.CommonProperties.RenderTransformTranslationY, (object)num2); } } else { Point location = point2; ILayoutDesigner designerForChild = this.ActiveView.ViewModel.GetLayoutDesignerForChild((SceneElement)child, false); Rect childRect = designerForChild.GetChildRect(child); Point point4 = this.ActiveView.TransformPoint(child.Visual, this.LayoutContainer.Visual, this.Context.Offsets[index]); point4.Offset(-childRect.X, -childRect.Y); location.Offset(-point4.X, -point4.Y); Rect rect = new Rect(location, this.Context.LayoutCacheRecords[index].Rect.Size); designerForChild.SetChildRect(child, rect, this.Context.LayoutCacheRecords[index].Overrides, overridesToIgnore, LayoutOverrides.None); } } } this.Context.Transaction.UpdateEditTransaction(); }
private void NestContents(SceneNode node) { SceneElement sceneElement1 = (SceneElement)node; ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection; int count = destinationCollection.Count; SceneElement[] sceneElementArray = new SceneElement[count]; LayoutCacheRecord[] layoutCacheRecordArray = new LayoutCacheRecord[count]; ILayoutDesigner designerForParent1 = this.SceneNode.ViewModel.GetLayoutDesignerForParent(this.SceneElement, true); Rect empty = Rect.Empty; for (int index = 0; index < count; ++index) { BaseFrameworkElement frameworkElement = destinationCollection[index] as BaseFrameworkElement; if (frameworkElement != null) { layoutCacheRecordArray[index] = designerForParent1.CacheLayout(frameworkElement); empty.Union(designerForParent1.GetChildRect(frameworkElement)); } } for (int index = 0; index < count; ++index) { SceneNode child = destinationCollection[index]; SceneElement sceneElement2 = child as SceneElement; if (sceneElement2 != null) { sceneElementArray[index] = sceneElement2; } this.SceneNode.ViewModel.RemoveElement(child); } destinationCollection.Add((SceneNode)sceneElement1); for (int index = 0; index < count; ++index) { if (sceneElementArray[index] != null) { sceneElement1.DefaultContent.Add((SceneNode)sceneElementArray[index]); } } this.SceneNode.ViewModel.Document.OnUpdatedEditTransaction(); this.SceneNode.DesignerContext.ActiveView.UpdateLayout(); ILayoutDesigner designerForParent2 = this.SceneNode.ViewModel.GetLayoutDesignerForParent(sceneElement1, true); for (int index = 0; index < count; ++index) { if (sceneElementArray[index] != null && layoutCacheRecordArray[index] != null) { designerForParent2.SetLayoutFromCache((BaseFrameworkElement)sceneElementArray[index], layoutCacheRecordArray[index], empty); } } if (sceneElementArray.Length != 1) { return; } VisualStateManagerSceneNode.MoveStates(sceneElementArray[0], sceneElement1); }
public static ProjectLayout Create( string name, IEnumerable <EpicMetadata> epics, int projectRowIndex, ILayoutDesigner designer) { var rows = designer.Layout(epics); var cards = rows .SelectMany((row, index) => row.Select(m => new EpicCard(m, index + projectRowIndex + 1))) .ToArray(); return(new ProjectLayout(name, cards, projectRowIndex, projectRowIndex + rows.Count)); }
private static SceneElement ChangeLayoutType(SceneElement sourceElement, ITypeId layoutType, ref SceneElement elementContainingChildren) { IDocumentRoot documentRoot = sourceElement.DocumentNode.DocumentRoot; IDocumentContext documentContext = documentRoot.DocumentContext; SceneViewModel viewModel = sourceElement.ViewModel; Size size = Size.Empty; BaseFrameworkElement frameworkElement = sourceElement as BaseFrameworkElement; if (frameworkElement != null) { size = frameworkElement.GetComputedTightBounds().Size; } using (viewModel.ForceBaseValue()) { SceneElement sceneElement = (SceneElement)viewModel.CreateSceneNode(layoutType); using (viewModel.DisableUpdateChildrenOnAddAndRemove()) { using (viewModel.DisableDrawIntoState()) { viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)sourceElement); Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)sourceElement); Dictionary <IPropertyId, List <SceneNode> > storedChildren = ChangeLayoutTypeCommand.StoreChildren(sourceElement); if (sourceElement.DocumentNode == documentRoot.RootNode) { documentRoot.RootNode = sceneElement.DocumentNode; sceneElement.DocumentNode.NameScope = new DocumentNodeNameScope(); } else { ISceneNodeCollection <SceneNode> collectionContainer = sourceElement.GetCollectionContainer(); int index = collectionContainer.IndexOf((SceneNode)sourceElement); sourceElement.Remove(); collectionContainer.Insert(index, (SceneNode)sceneElement); } SceneElementHelper.ApplyProperties((SceneNode)sceneElement, properties); elementContainingChildren = ChangeLayoutTypeCommand.ApplyChildren(sceneElement, storedChildren, size); } } if (sceneElement is GridElement || sceneElement is CanvasElement) { ILayoutDesigner designerForChild = sceneElement.ViewModel.GetLayoutDesignerForChild(sceneElement, true); if ((designerForChild.GetWidthConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike) { sceneElement.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width); } if ((designerForChild.GetHeightConstraintMode((BaseFrameworkElement)sceneElement) & LayoutConstraintMode.CanvasLike) != LayoutConstraintMode.NonOverlappingGridlike) { sceneElement.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height); } } return(sceneElement); } }
public override void Execute() { PerformanceUtility.StartPerformanceSequence(PerformanceEvent.Make3D); try { using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.SceneViewModel.ElementSelectionSet.PrimarySelection; using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoUnitName, false)) { ILayoutDesigner designerForChild = this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)frameworkElement, true); Rect childRect = designerForChild.GetChildRect(frameworkElement); DocumentNode newValue = this.CreateValue(frameworkElement); if (newValue == null) { editTransaction.Cancel(); } else if (this.CreateResource && this.ProcessAsResource(frameworkElement, newValue) == null) { editTransaction.Cancel(); } else { if (this.ShouldReplaceOriginal) { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)frameworkElement); Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)frameworkElement, true); this.SceneViewModel.ElementSelectionSet.Clear(); BaseFrameworkElement element = this.CreateElement(frameworkElement); using (this.SceneViewModel.ForceBaseValue()) { element.Name = frameworkElement.Name; ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement); int index = collectionForChild.IndexOf((SceneNode)frameworkElement); frameworkElement.Remove(); this.Postprocess(frameworkElement, element, properties, childRect); collectionForChild.Insert(index, (SceneNode)element); SceneElementHelper.ApplyProperties((SceneNode)element, properties); editTransaction.Update(); designerForChild.SetChildRect(element, childRect); } this.SceneViewModel.ElementSelectionSet.SetSelection((SceneElement)element); } editTransaction.Commit(); } } } } finally { PerformanceUtility.EndPerformanceSequence(PerformanceEvent.Make3D); } }
protected override void ApplyScale(Vector scale, Point center) { Dictionary <SceneElement, Size> dictionary = this.CalculateClampedSizes(ref scale); Vector vector1 = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0); Matrix startSharedTransform = this.StartSharedTransform; Matrix inverseMatrix = ElementUtilities.GetInverseMatrix(startSharedTransform); ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElementSet.PrimaryElement, true); foreach (SceneElement index in this.EditingElementSet.Elements) { double width = dictionary[index].Width; double height = dictionary[index].Height; Rect rect1 = this.StartBoundsDictionary[index]; Point renderTransformOrigin = ((Base2DElement)index).RenderTransformOrigin; Point point1 = new Point(rect1.X + rect1.Width * renderTransformOrigin.X, rect1.Y + rect1.Height * renderTransformOrigin.Y); Matrix matrix1 = this.ElementToElementsTransformDictionary[index]; Matrix matrix2 = new Matrix(); matrix2.Translate(-center.X, -center.Y); matrix1 *= matrix2; Point point2 = matrix1.Transform(point1); Vector vector2 = new Point(point2.X * scale.X, point2.Y * scale.Y) - point2; Vector vector3 = new Vector((width - rect1.Width) * renderTransformOrigin.X, (height - rect1.Height) * renderTransformOrigin.Y); Vector vector4 = vector2 * startSharedTransform - vector3; Matrix matrix3 = this.StartTransformsDictionary[index]; Matrix m = new Matrix(); m.Scale(scale.X, scale.Y); Matrix matrix4 = ElementUtilities.GetInverseMatrix(m) * matrix3 * inverseMatrix; Vector vector5 = new Vector(matrix3.OffsetX, matrix3.OffsetY) * inverseMatrix; matrix4.ScaleAt(scale.X, scale.Y, vector5.X, vector5.Y); CanonicalDecomposition newTransform = new CanonicalDecomposition(matrix4 * startSharedTransform); newTransform.ScaleX *= vector1.X; newTransform.ScaleY *= vector1.Y; newTransform.Translation += vector4; AdornedToolBehavior.UpdateElementTransform(index, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale | AdornedToolBehavior.TransformPropertyFlags.Skew | AdornedToolBehavior.TransformPropertyFlags.RotatationAngle); Rect rect2 = this.initialRects[index]; rect2.Offset(newTransform.TranslationX - this.initialTransforms[index].TranslationX, newTransform.TranslationY - this.initialTransforms[index].TranslationY); rect2.Width = width; rect2.Height = height; BaseFrameworkElement child = (BaseFrameworkElement)index; LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)width, (object)rect1.Width) ? 16 : 0) | (!object.Equals((object)height, (object)rect1.Height) ? 32 : 0)); designerForChild.SetChildRect(child, rect2, this.initialOverrides[index], overridesToIgnore, LayoutOverrides.None); if (!object.Equals((object)width, (object)rect1.Width) || !object.Equals((object)height, (object)rect1.Height)) { PathElement.EnsureStretchIsFill((SceneNode)index); } PathElement.PathTransformHelper pathTransformHelper; if (this.pathTransformHelpers.TryGetValue(index, out pathTransformHelper)) { pathTransformHelper.Update(scale.X * vector1.X, scale.Y * vector1.Y); } } }
protected void AdjustLayoutAfterReparenting(ICollection <BaseFrameworkElement> reparentedElements) { ILayoutDesigner designerForParent = this.LayoutContainer.ViewModel.GetLayoutDesignerForParent((SceneElement)this.LayoutContainer, true); for (int index = 0; index < this.Context.DraggedElements.Count; ++index) { BaseFrameworkElement element = this.Context.DraggedElements[index]; if (element.IsAttached && element.IsViewObjectValid && reparentedElements.Contains(element)) { designerForParent.SetLayoutFromCache(element, this.Context.LayoutCacheRecords[index], this.Context.BoundsOfAllElements); } } }
public void UpdateLayout(ILayoutDesigner designer, IViewOptions viewOptions) { var projects = new List <ProjectLayout>(); var projectGroups = Map.Epics.Where(e => ApplyFilter(e, viewOptions)).GroupBy(e => e.Epic.Project).OrderBy(p => p.Key); int row = 1; foreach (var projectGroup in projectGroups) { var projectLayout = ProjectLayout.Create(projectGroup.Key, projectGroup, row + 1, designer); projects.Add(projectLayout); row = projectLayout.LastRowIndex; } Projects = projects; OnLayoutUpdate?.Invoke(); }
public static Rect GetRoundedUpChildRect(ILayoutDesigner designer, BaseFrameworkElement element) { IPlatformGeometryHelper geometryHelper = element.Platform.GeometryHelper; IViewVisual visual = element.ViewObject as IViewVisual; if (geometryHelper.NeedRoundupLayoutRect(visual)) { using (IDisposable disposable = LayoutRoundingHelper.TurnOffLayoutRounding(element)) { if (disposable != null) { Rect childRect = designer.GetChildRect(element); return(geometryHelper.RoundupLayoutRect(childRect)); } } } return(designer.GetChildRect(element)); }
public override sealed void Execute() { BaseFrameworkElement child1 = this.SceneViewModel.ElementSelectionSet.PrimarySelection as BaseFrameworkElement; BaseFrameworkElement frameworkElement = child1.ParentElement as BaseFrameworkElement; ILayoutDesigner designerForParent = frameworkElement.ViewModel.GetLayoutDesignerForParent((SceneElement)frameworkElement, true); Rect childRect1 = designerForParent.GetChildRect(child1); using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoDescription)) { foreach (BaseFrameworkElement child2 in this.SceneViewModel.ElementSelectionSet.Selection) { Rect childRect2 = designerForParent.GetChildRect(child2); Vector offset = this.GetOffset(childRect1, childRect2); childRect2.Offset(offset); designerForParent.SetChildRect(child2, childRect2, false, false); } editTransaction.Commit(); } }
private SceneNode Copy(SceneNode node, ref int index) { SceneElement sceneElement1 = node as SceneElement; DocumentNode node1 = sceneElement1.DocumentNode.Clone(sceneElement1.DocumentContext); SceneElement sceneElement2 = (SceneElement)null; bool flag = false; if (node1 != null) { sceneElement2 = this.ViewModel.GetSceneNode(node1) as SceneElement; if (sceneElement2 != null) { if (sceneElement1.ParentElement != this.TargetNode) { DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)sceneElement2.DocumentNode; documentCompositeNode.ClearValue(DesignTimeProperties.ClassProperty); documentCompositeNode.ClearValue(DesignTimeProperties.SubclassProperty); documentCompositeNode.ClearValue(DesignTimeProperties.ClassModifierProperty); flag = true; } SmartInsertionPoint.From(this.InsertionPoint, index).Insert((SceneNode)sceneElement2); if (flag) { BaseFrameworkElement element = sceneElement2 as BaseFrameworkElement; ILayoutDesigner layoutDesigner = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, true); if (layoutDesigner != null) { this.ViewModel.Document.OnUpdatedEditTransaction(); LayoutCacheRecord layoutCacheRecord; if (element.ViewObject != null && sceneElement1 is BaseFrameworkElement && this.layoutCache.TryGetValue((SceneNode)sceneElement1, out layoutCacheRecord)) { layoutDesigner.SetLayoutFromCache(element, layoutCacheRecord, this.boundsOfAllElements); } } } } } if (index != -1) { ++index; } return((SceneNode)sceneElement2); }
protected override void ApplyScale(Vector scale, Point center) { Vector scale1 = new Vector(Math.Abs(scale.X), Math.Abs(scale.Y)); Vector scale2 = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0); Vector vector1 = new Vector(this.StartCenter.X, this.StartCenter.Y); Size newSize = this.ComputeNewSize(scale1); Point topLeft = this.StartBounds.TopLeft; CanonicalTransform canonicalTransform = new CanonicalTransform(this.StartTransform); canonicalTransform.ApplyScale(scale, this.StartCenter, center); Point point1 = (topLeft - vector1) * canonicalTransform.TransformGroup.Value + vector1; Point renderTransformOrigin = this.BaseEditingElement.RenderTransformOrigin; renderTransformOrigin.X *= newSize.Width; renderTransformOrigin.Y *= newSize.Height; CanonicalTransform newTransform = new CanonicalTransform(this.StartTransform); newTransform.ApplyScale(scale2, renderTransformOrigin, center); Vector vector2 = (Vector)renderTransformOrigin; Point point2 = (topLeft - vector2) * newTransform.TransformGroup.Value + vector2; newTransform.Translation += point1 - point2; AdornedToolBehavior.UpdateElementTransform(this.EditingElement, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale); ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElement, true); Rect rect = this.initialRect; rect.Offset(newTransform.TranslationX - this.StartTransform.TranslationX, newTransform.TranslationY - this.StartTransform.TranslationY); rect.Width = newSize.Width; rect.Height = newSize.Height; LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)rect.Width, (object)this.StartSize.Width) ? 16 : 0) | (!object.Equals((object)rect.Height, (object)this.StartSize.Height) ? 32 : 0)); designerForChild.SetChildRect(this.BaseEditingElement, rect, this.initialOverrides, overridesToIgnore, LayoutOverrides.None); if (!object.Equals((object)rect.Width, (object)this.StartSize.Width) || !object.Equals((object)rect.Height, (object)this.StartSize.Height)) { PathElement.EnsureStretchIsFill((SceneNode)this.EditingElement); } if (this.transformHelper == null) { return; } this.transformHelper.Update(scale1.X, scale1.Y); }
protected override void Initialize() { base.Initialize(); ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElementSet.PrimaryElement, true); this.pathTransformHelpers.Clear(); foreach (SceneElement element in this.EditingElementSet.Elements) { this.startWidthSet[element] = element.IsSet(BaseFrameworkElement.WidthProperty) == PropertyState.Set; this.startHeightSet[element] = element.IsSet(BaseFrameworkElement.HeightProperty) == PropertyState.Set; this.initialOverrides[element] = designerForChild.ComputeOverrides((BaseFrameworkElement)element); this.initialRects[element] = designerForChild.GetChildRect((BaseFrameworkElement)element); this.initialTransforms[element] = new CanonicalDecomposition(this.StartTransformsDictionary[element]); PathElement.PathTransformHelper transformHelper = PathElement.TryCreateTransformHelper(element, this.StartBoundsDictionary[element].Size); if (transformHelper != null) { this.pathTransformHelpers[element] = transformHelper; } } }
public void CompleteLayout(SceneViewModel viewModel, Point startPoint) { ILayoutDesigner layoutDesigner = (ILayoutDesigner)null; Point point = startPoint; for (int index = 0; index < this.records.Count; ++index) { if (index > 0) { point.Y += CanvasLikeDataViewLayoutBuilder.defaultInnerMargin.Height; } CanvasLikeDataViewLayoutBuilder.LabelField labelField = this.records[index]; BaseFrameworkElement element1 = (BaseFrameworkElement)viewModel.GetSceneNode(labelField.Label); BaseFrameworkElement element2 = (BaseFrameworkElement)viewModel.GetSceneNode(labelField.Field); if (layoutDesigner == null) { layoutDesigner = viewModel.GetLayoutDesignerForChild((SceneElement)element2, true); } Rect rect1 = element1 != null?element1.GetComputedTightBounds() : Rect.Empty; Rect computedTightBounds = element2.GetComputedTightBounds(); Point location = point; double num = element1 != null?Math.Max(rect1.Height, computedTightBounds.Height) : computedTightBounds.Height; if (element1 != null) { location.Y += (num - rect1.Height) / 2.0; Rect rect2 = new Rect(location, rect1.Size); CanvasLikeDataViewLayoutBuilder.SetElementRect(layoutDesigner, element1, rect2); location.Y -= (num - rect1.Height) / 2.0; location.X = rect2.Right + CanvasLikeDataViewLayoutBuilder.defaultInnerMargin.Width; } location.Y += (num - computedTightBounds.Height) / 2.0; Rect rect3 = new Rect(location, computedTightBounds.Size); CanvasLikeDataViewLayoutBuilder.SetElementRect(layoutDesigner, element2, rect3); double right = rect3.Right; double y = point.Y; point.Y += num; } }
private static MoveStrategy CreateByParentType(MoveStrategyContext context, BaseFrameworkElement parentContainer) { MoveStrategyFactory.MoveStrategyTypeHandlerFactory orCreateCache = DesignSurfacePlatformCaches.GetOrCreateCache <MoveStrategyFactory.MoveStrategyTypeHandlerFactory>(parentContainer.Platform.Metadata, DesignSurfacePlatformCaches.MoveStrategyFactoryCache); ItemsControlElement itemsControlElement = parentContainer as ItemsControlElement; TextBlockElement textBlockElement = parentContainer as TextBlockElement; Type type = (Type)null; if (itemsControlElement != null && itemsControlElement.ItemsHost != null) { type = orCreateCache.GetHandlerType((ITypeResolver)itemsControlElement.ProjectContext, itemsControlElement.ItemsHost.GetIType((ITypeResolver)parentContainer.ProjectContext), true); } if (type == (Type)null) { type = orCreateCache.GetHandlerType((ITypeResolver)parentContainer.ProjectContext, parentContainer.Type, false); } if (type == typeof(GenericMoveStrategy)) { ILayoutDesigner designerForParent = parentContainer.ViewModel.GetLayoutDesignerForParent((SceneElement)parentContainer, true); if ((designerForParent.GetWidthConstraintMode(parentContainer, (BaseFrameworkElement)null) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike && (designerForParent.GetHeightConstraintMode(parentContainer, (BaseFrameworkElement)null) & LayoutConstraintMode.CanvasLike) == LayoutConstraintMode.NonOverlappingGridlike) { type = typeof(LayoutMoveStrategy); } } if (textBlockElement != null && !parentContainer.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsTextBlockInlineUIContainer)) { type = (Type)null; } if (!(type != (Type)null)) { return((MoveStrategy)null); } MoveStrategy moveStrategy = (MoveStrategy)Activator.CreateInstance(type, new object[1] { (object)context }); moveStrategy.LayoutContainer = parentContainer; return(moveStrategy); }
protected virtual void DoUpdateElementPosition(Point pointBegin, Point pointEnd) { IViewVisual viewVisual1 = this.ActiveSceneInsertionPoint.SceneElement.Visual as IViewVisual; IViewVisual viewVisual2 = this.LayoutTargetElement.Visual as IViewVisual; IViewVisual visual = viewVisual2 != null ? viewVisual2.VisualParent as IViewVisual : (IViewVisual)null; if (visual != null && viewVisual1 != visual && (viewVisual1 != null && this.ActiveSceneViewModel.ProjectContext.ResolveType(PlatformTypes.UIElement).RuntimeType.IsAssignableFrom(visual.TargetType))) { GeneralTransform generalTransform = viewVisual1.TransformToVisual(visual); pointBegin = generalTransform.Transform(pointBegin); pointEnd = generalTransform.Transform(pointEnd); } double width = Math.Abs(pointEnd.X - pointBegin.X); double height = Math.Abs(pointEnd.Y - pointBegin.Y); this.ReplaceSubTransaction(); ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild((SceneElement)this.LayoutTargetElement, true); Vector vector = new Vector(Math.Min(pointBegin.X, pointEnd.X), Math.Min(pointBegin.Y, pointEnd.Y)); Rect rect = new Rect(vector.X, vector.Y, width, height); designerForChild.SetChildRect(this.LayoutTargetElement, rect, LayoutOverrides.None, LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None, SetRectMode.CreateAtPosition); }
public override void Execute() { BaseFrameworkElement child = this.SceneViewModel.ElementSelectionSet.PrimarySelection as BaseFrameworkElement; if (child == null) { return; } Rect childRect = child.ViewModel.GetLayoutDesignerForParent(child.Parent as SceneElement, true).GetChildRect(child); using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(this.UndoDescription)) { foreach (BaseFrameworkElement target in (IEnumerable <BaseFrameworkElement>) this.Selection) { if (target != child) { ILayoutDesigner designerForParent = target.ViewModel.GetLayoutDesignerForParent(target.Parent as SceneElement, true); this.SetSize(childRect, target, designerForParent); } } editTransaction.Commit(); } }
private SceneNode Move(SceneNode node, ref int index) { SceneElement sceneElement = node as SceneElement; ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection; bool flag = destinationCollection.Contains((SceneNode)sceneElement); BaseFrameworkElement element = sceneElement as BaseFrameworkElement; ILayoutDesigner layoutDesigner1 = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, false); if (sceneElement.IsAttached) { if (flag) { if (destinationCollection.IndexOf((SceneNode)sceneElement) < index) { --index; } layoutDesigner1 = (ILayoutDesigner)null; } this.TargetNode.ViewModel.RemoveElement((SceneNode)sceneElement); this.ViewModel.Document.OnUpdatedEditTransaction(); } SmartInsertionPoint.From(this.InsertionPoint, index).Insert((SceneNode)sceneElement); this.ViewModel.Document.OnUpdatedEditTransaction(); ILayoutDesigner layoutDesigner2 = element == null ? (ILayoutDesigner)null : this.ViewModel.GetLayoutDesignerForChild((SceneElement)element, false); LayoutCacheRecord layoutCacheRecord; if (layoutDesigner1 != null && layoutDesigner2 != null && (element != null && this.layoutCache.TryGetValue((SceneNode)element, out layoutCacheRecord))) { layoutDesigner2.SetLayoutFromCache(element, layoutCacheRecord, this.boundsOfAllElements); } if (index != -1) { ++index; } return((SceneNode)sceneElement); }
public static PathElement ConvertToPath(BaseFrameworkElement element) { SceneViewModel viewModel = element.ViewModel; PathGeometry pathGeometry = PathConversionHelper.ConvertToPathGeometry((SceneElement)element); PathElement pathElement = (PathElement)viewModel.CreateSceneNode(PlatformTypes.Path); ILayoutDesigner designerForChild = viewModel.GetLayoutDesignerForChild((SceneElement)element, true); Rect childRect = designerForChild.GetChildRect(element); Transform transform1 = Transform.Identity; if (element.IsSet(Base2DElement.RenderTransformProperty) == PropertyState.Set) { transform1 = (Transform)element.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty); } Point point1 = new Point(0.5, 0.5); if (element.IsSet(Base2DElement.RenderTransformOriginProperty) == PropertyState.Set) { point1 = (Point)element.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty); } bool flag = false; using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UndoUnitConvertToPath, true)) { using (viewModel.ForceBaseValue()) { pathElement.PathGeometry = pathGeometry; pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)Stretch.Fill); Brush textForeground = PathCommandHelper.GetTextForeground(element); if (textForeground != null) { flag = true; pathElement.SetValueAsWpf(ShapeElement.FillProperty, (object)textForeground); } viewModel.AnimationEditor.DeleteAllAnimations((SceneNode)element); Dictionary <IPropertyId, SceneNode> properties = SceneElementHelper.StoreProperties((SceneNode)element); ISceneNodeCollection <SceneNode> collectionForChild = element.Parent.GetCollectionForChild((SceneNode)element); int index = collectionForChild.IndexOf((SceneNode)element); collectionForChild[index] = (SceneNode)pathElement; if (flag) { List <IPropertyId> list = new List <IPropertyId>(); foreach (KeyValuePair <IPropertyId, SceneNode> keyValuePair in properties) { IPropertyId key = keyValuePair.Key; DependencyPropertyReferenceStep propertyReferenceStep = key as DependencyPropertyReferenceStep; if (propertyReferenceStep != null && !propertyReferenceStep.IsAttachable && (propertyReferenceStep.MemberType != MemberType.DesignTimeProperty && !PlatformTypeHelper.GetDeclaringType((IMember)propertyReferenceStep).IsAssignableFrom(typeof(Path)))) { list.Add(key); } } foreach (IPropertyId key in list) { properties.Remove(key); } } SceneElementHelper.ApplyProperties((SceneNode)pathElement, properties); } if (ProjectNeutralTypes.PrimitiveShape.IsAssignableFrom((ITypeId)element.Type)) { using (viewModel.ForceBaseValue()) { Rect bounds = pathGeometry.Bounds; double halfStrokeWidth = PathCommandHelper.GetHalfStrokeWidth(pathElement); bounds.Inflate(halfStrokeWidth / 2.0, halfStrokeWidth / 2.0); if (transform1 != Transform.Identity && bounds.Size != childRect.Size) { Point point2 = (Point)pathElement.GetComputedValueAsWpf(Base2DElement.RenderTransformOriginProperty); Point point3 = new Point(point2.X * childRect.Width, point2.Y * childRect.Height); Point point4 = new Point((point3.X - bounds.X) / bounds.Width, (point3.Y - bounds.Y) / bounds.Height); pathElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point4); } bounds.Offset(childRect.Left, childRect.Top); editTransaction.Update(); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, bounds); } } if (flag && !pathGeometry.IsEmpty()) { using (viewModel.ForceBaseValue()) { Rect bounds = pathGeometry.Bounds; bounds.Offset(childRect.Left, childRect.Top); Point point2 = new Point(bounds.Left + point1.X * bounds.Width, bounds.Top + point1.Y * bounds.Height); Point point3 = new Point(childRect.Left + childRect.Width * point1.X, childRect.Top + childRect.Height * point1.Y); Point point4 = new TransformGroup() { Children = { (Transform) new TranslateTransform(-point3.X, -point3.Y), transform1, (Transform) new TranslateTransform(point3.X, point3.Y) } }.Transform(point2); Transform transform2 = (Transform) new CanonicalTransform(transform1) { TranslationX = 0.0, TranslationY = 0.0 }.TransformGroup; Rect rect = new Rect(point4.X - bounds.Width * point1.X, point4.Y - bounds.Height * point1.Y, bounds.Width, bounds.Height); pathElement.SetValueAsWpf(Base2DElement.RenderTransformOriginProperty, (object)point1); editTransaction.Update(); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, rect); pathElement.RenderTransform = transform2; } } editTransaction.Commit(); } return(pathElement); }
public static Transform ReplacePathGeometry(PathElement pathElement, PathGeometry pathGeometry, SceneEditTransaction editTransaction) { Transform transform1 = Transform.Identity; using (pathElement.ViewModel.ForceBaseValue()) { if (pathGeometry == null) { pathElement.ClearLocalValue(PathElement.DataProperty); } else { editTransaction.Update(); ILayoutDesigner designerForChild = pathElement.ViewModel.GetLayoutDesignerForChild((SceneElement)pathElement, true); Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)pathElement); Path path = pathElement.Path; Transform transform2 = path == null ? (Transform)null : path.RenderTransform; Point point1 = path == null ? new Point(0.0, 0.0) : path.RenderTransformOrigin; double num = path == null || path.Stroke == null ? 0.0 : path.StrokeThickness; Rect bounds = pathGeometry.Bounds; PathGeometry pathGeometry1 = new PathGeometry(); pathGeometry1.AddGeometry((System.Windows.Media.Geometry)pathGeometry); Rect rect1 = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry1.Bounds, pathElement, false); Vector vector1 = new Vector(-rect1.Left, -rect1.Top); transform1 = (Transform) new TranslateTransform(vector1.X, vector1.Y); PathGeometry pathGeometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry1, transform1); pathElement.PathGeometry = pathGeometry2; PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform); PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, propertyReference, transform1); if (!bounds.IsEmpty) { bounds.Inflate(num / 2.0, num / 2.0); Rect rect2 = new Rect(childRect.Left + bounds.Left, childRect.Top + bounds.Top, bounds.Width, bounds.Height); editTransaction.Update(); designerForChild.SetChildRect((BaseFrameworkElement)pathElement, rect2); if (pathElement.IsSet(Base2DElement.RenderTransformOriginProperty) != PropertyState.Set) { if (transform2 != null) { if (transform2.Value.IsIdentity) { goto label_15; } } else { goto label_15; } } Vector vector2 = childRect.TopLeft + new Vector(point1.X * childRect.Width, point1.Y * childRect.Height) - rect2.TopLeft; Point point2 = new Point(0.0, 0.0); if (rect2.Width != 0.0) { point2.X = vector2.X / rect2.Width; } if (rect2.Height != 0.0) { point2.Y = vector2.Y / rect2.Height; } pathElement.RenderTransformOrigin = point2; } } } label_15: return(transform1); }
public abstract void SetSize(Rect sourceRect, BaseFrameworkElement target, ILayoutDesigner targetLayoutDesigner);