protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // switch selected edit mode to geometry // this instructs the diagram to show geometry handles for the selected shapes. m_DrawingDocument.Content.ActivePage.SelectionEditMode = ENSelectionEditMode.Geometry; drawing.ScreenVisibility.ShowGrid = false; // plotter commands CreateDescriptionPair(0, 0, CreateLineTo(), "Line To"); CreateDescriptionPair(0, 1, CreateArcTo(), "Arc To"); CreateDescriptionPair(0, 2, CreateCubicBezierTo(), "Cubic Bezier To"); CreateDescriptionPair(0, 3, CreateCircularArcTo(), "Circular Arc To"); CreateDescriptionPair(0, 4, CreateEllipticalArcTo(), "Elliptical Arc To"); // draw box commands CreateDescriptionPair(1, 0, CreateDrawRectangle(), "Draw Rectangle"); CreateDescriptionPair(1, 1, CreateDrawEllipse(), "Draw Ellipse"); CreateDescriptionPair(1, 2, CreateDrawPolygon(0), "Draw Polygon"); CreateDescriptionPair(1, 3, CreateDrawPolyline(0), "Draw Polyline"); CreateDescriptionPair(1, 4, CreateDrawPolygon(1), "Draw Polygon With Tension"); CreateDescriptionPair(1, 5, CreateDrawPolyline(1), "Draw Polyline With Tension"); CreateDescriptionPair(1, 6, CreateDrawPath(), "Draw Path"); }
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; 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(); 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(); 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; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; string[] tableDescription = new string[] { "Table in Auto Size Mode", "Table in Auto Height Mode", "Table in Fit To Shape Mode" }; ENTableBlockResizeMode[] tableBlockResizeMode = new ENTableBlockResizeMode[] { ENTableBlockResizeMode.AutoSize, ENTableBlockResizeMode.AutoHeight, ENTableBlockResizeMode.FitToShape }; double y = 100; for (int i = 0; i < 3; i++) { NShape shape = new NShape(); shape.SetBounds(new NRectangle(100, y, 300, 300)); y += 200; // create table NTableBlock tableBlock = CreateTableBlock(tableDescription[i]); tableBlock.Content.AllowSpacingBetweenCells = false; tableBlock.ResizeMode = tableBlockResizeMode[i]; shape.TextBlock = tableBlock; drawing.ActivePage.Items.AddChild(shape); } }
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(); 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 NArrowShapeFactory factory = new NArrowShapeFactory(); factory.DefaultSize = new NSize(60, 60); int row = 0, col = 0; double cellWidth = 180; double cellHeight = 120; 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); activePage.Items.Add(shape); if (col >= 5) { row++; col = 0; } NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight); if (shape.ShapeType == ENShapeType.Shape1D) { NPoint endPoint = beginPoint + new NPoint(cellWidth - 100, cellHeight - 100); 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(40); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }
protected override void InitDiagram() { const double XStep = 150; const double YStep = 100; 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 NCalloutShapeFactory factory = new NCalloutShapeFactory(); factory.DefaultSize = new NSize(70, 70); double x = 0; double y = 0; for (int i = 0; i < factory.ShapeCount; i++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.Tooltip = new NTooltip(factory.GetShapeInfo(i).Name); activePage.Items.Add(shape); if (shape.ShapeType == ENShapeType.Shape1D) { shape.SetBeginPoint(new NPoint(x, y)); shape.SetEndPoint(new NPoint(x + shape.Width, y + shape.Height)); } else { shape.SetBounds(x, y, shape.Width, shape.Height); } x += XStep; if (x > activePage.Width) { x = 0; y += YStep; } } // size page to content activePage.Layout.ContentPadding = new NMargins(70, 60, 70, 60); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }
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 NBrainstormingShapeFactory factory = new NBrainstormingShapeFactory(); factory.DefaultSize = new NSize(60, 60); for (int i = 0; i < factory.ShapeCount; i++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.Text = factory.GetShapeInfo(i).Name; MoveTextBelowShape(shape); activePage.Items.Add(shape); } // Arrange them NList <NShape> shapes = activePage.GetShapes(false); NLayoutContext layoutContext = new NLayoutContext(); layoutContext.BodyAdapter = new NShapeBodyAdapter(m_DrawingDocument); layoutContext.GraphAdapter = new NShapeGraphAdapter(); layoutContext.LayoutArea = activePage.GetContentEdge(); NTableFlowLayout tableLayout = new NTableFlowLayout(); tableLayout.HorizontalSpacing = 30; tableLayout.VerticalSpacing = 50; tableLayout.Direction = ENHVDirection.LeftToRight; tableLayout.MaxOrdinal = 5; tableLayout.Arrange(shapes.CastAll <object>(), layoutContext); // size page to content activePage.Layout.ContentPadding = new NMargins(40); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }
protected override void InitDiagram() { base.InitDiagram(); // hide ports and grid NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; drawing.ScreenVisibility.ShowPorts = false; drawing.ScreenVisibility.ShowGrid = false; }
protected override void InitDiagram() { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; activePage.Items.Add(CreateSampleLine1()); activePage.Items.Add(CreateSampleLine2()); activePage.Items.Add(CreateSamplePolyline1()); activePage.Items.Add(CreateSamplePolyline2()); activePage.Items.Add(CreateSampleLineDoubleBridge()); }
protected override NWidget CreateExampleControls() { NStackPanel stack = (NStackPanel)base.CreateExampleControls(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; NEditor editor = NDesigner.GetDesigner(activePage.LineJumps).CreateStateEditor(activePage.LineJumps); stack.Add(editor); return(stack); }
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; // create a AND shape NShape andShape = CreateAndShape(); andShape.SetBounds(300, 100, 150, 100); activePage.Items.Add(andShape); }
protected override void InitDiagram() { base.InitDiagram(); m_DrawingDocument.HistoryService.Pause(); try { NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; drawing.ScreenVisibility.ShowGrid = false; // create all shapes NConnectorShapeFactory factory = new NConnectorShapeFactory(); factory.DefaultSize = new NSize(120, 90); int row = 0, col = 0; double cellWidth = 300; double cellHeight = 200; for (int i = 0; i < factory.ShapeCount; i++, col++) { NShape shape = factory.CreateShape(i); shape.Text = factory.GetShapeInfo(i).Name; activePage.Items.Add(shape); if (col >= 4) { row++; col = 0; } NPoint beginPoint = new NPoint(50 + col * cellWidth, 50 + row * cellHeight); NPoint endPoint = beginPoint + new NPoint(cellWidth - 50, cellHeight - 50); shape.SetBeginPoint(beginPoint); shape.SetEndPoint(endPoint); } // 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; activePage.Layout.ContentPadding = new NMargins(20); // switch selected edit mode to geometry // this instructs the diagram to show geometry handles for the selected shapes. drawing.ScreenVisibility.ShowGrid = false; NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory(); ENArrowheadShape[] arrowheadShapes = NEnum.GetValues <ENArrowheadShape>(); double x = 20; double y = 0; for (int i = 1; i < arrowheadShapes.Length; i++) { ENArrowheadShape arrowheadShape = arrowheadShapes[i]; NShape shape = connectorShapes.CreateShape(ENConnectorShape.Line); drawing.ActivePage.Items.Add(shape); // create geometry arrowheads shape.Geometry.BeginArrowhead = new NArrowhead(arrowheadShape); shape.Geometry.EndArrowhead = new NArrowhead(arrowheadShape); shape.Text = NEnum.GetLocalizedString(arrowheadShape); shape.SetBeginPoint(new NPoint(x, y)); shape.SetEndPoint(new NPoint(x + 350, y)); y += 30; if (i == arrowheadShapes.Length / 2) { // Begin a second column of shapes x += 400; y = 0; } } activePage.SizeToContent(); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; CreateDiagram(drawing.ActivePage); NPage page = new NPage("Page-2"); drawing.Pages.Add(page); CreateDiagram(page); }
protected override void InitDiagram() { base.InitDiagram(); // create the books list CreateBooksList(); // create the shopping cart m_ShoppingCart = new NShoppingCart(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; // create a shape which hosts a widget CreateBookStore(activePage); }
protected override void InitDiagram() { base.InitDiagram(); // Configure the document NDrawing drawing = m_DrawingDocument.Content; drawing.ScreenVisibility.ShowGrid = false; // Add styles AddStyles(m_DrawingDocument); // Configure the active page NPage page = drawing.ActivePage; page.Bounds = new NRectangle(0, 0, 10000, 10000); page.ZoomMode = ENZoomMode.Fit; page.BackgroundFill = new NColorFill(NColor.LightBlue); // Create a map importer NEsriMapImporter mapImporter = new NEsriMapImporter(); mapImporter.MapBounds = NMapBounds.World; // Add an ESRI shapefile NEsriShapefile countries = new NEsriShapefile(Nevron.Nov.Diagram.NResources.RBIN_countries_zip); countries.NameColumn = "name_long"; countries.TextColumn = "name_long"; countries.MinTextZoomPercent = 50; countries.FillRule = new NMapFillRuleValue("mapcolor8", Colors); mapImporter.AddShapefile(countries); // Read the map data mapImporter.Read(); // Import the map to the drawing document mapImporter.Import(m_DrawingDocument, page.Bounds); // Size page to content page.SizeToContent(); }
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(); // Configure the document NDrawing drawing = m_DrawingDocument.Content; drawing.ScreenVisibility.ShowGrid = false; // Add styles AddStyles(m_DrawingDocument); // Configure the active page NPage page = drawing.ActivePage; page.ZoomMode = ENZoomMode.Fit; page.BackgroundFill = new NColorFill(NColor.LightBlue); // Create a map importer m_MapImporter = new NEsriMapImporter(); m_MapImporter.MapBounds = NMapBounds.World; // Add a shapefile NEsriShapefile countries = new NEsriShapefile(Nevron.Nov.Diagram.NResources.RBIN_countries_zip); countries.NameColumn = "name_long"; countries.TextColumn = "name_long"; countries.MinTextZoomPercent = 50; countries.FillRule = new NMapFillRuleRange("pop_est", NColor.White, new NColor(0, 80, 0), 12); m_MapImporter.AddShapefile(countries); // Set the shape created listener m_MapImporter.ShapeCreatedListener = new NCustomShapeCreatedListener(); // Read the map data m_MapImporter.Read(); // Import the map to the drawing document ImportMap(); }
protected override void InitDiagram() { base.InitDiagram(); // Configure the document NDrawing drawing = m_DrawingDocument.Content; drawing.ScreenVisibility.ShowGrid = false; // Add styles AddStyles(m_DrawingDocument); // Configure the active page NPage page = drawing.ActivePage; page.BackgroundFill = new NColorFill(NColor.LightBlue); page.Bounds = new NRectangle(0, 0, 10000, 10000); page.ZoomMode = ENZoomMode.Fit; // Create a map importer m_MapImporter = new NEsriMapImporter(); m_MapImporter.MapBounds = NMapBounds.World; m_MapImporter.MeridianSettings.RenderMode = ENArcRenderMode.BelowObjects; m_MapImporter.ParallelSettings.RenderMode = ENArcRenderMode.BelowObjects; m_MapImporter.Projection = m_Projections[DefaultProjectionIndex]; // Add an ESRI shapefile NEsriShapefile countries = new NEsriShapefile(Nevron.Nov.Diagram.NResources.RBIN_countries_zip); countries.NameColumn = "name_long"; countries.FillRule = new NMapFillRuleValue("mapcolor8", Colors); m_MapImporter.AddShapefile(countries); // Read the map data m_MapImporter.Read(); ImportMap(); }
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(); 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; 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(); 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 NAnnotationShapeFactory factory = new NAnnotationShapeFactory(); factory.DefaultSize = new NSize(60, 60); int row = 0, col = 0; double cellWidth = 0; // 180; double cellHeight = 150; bool is1D = false; for (int i = 0; i < factory.ShapeCount; i++, col++) { NShape shape = factory.CreateShape(i); NShape tempShape; shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; if (i == (int)ENAnnotationShape.Text || i == (int)ENAnnotationShape.FiveRuledColumn || i == (int)ENAnnotationShape.InfoLine || i == (int)ENAnnotationShape.NorthArrow5 || i == (int)ENAnnotationShape.NoteSymbol || i == (int)ENAnnotationShape.ReferenceTriangle || i == (int)ENAnnotationShape.ReferenceRectangle || i == (int)ENAnnotationShape.ReferenceHexagon || i == (int)ENAnnotationShape.ReferenceCircle || i == (int)ENAnnotationShape.ReferenceOval) { NGroup group = new NGroup(); group.Width = shape.Width; group.Height = shape.Height; if (i == (int)ENAnnotationShape.Text) { shape.PinX = 0; shape.SetFx(NShape.PinYProperty, "Height"); } else { shape.SetFx(NShape.PinXProperty, "Width / 2"); shape.SetFx(NShape.PinYProperty, "Height / 2"); } group.TextBlock = new NTextBlock(factory.GetShapeInfo(i).Name); shape.SetFx(NShape.WidthProperty, "$ParentSheet.Width"); shape.SetFx(NShape.HeightProperty, "$ParentSheet.Height"); MoveTextBelowShape(group); group.Shapes.Add(shape); activePage.Items.Add(group); tempShape = group; } else { if (i != (int)ENAnnotationShape.Benchmark) { shape.Text = factory.GetShapeInfo(i).Name; MoveTextBelowShape(shape); if (i == (int)ENAnnotationShape.ReferenceCallout1) { shape.TextBlock.PinX = 40; shape.TextBlock.PinY = 10; } if (i == (int)ENAnnotationShape.ReferenceCallout2) { shape.TextBlock.Angle = new NAngle(0); shape.TextBlock.PinY = 100; } } activePage.Items.Add(shape); tempShape = shape; } if (col >= 5) { row++; col = 0; cellWidth = 0; is1D = false; } int widthGap = is1D ? 150 : 100; is1D = shape.ShapeType == ENShapeType.Shape1D; NPoint beginPoint = new NPoint(widthGap + cellWidth, 50 + row * cellHeight); if (is1D) { NPoint endPoint = beginPoint + new NPoint(0, cellHeight - 60); if (i == (int)ENAnnotationShape.ReferenceCallout1 || i == (int)ENAnnotationShape.ReferenceCallout2) { tempShape.SetBeginPoint(beginPoint); tempShape.SetEndPoint(endPoint); } else { tempShape.SetBeginPoint(endPoint); tempShape.SetEndPoint(beginPoint); } } else { tempShape.SetBounds(beginPoint.X, beginPoint.Y, shape.Width, shape.Height); } cellWidth += widthGap + tempShape.Width; } // size page to content activePage.Layout.ContentPadding = new NMargins(40); activePage.SizeToContent(); } finally { m_DrawingDocument.HistoryService.Resume(); } }
protected override void InitDiagram() { base.InitDiagram(); const double XStep = 150; const double YStep = 200; 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 NDimensioningEngineeringShapeFactory factory = new NDimensioningEngineeringShapeFactory(); factory.DefaultSize = new NSize(90, 90); double x = 0; double y = 0; for (int i = 0; i < factory.ShapeCount; i++) { NShape shape = factory.CreateShape(i); shape.HorizontalPlacement = ENHorizontalPlacement.Center; shape.VerticalPlacement = ENVerticalPlacement.Center; shape.Tooltip = new NTooltip(factory.GetShapeInfo(i).Name); activePage.Items.Add(shape); if (shape.ShapeType == ENShapeType.Shape1D) { ENDimensioningEngineeringShapes shapeType = (ENDimensioningEngineeringShapes)i; switch (shapeType) { case ENDimensioningEngineeringShapes.VerticalBaseline: case ENDimensioningEngineeringShapes.Vertical: case ENDimensioningEngineeringShapes.VerticalOutside: case ENDimensioningEngineeringShapes.OrdinateVertical: case ENDimensioningEngineeringShapes.OrdinateVerticalMultiple: shape.SetBeginPoint(new NPoint(x + shape.Width, y + shape.Height)); shape.SetEndPoint(new NPoint(x + shape.Width, y)); break; case ENDimensioningEngineeringShapes.OrdinateHorizontalMultiple: case ENDimensioningEngineeringShapes.OrdinateHorizontal: shape.SetBeginPoint(new NPoint(x, y)); shape.SetEndPoint(new NPoint(x + shape.Width, y)); break; case ENDimensioningEngineeringShapes.Radius: case ENDimensioningEngineeringShapes.RadiusOutside: case ENDimensioningEngineeringShapes.ArcRadius: case ENDimensioningEngineeringShapes.Diameter: case ENDimensioningEngineeringShapes.DiameterOutside: shape.SetBeginPoint(new NPoint(x, y + shape.Height / 2)); shape.SetEndPoint(new NPoint(x + shape.Width, y - shape.Height / 2)); break; case ENDimensioningEngineeringShapes.AngleCenter: case ENDimensioningEngineeringShapes.AngleEven: case ENDimensioningEngineeringShapes.AngleOutside: case ENDimensioningEngineeringShapes.AngleUneven: shape.SetBeginPoint(new NPoint(x, y + shape.Width / 2)); shape.SetEndPoint(new NPoint(x + shape.Width, y + shape.Width / 2)); break; default: shape.SetBeginPoint(new NPoint(x, y)); shape.SetEndPoint(new NPoint(x + shape.Width, y + shape.Height)); break; } } else { shape.SetBounds(x, y, shape.Width, shape.Height); shape.LocPinY = 1; } x += XStep; if (x > activePage.Width) { x = 0; y += YStep; } } // 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; // hide grid and ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // create a stylesheet for styling the different bricks NStyleSheet styleSheet = new NStyleSheet(); m_DrawingDocument.StyleSheets.AddChild(styleSheet); // the first rule fills brichs with UserClass BRICK1 NRule ruleBrick1 = new NRule(); styleSheet.Add(ruleBrick1); NSelectorBuilder sb = ruleBrick1.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("BRICK1"); sb.End(); ruleBrick1.Declarations.Add(new NValueDeclaration <NFill>(NGeometry.FillProperty, new NHatchFill(ENHatchStyle.HorizontalBrick, NColor.DarkOrange, NColor.Gold))); // the second rule fills brichs with UserClass BRICK2 NRule ruleBrick2 = new NRule(); styleSheet.Add(ruleBrick2); sb = ruleBrick2.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("BRICK2"); sb.End(); ruleBrick2.Declarations.Add(new NValueDeclaration <NFill>(NGeometry.FillProperty, new NHatchFill(ENHatchStyle.HorizontalBrick, NColor.DarkRed, NColor.Gold))); // create all shapes // create the maze frame CreateBrick(new NRectangle(50, 0, 700, 50), "BRICK1"); CreateBrick(new NRectangle(750, 0, 50, 800), "BRICK1"); CreateBrick(new NRectangle(50, 750, 700, 50), "BRICK1"); CreateBrick(new NRectangle(0, 0, 50, 800), "BRICK1"); // create the maze obstacles CreateBrick(new NRectangle(100, 200, 200, 50), "BRICK2"); CreateBrick(new NRectangle(300, 50, 50, 200), "BRICK2"); CreateBrick(new NRectangle(450, 50, 50, 200), "BRICK2"); CreateBrick(new NRectangle(500, 200, 200, 50), "BRICK2"); CreateBrick(new NRectangle(50, 300, 250, 50), "BRICK2"); CreateBrick(new NRectangle(500, 300, 250, 50), "BRICK2"); CreateBrick(new NRectangle(350, 350, 100, 100), "BRICK2"); CreateBrick(new NRectangle(50, 450, 250, 50), "BRICK2"); CreateBrick(new NRectangle(500, 450, 250, 50), "BRICK2"); CreateBrick(new NRectangle(100, 550, 200, 50), "BRICK2"); CreateBrick(new NRectangle(300, 550, 50, 200), "BRICK2"); CreateBrick(new NRectangle(450, 550, 50, 200), "BRICK2"); CreateBrick(new NRectangle(500, 550, 200, 50), "BRICK2"); // create the first set of start/end shapes NShape start = CreateEllipse(new NRectangle(100, 100, 50, 50), "START"); NShape end = CreateEllipse(new NRectangle(650, 650, 50, 50), "END"); // connect them with a dynamic HV routable connector, // which is rerouted whenever the obstacles have changed NRoutableConnector routableConnector = new NRoutableConnector(); routableConnector.RerouteMode = ENRoutableConnectorRerouteMode.Always; routableConnector.Geometry.Stroke = new NStroke(3, NColor.Black); activePage.Items.Add(routableConnector); // connect the start and end shapes routableConnector.GlueBeginToShape(start); routableConnector.GlueEndToShape(end); // reroute the connector routableConnector.Reroute(); // size document to fit the maze activePage.SizeToContent(); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide the grid drawing.ScreenVisibility.ShowGrid = false; string[] tableDescription = new string[] { "Table With Column Ports", "Table With Row Ports", "Table With Cell Ports", "Table With Grid Ports" }; ENPortsDistributionMode[] tablePortDistributionModes = new ENPortsDistributionMode[] { ENPortsDistributionMode.ColumnsOnly, ENPortsDistributionMode.RowsOnly, ENPortsDistributionMode.CellBased, ENPortsDistributionMode.GridBased }; NTableBlock[] tableBlocks = new NTableBlock[tablePortDistributionModes.Length]; double margin = 40; double tableSize = 200; double gap = (drawing.ActivePage.Width - margin * 2 - tableSize * 2); double yPos = margin; int portDistributionModeIndex = 0; for (int y = 0; y < 2; y++) { double xPos = margin; for (int x = 0; x < 2; x++) { NShape shape = new NShape(); shape.SetBounds(new NRectangle(xPos, yPos, tableSize, tableSize)); xPos += tableSize + gap; // create table NTableBlock tableBlock = CreateTableBlock(tableDescription[portDistributionModeIndex]); // collect the block to connect it to the center shape tableBlocks[portDistributionModeIndex] = tableBlock; tableBlock.Content.AllowSpacingBetweenCells = false; tableBlock.ResizeMode = ENTableBlockResizeMode.FitToShape; tableBlock.PortsDistributionMode = tablePortDistributionModes[portDistributionModeIndex++]; shape.TextBlock = tableBlock; drawing.ActivePage.Items.AddChild(shape); } yPos += tableSize + gap; } NShape centerShape = new NBasicShapeFactory().CreateShape(ENBasicShape.Rectangle); centerShape.Text = "Table Ports allow you to connect tables to other shapes"; centerShape.TextBlock.FontStyleBold = true; ((NTextBlock)centerShape.TextBlock).VerticalAlignment = ENVerticalAlignment.Center; ((NTextBlock)centerShape.TextBlock).HorizontalAlignment = ENAlign.Center; drawing.ActivePage.Items.AddChild(centerShape); double center = drawing.ActivePage.Width / 2.0; double shapeSize = 100; centerShape.SetBounds(new NRectangle(center - shapeSize / 2.0, center - shapeSize / 2.0, shapeSize, shapeSize)); // get the column port for the first column on the bottom side NTableColumnPort columnPort; if (tableBlocks[0].TryGetColumnPort(0, false, out columnPort)) { Connect(columnPort, centerShape.GetPortByName("Left")); } // get the row port for the second row on the left side NTableRowPort rowPort; if (tableBlocks[1].TryGetRowPort(1, true, out rowPort)) { Connect(rowPort, centerShape.GetPortByName("Top")); } // get the cell port of the first cell on the top side NTableCellPort cellPort; if (tableBlocks[2].TryGetCellPort(0, 0, ENTableCellPortDirection.Top, out cellPort)) { Connect(cellPort, centerShape.GetPortByName("Bottom")); } // get the cell port of the first row on the left side NTableRowPort rowPort1; if (tableBlocks[3].TryGetRowPort(0, true, out rowPort1)) { Connect(rowPort1, centerShape.GetPortByName("Right")); } }