private void PerformLayout(Hashtable args) { // create a layout NSpringLayout layout = new NSpringLayout(); // configure the optional forces layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; // configure the layout if (args != null) { layout.BounceBackForce.Enabled = Boolean.Parse(args["BounceBackForce"].ToString()); layout.GravityForce.Enabled = Boolean.Parse(args["GravityForce"].ToString()); layout.ElectricalForce.NominalDistance = Single.Parse(args["NominalDistance"].ToString()); layout.SpringForce.LogBase = NLayoutsHelper.ParseFloat(args["LogBase"]); layout.SpringForce.SpringForceLaw = (SpringForceLaw)Enum.Parse(typeof(SpringForceLaw), args["SpringForceLaw"].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(); }
void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument) { NThinDiagramControl diagramControl = (NThinDiagramControl)control; NDrawingDocument document = diagramControl.Document; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); Dictionary <string, string> settings = helper.ParseSettings(argument); // Create and configure the layout NSpringLayout layout = new NSpringLayout(); layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; layout.BounceBackForce.Enabled = Boolean.Parse(settings["BounceBackForce"]); layout.GravityForce.Enabled = Boolean.Parse(settings["GravityForce"]); layout.ElectricalForce.NominalDistance = Single.Parse(settings["NominalDistance"]); layout.SpringForce.LogBase = helper.ParseFloat(settings["LogBase"]); layout.SpringForce.SpringForceLaw = (SpringForceLaw)Enum.Parse(typeof(SpringForceLaw), settings["SpringForceLaw"]); // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); // Update the view diagramControl.UpdateView(); }
private void InitDocument(NDrawingDocument document) { // Remove the standard frame document.BackgroundStyle.FrameStyle.Visible = false; // Adjust the graphics quality document.GraphicsSettings.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // Set up visual formatting document.Style.FillStyle = new NColorFillStyle(Color.Linen); document.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); document.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); // Adjust the text properties document.Style.TextStyle.FontStyle = new NFontStyle("arial", 15f); // Create the initial diagram CreatePredefinedGraph(document); // Create the layout NSpringLayout layout = new NSpringLayout(); // Configure the optional forces layout.BounceBackForce.Padding = 100f; layout.GravityForce.AttractionCoefficient = 0.2f; // Get the shapes to layout NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D); // Layout the shapes layout.Layout(shapes, new NDrawingLayoutContext(document)); // Resize document to fit all shapes document.SizeToContent(); }