Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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
                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();
            }
        }
        private void ImportMap()
        {
            NPage page = m_DrawingDocument.Content.ActivePage;

            page.Items.Clear();
            page.Bounds = new NRectangle(0, 0, 10000, 10000);

            // Import the map to the drawing document
            m_MapImporter.Import(m_DrawingDocument, page.Bounds);

            // Size page to content
            page.SizeToContent();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Arranges the shapes in the active page.
        /// </summary>
        protected virtual void ArrangeDiagram()
        {
            // get all top-level shapes that reside in the active page
            NPage          activePage = m_DrawingDocument.Content.ActivePage;
            NList <NShape> shapes     = activePage.GetShapes(false);

            // create a layout context and use it to arrange the shapes using the current layout
            NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(m_DrawingDocument, activePage);

            m_Layout.Arrange(shapes.CastAll <object>(), layoutContext);

            // size the page to the content size
            activePage.SizeToContent();
        }
        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();

            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();
            }
        }
        /// <summary>
        /// Arranges the shapes in the active page.
        /// </summary>
        private void ArrangeDiagram()
        {
            // Create and configure a layout
            NLayeredGraphLayout layout = new NLayeredGraphLayout();

            // Get all top-level shapes that reside in the active page
            NPage          activePage = m_DrawingDocument.Content.ActivePage;
            NList <NShape> shapes     = activePage.GetShapes(false);

            // Create a layout context and use it to arrange the shapes using the current layout
            NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(m_DrawingDocument, activePage);

            layout.Arrange(shapes.CastAll <object>(), layoutContext);

            // Size the page to the content size
            activePage.SizeToContent();
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
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
                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();
            }
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 12
0
        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();
        }
Exemplo n.º 13
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();
            }
        }
Exemplo n.º 14
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();
            }
        }
Exemplo n.º 15
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
                NEpcShapeFactory factory = new NEpcShapeFactory();
                factory.DefaultSize = new NSize(80, 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);
                    NShape tempShape;
                    shape.HorizontalPlacement = ENHorizontalPlacement.Center;
                    shape.VerticalPlacement   = ENVerticalPlacement.Center;
                    if (i == (int)ENEpcShape.AND ||
                        i == (int)ENEpcShape.OR ||
                        i == (int)ENEpcShape.XOR)
                    {
                        NGroup group = new NGroup();
                        group.Width  = shape.Width;
                        group.Height = shape.Height;
                        group.Shapes.Add(shape);
                        group.TextBlock = new NTextBlock(factory.GetShapeInfo(i).Name);
                        shape.SetFx(NShape.PinXProperty, "Width / 2");
                        shape.SetFx(NShape.PinYProperty, "Height / 2");
                        shape.SetFx(NShape.WidthProperty, "$ParentSheet.Width");
                        shape.SetFx(NShape.HeightProperty, "$ParentSheet.Height");
                        MoveTextBelowShape(group);

                        activePage.Items.Add(group);
                        tempShape = group;
                    }
                    else
                    {
                        shape.Text = factory.GetShapeInfo(i).Name;
                        if (i == (int)ENEpcShape.InformationMaterial)
                        {
                            shape.TextBlock.Fill = new NColorFill(NColor.Black);
                        }
                        MoveTextBelowShape(shape);
                        activePage.Items.Add(shape);
                        tempShape = 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 - 100, cellHeight - 100);
                        tempShape.SetBeginPoint(beginPoint);
                        tempShape.SetEndPoint(endPoint);
                    }
                    else
                    {
                        tempShape.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();
            }
        }
Exemplo n.º 16
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
                NGenogramShapeFactory factory = new NGenogramShapeFactory();

                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;

                    NTextBlock textBlock = shape.GetFirstDescendant <NTextBlock>();

                    if (textBlock == null ||
                        i == (int)ENGenogramShape.Male ||
                        i == (int)ENGenogramShape.Female ||
                        i == (int)ENGenogramShape.Pet ||
                        i == (int)ENGenogramShape.UnknownGender)
                    {
                        textBlock = (NTextBlock)shape.TextBlock;
                    }

                    textBlock.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);
                    if (shape.ShapeType == ENShapeType.Shape1D)
                    {
                        NPoint endPoint = beginPoint + new NPoint(cellWidth - 50, cellHeight - 50);

                        shape.SetBeginPoint(beginPoint);
                        shape.SetEndPoint(endPoint);
                    }
                    else
                    {
                        textBlock.SetFx(NTextBlock.PinYProperty, "$Parent.Height + Height + 10");
                        textBlock.ResizeMode = ENTextBlockResizeMode.TextSize;
                        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();
            }
        }