Example #1
0
        protected NShape CreateComputer()
        {
            NNetworkShapeFactory networkShapes = new NNetworkShapeFactory();
            NShape computerShape = networkShapes.CreateShape((int)ENNetworkShape.Computer);

            return(computerShape);
        }
        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
                NNetworkShapeFactory factory = new NNetworkShapeFactory();
                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.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 flowLayout = new NTableFlowLayout();
                flowLayout.HorizontalSpacing = 30;
                flowLayout.VerticalSpacing   = 50;
                flowLayout.Direction         = ENHVDirection.LeftToRight;
                flowLayout.MaxOrdinal        = 5;
                flowLayout.Arrange(shapes.CastAll <object>(), layoutContext);

                // Size page to content
                activePage.Layout.ContentPadding = new NMargins(40);
                activePage.SizeToContent();
            }
            finally
            {
                m_DrawingDocument.HistoryService.Resume();
            }
        }