示例#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
                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();
            }
        }
示例#2
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();
        }
        /// <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();
        }
        /// <summary>
        /// Overriden to create the tree template
        /// </summary>
        /// <param name="document">document in which to create the template</param>
        protected override void CreateTemplate(NDrawingDocument document)
        {
            // create the tree
            NList <NShape> elements = CreateTree(document);

            if (m_LayoutType == ENTreeLayoutType.None)
            {
                return;
            }

            // layout the tree
            NLayeredTreeLayout layout = new NLayeredTreeLayout();

            // sync measurement unit
            layout.OrthogonalEdgeRouting = false;

            switch (m_LayoutType)
            {
            case ENTreeLayoutType.Layered:
                layout.VertexSpacing = m_fHorizontalSpacing;
                layout.LayerSpacing  = m_fVerticalSpacing;
                break;

            case ENTreeLayoutType.LayeredLeftAligned:
                layout.VertexSpacing             = m_fHorizontalSpacing;
                layout.LayerSpacing              = m_fVerticalSpacing;
                layout.ParentPlacement.Anchor    = ENParentAnchor.SubtreeNear;
                layout.ParentPlacement.Alignment = ENRelativeAlignment.Near;
                break;

            case ENTreeLayoutType.LayeredRightAligned:
                layout.VertexSpacing             = m_fHorizontalSpacing;
                layout.LayerSpacing              = m_fVerticalSpacing;
                layout.ParentPlacement.Anchor    = ENParentAnchor.SubtreeFar;
                layout.ParentPlacement.Alignment = ENRelativeAlignment.Far;
                break;
            }

            // apply layout
            NDrawingLayoutContext context = new NDrawingLayoutContext(document, new NRectangle(Origin, NSize.Zero));

            layout.Arrange(elements.CastAll <object>(), context);
        }