Exemplo n.º 1
0
        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();
        }