Example #1
0
        private void CreateShapeWithLogicalLinePort()
        {
            NPointF[] points = new NPointF[] { new NPointF(151, 291),
                                               new NPointF(151, 316),
                                               new NPointF(123, 336),
                                               new NPointF(151, 350),
                                               new NPointF(158, 319),
                                               new NPointF(180, 312) };

            // create a polyline shape with a logical line port
            NPolylineShape shape = new NPolylineShape(points);

            shape.Name   = "Shape with a Logical Line Port";
            shape.Bounds = base.GetGridCell(5, 1);

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

            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30);

            shape.Ports.RemoveAllChildren();
            shape.Ports.AddChild(port);
            shape.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            // connect it with the center shape
            document.ActiveLayer.AddChild(shape);
            ConnectShapes(centerShape, shape);

            // descibte it
            NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(5, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
Example #2
0
        private void CreateArrowShapeWithLogicalLinePort()
        {
            // create a filled graph connector with one logical line port
            NArrowShape shape = new NArrowShape(ArrowType.DoubleArrow, new NPointF(15, 380), new NPointF(55, 420), 10, 45, 30);

            shape.Bounds = base.GetGridCell(6, 1);
            shape.Name   = "Filled shape with Stroke Port";

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

            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30);

            shape.Ports.RemoveAllChildren();
            shape.Ports.AddChild(port);
            shape.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            // connect it with the center shape
            document.ActiveLayer.AddChild(shape);
            ConnectShapes(centerShape, shape);

            // descibte it
            NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(6, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
        public void CreatePolygon()
        {
            // create polygon
            NRectangleF cell       = this.DocumentHelper.GetGridCell(0, 2);
            int         xdeviation = (int)cell.Width / 4;
            int         ydeviation = (int)cell.Height / 4;

            NPointF[] points = new NPointF[]
            {
                new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height))
            };

            NPolygonShape polygon = new NPolygonShape(points);

            // set fill and stroke styles
            polygon.Style.FillStyle   = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant1, Color.Green, Color.Yellow);
            polygon.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDot);

            // add to active layer
            Document.ActiveLayer.AddChild(polygon);

            // add description
            cell = this.DocumentHelper.GetGridCell(1, 2);
            NTextShape text = new NTextShape("Polygon with gradient fill style and dash-dot stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
        protected void CreateLabels(NDrawingDocument document)
        {
            NRectangleF bounds;

            // title
            bounds       = this.GetElementBounds(2, 1);
            bounds.Width = 16 * bounds.Width;
            NTextShape text = new NTextShape("Periodic Table of the Elements", bounds);

            text.Style.TextStyle = new NTextStyle(new Font("Times New Roman", 24, FontStyle.Bold));
            document.ActiveLayer.AddChild(text);

            // Lanthanide Series
            bounds               = this.GetElementBounds(1, 9);
            bounds.Width         = 4 * bounds.Width;
            text                 = new NTextShape("* Lanthanide Series:", bounds);
            text.Style.TextStyle = new NTextStyle(new Font("Times New Roman", 12, FontStyle.Bold | FontStyle.Italic));
            text.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            document.ActiveLayer.AddChild(text);

            // Actinide Series
            bounds               = this.GetElementBounds(1, 10);
            bounds.Width         = 4 * bounds.Width;
            text                 = new NTextShape("* Actinide Series::", bounds);
            text.Style.TextStyle = new NTextStyle(new Font("Times New Roman", 12, FontStyle.Bold | FontStyle.Italic));
            text.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Right;
            document.ActiveLayer.AddChild(text);
        }
        public void CreateClosedCurve()
        {
            // create curve
            NRectangleF cell       = this.DocumentHelper.GetGridCell(0, 3);
            int         xdeviation = (int)cell.Width / 4;
            int         ydeviation = (int)cell.Height / 4;

            NPointF[] points = new NPointF[]
            {
                new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height))
            };

            NClosedCurveShape curve = new NClosedCurveShape(points, 1);

            // set fill and stroke styles
            curve.Style.FillStyle   = new NHatchFillStyle(HatchStyle.SmallGrid, Color.LightSalmon, Color.Chocolate);
            curve.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDotDot);

            // add to active layer
            Document.ActiveLayer.AddChild(curve);

            // add description
            cell = this.DocumentHelper.GetGridCell(1, 3);
            NTextShape text = new NTextShape("Closed curve with hatch fill style and dash-dot-dot stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
        public void CreateDoubleArrow()
        {
            // create double arrow
            NRectangleF cell       = this.DocumentHelper.GetGridCell(2, 1);
            NPointF     startPoint = new NPointF(cell.X, cell.Y + cell.Height / 2);
            NPointF     endPoint   = new NPointF(cell.Right, cell.Y + cell.Height / 2);

            NArrowShape arrow = new NArrowShape(ArrowType.DoubleArrow, startPoint, endPoint, 20, 45, 60);

            // set styles
            try
            {
                Bitmap bmp = new Bitmap(this.MapPathSecure(this.TemplateSourceDirectory + "\\..\\Images\\ConceptCar2.png"));
                arrow.Style.FillStyle = new NImageFillStyle(bmp, 125);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to load concept car resource. Exception was: " + ex.Message);
            }

            arrow.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Solid);

            // add to the active layer
            Document.ActiveLayer.AddChild(arrow);

            // add description
            cell = this.DocumentHelper.GetGridCell(3, 1);
            NTextShape text = new NTextShape("Single arrow with semi transparent image fill style and solid stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
        private NGroup CreateElement(string text)
        {
            NGroup group = new NGroup();

            document.ActiveLayer.AddChild(group);

            // Create the text shape
            NTextShape textShape = new NTextShape(text, 0, 0, 1, 1);

            group.Shapes.AddChild(textShape);
            textShape.SizeToText(new NMarginsF(10, 2, 10, 2));

            // Create the line shape under the text
            NRectangleF rect      = textShape.Bounds;
            NLineShape  lineShape = new NLineShape(rect.X, rect.Bottom, rect.Right, rect.Bottom);

            group.Shapes.AddChild(lineShape);

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

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

            return(group);
        }
Example #8
0
        private void CreateGroup(int row, int col, Color color)
        {
            string transactionName = color.ToString().Replace("Color [", string.Empty).Replace("]", string.Empty) + " group";

            // start transaction
            document.StartTransaction(transactionName);

            // create the shapes in the group
            NPolygonShape     polygon = new NPolygonShape(base.GetRandomPoints(base.GetGridCell(row, col), 6));
            NClosedCurveShape curve   = new NClosedCurveShape(base.GetRandomPoints(base.GetGridCell(row, col + 1), 6), 1);
            NTextShape        text    = new NTextShape(transactionName, base.GetGridCell(row, col, 0, 1));

            // create the group
            NGroup group = new NGroup();

            group.Shapes.AddChild(polygon);
            group.Shapes.AddChild(curve);
            group.Shapes.AddChild(text);
            group.UpdateModelBounds();

            // apply styles to it
            group.Style.FillStyle   = new NColorFillStyle(Color.FromArgb(50, color));
            group.Style.StrokeStyle = new NStrokeStyle(1, color);
            group.Style.TextStyle   = new NTextStyle(new Font("Arial", 10), color);
            group.Style.TextStyle.StringFormatStyle.VertAlign = VertAlign.Bottom;

            // add the group to the active layer
            document.ActiveLayer.AddChild(group);

            // commit the transaction
            document.HistoryService.Commit();
        }
        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);
        }
Example #10
0
        private void CreateStretchedText()
        {
            // create text
            NTextShape text = new NTextShape("Stretched text", base.GetGridCell(0, 1));

            text.Style.TextStyle = new NTextStyle(new Font("Tahoma", 8), base.GetPredefinedColor(1));
            text.Mode            = BoxTextMode.Stretch;

            // add to active layer
            document.ActiveLayer.AddChild(text);
            document.SmartRefreshAllViews();
        }
Example #11
0
        private void CreateWrappedText()
        {
            // create text
            NTextShape text = new NTextShape("Wrapped text with font: Tahoma and size: 8", base.GetGridCell(0, 0));

            text.Style.TextStyle = new NTextStyle(new Font("Tahoma", 8), base.GetPredefinedColor(0));
            text.Mode            = BoxTextMode.Wrap;

            // add to active layer
            document.ActiveLayer.AddChild(text);
            document.SmartRefreshAllViews();
        }
Example #12
0
        private void textStyleButton_Click(object sender, System.EventArgs e)
        {
            // get the selected text shape
            NTextShape text = (view.Selection.AnchorNode as NTextShape);

            if (text == null)
            {
                return;
            }

            // show it text style editor
            base.ShowTextStyleEditor(text);
        }
        private void CreateCurveShape(int row, int col)
        {
            NRectangleF cell  = GetGridCell(row, col);
            Color       color = GetPredefinedColor(5);

            int xdeviation = (int)cell.Width / 4;
            int ydeviation = (int)cell.Height / 4;

            NPointF[] points = new NPointF[]
            {
                new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)),
                new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)),
                new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height))
            };

            // create curve
            NCurveShape curve = new NCurveShape(points, 1);

            // set stroke style
            curve.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.DashDotDot);

            // set arrowheads style
            NArrowheadStyle arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.QuillArrow,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            curve.Style.StartArrowheadStyle = arrowheadStyle;

            arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.SunkenArrow,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            curve.Style.EndArrowheadStyle = arrowheadStyle;

            // add to the active layer
            document.ActiveLayer.AddChild(curve);

            // add description
            cell = GetGridCell(row + 1, col);
            NTextShape text = new NTextShape("Curve with dash-dot-dot style and QuillArrow and SunkenArrow arrowheads", cell);

            document.ActiveLayer.AddChild(text);
        }
Example #14
0
        private void CreateWrappedTextWithBackplane()
        {
            // create text
            NTextShape text = new NTextShape("Wrapped text with backplane", base.GetGridCell(1, 0));

            text.Style.TextStyle = new NTextStyle(new Font("Arial", 10), base.GetPredefinedColor(2));
            text.Style.TextStyle.BackplaneStyle.Visible = true;
            text.Style.TextStyle.BackplaneStyle.Shape   = BackplaneShape.Ellipse;
            text.Mode = BoxTextMode.Wrap;

            // add to active layer
            document.ActiveLayer.AddChild(text);
            document.SmartRefreshAllViews();
        }
Example #15
0
        private void CreateStretchedTextWithBackplane()
        {
            // create text
            NTextShape text = new NTextShape("Stretched text with backplane", base.GetGridCell(1, 1));

            text.Style.TextStyle = new NTextStyle(new Font("Arial", 10), base.GetPredefinedColor(3));
            text.Style.TextStyle.BackplaneStyle.Visible = true;
            text.Style.TextStyle.BackplaneStyle.Shape   = BackplaneShape.SmoothEdgeRectangle;
            text.Mode = BoxTextMode.Stretch;

            // add to active layer
            document.ActiveLayer.AddChild(text);
            document.SmartRefreshAllViews();
        }
        public void CreateEllipse()
        {
            // create ellipse
            NRectangleF   cell    = this.DocumentHelper.GetGridCell(0, 1);
            NEllipseShape ellipse = new NEllipseShape(cell);

            // set fill and stroke styles
            ellipse.Style.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Magenta, Color.LightGreen);
            ellipse.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Dash);

            // add to active layer
            Document.ActiveLayer.AddChild(ellipse);

            // add description
            cell = this.DocumentHelper.GetGridCell(1, 1);
            NTextShape text = new NTextShape("Ellipse with gradient fill style and dash stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
        public void CreateRect()
        {
            // create rect
            NRectangleF     cell = this.DocumentHelper.GetGridCell(0, 0);
            NRectangleShape rect = new NRectangleShape(cell);

            // set fill and stroke styles
            rect.Style.FillStyle   = new NColorFillStyle(Color.Magenta);
            rect.Style.StrokeStyle = new NStrokeStyle(1, Color.Black);

            // add to active layer
            Document.ActiveLayer.AddChild(rect);

            // add description
            cell = this.DocumentHelper.GetGridCell(1, 0);
            NTextShape text = new NTextShape("Rectangle with color fill style and solid stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
        private void CreateRect()
        {
            // create rect
            NRectangleF     cell = GetGridCell(0, 0);
            NRectangleShape rect = new NRectangleShape(cell);

            // set fill and stroke styles
            rect.Style.FillStyle   = new NColorFillStyle(GetPredefinedColor(0));
            rect.Style.StrokeStyle = new NStrokeStyle(1, Color.Black);

            // add to active layer
            document.ActiveLayer.AddChild(rect);

            // add description
            cell = GetGridCell(1, 0);
            NTextShape text = new NTextShape("Rectangle with color fill style and solid stroke style", cell);

            document.ActiveLayer.AddChild(text);
        }
Example #19
0
        private void CreateShapeWithDynamicPort()
        {
            // NOTE: the triangle shape is by default created with one dynamic port (the default one) and
            // three rotated bounds ports located at the triangle vertices).
            NBasicShapesFactory factory = new NBasicShapesFactory(document);
            NShape shape = factory.CreateShape((int)BasicShapes.Triangle);

            shape.Name   = "Shape with Dynamic Port";
            shape.Bounds = base.GetGridCell(0, 1);

            // connect it with the center shape
            document.ActiveLayer.AddChild(shape);
            ConnectShapes(centerShape, shape);

            // describe it
            NTextShape text = new NTextShape("Shape with Dynamic Port", base.GetGridCell(0, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
Example #20
0
        private void textEdit_TextChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            // get the selected text shape
            NTextShape text = (view.Selection.AnchorNode as NTextShape);

            if (text == null)
            {
                return;
            }

            // change its text
            text.Text = textEditBox.Text;
            document.SmartRefreshAllViews();
        }
Example #21
0
        private void EventSinkService_NodeSelected(NNodeEventArgs args)
        {
            // get the selected text shape
            NTextShape text = (view.Selection.AnchorNode as NTextShape);

            if (text == null)
            {
                return;
            }

            // update the form controls from the shape
            PauseEventsHandling();

            selectedTextGroupBox.Enabled = true;
            textEditBox.Text             = text.Text;
            textModeCombo.SelectedItem   = text.Mode;
            allowDownwardCheck.Checked   = text.AllowDownwardOrientation;

            ResumeEventsHandling();
        }
Example #22
0
        private void CreateShapeWithAutoCenterDirection()
        {
            NRectangleShape shape = new NRectangleShape(base.GetGridCell(1, 1));

            shape.Name              = "Port with Auto Center direction";
            shape.Style.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133));
            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            shape.CreateShapeElements(ShapeElementsMask.Ports);
            NRotatedBoundsPort port = new NRotatedBoundsPort(new NContentAlignment(50, 30));

            port.DirectionMode = BoundsPortDirectionMode.AutoCenter;
            shape.Ports.AddChild(port);

            document.ActiveLayer.AddChild(shape);

            // describe it
            NTextShape text = new NTextShape("Port with Auto Center direction", base.GetGridCell(1, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
Example #23
0
        private void CreateXMLFormattedText()
        {
            NRectangleF cell = base.GetGridCell(2, 0, 1, 1);

            // create text
            NTextShape text = new NTextShape(
                "<b>XML</b> Formatted Text allows you to <br></br>" +
                "<font face = 'Tahoma' size = '19'>mix</font>   <font face = 'Impact' size = '22'>fonts</font> <br></br>" +
                "<font gradient = '0, 0, white, red'>display text with gradiens</font> <br></br>" +
                "<font size = '22' border = '1' bordercolor = 'gray'>display text with borders</font> <br></br>" +
                "<font shadowoffset = '2, 2' shadowfadelength = '3' shadowtype = 'gaussianblur'>display text with shadows</font> <br></br>" +
                "display text with <b>bold</b>, <i>italic</i>, <u>underline</u> and <strike>strikeout</strike>",
                cell);

            text.Style.TextStyle            = new NTextStyle(new Font("Arial", 12), base.GetPredefinedColor(4));
            text.Style.TextStyle.TextFormat = TextFormat.XML;

            // add to active layer
            document.ActiveLayer.AddChild(text);
            document.SmartRefreshAllViews();
        }
Example #24
0
        private void CreateShapeWithAutoLinePort()
        {
            NBezierCurveShape shape = new NBezierCurveShape(new NPointF(0, 0), new NPointF(1, 0), new NPointF(1, 2), new NPointF(2, 2));

            shape.Name              = "Line Port with AutoLine direction";
            shape.Bounds            = base.GetGridCell(5, 1);
            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            shape.CreateShapeElements(ShapeElementsMask.Ports);
            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 50);

            port.DirectionMode = LogicalLinePortDirectionMode.AutoLine;
            shape.Ports.AddChild(port);

            document.ActiveLayer.AddChild(shape);

            // describe it
            NTextShape text = new NTextShape("Line Port with AutoLine direction", base.GetGridCell(5, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
        private void CreateEllipticalArcShape(int row, int col)
        {
            NRectangleF cell  = GetGridCell(row, col);
            Color       color = GetPredefinedColor(2);

            // create arc
            NEllipticalArcShape arc = new NEllipticalArcShape(new NPointF(cell.X, cell.Y), new NPointF(cell.Right, cell.Bottom));

            // set stroke style
            arc.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.Dot);

            // set arrowheads style
            NArrowheadStyle arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.ClosedFork,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            arc.Style.StartArrowheadStyle = arrowheadStyle;

            arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.DoubleArrow,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            arc.Style.EndArrowheadStyle = arrowheadStyle;

            // add to the active layer
            document.ActiveLayer.AddChild(arc);

            // add description
            cell = GetGridCell(row + 1, col);
            NTextShape text = new NTextShape("Elliptical arc with dots style and ClosedFork and DoubleArrow arrowheads", cell);

            document.ActiveLayer.AddChild(text);
        }
        private void CreateBezierShape(int row, int col)
        {
            NRectangleF cell  = GetGridCell(row, col);
            Color       color = GetPredefinedColor(4);

            // create bezier
            NBezierCurveShape bezier = new NBezierCurveShape(cell.Location, new NPointF(cell.Right, cell.Bottom));

            // set stroke style
            bezier.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.Solid);

            // set arrowheads style
            NArrowheadStyle arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.ManyOptional,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            bezier.Style.StartArrowheadStyle = arrowheadStyle;

            arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.Many,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            bezier.Style.EndArrowheadStyle = arrowheadStyle;

            // add to the active layer
            document.ActiveLayer.AddChild(bezier);

            // add description
            cell = GetGridCell(row + 1, col);
            NTextShape text = new NTextShape("Bezier curve with solid style and ManyOptional and Many arrowheads", cell);

            document.ActiveLayer.AddChild(text);
        }
Example #27
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;
                }
            }
        }
        private void CreateLineShape(int row, int col)
        {
            // create line
            NRectangleF cell  = GetGridCell(row, col);
            Color       color = GetPredefinedColor(0);

            NLineShape line = new NLineShape(cell.X, cell.Y, cell.Right, cell.Bottom);

            // set stroke style
            line.Style.StrokeStyle = new NStrokeStyle(1, color, LinePattern.Dash);

            // set arrowheads style
            NArrowheadStyle arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.Circle,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            line.Style.StartArrowheadStyle = arrowheadStyle;

            arrowheadStyle = new NArrowheadStyle(
                ArrowheadShape.Arrow,
                "",
                new NSizeL(12, 12),
                new NColorFillStyle(color),
                new NStrokeStyle(1, Color.Black));

            line.Style.EndArrowheadStyle = arrowheadStyle;

            // add to the active layer
            document.ActiveLayer.AddChild(line);

            // add description
            cell = GetGridCell(row + 1, col);
            NTextShape text = new NTextShape("Line with dash style and Circle and Arrow arrowheads", cell);

            document.ActiveLayer.AddChild(text);
        }
        public void CreateSingleArrow()
        {
            // create single arrow
            NRectangleF cell       = this.DocumentHelper.GetGridCell(2, 0);
            NPointF     startPoint = new NPointF(cell.X, cell.Y + cell.Height / 2);
            NPointF     endPoint   = new NPointF(cell.Right, cell.Y + cell.Height / 2);

            NArrowShape arrow = new NArrowShape(ArrowType.SingleArrow, startPoint, endPoint, 20, 45, 60);

            // set styles
            arrow.Style.FillStyle   = new NHatchFillStyle(HatchStyle.SmallGrid, Color.Yellow, Color.Coral);
            arrow.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Dot);

            // add to the active layer
            Document.ActiveLayer.AddChild(arrow);

            // add description
            cell = this.DocumentHelper.GetGridCell(3, 0);
            NTextShape text = new NTextShape("Single arrow with hatch fill style and dot stroke style", cell);

            Document.ActiveLayer.AddChild(text);
        }
Example #30
0
        private void CreateShapeWithAutoPrevPort()
        {
            NBasicShapesFactory factory = new NBasicShapesFactory(document);
            NShape shape = factory.CreateShape((int)BasicShapes.Triangle);

            shape.Name              = "Point Port with AutoPrev direction";
            shape.Bounds            = base.GetGridCell(4, 1);
            shape.Style.FillStyle   = new NGradientFillStyle(GradientStyle.DiagonalUp, GradientVariant.Variant4, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133));
            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            NPointPort port = new NPointPort(shape.UniqueId, PointIndexMode.Second, -1);

            port.DirectionMode = PointPortDirectionMode.AutoPrev;
            shape.Ports.RemoveAllChildren();
            shape.Ports.AddChild(port);

            document.ActiveLayer.AddChild(shape);

            // describe it
            NTextShape text = new NTextShape("Point Port with AutoPrev direction", base.GetGridCell(4, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }