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); }
private void randomCurveButton_Click(object sender, System.EventArgs e) { // create shape NCurveShape shape = null; try { shape = new NCurveShape(base.GetRandomPoints(view.Viewport, (int)pointsCountNumericUpDown.Value), 1); } catch { return; } // add to active layer document.ActiveLayer.AddChild(shape); document.SmartRefreshAllViews(); }