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, 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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
        private NShape CreateLabelShape(string text)
        {
            NShape labelShape = new NShape();

            // Configure shape
            labelShape.SetBounds(0, 0, 100, 30);
            labelShape.SetProtectionMask(ENDiagramItemOperationMask.All);
            labelShape.CanSplit  = false;
            labelShape.GraphPart = false;
            labelShape.RouteThroughHorizontally = true;
            labelShape.RouteThroughVertically   = true;

            // Set text and make text block resize to text
            labelShape.Text = text;
            ((NTextBlock)labelShape.TextBlock).ResizeMode = ENTextBlockResizeMode.TextSize;

            // Set text background and border
            labelShape.TextBlock.BackgroundFill  = new NColorFill(NColor.White);
            labelShape.TextBlock.Border          = NBorder.CreateFilledBorder(NColor.Black);
            labelShape.TextBlock.BorderThickness = new NMargins(1);
            labelShape.TextBlock.Padding         = new NMargins(2);

            // Add a port to the shape
            labelShape.Ports.Add(new NPort(0.5, 0.5, true));

            return(labelShape);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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();
            }
        }
예제 #8
0
        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();
            }
        }
예제 #9
0
        /// <summary>
        /// Overriden to create the family tree template
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            NPoint pt;
            NShape node;
            NShape edge = null;
            NPage  page = document.Content.ActivePage;

            // determine the elements dimensions
            double childrenWidth = m_nChildrenCount * m_VerticesSize.Width + (m_nChildrenCount - 1) * m_fHorizontalSpacing;
            double parentsWidth  = m_VerticesSize.Width * 2 + m_fHorizontalSpacing;

            // determine the template dimensions
            double     templateWidth  = Math.Max(childrenWidth, parentsWidth);
            NRectangle templateBounds = new NRectangle(m_Origin.X, m_Origin.Y, templateWidth, m_VerticesSize.Height * 2 + m_fVerticalSpacing);
            NPoint     center         = templateBounds.Center;

            // create the parent nodes
            NShape father = CreateVertex(m_VerticesShape);

            pt = new NPoint(center.X - (m_VerticesSize.Width + m_fHorizontalSpacing / 2), templateBounds.Y);
            father.SetBounds(new NRectangle(pt, m_VerticesSize));
            page.Items.AddChild(father);

            NShape mother = CreateVertex(m_VerticesShape);

            pt = new NPoint(center.X + m_fHorizontalSpacing / 2, templateBounds.Y);
            mother.SetBounds(new NRectangle(pt, m_VerticesSize));
            page.Items.AddChild(mother);

            // create the children
            if (m_nChildrenCount > 0)
            {
                double childrenY = templateBounds.Y + m_VerticesSize.Height + m_fVerticalSpacing;
                for (int i = 0; i < m_nChildrenCount; i++)
                {
                    // create the child
                    node = CreateVertex(m_VerticesShape);
                    pt   = new NPoint(i * (m_VerticesSize.Width + m_fHorizontalSpacing), childrenY);
                    node.SetBounds(new NRectangle(pt, m_VerticesSize));
                    page.Items.AddChild(node);

                    // attach it to the parents
                    edge = CreateEdge(ENConnectorShape.BottomToTop1);
                    page.Items.AddChild(edge);

                    edge.GlueBeginToGeometryIntersection(father);
                    edge.GlueEndToShape(node);

                    edge = CreateEdge(ENConnectorShape.BottomToTop1);
                    page.Items.AddChild(edge);

                    edge.GlueBeginToGeometryIntersection(mother);
                    edge.GlueEndToShape(node);
                }
            }
        }
예제 #10
0
        /// <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()
        {
            NPage activePage = m_DrawingDocument.Content.ActivePage;

            // Create a barcode widget
            NMatrixBarcode barcode = new NMatrixBarcode(ENMatrixBarcodeSymbology.QrCode, "https://www.nevron.com");

            // Create a shape and place the barcode widget in it
            NShape shape = new NShape();

            shape.SetBounds(100, 100, 100, 100);
            shape.Widget = barcode;
            activePage.Items.Add(shape);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            m_DrawingView.ActivePage.Interaction.GluingShapes += Interaction_GluingShapes;

            // create the coffee cup
            NShape coffeeCup = CreateCoffeeCupShape();

            coffeeCup.SetBounds(new NRectangle(50, 50, 100, 200));
            m_DrawingDocument.Content.ActivePage.Items.Add(coffeeCup);

            NShape trapedzoid = CreateTrapedzoidShape();

            trapedzoid.SetBounds(new NRectangle(200, 150, 100, 100));
            m_DrawingDocument.Content.ActivePage.Items.Add(trapedzoid);
        }
예제 #16
0
        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);
        }
예제 #17
0
        protected void CreateDescriptionPair(int row, int col, NShape shape, string text)
        {
            const double startX  = 20;
            const double startY  = 100;
            const double width   = 80;
            const double height  = 100;
            const double spacing = 20;

            m_DrawingDocument.Content.ActivePage.Items.Add(shape);
            shape.SetBounds(new NRectangle(startX + col * (width + spacing), startY + row * (height + spacing), width, height / 2));

            NShape textShape = new NShape();

            textShape.Init2DShape();
            textShape.Text = text;
            textShape.SetBounds(new NRectangle(startX + col * (width + spacing), startY + row * (height + spacing) + height / 2, width, height / 2));
            m_DrawingDocument.Content.ActivePage.Items.Add(textShape);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
        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();
            }
        }
예제 #23
0
        protected override void InitDiagram()
        {
            base.InitDiagram();

            NStyleSheet sheet = new NStyleSheet();

            m_DrawingDocument.StyleSheets.Add(sheet);

            // create a rule that applies to the TextBlocks of all shapes with user class Connectors
            string connectorClass = NDR.StyleSheetNameConnectors;
            {
                NRule rule2 = new NRule();
                sheet.Add(rule2);

                NSelectorBuilder sb = rule2.GetSelectorBuilder();
                sb.Start();
                sb.Type(NTextBlock.NTextBlockSchema); sb.ChildOf(); sb.UserClass(connectorClass);
                sb.End();

                rule2.Declarations.Add(new NValueDeclaration <NFill>(NTextBlock.BackgroundFillProperty, new NColorFill(NColor.White)));
            }

            // get drawing and active page
            NDrawing drawing    = m_DrawingDocument.Content;
            NPage    activePage = drawing.ActivePage;

            // hide ports and grid
            drawing.ScreenVisibility.ShowGrid  = false;
            drawing.ScreenVisibility.ShowPorts = false;

            NBasicShapeFactory        basicShapesFactory        = new NBasicShapeFactory();
            NFlowchartingShapeFactory flowChartingShapesFactory = new NFlowchartingShapeFactory();
            NConnectorShapeFactory    connectorShapesFactory    = new NConnectorShapeFactory();

            // create title
            NShape titleShape = basicShapesFactory.CreateTextShape("Bubble Sort");

            titleShape.SetBounds(GetGridCell(0, 1, 2, 1));
            titleShape.TextBlock.FontName  = "Arial";
            titleShape.TextBlock.FontSize  = 40;
            titleShape.TextBlock.FontStyle = ENFontStyle.Bold;
            titleShape.TextBlock.Fill      = new NColorFill(new NColor(68, 90, 108));
            titleShape.TextBlock.Shadow    = new NShadow();
            activePage.Items.AddChild(titleShape);

            // begin shape
            NShape shapeBegin = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Termination);

            shapeBegin.SetBounds(GetGridCell(0, 0));
            shapeBegin.Text = "BEGIN";
            activePage.Items.Add(shapeBegin);

            // get array item shape
            NShape shapeGetItem = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Data);

            shapeGetItem.SetBounds(GetGridCell(1, 0));
            shapeGetItem.Text = "Get array item [1...n]";
            activePage.Items.Add(shapeGetItem);

            // i = 1 shape
            NShape shapeI1 = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process);

            shapeI1.SetBounds(GetGridCell(2, 0));
            shapeI1.Text = "i = 1";
            activePage.Items.Add(shapeI1);

            // j = n shape
            NShape shapeJEN = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process);

            shapeJEN.SetBounds(GetGridCell(3, 0));
            shapeJEN.Text = "j = n";
            activePage.Items.Add(shapeJEN);

            // less comparison shape
            NShape shapeLess = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision);

            shapeLess.SetBounds(GetGridCell(4, 0));
            shapeLess.Text = "item[i] < item[j - 1]?";
            activePage.Items.Add(shapeLess);

            // swap shape
            NShape shapeSwap = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process);

            shapeSwap.SetBounds(GetGridCell(4, 1));
            shapeSwap.Text = "Swap item[i] and item[j-1]";
            activePage.Items.Add(shapeSwap);

            // j > i + 1? shape
            NShape shapeJQ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision);

            shapeJQ.SetBounds(GetGridCell(5, 0));
            shapeJQ.Text = "j = (i + 1)?";
            activePage.Items.Add(shapeJQ);

            // dec j shape
            NShape shapeDecJ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process);

            shapeDecJ.SetBounds(GetGridCell(5, 1));
            shapeDecJ.Text = "j = j - 1";
            activePage.Items.Add(shapeDecJ);

            // i > n - 1? shape
            NShape shapeIQ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision);

            shapeIQ.SetBounds(GetGridCell(6, 0));
            shapeIQ.Text = "i = (n - 1)?";
            activePage.Items.Add(shapeIQ);

            // inc i shape
            NShape shapeIncI = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process);

            shapeIncI.SetBounds(GetGridCell(6, 1));
            shapeIncI.Text = "i = i + 1";
            activePage.Items.Add(shapeIncI);

            // end shape
            NShape shapeEnd = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Termination);

            shapeEnd.SetBounds(GetGridCell(7, 0));
            shapeEnd.Text = "END";
            activePage.Items.Add(shapeEnd);

            // connect begin with get array item
            NShape connector1 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector1.UserClass = connectorClass;
            activePage.Items.AddChild(connector1);
            connector1.GlueBeginToShape(shapeBegin);
            connector1.GlueEndToShape(shapeGetItem);

            // connect get array item with i = 1
            NShape connector2 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector2.UserClass = connectorClass;
            activePage.Items.AddChild(connector2);
            connector2.GlueBeginToShape(shapeGetItem);
            connector2.GlueEndToShape(shapeI1);

            // connect i = 1 and j = n
            NShape connector3 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector3.UserClass = connectorClass;
            activePage.Items.AddChild(connector3);
            connector3.GlueBeginToShape(shapeI1);
            connector3.GlueEndToShape(shapeJEN);

            // connect j = n and item[i] < item[j-1]?
            NShape connector4 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector4.UserClass = connectorClass;
            activePage.Items.AddChild(connector4);
            connector4.GlueBeginToShape(shapeJEN);
            connector4.GlueEndToShape(shapeLess);

            // connect item[i] < item[j-1]? and j = (i + 1)?
            NShape connector5 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector5.UserClass = connectorClass;
            connector5.Text      = "No";
            activePage.Items.AddChild(connector5);
            connector5.GlueBeginToShape(shapeLess);
            connector5.GlueEndToShape(shapeJQ);

            // connect j = (i + 1)? and i = (n - 1)?
            NShape connector6 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector6.UserClass = connectorClass;
            activePage.Items.AddChild(connector6);
            connector6.GlueBeginToShape(shapeJQ);
            connector6.GlueEndToShape(shapeIQ);

            // connect i = (n - 1) and END
            NShape connector7 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector7.UserClass = connectorClass;
            activePage.Items.AddChild(connector7);
            connector7.GlueBeginToShape(shapeIQ);
            connector7.GlueEndToShape(shapeEnd);

            // connect item[i] < item[j-1]? and Swap
            NShape connector8 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector8.UserClass = connectorClass;
            connector8.Text      = "Yes";
            activePage.Items.AddChild(connector8);
            connector8.GlueBeginToShape(shapeLess);
            connector8.GlueEndToShape(shapeSwap);

            // connect j = (i + 1)? and j = (j - 1)
            NShape connector9 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector9.UserClass = connectorClass;
            activePage.Items.AddChild(connector9);
            connector9.GlueBeginToShape(shapeJQ);
            connector9.GlueEndToShape(shapeDecJ);

            // connect i = (n - 1)? and i = (i + 1)
            NShape connector10 = connectorShapesFactory.CreateShape(ENConnectorShape.Line);

            connector10.UserClass = connectorClass;
            activePage.Items.AddChild(connector10);
            connector10.GlueBeginToShape(shapeIQ);
            connector10.GlueEndToShape(shapeIncI);

            // connect Swap to No connector
            NShape connector11 = connectorShapesFactory.CreateShape(ENConnectorShape.TopBottomToSide);

            connector11.UserClass = connectorClass;
            activePage.Items.AddChild(connector11);
            connector11.GlueBeginToShape(shapeSwap);
            connector11.GlueEndToShape(connector5);

            // connect i = i + 1 to connector3
            NShape connector12 = connectorShapesFactory.CreateSideToSide(m_GridSpacing.Width * 2);

            connector12.UserClass = connectorClass;
            activePage.Items.AddChild(connector12);
            connector12.GlueBeginToPort(shapeIncI.GetPortByName("Right"));
            connector12.GlueEndToGeometryContour(connector3, 0.5f);

            // connect j = j - 1 to connector4
            NShape connector13 = connectorShapesFactory.CreateSideToSide(m_GridSpacing.Width);

            connector13.UserClass = connectorClass;
            activePage.Items.AddChild(connector13);
            connector13.GlueBeginToPort(shapeDecJ.GetPortByName(("Right")));
            connector13.GlueEndToGeometryContour(connector4, 0.5f);
        }
예제 #24
0
        /// <summary>
        /// Creates a tree in the specified document
        /// </summary>
        /// <param name="document">document in which to create a tree</param>
        /// <returns>tree elements</returns>
        protected virtual NList <NShape> CreateTree(NDrawingDocument document)
        {
            NPage          page     = document.Content.ActivePage;
            NList <NShape> elements = new NList <NShape>();

            NShape cur  = null;
            NShape edge = null;

            NList <NShape> curRowVertices  = null;
            NList <NShape> prevRowVertices = null;

            int    i, j, level;
            int    childrenCount, levelNodesCount;
            Random rnd = new Random();

            for (level = 1; level <= m_nLevels; level++)
            {
                curRowVertices = new NList <NShape>();

                if (m_bBalanced)
                {
                    //Create a balanced tree
                    levelNodesCount = (int)Math.Pow(m_nBranchNodes, level - 1);
                    for (i = 0; i < levelNodesCount; i++)
                    {
                        // create the cur node
                        cur = CreateVertex(m_VerticesShape);
                        cur.SetBounds(new NRectangle(m_Origin, GetSize(rnd)));

                        page.Items.AddChild(cur);
                        elements.Add(cur);

                        // connect with ancestor
                        if (level > 1)
                        {
                            edge = CreateEdge(m_ConnectorShape);
                            page.Items.AddChild(edge);

                            int parentIndex = (int)Math.Floor((double)(i / m_nBranchNodes));
                            edge.GlueBeginToGeometryIntersection(prevRowVertices[parentIndex]);
                            edge.GlueEndToShape(cur);
                        }

                        curRowVertices.Add(cur);
                    }
                }
                else
                {
                    //Create an unbalanced tree
                    if (level == 1)
                    {
                        // Create the current node
                        cur = CreateVertex(m_VerticesShape);
                        cur.SetBounds(new NRectangle(m_Origin, GetSize(rnd)));

                        page.Items.AddChild(cur);
                        elements.Add(cur);

                        curRowVertices.Add(cur);
                    }
                    else
                    {
                        levelNodesCount = prevRowVertices.Count;
                        do
                        {
                            // Ensure that the desired level depth is reached
                            for (i = 0; i < levelNodesCount; i++)
                            {
                                childrenCount = rnd.Next(0, m_nBranchNodes + 1);
                                for (j = 0; j < childrenCount; j++)
                                {
                                    // Create the current node
                                    cur = CreateVertex(m_VerticesShape);
                                    cur.SetBounds(new NRectangle(m_Origin, GetSize(rnd)));

                                    page.Items.AddChild(cur);
                                    elements.Add(cur);
                                    curRowVertices.Add(cur);

                                    // Connect with ancestor
                                    edge = CreateEdge(m_ConnectorShape);
                                    page.Items.AddChild(edge);

                                    edge.GlueBeginToGeometryIntersection(prevRowVertices[i]);
                                    edge.GlueEndToShape(cur);
                                }
                            }
                        }while (level < m_nLevels && curRowVertices.Count == 0);
                    }
                }

                prevRowVertices = curRowVertices;
            }

            return(elements);
        }
예제 #25
0
        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"));
            }
        }
예제 #26
0
        /// <summary>
        /// Overriden to create the triangular grid template in the specified document
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            NPage      page           = document.Content.ActivePage;
            NRectangle templateBounds = new NRectangle(m_Origin.X, m_Origin.Y,
                                                       m_nLevels * m_VerticesSize.Width + (m_nLevels - 1) * m_fHorizontalSpacing,
                                                       m_nLevels * m_VerticesSize.Height + (m_nLevels - 1) * m_fVerticalSpacing);
            NPoint location;
            NShape cur = null, prev = null;
            NShape edge = null;

            NList <NShape> curRowNodes  = null;
            NList <NShape> prevRowNodes = null;

            for (int level = 1; level <= m_nLevels; level++)
            {
                // determine the location of the first node in the level
                location = new NPoint(templateBounds.X + (templateBounds.Width - level * m_VerticesSize.Width - (level - 1) * m_fHorizontalSpacing) / 2,
                                      templateBounds.Y + (level - 1) * (m_VerticesSize.Height + m_fVerticalSpacing));

                curRowNodes = new NList <NShape>();
                for (int i = 0; i < level; i++)
                {
                    cur = CreateVertex(m_VerticesShape);
                    cur.SetBounds(new NRectangle(location, m_VerticesSize));
                    page.Items.AddChild(cur);

                    location.X += m_VerticesSize.Width + m_fHorizontalSpacing;

                    // connect the current node with its ancestors and prev node
                    if (m_bConnectGrid == false)
                    {
                        continue;
                    }

                    // connect with prev
                    if (i > 0)
                    {
                        edge = CreateEdge(ENConnectorShape.Line);
                        page.Items.AddChild(edge);

                        edge.GlueBeginToGeometryIntersection(prev);
                        edge.GlueEndToShape(cur);
                    }

                    // connect with ancestors
                    if (level > 1)
                    {
                        if (i < prevRowNodes.Count)
                        {
                            edge = CreateEdge(ENConnectorShape.Line);
                            page.Items.AddChild(edge);

                            edge.GlueBeginToGeometryIntersection((NShape)prevRowNodes[i]);
                            edge.GlueEndToShape(cur);
                        }

                        if (i > 0)
                        {
                            edge = CreateEdge(ENConnectorShape.Line);
                            page.Items.AddChild(edge);

                            edge.GlueBeginToGeometryIntersection((NShape)prevRowNodes[i - 1]);
                            edge.GlueEndToShape(cur);
                        }
                    }

                    curRowNodes.Add(cur);
                    prev = cur;
                }

                prevRowNodes = curRowNodes;
            }
        }
예제 #27
0
        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);
        }
예제 #28
0
        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();
            }
        }
예제 #29
0
        /// <summary>
        /// Creates a custom shape that is essentially a group consisting of three other shapes each with different filling.
        /// You need to use groups to have shapes that mix different fill, or stroke styles.
        /// </summary>
        /// <returns></returns>
        protected NShape CreateCoffeeCupShape()
        {
            // create the points and paths from which the shape consits
            NPoint[] cupPoints = new NPoint[] {
                new NPoint(45, 268),
                new NPoint(63, 331),
                new NPoint(121, 331),
                new NPoint(140, 268)
            };

            NGraphicsPath handleGraphicsPath = new NGraphicsPath();

            handleGraphicsPath.AddClosedCurve(new NPoint[] {
                new NPoint(175, 295),
                new NPoint(171, 278),
                new NPoint(140, 283),
                new NPoint(170, 290),
                new NPoint(128, 323)
            }, 1);

            NGraphicsPath steamGraphicsPath = new NGraphicsPath();

            steamGraphicsPath.AddCubicBeziers(new NPoint[] {
                new NPoint(92, 270),
                new NPoint(53, 163),
                new NPoint(145, 160),
                new NPoint(86, 50),
                new NPoint(138, 194),
                new NPoint(45, 145),
                new NPoint(92, 270)
            });
            steamGraphicsPath.CloseFigure();

            // calculate some bounds
            NRectangle handleBounds   = handleGraphicsPath.ExactBounds;
            NRectangle cupBounds      = NGeometry2D.GetBounds(cupPoints);
            NRectangle steamBounds    = steamGraphicsPath.ExactBounds;
            NRectangle geometryBounds = NRectangle.Union(cupBounds, handleBounds, steamBounds);

            // normalize the points and paths by transforming them to relative coordinates
            NRectangle normalRect = new NRectangle(0, 0, 1, 1);
            NMatrix    transform  = NMatrix.CreateBoundsStretchMatrix(geometryBounds, normalRect);

            transform.TransformPoints(cupPoints);
            handleGraphicsPath.Transform(transform);
            steamGraphicsPath.Transform(transform);

            // create the cup shape
            NDrawPolygon cupPolygon = new NDrawPolygon(normalRect, cupPoints);

            cupPolygon.Relative = true;
            NShape cupShape = new NShape();

            cupShape.Init2DShape();
            cupShape.Geometry.Fill = new NColorFill(NColor.Brown);
            cupShape.Geometry.Add(cupPolygon);
            cupShape.SetBounds(geometryBounds);

            // create the cup handle
            NDrawPath handlePath = new NDrawPath(normalRect, handleGraphicsPath);

            handlePath.Relative = true;
            NShape handleShape = new NShape();

            handleShape.Init2DShape();
            handleShape.Geometry.Fill = new NColorFill(NColor.LightSalmon);
            handleShape.Geometry.Add(handlePath);
            handleShape.SetBounds(geometryBounds);

            // create the steam
            NDrawPath steamPath = new NDrawPath(steamGraphicsPath.Bounds, steamGraphicsPath);

            steamPath.Relative = true;
            NShape steamShape = new NShape();

            steamShape.Init2DShape();
            steamShape.Geometry.Fill = new NColorFill(new NColor(50, 122, 122, 122));
            steamShape.Geometry.Add(steamPath);
            steamShape.SetBounds(geometryBounds);

            // group the shapes as a single group
            NGroup      group;
            NBatchGroup batch = new NBatchGroup(m_DrawingDocument);

            batch.Build(cupShape, handleShape, steamShape);
            batch.Group(null, out group);

            // alter some properties of the group
            group.SelectionMode = ENGroupSelectionMode.GroupOnly;
            group.SnapToShapes  = false;

            return(group);
        }
예제 #30
0
        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
                NDrawingToolShapeFactory factory = new NDrawingToolShapeFactory();
                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);

                    if (i != (int)ENDrawingToolShapes.SectorNumeric &&
                        i != (int)ENDrawingToolShapes.ArcNumeric &&
                        i != (int)ENDrawingToolShapes.RightTriangle)
                    {
                        shape.Text = factory.GetShapeInfo(i).Name;
                        MoveTextBelowShape(shape);
                    }
                    activePage.Items.Add(shape);

                    if (shape.ShapeType == ENShapeType.Shape1D)
                    {
                        if (i == (int)ENDrawingToolShapes.CircleRadius)
                        {
                            shape.SetBeginPoint(new NPoint(x + shape.Width / 2, y));
                        }
                        else
                        {
                            shape.SetBeginPoint(new NPoint(x, y));
                        }

                        double width = shape.Width;

                        if (i == (int)ENDrawingToolShapes.MultigonEdge)
                        {
                            width = 90;
                        }
                        else if (i == (int)ENDrawingToolShapes.MultigonCenter)
                        {
                            width = 30;
                        }

                        shape.SetEndPoint(new NPoint(x + width, y + shape.Height));
                    }
                    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();
            }
        }