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 NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(251, 203, 156), Color.FromArgb(247, 150, 56)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); NStyleSheet sheet = new NStyleSheet("edges"); sheet.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); sheet.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); document.StyleSheets.AddChild(sheet); // Create the initial diagram DiagramRenderer renderer = new DiagramRenderer(); renderer.CreateRandomDiagram(document, 15, 15); // Layout the diagram renderer.ApplyLayout(document, null); // Resize document to fit all shapes 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); DiagramRenderer renderer = new DiagramRenderer(); switch (settings["command"]) { case "randomGrid1Button": renderer.CreateRandomDiagram(document, 10, 10); break; case "randomGrid2Button": renderer.CreateRandomDiagram(document, 15, 15); break; case "triangularGrid1Button": renderer.CreateTriangularGridDiagram(document, 6); break; case "triangularGrid2Button": renderer.CreateTriangularGridDiagram(document, 8); break; } // Layout the diagram renderer.ApplyLayout(document, settings); // Resize document to fit all shapes document.SizeToContent(); // Update the view diagramControl.UpdateView(); }