protected override void InitDiagram() { base.InitDiagram(); NGraphTemplate template; // create rectangular grid template template = new NRectangularGridTemplate(); template.Origin = new NPoint(10, 23); template.VerticesShape = ENBasicShape.Rectangle; template.EdgesUserClass = NDR.StyleSheetNameConnectors; template.Create(m_DrawingDocument); // create tree template template = new NGenericTreeTemplate(); template.Origin = new NPoint(250, 23); template.VerticesShape = ENBasicShape.Triangle; template.EdgesUserClass = NDR.StyleSheetNameConnectors; template.Create(m_DrawingDocument); // create elliptical grid template template = new NEllipticalGridTemplate(); template.Origin = new NPoint(10, 250); template.VerticesShape = ENBasicShape.Ellipse; template.EdgesUserClass = NDR.StyleSheetNameConnectors; template.Create(m_DrawingDocument); // hook selection events NPageSelection selection = m_DrawingDocument.Content.ActivePage.Selection; selection.Mode = Nov.UI.ENSelectionMode.Single; selection.Selected += OnSelectionSelected; selection.Deselected += OnSelectionDeselected; }
private void CreateTreeDiagram(int levels, int branchNodes) { // create a random tree NGenericTreeTemplate tree = new NGenericTreeTemplate(); tree.EdgesUserClass = "Connector"; tree.Balanced = false; tree.Levels = levels; tree.BranchNodes = branchNodes; tree.HorizontalSpacing = 10; tree.VerticalSpacing = 10; tree.VerticesShape = GetDefaultShapeType(); tree.VerticesSize = GetDefaultShapeSize(); tree.VertexSizeDeviation = 1; tree.Create(m_DrawingDocument); // randomly set the children placement of ten shapes to col NList <NShape> shapes = m_DrawingDocument.Content.ActivePage.GetShapes(false, NDiagramFilters.ShapeType2D); Random random = new Random(); for (int i = 0; i < shapes.Count / 2; i++) { int index = random.Next(shapes.Count); NShape shape = shapes[index]; shape.Geometry.Fill = new NColorFill(NColor.Orange); shape.LayoutData.TipOverChildrenPlacement = ENTipOverChildrenPlacement.ColRight; } }
protected override void InitDiagram() { base.InitDiagram(); // create a tree NGenericTreeTemplate tree = new NGenericTreeTemplate(); tree.ConnectorType = ENConnectorShape.RoutableConnector; tree.VerticesShape = ENBasicShape.Circle; tree.Levels = 6; tree.BranchNodes = 2; tree.HorizontalSpacing = 10; tree.VerticalSpacing = 10; tree.VerticesSize = new NSize(40, 40); tree.Create(m_DrawingDocument); // arrange diagram ArrangeDiagram(); // fit active page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
protected virtual void OnRandomTree2ButtonClick(NEventArgs arg) { m_DrawingDocument.StartHistoryTransaction("Create Random Tree 2"); try { m_DrawingDocument.Content.ActivePage.Items.Clear(); // create a random tree NGenericTreeTemplate tree = new NGenericTreeTemplate(); tree.EdgesUserClass = "Connector"; tree.Levels = 8; tree.BranchNodes = 2; tree.HorizontalSpacing = 10; tree.VerticalSpacing = 10; tree.VerticesShape = GetDefaultShapeType(); tree.VerticesSize = GetDefaultShapeSize(); if (m_Layout is NBalloonTreeLayout) { tree.Balanced = true; tree.VertexSizeDeviation = 0; } else { tree.Balanced = false; tree.VertexSizeDeviation = 1; } tree.Create(m_DrawingDocument); // layout the tree ArrangeDiagram(); } finally { m_DrawingDocument.CommitHistoryTransaction(); } }
protected override void InitDiagram() { base.InitDiagram(); // create random diagram NGenericTreeTemplate template = new NGenericTreeTemplate(); template.EdgesUserClass = "Connector"; template.Balanced = false; template.Levels = 6; template.BranchNodes = 3; template.HorizontalSpacing = 10; template.VerticalSpacing = 10; template.VerticesSize = new NSize(50, 50); template.VertexSizeDeviation = 1; template.Create(m_DrawingDocument); // arrange diagram ArrangeDiagram(); // fit active page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }