private NCompositeShape CreateVerticalPipe()
        {
            NDynamicPort    port;
            NCompositeShape shape = new NCompositeShape();
            NRectanglePath  rect  = new NRectanglePath(SIZE, 0, SIZE, 3 * SIZE);

            NStyle.SetStrokeStyle(rect, new NStrokeStyle(0, Color.White));

            shape.Primitives.AddChild(rect);
            shape.Primitives.AddChild(new NLinePath(SIZE, 0, SIZE, 3 * SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, 3 * SIZE));
            shape.UpdateModelBounds();

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }
Beispiel #2
0
        protected NCompositeShape CreateState(XmlElement state)
        {
            string pathPoints = state.Attributes["PathPoints"].Value.ToString();
            string pathTypes  = state.Attributes["PathTypes"].Value.ToString();

            string[]  pathPointsStr = pathPoints.Split(' ');
            NPointF[] pathPointsF   = new NPointF[pathPointsStr.Length];

            float scaleX = NDrawingView1.Dimensions.Width;
            float scaleY = NDrawingView1.Dimensions.Height;

            for (int i = 0; i < pathPointsStr.Length; i++)
            {
                string[] xyStr = pathPointsStr[i].Split(',');

                pathPointsF[i].X = (Single.Parse(xyStr[0])) * scaleX;
                pathPointsF[i].Y = (Single.Parse(xyStr[1])) * scaleY;
            }

            string[] pathTypesStr = pathTypes.Split(' ');
            byte[]   pathTypesB   = new byte[pathTypesStr.Length];

            for (int i = 0; i < pathTypesStr.Length; i++)
            {
                pathTypesB[i] = Byte.Parse(pathTypesStr[i]);
            }

            NCustomPath     path  = new NCustomPath(pathPointsF, pathTypesB, PathType.ClosedFigure);
            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(path);
            shape.UpdateModelBounds();

            return(shape);
        }
        private void CreateCustomOpenFigureShape()
        {
            // create the coffee cup shape
            GraphicsPath graphicsPath = new GraphicsPath();

            AddStrokeCup(graphicsPath);
            AddStrokeCupHandle(graphicsPath);
            AddStrokeSteam(graphicsPath);

            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.OpenFigure));
            shape.UpdateModelBounds();

            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0, 0xaa));
            document.ActiveLayer.AddChild(shape);

            // describe the shape
            NTextShape text = new NTextShape("Custom Shape 2", 195, 340, 120, 50);

            text.Style.FillStyle           = new NColorFillStyle(Color.Black);
            text.Style.TextStyle           = new NTextStyle();
            text.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9));
            document.ActiveLayer.AddChild(text);
        }
        private void CreateArchitecturalDocument()
        {
            // set global document styles
            document.Style.TextStyle = new NTextStyle(new Font("Arial", 8.25f));
            document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            document.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Center;

            // create the rim rect
            NRectangleShape rimRect = new NRectangleShape(new NRectangleF(0, 0, 5, 7));

            rimRect.Style.FillStyle = new NColorFillStyle(Color.FromArgb(0, Color.White));
            document.ActiveLayer.AddChild(rimRect);

            // create the room rects
            NRectangleShape roomRect1 = new NRectangleShape(new NRectangleF(0, 0, 2, 3));

            roomRect1.Text = "Room 1";
            document.ActiveLayer.AddChild(roomRect1);

            NRectangleShape roomRect2 = new NRectangleShape(new NRectangleF(3, 0, 2, 3));

            roomRect2.Text = "Room 2";
            document.ActiveLayer.AddChild(roomRect2);

            NRectangleShape roomRect3 = new NRectangleShape(new NRectangleF(0, 4, 2, 3));

            roomRect3.Text = "Room 3";
            document.ActiveLayer.AddChild(roomRect3);

            // create the stairs case
            NCompositeShape stairCase = new NCompositeShape();

            float stepXSize = 0.7f;
            float stepYSize = 0.25f;

            for (int i = 0; i < 9; i++)
            {
                NRectanglePath step = new NRectanglePath(0, stepYSize * i, stepXSize, stepYSize);
                stairCase.Primitives.AddChild(step);
            }

            stairCase.UpdateModelBounds();
            stairCase.Bounds = new NRectangleF(4, 4, 1, 3);

            stairCase.Text = "Stairs";
            NTextStyle textStyle = (document.Style.TextStyle.Clone() as NTextStyle);

            textStyle.Orientation     = 90;
            stairCase.Style.TextStyle = textStyle;

            document.ActiveLayer.AddChild(stairCase);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(0.5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
        private NCompositeShape CreateCrossPipe()
        {
            NDynamicPort    port;
            NCompositeShape shape   = new NCompositeShape();
            NPolygonPath    polygon = new NPolygonPath(new NPointF[] {
                new NPointF(0, SIZE),
                new NPointF(SIZE, SIZE),
                new NPointF(SIZE, 0),
                new NPointF(2 * SIZE, 0),
                new NPointF(2 * SIZE, SIZE),
                new NPointF(3 * SIZE, SIZE),
                new NPointF(3 * SIZE, 2 * SIZE),
                new NPointF(2 * SIZE, 2 * SIZE),
                new NPointF(2 * SIZE, 3 * SIZE),
                new NPointF(SIZE, 3 * SIZE),
                new NPointF(SIZE, 2 * SIZE),
                new NPointF(0, 2 * SIZE)
            });

            NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White));
            shape.Primitives.AddChild(polygon);
            shape.Primitives.AddChild(new NLinePath(0, SIZE, SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, SIZE, SIZE, 0));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 0, 2 * SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, SIZE, 3 * SIZE, SIZE));
            shape.Primitives.AddChild(new NLinePath(3 * SIZE, 2 * SIZE, 2 * SIZE, 2 * SIZE));
            shape.Primitives.AddChild(new NLinePath(2 * SIZE, 2 * SIZE, 2 * SIZE, 3 * SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, 3 * SIZE, SIZE, 2 * SIZE));
            shape.Primitives.AddChild(new NLinePath(SIZE, 2 * SIZE, 0, 2 * SIZE));
            shape.UpdateModelBounds();

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, LEFT, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, TOP, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, RIGHT, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            port      = new NDynamicPort(shape.UniqueId, BOTTOM, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }
        private void CreateCompositeShape(int row, int col, AbilitiesMask protection)
        {
            // create a composite shape
            NCompositeShape shape = new NCompositeShape();

            shape.Protection = new NAbilities(protection);
            shape.Text       = "Protected from: " + protection.ToString();

            shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(0, 0, 1, 1)));
            shape.Primitives.AddChild(new NRectanglePath(new NRectangleF(2, 2, 1, 1)));

            shape.UpdateModelBounds();
            shape.Bounds = base.GetGridCell(row, col);

            document.ActiveLayer.AddChild(shape);
        }
Beispiel #7
0
        protected NCompositeShape CreateLegendItem(NRectangleF bounds, string str, NFillStyle fillStyle)
        {
            NCompositeShape item = new NCompositeShape();

            NRectanglePath rect = new NRectanglePath(0, 0, 2, 2);

            NStyle.SetFillStyle(rect, (fillStyle.Clone() as NFillStyle));
            item.Primitives.AddChild(rect);

            NTextPrimitive text = new NTextPrimitive(str, new NRectangleF(2, 0, 4, 2));

            item.Primitives.AddChild(text);

            item.UpdateModelBounds();
            item.Bounds = bounds;
            return(item);
        }
        private void CreateMechanicalEngineeringDocument()
        {
            // create the key shape
            NCompositeShape key = new NCompositeShape();

            NRectanglePath keyRect = new NRectanglePath(new NRectangleF(12.5f, 30, 5f, 50));

            key.Primitives.AddChild(keyRect);

            NEllipsePath keyCircle = new NEllipsePath(new NRectangleF(0, 0, 30, 30));

            key.Primitives.AddChild(keyCircle);

            NEllipsePath keyHole = new NEllipsePath(new NRectangleF(13f, 2f, 4f, 4f));

            NStyle.SetFillStyle(keyHole, new NColorFillStyle(Color.White));
            NStyle.SetStrokeStyle(keyHole, new NStrokeStyle(0, Color.Black));
            key.Primitives.AddChild(keyHole);

            key.UpdateModelBounds();
            key.Style.FillStyle   = new NColorFillStyle(Color.DarkGray);
            key.Style.StrokeStyle = new NStrokeStyle(0, Color.Black);

            document.ActiveLayer.AddChild(key);

            // create the octagram
            NBasicShapesFactory factory = new NBasicShapesFactory(document);
            NShape octagram             = factory.CreateShape((int)BasicShapes.Octagram);

            octagram.Bounds            = new NRectangleF(40, 0, 40, 40);
            octagram.Style.FillStyle   = new NColorFillStyle(Color.DarkGray);
            octagram.Style.StrokeStyle = new NStrokeStyle(0, Color.Black);

            document.ActiveLayer.AddChild(octagram);

            // update the drawing bounds to size to content with some margins
            document.AutoBoundsMinSize = new NSizeF(1, 1);
            document.AutoBoundsPadding = new Nevron.Diagram.NMargins(5f);
            document.AutoBoundsMode    = AutoBoundsMode.AutoSizeToContent;
        }
Beispiel #9
0
        private void InitDocument()
        {
            document.Style.StartArrowheadStyle.Shape = ArrowheadShape.None;
            document.Style.EndArrowheadStyle.Shape   = ArrowheadShape.None;

            int row         = 0;
            int col         = 0;
            int maxColCount = 5;
            int index       = 0;

            foreach (NPointShape pointShape in document.PointShapeStencil.PredefinedPointShapes)
            {
                // create the path representing the arrow head shape
                NCustomPath path = new NCustomPath((GraphicsPath)pointShape.Path.Clone(), pointShape.Closed? PathType.ClosedFigure: PathType.OpenFigure);

                // create a shape to host the path
                NCompositeShape shape = new NCompositeShape();
                shape.Primitives.AddChild(path);
                shape.UpdateModelBounds();

                // reposition the shape and add to active layer
                shape.Bounds = base.GetGridCell(row, col);
                document.ActiveLayer.AddChild(shape);

                // describe it
                string     str  = NExamplesHelper.InsertSpacesBeforeUppers(((PointShape)(index + 2)).ToString());
                NTextShape text = new NTextShape(str, base.GetGridCell(row + 1, col));
                document.ActiveLayer.AddChild(text);

                col++;
                index++;

                if (col > maxColCount)
                {
                    row += 2;
                    col  = 0;
                }
            }
        }
Beispiel #10
0
        protected NCompositeShape CreateCoffeeCupShape(NPointF location, float scale)
        {
            NCompositeShape shape = new NCompositeShape();

            // create the cup as a polygon path
            NPolygonPath cup = new NPolygonPath(new NPointF[] { new NPointF(45, 268),
                                                                new NPointF(63, 331),
                                                                new NPointF(121, 331),
                                                                new NPointF(140, 268) });

            shape.Primitives.AddChild(cup);

            // create the cup hangle as a closed curve path
            NClosedCurvePath handle = new NClosedCurvePath(new NPointF[] { new NPointF(175, 295),
                                                                           new NPointF(171, 278),
                                                                           new NPointF(140, 283),
                                                                           new NPointF(170, 290),
                                                                           new NPointF(128, 323) }, 1);

            NStyle.SetFillStyle(handle, new NColorFillStyle(Color.LightSalmon));
            shape.Primitives.AddChild(handle);

            // create the steam as a custom filled path
            GraphicsPath path = new GraphicsPath();

            path.AddBeziers(new PointF[] { new PointF(92, 258),
                                           new PointF(53, 163),
                                           new PointF(145, 160),
                                           new PointF(86, 50),
                                           new PointF(138, 194),
                                           new PointF(45, 145),
                                           new PointF(92, 258) });
            path.CloseAllFigures();

            NCustomPath steam = new NCustomPath(path, PathType.ClosedFigure);

            NStyle.SetFillStyle(steam, new NColorFillStyle(Color.FromArgb(50, 122, 122, 122)));
            shape.Primitives.AddChild(steam);

            // update the shape model bounds to fit the primitives it contains
            shape.UpdateModelBounds();

            // create the shape ports
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            // create dynamic port anchored to the cup center
            NDynamicPort dynamicPort = new NDynamicPort(cup.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

            shape.Ports.AddChild(dynamicPort);

            // create rotated bounds port anchored to the middle right side of the handle
            NRotatedBoundsPort rotatedBoundsPort = new NRotatedBoundsPort(handle.UniqueId, ContentAlignment.MiddleRight);

            shape.Ports.AddChild(rotatedBoundsPort);

            // apply style to the shape
            shape.Style.FillStyle = new NColorFillStyle(Color.LightCoral);

            // position it and scale the shape
            shape.Location = location;
            shape.Width    = shape.Width * scale;
            shape.Height   = shape.Height * scale;

            return(shape);
        }
        protected NCompositeShape CreateOrgChartShape(NPersonalInfo info)
        {
            NRectangleF bounds = info.Bounds;
            float       bottomPortAlignment = info.BottomPortAlignment;
            Bitmap      photo = new Bitmap(this.MapPathSecure(info.Picture));

            // compose a new graph vertex from a frame and an image
            NRectanglePath  frame           = new NRectanglePath(bounds);
            NRectanglePath  image           = new NRectanglePath(new NPointF(bounds.X + 5, bounds.Y + 5), new NSizeF(photo.Size));
            NImageFillStyle imgageFillStyle = new NImageFillStyle(photo, 0xff);

            NStyle.SetFillStyle(image, imgageFillStyle);

            NCompositeShape shape = new NCompositeShape();

            shape.Primitives.AddChild(frame);
            shape.Primitives.AddChild(image);
            shape.UpdateModelBounds();
            Document.ActiveLayer.AddChild(shape);

            // set the vertex fill style
            NColorFillStyle fillStyle = null;

            switch (info.Level)
            {
            case 0:
                fillStyle = new NColorFillStyle(Color.FromArgb(241, 100, 34));
                break;

            case 1:
                fillStyle = new NColorFillStyle(Color.FromArgb(249, 167, 26));
                break;

            case 2:
                fillStyle = new NColorFillStyle(Color.FromArgb(255, 247, 151));
                break;
            }

            fillStyle.ImageFiltersStyle.Filters.Add(new NLightingImageFilter());
            shape.Style.FillStyle = fillStyle;

            NInteractivityStyle interactivityStyle = new NInteractivityStyle();

            interactivityStyle.Tooltip.Text = "Click to show " + info.Name + " personal information";
            interactivityStyle.UrlLink.Url  = "../Examples/WebControl/GettingStarted/NPersonalInfoPage.aspx?" + info.Id.ToString();
            shape.Style.InteractivityStyle  = interactivityStyle;

            // add a new label for the person name
            NRotatedBoundsLabel nameLabel = new NRotatedBoundsLabel(info.Name, shape.UniqueId, new Nevron.Diagram.NMargins(40, 1, 50, 1));

            shape.Labels.AddChild(nameLabel);
            NStyle.SetTextStyle(nameLabel, nameLabel.ComposeTextStyle().Clone() as NTextStyle);
            nameLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            nameLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top;

            // configure default label (used for the person position)
            NRotatedBoundsLabel positionLabel = shape.Labels.DefaultLabel as NRotatedBoundsLabel;

            NStyle.SetTextStyle(positionLabel, positionLabel.ComposeTextStyle().Clone() as NTextStyle);
            positionLabel.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial", 10, FontStyle.Bold));
            positionLabel.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            positionLabel.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom;
            positionLabel.Margins = new Nevron.Diagram.NMargins(40, 5, 1, 50);
            positionLabel.Text    = info.Position;

            // create the optional ports of the shape
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            // add rotated bounds ports
            NPort leftPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleLeft));

            leftPort.Name = "Left";
            shape.Ports.AddChild(leftPort);

            NPort rightPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.MiddleRight));

            rightPort.Name = "Right";
            shape.Ports.AddChild(rightPort);

            NPort topPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(ContentAlignment.TopCenter));

            topPort.Name = "Top";
            shape.Ports.AddChild(topPort);

            NRotatedBoundsPort bottomPort = new NRotatedBoundsPort(shape.UniqueId, new NContentAlignment(bottomPortAlignment, 50));

            bottomPort.Name = "Bottom";
            shape.Ports.AddChild(bottomPort);

            return(shape);
        }
        protected NCompositeShape CreateComputer()
        {
            NCompositeShape computer = new NCompositeShape();

            // create the frame
            NEllipsePath frame = new NEllipsePath(-28, -28, 140, 140);

            NStyle.SetFillStyle(frame, new NColorFillStyle(Color.WhiteSmoke));
            computer.Primitives.AddChild(frame);

            // create display 1
            computer.Primitives.AddChild(new NRectanglePath(0, 0, 57, 47));

            // create display 2
            computer.Primitives.AddChild(new NRectanglePath(6, 4, 47, 39));

            // create the keyboard
            computer.Primitives.AddChild(new NRectanglePath(-21, 53, 60, 14));

            // create the tower case
            computer.Primitives.AddChild(new NRectanglePath(65, 0, 32, 66));

            // create floppy 1
            computer.Primitives.AddChild(new NRectanglePath(70, 5, 20, 3.75f));

            // create floppy 2
            computer.Primitives.AddChild(new NRectanglePath(70, 15, 20, 3.75f));

            // create floppy 3
            computer.Primitives.AddChild(new NRectanglePath(70, 25, 20, 3.75f));

            // create the mouse tail
            computer.Primitives.AddChild(new NBezierCurvePath(new NPointF(38, 82), new NPointF(61, 74), new NPointF(27, 57), new NPointF(63, 54)));

            // create the mouse
            NEllipsePath mouse = new NEllipsePath(26, 79, 11, 19);

            mouse.Rotate(CoordinateSystem.Scene, 42, new NPointF(36.5f, 88.5f));
            computer.Primitives.AddChild(mouse);

            // update the model bounds to fit the primitives
            computer.UpdateModelBounds();

            // the default fill style is dold
            computer.Style.FillStyle = new NColorFillStyle(Color.Gold);

            // create the computer ports
            computer.CreateShapeElements(ShapeElementsMask.Ports);

            // create a dynamic port anchored to the center of the frame
            NDynamicPort port = new NDynamicPort(frame.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

            port.Name = "port";

            // make the new port the one and default port of the computer
            computer.Ports.RemoveAllChildren();
            computer.Ports.AddChild(port);
            computer.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            return(computer);
        }
        void InitToolbar()
        {
            if (nDrawingViewToolbar.RequiresInitialization)
            {
                ActiveCommand = toolbarButtons[0].CommandName;

                // begin view init
                nDrawingViewToolbar.ViewLayout      = CanvasLayout.Normal;
                nDrawingViewToolbar.DocumentPadding = new Nevron.Diagram.NMargins(0);

                // init document
                nDrawingViewToolbar.Document.BeginInit();

                nDrawingViewToolbar.Document.AutoBoundsPadding = new Nevron.Diagram.NMargins(4);

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

                // set up visual formatting
                nDrawingViewToolbar.Document.Style.FillStyle = new NColorFillStyle(Color.White);
                nDrawingViewToolbar.Document.Style.TextStyle.FontStyle.InitFromFont(new Font("Arial Narrow", 8));

                nDrawingViewToolbar.Document.BackgroundStyle.FrameStyle.Visible = false;

                //	set up the shape factories
                NBasicShapesFactory buttonFactory = new NBasicShapesFactory(nDrawingViewToolbar.Document);
                buttonFactory.DefaultSize = new NSizeF(24, 24);

                NBrainstormingShapesFactory iconFactory = new NBrainstormingShapesFactory(nDrawingViewToolbar.Document);
                iconFactory.DefaultSize = new NSizeF(16, 16);

                //	create a batch layout, which will align shapes
                NBatchLayout batchLayout = new NBatchLayout(nDrawingViewToolbar.Document);

                //	create buttons
                int count = toolbarButtons.Length;
                for (int i = 0; i < count; i++)
                {
                    ToolbarButton btn         = toolbarButtons[i];
                    bool          isActive    = (this.ActiveCommand == btn.CommandName);
                    NShape        buttonShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle);

                    //	create the button shape group
                    NGroup      g      = new NGroup();
                    NBatchGroup bgroup = new NBatchGroup(nDrawingViewToolbar.Document);
                    NNodeList   shapes = new NNodeList();
                    if (btn.IsSeparator)
                    {
                        buttonShape.Width            /= 2;
                        buttonShape.Style.StrokeStyle = new NStrokeStyle(Color.White);
                        shapes.Add(buttonShape);
                    }
                    else if (!btn.IsColorSelector)
                    {
                        shapes.Add(buttonShape);
                    }
                    else
                    {
                        buttonShape.Style.FillStyle = new NColorFillStyle(btn.Color);
                        shapes.Add(buttonShape);
                    }

                    NRectanglePath  imagePath = new NRectanglePath(0f, 0f, btn.IconSize.Width, btn.IconSize.Height);
                    NImageFillStyle fs1       = new NImageFillStyle(this.MapPathSecure(@"..\..\..\Images\FlowChartBuilder\" + btn.IconFile));
                    NStyle.SetFillStyle(imagePath, fs1);
                    NStyle.SetStrokeStyle(imagePath, new NStrokeStyle(0, Color.White));
                    NCompositeShape imageShape = new NCompositeShape();
                    imageShape.Primitives.AddChild(imagePath);
                    imageShape.UpdateModelBounds();
                    shapes.Add(imageShape);

                    NShape coverShape = buttonFactory.CreateShape(BasicShapes.RoundedRectangle);
                    coverShape.Width = buttonShape.Width;
                    coverShape.Name  = "coverShape";
                    shapes.Add(coverShape);

                    if (!isActive && !btn.IsClientSide && !btn.IsSeparator)
                    {
                        if (btn.IsColorSelector)
                        {
                            coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(180, Color.White));
                        }
                        else
                        {
                            coverShape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(160, Color.White));
                        }
                        coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(160, Color.White));
                    }
                    else
                    {
                        coverShape.Style.FillStyle   = new NColorFillStyle(Color.FromArgb(0, Color.White));
                        coverShape.Style.StrokeStyle = new NStrokeStyle(Color.FromArgb(0, Color.White));
                        if (!btn.IsSeparator)
                        {
                            coverShape.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.FromArgb(70, Color.Black), new NPointL(1, 0));
                        }
                    }

                    // perform layout
                    batchLayout.Build(shapes);
                    batchLayout.AlignVertically(buttonShape, VertAlign.Center, false);
                    batchLayout.AlignHorizontally(buttonShape, HorzAlign.Center, false);

                    // group shapes
                    bgroup.Build(shapes);
                    bgroup.Group(null, false, out g);

                    // enable interactivity
                    if (!btn.IsSeparator)
                    {
                        g.Style.InteractivityStyle = new NInteractivityStyle(true, btn.CommandName, btn.Title, CursorType.Hand);
                    }

                    // set the command of the button
                    g.Tag = btn.CommandName;

                    nDrawingViewToolbar.Document.ActiveLayer.AddChild(g);
                }

                // 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        = toolbarButtons.Length;
                layout.HorizontalSpacing = 7;

                // create a layout context
                NLayoutContext layoutContext = new NLayoutContext();
                layoutContext.GraphAdapter         = new NShapeGraphAdapter();
                layoutContext.BodyAdapter          = new NShapeBodyAdapter(nDrawingViewToolbar.Document);
                layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(nDrawingViewToolbar.Document);

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

                nDrawingViewToolbar.Document.EndInit();
            }
        }
        private NCompositeShape CreateEndPipe(string type)
        {
            NDynamicPort      port;
            NCompositeShape   shape = new NCompositeShape();
            NPolygonPath      polygon;
            NContentAlignment ca;

            switch (type)
            {
            case "W":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(3 * SIZE, SIZE),
                    new NPointF(2 * SIZE, 1.5f * SIZE),
                    new NPointF(3 * SIZE, 2 * SIZE)
                });

                ca = RIGHT;
                break;

            case "N":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(SIZE, 3 * SIZE),
                    new NPointF(1.5f * SIZE, 2 * SIZE),
                    new NPointF(2 * SIZE, 3 * SIZE)
                });

                ca = BOTTOM;
                break;

            case "E":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(0, SIZE),
                    new NPointF(SIZE, 1.5f * SIZE),
                    new NPointF(0, 2 * SIZE)
                });

                ca = LEFT;
                break;

            case "S":
                polygon = new NPolygonPath(new NPointF[] {
                    new NPointF(SIZE, 0),
                    new NPointF(1.5f * SIZE, SIZE),
                    new NPointF(2 * SIZE, 0)
                });

                ca = TOP;
                break;

            default:
                throw new ArgumentException("Unsupported elbow pipe type");
            }

            NStyle.SetStrokeStyle(polygon, new NStrokeStyle(0, Color.White));
            shape.Primitives.AddChild(polygon);
            shape.Primitives.AddChild(new NLinePath(polygon.Points[0], polygon.Points[1]));
            shape.Primitives.AddChild(new NLinePath(polygon.Points[1], polygon.Points[2]));
            shape.UpdateModelBounds(new NRectangleF(0, 0, 3 * SIZE, 3 * SIZE));

            if (shape.Ports == null)
            {
                shape.CreateShapeElements(ShapeElementsMask.Ports);
            }

            port      = new NDynamicPort(shape.UniqueId, ca, DynamicPortGlueMode.GlueToContour);
            port.Type = PortType.InwardAndOutward;
            shape.Ports.AddChild(port);

            SetProtections(shape);
            return(shape);
        }