private void InitDocument() { NDrawingDocument document = NDrawingView1.Document; // remove the standard frame document.BackgroundStyle.FrameStyle.Visible = false; // set up visual formatting document.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); // create a stylesheet for the edges 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); // generate a simple tree NGenericTreeTemplate tree = new NGenericTreeTemplate(); tree.VerticesSize = new NSizeF(80, 80); tree.EdgesStyleSheetName = "edges"; tree.Create(document); // create a show/hide decorator for all shapes that have children NNodeList shapes = document.ActiveLayer.Descendants(NFilters.Shape2D, -1); int i, count = shapes.Count; for (i = 0; i < count; i++) { NShape shape = (NShape)shapes[i]; if (shape.GetOutgoingShapes().Count == 0) { continue; } shape.CreateShapeElements(ShapeElementsMask.Decorators); NShowHideSubtreeDecorator decorator = new NShowHideSubtreeDecorator(); decorator.Name = "ShowHideSubtree"; shape.Decorators.AddChild(new NShowHideSubtreeDecorator()); } // size the document to the content document.SizeToContent(); }