Exemplo n.º 1
0
        private NGroup CreateStartElement(string text)
        {
            NGroup group = new NGroup();

            document.ActiveLayer.AddChild(group);

            // Create the ellipse shape
            NShape ellipseShape = new NEllipseShape(0, 0, 1, 1);

            group.Shapes.AddChild(ellipseShape);
            ellipseShape.Text = text;
            ellipseShape.SizeToText(new NMarginsF(100, 18, 10, 18));
            ellipseShape.Location = new NPointF(0, 0);

            // Create the check shape
            NBrainstormingShapesFactory brainstormingFactory = new NBrainstormingShapesFactory(document);
            NShape checkShape = brainstormingFactory.CreateShape(BrainstormingShapes.Check);

            checkShape.Bounds = new NRectangleF(26, 12, 24, 23);
            group.Shapes.AddChild(checkShape);

            // Create the ports
            CreatePorts(group, ellipseShape);

            // Set the protections
            SetProtections(group);
            group.UpdateModelBounds();

            return(group);
        }
Exemplo n.º 2
0
        private void InitDocument()
        {
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));

            NBrainstormingShapesFactory factory = new NBrainstormingShapesFactory(document);

            factory.DefaultSize = new NSizeF(80, 60);

            int count = factory.ShapesCount;

            for (int i = 0; i < count; i++)
            {
                // create a brainstorming shape
                NShape shape = factory.CreateShape(i);
                shape.Style.InteractivityStyle = new NInteractivityStyle(shape.Name);

                // add it to the active layer
                document.ActiveLayer.AddChild(shape);
            }

            // layout the shapes in the active layer using a table layout
            NTableLayout layout = new NTableLayout();

            // setup the table layout
            layout.Direction     = LayoutDirection.LeftToRight;
            layout.ConstrainMode = CellConstrainMode.Ordinal;
            layout.MaxOrdinal    = 5;
            layout.HorizontalContentPlacement = ContentPlacement.Center;
            layout.VerticalContentPlacement   = ContentPlacement.Center;
            layout.VerticalSpacing            = 20;
            layout.HorizontalSpacing          = 20;

            // get the shapes to layout
            NNodeList shapes = document.ActiveLayer.Children(NFilters.Shape2D);

            // create a layout context
            NLayoutContext layoutContext = new NLayoutContext();

            layoutContext.GraphAdapter         = new NShapeGraphAdapter();
            layoutContext.BodyAdapter          = new NShapeBodyAdapter(document);
            layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document);

            // layout the shapes
            layout.Layout(shapes, layoutContext);

            // resize document to fit all shapes
            document.SizeToContent();
        }
        protected void InitDocument()
        {
            NDrawingDocument document = NDrawingView1.Document;

            document.GraphicsSettings.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            document.GraphicsSettings.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            document.GraphicsSettings.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

            document.Style.FillStyle = new NColorFillStyle(Color.Linen);
            document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));
            document.BackgroundStyle.FrameStyle.Visible = false;

            NBrainstormingShapesFactory factory = new NBrainstormingShapesFactory(document);
            int maxOrdinal = 0;

            switch (shapeSizeDropDownList.SelectedValue)
            {
            case "Small":
                factory.DefaultSize = new NSizeF(40, 30);
                maxOrdinal          = 7;
                break;

            case "Medium":
                factory.DefaultSize = new NSizeF(80, 60);
                maxOrdinal          = 4;
                break;

            case "Large":
                factory.DefaultSize = new NSizeF(200, 150);
                maxOrdinal          = 1;
                break;

            default:
                throw new NotImplementedException(shapeSizeDropDownList.SelectedValue);
            }

            int count = factory.ShapesCount;

            for (int i = 0; i < count; i++)
            {
                // create a basic shape
                NShape shape = factory.CreateShape(i);
                shape.Style.InteractivityStyle = new NInteractivityStyle(shape.Name);

                // add it to the active layer
                document.ActiveLayer.AddChild(shape);
            }

            // layout the shapes in the active layer using a table layout
            NTableLayout layout = new NTableLayout();

            // setup the table layout
            layout.Direction                  = LayoutDirection.LeftToRight;
            layout.ConstrainMode              = CellConstrainMode.Ordinal;
            layout.MaxOrdinal                 = maxOrdinal;
            layout.VerticalSpacing            = 20;
            layout.HorizontalSpacing          = 20;
            layout.HorizontalContentPlacement = ContentPlacement.Center;
            layout.VerticalContentPlacement   = ContentPlacement.Center;

            // create a layout context
            NLayoutContext layoutContext = new NLayoutContext();

            layoutContext.GraphAdapter         = new NShapeGraphAdapter();
            layoutContext.BodyAdapter          = new NShapeBodyAdapter(document);
            layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document);

            // layout the shapes
            layout.Layout(document.ActiveLayer.Children(null), layoutContext);

            // resize document to fit all shapes
            document.SizeToContent();
        }