protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 381, 600); NTextBlock textBlock1 = new NTextBlock(); shape1.TextBlock = textBlock1; textBlock1.Content.Blocks.Clear(); AddFormattedTextToContent(textBlock1.Content); drawing.ActivePage.Items.Add(shape1); NShape shape2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape2.SetBounds(401, 10, 381, 600); NTextBlock textBlock2 = new NTextBlock(); shape2.TextBlock = textBlock2; textBlock2.Content.Blocks.Clear(); AddFormattedTextWithImagesToContent(textBlock2.Content); drawing.ActivePage.Items.Add(shape2); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; // plotter commands NBasicShapeFactory basicShapes = new NBasicShapeFactory(); // create a rounded rect NShape rectShape = basicShapes.CreateShape(ENBasicShape.Rectangle); rectShape.SetBounds(50, 50, 100, 100); rectShape.Text = "Move me close to the star"; rectShape.GetPortByName("Top").GlueMode = ENPortGlueMode.Outward; activePage.Items.Add(rectShape); // create a star NShape pentagramShape = basicShapes.CreateShape(ENBasicShape.Pentagram); pentagramShape.SetBounds(310, 310, 100, 100); activePage.Items.Add(pentagramShape); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; // hide the grid drawing.ScreenVisibility.ShowGrid = false; // create two shapes and a line connector between them NBasicShapeFactory basicShapes = new NBasicShapeFactory(); NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory(); m_BeginShape = basicShapes.CreateShape(ENBasicShape.Ellipse); m_BeginShape.Size = new NSize(150, 100); drawing.ActivePage.Items.Add(m_BeginShape); m_EndShape = basicShapes.CreateShape(ENBasicShape.Pentagram); m_EndShape.Size = new NSize(100, 100); drawing.ActivePage.Items.Add(m_EndShape); m_Connector = connectorShapes.CreateShape(ENConnectorShape.Line); m_Connector.GlueBeginToNearestPort(m_BeginShape); m_Connector.GlueEndToNearestPort(m_EndShape); drawing.ActivePage.Items.Add(m_Connector); // perform inital layout of shapes OnTimerTick(); }
protected override void InitDiagram() { base.InitDiagram(); // Create a group NGroup group = new NGroup(); m_DrawingDocument.Content.ActivePage.Items.Add(group); group.PinX = 300; group.PinY = 300; // Create some shapes and add them to the group NBasicShapeFactory factory = new NBasicShapeFactory(); NShape root = factory.CreateShape(ENBasicShape.Rectangle); root.Text = "Root"; group.Shapes.Add(root); NShape shape1 = factory.CreateShape(ENBasicShape.Circle); shape1.Text = "Circle 1"; group.Shapes.Add(shape1); NShape shape2 = factory.CreateShape(ENBasicShape.Circle); shape2.Text = "Circle 2"; group.Shapes.Add(shape2); NShape shape3 = factory.CreateShape(ENBasicShape.Circle); shape3.Text = "Circle 3"; group.Shapes.Add(shape3); // Connect the shapes ConnectShapes(root, shape1); ConnectShapes(root, shape2); ConnectShapes(root, shape3); // Update group bounds group.UpdateBounds(); // Create a layout context and configure the area you want the group to be arranged in. // The layout area is in page coordinates NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(m_DrawingDocument, group); layoutContext.LayoutArea = new NRectangle(100, 100, 200, 200); // Layout the shapes in the group NRadialGraphLayout layout = new NRadialGraphLayout(); layout.Arrange(group.Shapes.ToArray(), layoutContext); // Update the group bounds group.UpdateBounds(); }
protected override void InitDiagram() { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // 1. Create some shape factories NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NConnectorShapeFactory connectorShapesFactory = new NConnectorShapeFactory(); // 2. Create and add some shapes NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(new NRectangle(50, 50, 100, 100)); activePage.Items.Add(shape1); NShape shape2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape2.SetBounds(new NRectangle(400, 50, 100, 100)); activePage.Items.Add(shape2); // 3. Connect the shapes NShape connector = connectorShapesFactory.CreateShape(ENConnectorShape.Line); activePage.Items.Add(connector); connector.GlueBeginToShape(shape1); connector.GlueEndToShape(shape2); // Add 2 outward ports to the connector NPort port1 = new NPort(0.3, 0.3, true); port1.GlueMode = ENPortGlueMode.Outward; connector.Ports.Add(port1); NPort port2 = new NPort(0.7, 0.7, true); port2.GlueMode = ENPortGlueMode.Outward; connector.Ports.Add(port2); // Attach label shapes to the outward ports of the connector NShape labelShape1 = CreateLabelShape("Label 1"); activePage.Items.Add(labelShape1); labelShape1.GlueMasterPortToPort(labelShape1.Ports[0], port1); NShape labelShape2 = CreateLabelShape("Label 2"); activePage.Items.Add(labelShape2); labelShape2.GlueMasterPortToPort(labelShape2.Ports[0], port2); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 600, 1000); NTextBlock textBlock = new NTextBlock(); shape1.TextBlock = textBlock; textBlock.Padding = new NMargins(20); textBlock.Content.Blocks.Clear(); textBlock.Content.HorizontalAlignment = ENAlign.Left; AddFormattedTextToContent(textBlock.Content); drawing.ActivePage.Items.Add(shape1); }
protected override void InitDiagram() { base.InitDiagram(); const double width = 40; const double height = 40; const double distance = 80; NBasicShapeFactory basicShapes = new NBasicShapeFactory(); NPage activePage = m_DrawingDocument.Content.ActivePage; int[] from = new int[] { 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6 }; int[] to = new int[] { 2, 3, 4, 4, 5, 8, 6, 7, 5, 8, 10, 8, 9, 10 }; NShape[] shapes = new NShape[10]; int vertexCount = shapes.Length; int edgeCount = from.Length; int count = vertexCount + edgeCount; for (int i = 0; i < count; i++) { if (i < vertexCount) { int j = vertexCount % 2 == 0 ? i : i + 1; shapes[i] = basicShapes.CreateShape(ENBasicShape.Rectangle); if (vertexCount % 2 != 0 && i == 0) { shapes[i].SetBounds(new NRectangle( (width + (distance * 1.5)) / 2, distance + (j / 2) * (distance * 1.5), width, height)); } else { shapes[i].SetBounds(new NRectangle( width / 2 + (j % 2) * (distance * 1.5), height + (j / 2) * (distance * 1.5), width, height)); } activePage.Items.Add(shapes[i]); } else { NRoutableConnector edge = new NRoutableConnector(); edge.UserClass = "Connector"; activePage.Items.Add(edge); edge.GlueBeginToShape(shapes[from[i - vertexCount] - 1]); edge.GlueEndToShape(shapes[to[i - vertexCount] - 1]); } } // arrange diagram ArrangeDiagram(); // fit active page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); double padding = 10; double sizeX = 160; double sizeY = 160; for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(padding + x * (padding + sizeX), padding + y * (padding + sizeY), sizeX, sizeY); shape1.TextBlock = new NTextBlock(); shape1.TextBlock.Padding = new NMargins(20); shape1.TextBlock.Text = "The quick brown fox jumps over the lazy dog"; drawing.ActivePage.Items.Add(shape1); } } }
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); }
/// <summary> /// Creates an ellipse shapeand applies the specified class to ut (used for Start and End shapes) /// </summary> /// <param name="bounds"></param> /// <param name="userClass"></param> /// <returns></returns> NShape CreateEllipse(NRectangle bounds, string userClass) { NBasicShapeFactory factory = new NBasicShapeFactory(); NShape shape = factory.CreateShape(ENBasicShape.Ellipse); shape.SetBounds(bounds); shape.UserClass = userClass; m_DrawingDocument.Content.ActivePage.Items.Add(shape); return(shape); }
protected override void InitDiagram() { base.InitDiagram(); NBasicShapeFactory factory = new NBasicShapeFactory(); NShape shape = factory.CreateShape(ENBasicShape.Rectangle); shape.SetBounds(100, 100, 150, 100); NPage activePage = m_DrawingDocument.Content.ActivePage; activePage.Items.Add(shape); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; // plotter commands NBasicShapeFactory basicShapes = new NBasicShapeFactory(); NConnectorShapeFactory connectorFactory = new NConnectorShapeFactory(); // create a rounded rect NShape rectShape = basicShapes.CreateShape(ENBasicShape.Rectangle); rectShape.DefaultShapeGlue = ENDefaultShapeGlue.GlueToGeometryIntersection; rectShape.Geometry.CornerRounding = 10; rectShape.SetBounds(50, 50, 100, 100); activePage.Items.Add(rectShape); // create a rounded pentagram NShape pentagramShape = basicShapes.CreateShape(ENBasicShape.Pentagram); pentagramShape.DefaultShapeGlue = ENDefaultShapeGlue.GlueToGeometryIntersection; pentagramShape.Geometry.CornerRounding = 20; pentagramShape.SetBounds(310, 310, 100, 100); activePage.Items.Add(pentagramShape); // create a rounded routable connector NShape connector = connectorFactory.CreateShape(ENConnectorShape.RoutableConnector); connector.Geometry.CornerRounding = 30; connector.GlueBeginToShape(rectShape); connector.GlueEndToShape(pentagramShape); activePage.Items.Add(connector); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 200, 200); shape1.TextBlock = new NTextBlock(); shape1.TextBlock.Padding = new NMargins(20); shape1.TextBlock.Text = "This text cantains many typpos. This text contuins manyy typos."; drawing.ActivePage.Items.Add(shape1); }
protected override void InitDiagram() { base.InitDiagram(); // create some shapes NPage activePage = m_DrawingDocument.Content.ActivePage; NBasicShapeFactory basicShapes = new NBasicShapeFactory(); for (int i = 0; i < 20; i++) { NShape shape = basicShapes.CreateShape(ENBasicShape.Rectangle); activePage.Items.Add(shape); } // arrange diagram ArrangeDiagram(); // fit page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NShape shape1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); shape1.SetBounds(10, 10, 600, 1000); NImageBlock imageBlock = shape1.ImageBlock; imageBlock.Image = NResources.Image_FishBowl_wmf; imageBlock.Padding = new NMargins(20); drawing.ActivePage.Items.Add(shape1); }
protected override void InitDiagram() { base.InitDiagram(); NPage activePage = m_DrawingDocument.Content.ActivePage; // we will be using basic shapes with default size of 120, 60 NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); basicShapesFactory.DefaultSize = new NSize(120, 60); // create the president NShape president = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); president.Text = "President"; activePage.Items.Add(president); // create the VPs. // NOTE: The child nodes of the VPs are layed out in cols NShape vpMarketing = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); vpMarketing.Text = "VP Marketing"; vpMarketing.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); activePage.Items.Add(vpMarketing); NShape vpSales = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); vpSales.Text = "VP Sales"; vpSales.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); activePage.Items.Add(vpSales); NShape vpProduction = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); vpProduction.Text = "VP Production"; vpProduction.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); activePage.Items.Add(vpProduction); // connect president with VP NRoutableConnector connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(president); connector.GlueEndToShape(vpMarketing); connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(president); connector.GlueEndToShape(vpSales); connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(president); connector.GlueEndToShape(vpProduction); // crete the marketing managers NShape marketingManager1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); marketingManager1.Text = "Manager1"; activePage.Items.Add(marketingManager1); NShape marketingManager2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); marketingManager2.Text = "Manager2"; activePage.Items.Add(marketingManager2); // connect the marketing manager with the marketing VP connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpMarketing); connector.GlueEndToShape(marketingManager1); connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpMarketing); connector.GlueEndToShape(marketingManager2); // crete the sales managers NShape salesManager1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); salesManager1.Text = "Manager1"; activePage.Items.Add(salesManager1); NShape salesManager2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); salesManager2.Text = "Manager2"; activePage.Items.Add(salesManager2); // connect the sales manager with the sales VP connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpSales); connector.GlueEndToShape(salesManager1); connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpSales); connector.GlueEndToShape(salesManager2); // crete the production managers NShape productionManager1 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); productionManager1.Text = "Manager1"; activePage.Items.Add(productionManager1); NShape productionManager2 = basicShapesFactory.CreateShape(ENBasicShape.Rectangle); productionManager2.Text = "Manager2"; activePage.Items.Add(productionManager2); // connect the production manager with the production VP connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpProduction); connector.GlueEndToShape(productionManager1); connector = new NRoutableConnector(); activePage.Items.Add(connector); connector.GlueBeginToShape(vpProduction); connector.GlueEndToShape(productionManager2); // arrange diagram ArrangeDiagram(); // fit active page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
protected override void InitDiagram() { base.InitDiagram(); NPage activePage = m_DrawingDocument.Content.ActivePage; // we will be using basic shapes for this example NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); basicShapesFactory.DefaultSize = new NSize(80, 80); NList <NPerson> persons = new NList <NPerson>(); // create persons NPerson personEmil = new NPerson("Emil Moore", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personAndre = new NPerson("Andre Smith", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personRobert = new NPerson("Robert Johnson", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personBob = new NPerson("Bob Williams", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personPeter = new NPerson("Peter Brown", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personSilvia = new NPerson("Silvia Moore", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personEmily = new NPerson("Emily Smith", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personMonica = new NPerson("Monica Johnson", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personSamantha = new NPerson("Samantha Miller", basicShapesFactory.CreateShape(ENBasicShape.Circle)); NPerson personIsabella = new NPerson("Isabella Davis", basicShapesFactory.CreateShape(ENBasicShape.Circle)); persons.Add(personEmil); persons.Add(personAndre); persons.Add(personRobert); persons.Add(personBob); persons.Add(personPeter); persons.Add(personSilvia); persons.Add(personEmily); persons.Add(personMonica); persons.Add(personSamantha); persons.Add(personIsabella); // create family relashionships personEmil.m_Family = personSilvia; personAndre.m_Family = personEmily; personRobert.m_Family = personMonica; // create friend relationships personEmily.m_Friends.Add(personBob); personEmily.m_Friends.Add(personMonica); personAndre.m_Friends.Add(personPeter); personAndre.m_Friends.Add(personIsabella); personSilvia.m_Friends.Add(personBob); personSilvia.m_Friends.Add(personSamantha); personSilvia.m_Friends.Add(personIsabella); personEmily.m_Friends.Add(personIsabella); personEmily.m_Friends.Add(personPeter); personPeter.m_Friends.Add(personRobert); // create the person vertices for (int i = 0; i < persons.Count; i++) { activePage.Items.Add(persons[i].m_Shape); } // creeate the family relations for (int i = 0; i < persons.Count; i++) { NPerson currentPerson = persons[i]; if (currentPerson.m_Family != null) { NRoutableConnector connector = new NRoutableConnector(); connector.MakeLine(); activePage.Items.Add(connector); connector.GlueBeginToShape(currentPerson.m_Shape); connector.GlueEndToShape(currentPerson.m_Family.m_Shape); connector.Geometry.Stroke = new NStroke(2, NColor.Coral); connector.LayoutData.SpringStiffness = 2; connector.LayoutData.SpringLength = 100; } } for (int i = 0; i < persons.Count; i++) { NPerson currentPerson = persons[i]; for (int j = 0; j < currentPerson.m_Friends.Count; j++) { NRoutableConnector connector = new NRoutableConnector(); connector.MakeLine(); activePage.Items.Add(connector); connector.GlueBeginToShape(currentPerson.m_Shape); connector.GlueEndToShape(currentPerson.m_Friends[j].m_Shape); connector.Geometry.Stroke = new NStroke(2, NColor.Green); connector.LayoutData.SpringStiffness = 1; connector.LayoutData.SpringLength = 200; } } // arrange diagram ArrangeDiagram(); // fit active page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
/// <summary> /// Creates a random barycenter diagram with the specified settings /// </summary> /// <param name="fixedCount">number of fixed vertices (must be larger than 3)</param> /// <param name="freeCount">number of free vertices</param> private void CreateRandomBarycenterDiagram(int fixedCount, int freeCount) { if (fixedCount < 3) { throw new ArgumentException("Needs at least three fixed vertices"); } // clean up the active page NPage activePage = m_DrawingDocument.Content.ActivePage; activePage.Items.Clear(); // we will be using basic circle shapes with default size of (30, 30) NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); basicShapesFactory.DefaultSize = new NSize(30, 30); NConnectorShapeFactory connectorsShapesFactory = new NConnectorShapeFactory(); // create the fixed vertices NShape[] fixedShapes = new NShape[fixedCount]; for (int i = 0; i < fixedCount; i++) { fixedShapes[i] = basicShapesFactory.CreateShape(ENBasicShape.Circle); //((NDynamicPort)fixedShapes[i].Ports.GetChildByName("Center", -1)).GlueMode = DynamicPortGlueMode.GlueToLocation; fixedShapes[i].Geometry.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant3, new NColor(251, 203, 156), new NColor(247, 150, 56)); fixedShapes[i].Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); // setting the ForceXMoveable and ForceYMoveable properties to false // specifies that the layout cannot move the shape in both X and Y directions NForceDirectedGraphLayout.SetXMoveable(fixedShapes[i], false); NForceDirectedGraphLayout.SetYMoveable(fixedShapes[i], false); activePage.Items.AddChild(fixedShapes[i]); } // create the free vertices NShape[] freeShapes = new NShape[freeCount]; for (int i = 0; i < freeCount; i++) { freeShapes[i] = basicShapesFactory.CreateShape(ENBasicShape.Circle); freeShapes[i].Geometry.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant3, new NColor(192, 194, 194), new NColor(129, 133, 133)); freeShapes[i].Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); activePage.Items.AddChild(freeShapes[i]); } // link the fixed shapes in a circle for (int i = 0; i < fixedCount; i++) { NRoutableConnector connector = new NRoutableConnector(); connector.MakeLine(); activePage.Items.AddChild(connector); if (i == 0) { connector.GlueBeginToShape(fixedShapes[fixedCount - 1]); connector.GlueEndToShape(fixedShapes[0]); } else { connector.GlueBeginToShape(fixedShapes[i - 1]); connector.GlueEndToShape(fixedShapes[i]); } } // link each free shape with two different random fixed shapes Random rnd = new Random(); for (int i = 0; i < freeCount; i++) { int firstFixed = rnd.Next(fixedCount); int secondFixed = (firstFixed + rnd.Next(fixedCount / 3) + 1) % fixedCount; // link with first fixed NRoutableConnector lineShape = new NRoutableConnector(); lineShape.MakeLine(); activePage.Items.AddChild(lineShape); lineShape.GlueBeginToShape(freeShapes[i]); lineShape.GlueEndToShape(fixedShapes[firstFixed]); // link with second fixed lineShape = new NRoutableConnector(); lineShape.MakeLine(); activePage.Items.AddChild(lineShape); lineShape.GlueBeginToShape(freeShapes[i]); lineShape.GlueEndToShape(fixedShapes[secondFixed]); } // link each free shape with another free shape for (int i = 1; i < freeCount; i++) { NRoutableConnector connector = new NRoutableConnector(); connector.MakeLine(); activePage.Items.AddChild(connector); connector.GlueBeginToShape(freeShapes[i - 1]); connector.GlueEndToShape(freeShapes[i]); } // send all edges to back NBatchReorder batchReorder = new NBatchReorder(m_DrawingDocument); batchReorder.Build(activePage.GetShapes(false, NDiagramFilters.ShapeType1D).CastAll <NDiagramItem>()); batchReorder.SendToBack(activePage); // arrange the elements ArrangeDiagram(); }
/// <summary> /// Creates a triangular grid diagram with the specified count of levels /// </summary> /// <param name="levels"></param> private void CreateTriangularGridDiagram(int levels) { // clean up the active page NPage activePage = m_DrawingDocument.Content.ActivePage; activePage.Items.Clear(); // we will be using basic circle shapes with default size of (30, 30) NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); basicShapesFactory.DefaultSize = new NSize(30, 30); NConnectorShapeFactory connectorShapesFactory = new NConnectorShapeFactory(); NShape cur = null, prev = null; NRoutableConnector edge = null; NList <NShape> curRowShapes = null; NList <NShape> prevRowShapes = null; for (int level = 1; level < levels; level++) { curRowShapes = new NList <NShape>(); for (int i = 0; i < level; i++) { cur = basicShapesFactory.CreateShape(ENBasicShape.Circle); cur.Geometry.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant3, new NColor(192, 194, 194), new NColor(129, 133, 133)); cur.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); activePage.Items.Add(cur); // connect with prev if (i > 0) { edge = new NRoutableConnector(); edge.MakeLine(); activePage.Items.Add(edge); edge.GlueBeginToShape(prev); edge.GlueEndToShape(cur); } // connect with ancestors if (level > 1) { if (i < prevRowShapes.Count) { edge = new NRoutableConnector(); edge.MakeLine(); activePage.Items.Add(edge); edge.GlueBeginToShape(prevRowShapes[i]); edge.GlueEndToShape(cur); } if (i > 0) { edge = new NRoutableConnector(); edge.MakeLine(); activePage.Items.Add(edge); edge.GlueBeginToShape(prevRowShapes[i - 1]); edge.GlueEndToShape(cur); } } // fix the three corner vertices if (level == 1 || (level == levels - 1 && (i == 0 || i == level - 1))) { NForceDirectedGraphLayout.SetXMoveable(cur, false); NForceDirectedGraphLayout.SetYMoveable(cur, false); cur.Geometry.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant3, new NColor(251, 203, 156), new NColor(247, 150, 56)); cur.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); } curRowShapes.Add(cur); prev = cur; } prevRowShapes = curRowShapes; } // send all edges to back NBatchReorder batchReorder = new NBatchReorder(m_DrawingDocument); batchReorder.Build(activePage.GetShapes(false, NDiagramFilters.ShapeType1D).CastAll <NDiagramItem>()); batchReorder.SendToBack(activePage); // arrange the elements ArrangeDiagram(); }
protected override void InitDiagram() { base.InitDiagram(); NPage activePage = m_DrawingDocument.Content.ActivePage; NBasicShapeFactory basicShapes = new NBasicShapeFactory(); int min = 100; int max = 200; NShape shape; Random random = new Random(); for (int i = 0; i < 5; i++) { shape = basicShapes.CreateShape(ENBasicShape.Rectangle); NColor[] shapeLightColors = new NColor[] { new NColor(236, 97, 49), new NColor(247, 150, 56), new NColor(68, 90, 108), new NColor(129, 133, 133), new NColor(255, 165, 109) }; NColor[] shapeDarkColors = new NColor[] { new NColor(246, 176, 152), new NColor(251, 203, 156), new NColor(162, 173, 182), new NColor(192, 194, 194), new NColor(255, 210, 182) }; shape.Geometry.Fill = new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant3, shapeLightColors[i], shapeDarkColors[i]); shape.Geometry.Stroke = new NStroke(1, new NColor(68, 90, 108)); // generate random width and height float width = random.Next(min, max); float height = random.Next(min, max); // instruct the layouts to use fixed, uses specified desired width and desired height // shape.LayoutData.UseShapeWidth = false; // shape.LayoutData.DesiredWidth = width; // shape.LayoutData.UseShapeHeight = false; // shape.LayoutData.DesiredHeight = height; switch (i) { case 0: shape.LayoutData.DockArea = ENDockArea.Top; shape.Text = "Top (" + i.ToString() + ")"; break; case 1: shape.LayoutData.DockArea = ENDockArea.Bottom; shape.Text = "Bottom (" + i.ToString() + ")"; break; case 2: shape.LayoutData.DockArea = ENDockArea.Left; shape.Text = "Left (" + i.ToString() + ")"; break; case 3: shape.LayoutData.DockArea = ENDockArea.Right; shape.Text = "Right (" + i.ToString() + ")"; break; case 4: shape.LayoutData.DockArea = ENDockArea.Center; shape.Text = "Center (" + i.ToString() + ")"; break; } //shape.Style.FillStyle = new NColorFillStyle(GetPredefinedColor(i)); shape.SetBounds(new NRectangle(0, 0, width, height)); activePage.Items.Add(shape); } // arrange diagram ArrangeDiagram(); // fit page m_DrawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit; }
/// <summary> /// Creates the book store interface /// </summary> /// <param name="activePage"></param> void CreateBookStore(NPage activePage) { const double x1 = 50; const double x2 = x1 + 200; const double x3 = x2 + 50; const double x4 = x3 + 400; const double y1 = 50; const double y2 = y1 + 50; const double y3 = y2 + 50; const double y4 = y3 + 20; const double y5 = y4 + 200; const double y6 = y5 + 20; const double y7 = y6 + 50; // prev button NShape prevButtonShape = CreateButtonShape("Show Prev Book"); SetLeftTop(prevButtonShape, new NPoint(x1, y1)); ((NButton)prevButtonShape.Widget).Click += delegate(NEventArgs args) { LoadBook(m_nSelectedBook - 1); }; activePage.Items.Add(prevButtonShape); // next button NShape nextButtonShape = CreateButtonShape("Show Next Book"); SetRightTop(nextButtonShape, new NPoint(x2, y1)); ((NButton)nextButtonShape.Widget).Click += delegate(NEventArgs args) { LoadBook(m_nSelectedBook + 1); }; activePage.Items.Add(nextButtonShape); // add to cart NShape addToCartButton = CreateButtonShape("Add to Cart"); SetRightTop(addToCartButton, new NPoint(x2, y6)); ((NButton)addToCartButton.Widget).Click += delegate(NEventArgs args) { m_ShoppingCart.AddItem(m_Books[m_nSelectedBook], this); }; activePage.Items.Add(addToCartButton); // create selected book shapes NBasicShapeFactory basicShapes = new NBasicShapeFactory(); // selected image m_SelectedBookImage = basicShapes.CreateShape(ENBasicShape.Rectangle); SetLeftTop(m_SelectedBookImage, new NPoint(x1, y2)); NSize minBookSize = GetMinBookImageSize(); m_SelectedBookImage.Width = x2 - x1; m_SelectedBookImage.Height = y5 - y2; activePage.Items.Add(m_SelectedBookImage); // selected title m_SelectedBookTitle = basicShapes.CreateShape(ENBasicShape.Text); m_SelectedBookTitle.TextBlock.InitXForm(ENTextBlockXForm.ShapeBox); m_SelectedBookTitle.TextBlock.FontSize = 25; m_SelectedBookTitle.TextBlock.Fill = new NColorFill(NColor.DarkBlue); SetLeftTop(m_SelectedBookTitle, new NPoint(x3, y2)); m_SelectedBookTitle.Width = x4 - x3; m_SelectedBookTitle.Height = y3 - y2; activePage.Items.Add(m_SelectedBookTitle); // selected description m_SelectedBookDescription = basicShapes.CreateShape(ENBasicShape.Text); m_SelectedBookDescription.TextBlock.InitXForm(ENTextBlockXForm.ShapeBox); SetLeftTop(m_SelectedBookDescription, new NPoint(x3, y4)); m_SelectedBookDescription.Width = x4 - x3; m_SelectedBookDescription.Height = y5 - y4; activePage.Items.Add(m_SelectedBookDescription); // load the first book LoadBook(0); // create the shape that hosts the shopping cart widget NShape shoppingCartShape = new NShape(); shoppingCartShape.Init2DShape(); m_ShoppingCartWidget = new NContentHolder(); m_ShoppingCartWidget.Content = m_ShoppingCart.CreateWidget(this); shoppingCartShape.Widget = m_ShoppingCartWidget; SetLeftTop(shoppingCartShape, new NPoint(x1, y7)); BindSizeToDesiredSize(shoppingCartShape); activePage.Items.Add(shoppingCartShape); }
private void CreateDiagram(NPage page) { NBasicShapeFactory basisShapes = new NBasicShapeFactory(); NFlowchartingShapeFactory flowChartingShapes = new NFlowchartingShapeFactory(); NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory(); NShape titleShape = basisShapes.CreateShape(ENBasicShape.Rectangle); titleShape.Geometry.Fill = new NColorFill(NColor.LightGray); titleShape.Text = page.Title; titleShape.SetBounds(10, 10, page.Width - 20, 50); page.Items.Add(titleShape); NShape nonPrintableShape = basisShapes.CreateShape(ENBasicShape.Rectangle); nonPrintableShape.Text = "Non printable shape"; nonPrintableShape.AllowPrint = false; nonPrintableShape.Geometry.Fill = new NColorFill(NColor.Tomato); nonPrintableShape.SetBounds(50, 150, 150, 50); page.Items.Add(nonPrintableShape); NShape isLifeGood = flowChartingShapes.CreateShape(ENFlowchartingShape.Decision); isLifeGood.Text = "Is Life Good?"; isLifeGood.SetBounds(300, 150, 150, 100); isLifeGood.Geometry.Fill = new NColorFill(NColor.LightSkyBlue); page.Items.Add(isLifeGood); NShape goodShape = flowChartingShapes.CreateShape(ENFlowchartingShape.Termination); goodShape.Text = "Good"; goodShape.SetBounds(200, 300, 100, 100); goodShape.Geometry.Fill = new NColorFill(NColor.Gold); page.Items.Add(goodShape); NShape changeSomething = flowChartingShapes.CreateShape(ENFlowchartingShape.Process); changeSomething.Text = "Change Something"; changeSomething.Geometry.Fill = new NColorFill(NColor.Thistle); changeSomething.SetBounds(450, 300, 100, 100); page.Items.Add(changeSomething); NShape yesConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); yesConnector.Text = "Yes"; yesConnector.GlueBeginToPort(isLifeGood.GetPortByName("Left")); yesConnector.GlueEndToPort(goodShape.GetPortByName("Top")); page.Items.Add(yesConnector); NShape noConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); noConnector.Text = "No"; noConnector.GlueBeginToPort(isLifeGood.GetPortByName("Right")); noConnector.GlueEndToPort(changeSomething.GetPortByName("Top")); page.Items.Add(noConnector); NShape gobackConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); gobackConnector.GlueBeginToPort(changeSomething.GetPortByName("Right")); gobackConnector.GlueEndToPort(isLifeGood.GetPortByName("Top")); page.Items.Add(gobackConnector); }
protected virtual NShape CreateShape() { NBasicShapeFactory factory = new NBasicShapeFactory(); return(factory.CreateShape(ENBasicShape.Rectangle)); }
protected override void InitDiagram() { base.InitDiagram(); m_DrawingDocument.HistoryService.Pause(); try { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // Hide grid and ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // create all shapes NBasicShapeFactory factory = new NBasicShapeFactory(); factory.DefaultSize = new NSize(120, 90); int row = 0, col = 0; double cellWidth = 240; double cellHeight = 150; for (int i = 0; i < factory.ShapeCount; i++, col++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.Text = factory.GetShapeInfo(i).Name; MoveTextBelowShape(shape); if (i == (int)ENBasicShape.ThreeDBox) { shape.TextBlock.Padding = new NMargins(0, 15, 0, 0); } else if (i == (int)ENBasicShape.Concentric) { shape.TextBlock.Angle = NAngle.Zero; } activePage.Items.Add(shape); if (col >= 4) { row++; col = 0; } NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight); if (shape.ShapeType == ENShapeType.Shape1D) { NPoint endPoint = beginPoint + new NPoint(cellWidth - 50, cellHeight - 50); if (i == (int)ENBasicShape.CenterDragCircle) { beginPoint.Translate(cellWidth / 3, cellHeight / 3); endPoint.Translate(-cellWidth / 3, -cellHeight / 3); } shape.SetBeginPoint(beginPoint); shape.SetEndPoint(endPoint); } else { shape.SetBounds(beginPoint.X, beginPoint.Y, shape.Width, shape.Height); } } // size page to content activePage.Layout.ContentPadding = new NMargins(50); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; NBasicShapeFactory basisShapes = new NBasicShapeFactory(); NFlowchartingShapeFactory flowChartingShapes = new NFlowchartingShapeFactory(); NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory(); NShape nonPrintableShape = basisShapes.CreateShape(ENBasicShape.Rectangle); nonPrintableShape.Text = "Non printable shape"; nonPrintableShape.AllowPrint = false; nonPrintableShape.Geometry.Fill = new NColorFill(NColor.Tomato); nonPrintableShape.SetBounds(50, 50, 150, 50); activePage.Items.Add(nonPrintableShape); NShape isLifeGood = flowChartingShapes.CreateShape(ENFlowchartingShape.Decision); isLifeGood.Text = "Is Life Good?"; isLifeGood.SetBounds(300, 50, 150, 100); isLifeGood.Geometry.Fill = new NColorFill(NColor.LightSkyBlue); activePage.Items.Add(isLifeGood); NShape goodShape = flowChartingShapes.CreateShape(ENFlowchartingShape.Termination); goodShape.Text = "Good"; goodShape.SetBounds(200, 200, 100, 100); goodShape.Geometry.Fill = new NColorFill(NColor.Gold); activePage.Items.Add(goodShape); NShape changeSomething = flowChartingShapes.CreateShape(ENFlowchartingShape.Process); changeSomething.Text = "Change Something"; changeSomething.Geometry.Fill = new NColorFill(NColor.Thistle); changeSomething.SetBounds(450, 200, 100, 100); activePage.Items.Add(changeSomething); NShape yesConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); yesConnector.Text = "Yes"; yesConnector.GlueBeginToPort(isLifeGood.GetPortByName("Left")); yesConnector.GlueEndToPort(goodShape.GetPortByName("Top")); activePage.Items.Add(yesConnector); NShape noConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); noConnector.Text = "No"; noConnector.GlueBeginToPort(isLifeGood.GetPortByName("Right")); noConnector.GlueEndToPort(changeSomething.GetPortByName("Top")); activePage.Items.Add(noConnector); NShape gobackConnector = connectorShapes.CreateShape(ENConnectorShape.RoutableConnector); gobackConnector.GlueBeginToPort(changeSomething.GetPortByName("Right")); gobackConnector.GlueEndToPort(isLifeGood.GetPortByName("Top")); activePage.Items.Add(gobackConnector); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // Hide the grid and the ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // Create a shape factory NBasicShapeFactory basicShapeFactory = new NBasicShapeFactory(); basicShapeFactory.DefaultSize = new NSize(100, 100); // Create the Name shape NShape nameShape = basicShapeFactory.CreateShape(ENBasicShape.Rectangle); nameShape.Width = 150; nameShape.PinX = activePage.Width / 2; nameShape.PinY = 100; NParagraph paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.FirstName))); paragraph.Inlines.Add(new NTextInline(" ")); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.LastName))); nameShape.GetTextBlock().Content.Blocks.Clear(); nameShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(nameShape); // Create the City shape NShape cityShape = basicShapeFactory.CreateShape(ENBasicShape.SixPointStar); cityShape.PinX = nameShape.PinX - 150; cityShape.PinY = nameShape.PinY + 200; paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergePredefinedFieldValue(ENMailMergeDataField.City))); cityShape.GetTextBlock().Content.Blocks.Clear(); cityShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(cityShape); // Create the Birth Date shape NShape birthDateShape = basicShapeFactory.CreateShape(ENBasicShape.Circle); birthDateShape.PinX = nameShape.PinX + 150; birthDateShape.PinY = cityShape.PinY; paragraph = new NParagraph(); paragraph.Inlines.Add(new NFieldInline(new NMailMergeSourceFieldValue("BirthDate"))); birthDateShape.GetTextBlock().Content.Blocks.Clear(); birthDateShape.GetTextBlock().Content.Blocks.Add(paragraph); activePage.Items.Add(birthDateShape); // Connect the shapes NRoutableConnector connector = new NRoutableConnector(); connector.Text = "City"; connector.TextBlock.BackgroundFill = new NColorFill(NColor.White); connector.GlueBeginToNearestPort(nameShape); connector.GlueEndToNearestPort(cityShape); activePage.Items.Add(connector); connector = new NRoutableConnector(); connector.Text = "Birth Date"; connector.TextBlock.BackgroundFill = new NColorFill(NColor.White); connector.GlueBeginToNearestPort(nameShape); connector.GlueEndToNearestPort(birthDateShape); activePage.Items.Add(connector); // Load a mail merge data source from resource Stream stream = NResources.Instance.GetResourceStream("RSTR_Employees_csv"); NMailMergeDataSource dataSource = NDataSourceFormat.Csv.LoadFromStream(stream, new NDataSourceLoadSettings(null, null, true)); // Set some field mappings NMailMergeFieldMap fieldMap = new NMailMergeFieldMap(); fieldMap.Set(ENMailMergeDataField.CourtesyTitle, "TitleOfCourtesy"); fieldMap.Set(ENMailMergeDataField.FirstName, "FirstName"); fieldMap.Set(ENMailMergeDataField.LastName, "LastName"); fieldMap.Set(ENMailMergeDataField.City, "City"); // Configure the drawing's mail merge drawing.MailMerge.DataSource = dataSource; }