public void ApplyLayout(NDrawingDocument document, Dictionary <string, string> settings) { // Create the layout NBarycenterLayout layout = new NBarycenterLayout(); // Configure the optional forces layout.BounceBackForce.RepulsionCoefficient = 20f; layout.GravityForce.AttractionCoefficient = 0.2f; // Free vertices are placed in the fixed vertices barycenter layout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter; // Fixed vertices are placed on the rim of the specified ellipse layout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim; layout.FixedVertexPlacement.PredefinedEllipseBounds = new NRectangleF(0, 0, 700, 700); // Configure the layout if (settings != null) { layout.BounceBackForce.Enabled = Boolean.Parse(settings["BounceBackForce"]); layout.GravityForce.Enabled = Boolean.Parse(settings["GravityForce"]); layout.MinFixedVerticesCount = Int32.Parse(settings["MinFixedVerticesCount"]); } // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); }
private void PerformLayout(Hashtable args) { // create a layout NBarycenterLayout layout = new NBarycenterLayout(); // configure the optional forces layout.BounceBackForce.RepulsionCoefficient = 20f; layout.GravityForce.AttractionCoefficient = 0.2f; // free vertices are placed in the fixed vertices barycenter layout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter; // fixed vertices are placed on the rim of the specified ellipse layout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim; layout.FixedVertexPlacement.PredefinedEllipseBounds = new NRectangleF(0, 0, 700, 700); // configure the layout if (args != null) { layout.BounceBackForce.Enabled = Boolean.Parse(args["BounceBackForce"].ToString()); layout.GravityForce.Enabled = Boolean.Parse(args["GravityForce"].ToString()); layout.MinFixedVerticesCount = Int32.Parse(args["MinFixedVerticesCount"].ToString()); } // get the shapes to layout NNodeList shapes = NDrawingView1.Document.ActiveLayer.Children(NFilters.Shape2D); // layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(NDrawingView1.Document)); // resize document to fit all shapes NDrawingView1.Document.SizeToContent(); }