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);
        }
Пример #2
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 randomClosedCurveButton_Click(object sender, System.EventArgs e)
        {
            // create shape
            NClosedCurveShape shape = null;

            try
            {
                shape = new NClosedCurveShape(base.GetRandomPoints(view.Viewport, (int)pointsCountNumericUpDown.Value), 1);
            }
            catch
            {
                return;
            }

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