src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/Diagram/EntityDesignerDiagram.cs
/// <summary>
///     Performs an AutoLayoutDiagram command on the list of shapes passed in
/// </summary>
Performs an AutoLayoutDiagram command on the list of shapes passed in
Performs an AutoLayoutDiagram command on the list of shapes passed in
public void AutoLayoutDiagram(IList shapes)
        {
            using (new VsUtils.HourglassHelper())
            {
                var inheritanceLinks = new List<ShapeElement>();
                var inheritanceShapes = new List<ShapeElement>();
                var otherShapes = new List<ShapeElement>();
                foreach (ShapeElement shape in shapes)
                {
                    var isInheritanceClass = false;
                    var entityTypeShape = shape as EntityTypeShape;
                    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);
                    }
                }
                const VGNodeFixedStates ignoreShapeFlags =
                    VGNodeFixedStates.FixedPlace | 
                    VGNodeFixedStates.PermeablePlace; 
                const VGNodeFixedStates noMoveShapeFlags = VGNodeFixedStates.FixedPlace;
                using (var t = Store.TransactionManager.BeginTransaction(EntityDesignerResources.Tx_LayoutDiagram))
                {
                    t.Context.Add(EfiTransactionOriginator.TransactionOriginatorDiagramId, DiagramId);
                    using (new SaveLayoutFlags(inheritanceShapes, ignoreShapeFlags))
                    {
                        AutoLayoutShapeElements(
                            shapes,
                            VGRoutingStyle.VGRouteNetwork,
                            PlacementValueStyle.VGPlaceWE,
                            false);
                    }
                    using (new SaveLayoutFlags(otherShapes, noMoveShapeFlags))
                    {
                        AutoLayoutShapeElements(
                            shapes,
                            VGRoutingStyle.VGRouteOrgChartNS,
                            PlacementValueStyle.VGPlaceSN,
                            false);
                    }
                    using (new SaveLayoutFlags(shapes, noMoveShapeFlags))
                    {
                        AutoLayoutShapeElements(
                            inheritanceLinks,
                            VGRoutingStyle.VGRouteRightAngle,
                            PlacementValueStyle.VGPlaceUndirected,
                            false);
                    }
                    Reroute();
                    t.Commit();
                }
            } 
        }
public void AutoLayoutDiagram ( IList shapes ) { using ( new VsUtils . HourglassHelper ( ) ) { var inheritanceLinks = new List < ShapeElement > ( ) ; var inheritanceShapes = new List < ShapeElement > ( ) ; var otherShapes = new List < ShapeElement > ( ) ; foreach ( ShapeElement shape in shapes ) { var isInheritanceClass = false ; var entityTypeShape = shape as EntityTypeShape ; 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 ) ; } } const VGNodeFixedStates ignoreShapeFlags = VGNodeFixedStates . FixedPlace | VGNodeFixedStates . PermeablePlace ; const VGNodeFixedStates noMoveShapeFlags = VGNodeFixedStates . FixedPlace ; using ( var t = Store . TransactionManager . BeginTransaction ( EntityDesignerResources . Tx_LayoutDiagram ) ) { t . Context . Add ( EfiTransactionOriginator . TransactionOriginatorDiagramId , DiagramId ) ; using ( new SaveLayoutFlags ( inheritanceShapes , ignoreShapeFlags ) ) { AutoLayoutShapeElements ( shapes , VGRoutingStyle . VGRouteNetwork , PlacementValueStyle . VGPlaceWE , false ) ; } using ( new SaveLayoutFlags ( otherShapes , noMoveShapeFlags ) ) { AutoLayoutShapeElements ( shapes , VGRoutingStyle . VGRouteOrgChartNS , PlacementValueStyle . VGPlaceSN , false ) ; } using ( new SaveLayoutFlags ( shapes , noMoveShapeFlags ) ) { AutoLayoutShapeElements ( inheritanceLinks , VGRoutingStyle . VGRouteRightAngle , PlacementValueStyle . VGPlaceUndirected , false ) ; } Reroute ( ) ; t . Commit ( ) ; } } }
Performs an AutoLayoutDiagram command on the list of shapes passed in
Performs an AutoLayoutDiagram command on the list of shapes passed in
// Put up an hourglass because this may take a while // 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 // 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. // get a list of all lines leading to/from the 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 // don't consider for placement // 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 // Perform the auto layout // Since the inheritance shapes will be moved later, // tell this layout to ignore them and place other objects on // top if necessary // 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 // DD 40516: Make inheritance lines connect at single point and // don't move anything else // restore cursor
shapes
IList