protected override void InitDiagram() { base.InitDiagram(); // create all shapes NBasicShapeFactory basicShapes = new NBasicShapeFactory(); NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory(); // create the group NGroup group = new NGroup(); // make some background for the group NDrawRectangle drawRect = new NDrawRectangle(0, 0, 1, 1); drawRect.Relative = true; group.Geometry.Add(drawRect); group.Geometry.Fill = new NColorFill(NColor.LightCoral); group.SetBounds(new Nov.Graphics.NRectangle(50, 50, 230, 330)); // create a rectangle that is scaled and repositioned NShape rect1 = basicShapes.CreateShape(ENBasicShape.Rectangle); rect1.Text = "Scale and Reposition"; group.Shapes.Add(rect1); rect1.ResizeInGroup = ENResizeInGroup.ScaleAndReposition; rect1.SetBounds(new Nov.Graphics.NRectangle(10, 10, 100, 100)); // create a rectangle that is only repositioned NShape rect2 = basicShapes.CreateShape(ENBasicShape.Rectangle); rect2.Text = "Reposition Only"; group.Shapes.Add(rect2); rect2.ResizeInGroup = ENResizeInGroup.RepositionOnly; rect2.SetBounds(new Nov.Graphics.NRectangle(120, 120, 100, 100)); // create a 1D shape NShape arrow = connectorShapes.CreateShape(ENConnectorShape.Single45DegreesArrow); arrow.Text = "1D Shape"; group.Shapes.Add(arrow); arrow.SetBeginPoint(new NPoint(10, 250)); arrow.SetEndPoint(new NPoint(220, 290)); // add the group m_DrawingDocument.Content.ActivePage.Items.Add(group); }
protected NGroup CreateNetwork(NPoint location, string labelText) { bool rectValid = false; NRectangle rect = NRectangle.Zero; NPage activePage = m_DrawingDocument.Content.ActivePage; NList <NShape> shapes = activePage.GetShapes(false); for (int i = 0; i < shapes.Count; i++) { NRectangle bounds = shapes[i].GetAlignBoxInPage(); if (rectValid) { rect = NRectangle.Union(rect, bounds); } else { rect = bounds; rectValid = true; } } if (rectValid) { // determine how much is out of layout area } // create computer1 NShape computer1 = CreateComputer(); computer1.SetBounds(0, 0, computer1.Width, computer1.Height); // create computer2 NShape computer2 = CreateComputer(); computer2.SetBounds(150, 0, computer2.Width, computer2.Height); // create computer3 NShape computer3 = CreateComputer(); computer3.SetBounds(75, 120, computer3.Width, computer3.Height); // create the group that contains the comptures NGroup group = new NGroup(); NBatchGroup batchGroup = new NBatchGroup(m_DrawingDocument); batchGroup.Build(computer1, computer2, computer3); batchGroup.Group(m_DrawingDocument.Content.ActivePage, out group); // connect the computers in the network ConnectComputers(computer1, computer2, group); ConnectComputers(computer2, computer3, group); ConnectComputers(computer3, computer1, group); // insert a frame NDrawRectangle drawRect = new NDrawRectangle(0, 0, 1, 1); drawRect.Relative = true; group.Geometry.Add(drawRect); // change group fill style group.Geometry.Fill = new NStockGradientFill(ENGradientStyle.FromCenter, ENGradientVariant.Variant2, NColor.Gainsboro, NColor.White); // reposition and resize the group group.SetBounds(location.X, location.Y, group.Width, group.Height); // set label text group.TextBlock.Text = labelText; return(group); }