// Sets all the flags on the elements stored to this value public void SetFlags(VGNodeFixedStates flags) { for (var i = 0; i < _elements.Count; i++) { var node = _elements[i] as NodeShape; if (node != null) { node.LayoutObjectFixedFlags = flags; } } }
public void SetFlags(VGNodeFixedStates flags) { for (int i = 0; i < this.Elements.Count; i++) { NodeShape shape = this.Elements[i] as NodeShape; if (shape != null) { shape.LayoutObjectFixedFlags = flags; } } }
public SaveLayoutFlags(IList elements, VGNodeFixedStates flags) : this(elements) { this.SetFlags(flags); }
/// <summary> /// Performs an AutoLayoutDiagram command on the list of shapes passed in /// </summary> public void AutoLayoutDiagram(IList shapes) { // Put up an hourglass because this may take a while using (new VsUtils.HourglassHelper()) { // Inheritance lines need to be placed using a different styling // so that the lines join at the same point. Sort out which shapes we have var inheritanceLinks = new List <ShapeElement>(); var inheritanceShapes = new List <ShapeElement>(); var otherShapes = new List <ShapeElement>(); foreach (ShapeElement shape in shapes) { // Fix a bug when the user tries to layout a diagram that contains inheritance classes multiple times, the shapes are moved to the bottom of the screen. // The fix is to include both base class and derived class in the inheritance shapes list; before the fix we only includes the derived class in the list. var isInheritanceClass = false; var entityTypeShape = shape as ConfigurationElementShape; // get a list of all lines leading to/from the shape if (entityTypeShape != null) { var allLinks = new ArrayList(entityTypeShape.FromRoleLinkShapes); allLinks.AddRange(entityTypeShape.ToRoleLinkShapes); foreach (LinkShape link in allLinks) { if (link is InheritanceConnector) { isInheritanceClass = true; break; } } } if (isInheritanceClass) { inheritanceShapes.Add(shape); } else if (shape is InheritanceConnector) { inheritanceLinks.Add(shape); } else { otherShapes.Add(shape); } } // These flags are based on AutoLayout code from the ClassDesigner // Flags we set so the graph object ignores a shape (treats that shape as invisible) when doing layout const VGNodeFixedStates ignoreShapeFlags = VGNodeFixedStates.FixedPlace | // don't consider for placement VGNodeFixedStates.PermeablePlace; // place on top if desired (ignore for placement purposes) // Flags we set so the graph object recognizes but doesn't move a shape when doing layout const VGNodeFixedStates noMoveShapeFlags = VGNodeFixedStates.FixedPlace; // Perform the auto layout using (var t = Store.TransactionManager.BeginTransaction("LayoutDiagram")) { //t.Context.Add(EfiTransactionOriginator.TransactionOriginatorDiagramId, DiagramId); using (new SaveLayoutFlags(inheritanceShapes, ignoreShapeFlags)) { // Since the inheritance shapes will be moved later, // tell this layout to ignore them and place other objects on // top if necessary AutoLayoutShapeElements( shapes, VGRoutingStyle.VGRouteNetwork, PlacementValueStyle.VGPlaceWE, false); } using (new SaveLayoutFlags(otherShapes, noMoveShapeFlags)) { // DD 40487: Move any classes that have inheritance, while keeping // the others in place. Use org chart and PlaceSN so that parent // classes appear above child ones AutoLayoutShapeElements( shapes, VGRoutingStyle.VGRouteOrgChartNS, PlacementValueStyle.VGPlaceSN, false); } using (new SaveLayoutFlags(shapes, noMoveShapeFlags)) { // DD 40516: Make inheritance lines connect at single point and // don't move anything else AutoLayoutShapeElements( inheritanceLinks, VGRoutingStyle.VGRouteRightAngle, PlacementValueStyle.VGPlaceUndirected, false); } Reroute(); t.Commit(); } } // restore cursor }