private void Demo0(Graphics g) { renderXY(g);//初始化坐标轴 //========划线-画点 Pen pen1 = new Pen(Color.Red, 1); Pen pen2 = new Pen(Color.Blue); int total_point_num=1000; PointF[] CurvePoints = new PointF[total_point_num]; for (int x = 0; x < total_point_num; x += 10) { //计算点坐标-正弦曲线 float y = (float)( 100*Math.Sin(x*300) ); //坐标轴置换 y = -y + this.pictureBox1.Height-200; //点保存到数组中,供下文创建路径用 CurvePoints[x] = new PointF(x, y); //画空心点-画笔,矩形(坐标x,坐标y,宽度,高度); g.DrawEllipse(pen2, new RectangleF(x, y, 3, 3)); } //创建路径 GraphicsPath myPath = new GraphicsPath(); //AddCurve(点阵,起点,终点,弯曲程度) //myPath.AddCurve(CurvePoints, 0, 7, 0.8f); myPath.AddCurve(CurvePoints,0,300,0.01F); //定义画笔 Pen myPen = new Pen(Color.Red, 1); //划线--------------------------------------------bug为什么点稀疏的时候不是两两连接? //g.DrawPath(myPen, myPath); //g.DrawCurve(pen1, CurvePoints, 0.05F); }
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; //Создаем массив точек Point[] points = { new Point(5, 10), new Point(23, 130), new Point(130, 57)}; GraphicsPath path = new GraphicsPath(); //рисуем первую траекторию path.StartFigure(); path.AddEllipse(170, 170, 100, 50); // заливаем траекторию цветом g.FillPath(Brushes.Aqua, path); //рисуем вторую траекторию path.StartFigure(); path.AddCurve(points, 0.5F); path.AddArc(100, 50, 100, 100, 0, 120); path.AddLine(50, 150, 50, 220); // Закрываем траекторию path.CloseFigure(); //рисуем четвертую траекторию path.StartFigure(); path.AddArc(180, 30, 60, 60, 0, -170); g.DrawPath(new Pen(Color.Blue, 3), path); g.Dispose(); }
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Point[] points = { new Point(5,10) , new Point(23 , 130), new Point(130 , 57) }; GraphicsPath path = new GraphicsPath(); path.StartFigure(); path.AddEllipse(170 , 170 , 100 , 50); g.FillPath(Brushes.Black, path); path.CloseFigure(); path.StartFigure(); path.AddCurve(points , 0.5F); g.FillPath(Brushes.Blue, path); //coords g.TranslateTransform(40, 40); Point A = new Point(0, 0); Point B = new Point(150 , 150); g.DrawLine(new Pen(Brushes.Black, 3), A, B); g.Dispose(); }
public override RectangleF ReturnBounds() { Point[] points = (Point[])pointsList.ToArray(typeof(Point)); GraphicsPath path = new GraphicsPath(); path.AddCurve(points,1); path.Transform(this.TMatrix.TransformationMatrix); return path.GetBounds(); }
public void AddCurve(IEnumerable <PointF> points, float tension = 0.5f) { var sdpoints = from p in points select p.ToSD(); var pointArray = sdpoints.ToArray(); Control.AddCurve(pointArray, tension); position = pointArray.Last(); }
/// <summary> /// Sony NS 2013-06-26 /// AddCurve for LineString type /// </summary> /// <param name="g"></param> /// <param name="line"></param> /// <param name="pen"></param> /// <param name="map"></param> public static void DrawCurve(System.Drawing.Graphics g, ILineString curveLine, System.Drawing.Pen pen, SharpMap.Map map) { if (curveLine.Coordinates.Length > 1) { System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); //gp.AddLines(LimitValues(Transform.TransformToImage(line, map), extremeValueLimit)); gp.AddCurve(Transform.TransformToImage(curveLine, map)); g.DrawPath(pen, gp); } }
public Form1() { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserMouse | ControlStyles.ResizeRedraw, true); //create graph path path = new GraphicsPath(); path.AddCurve(new Point[] { new Point(10, 20), new Point(102, 203), new Point(150, 20) }); path.AddEllipse(new Rectangle(100, 200, 300, 300)); path.AddRectangle(new Rectangle(150, 100, 240, 50)); }
protected override void UpdatePath() { if (this.Points == null || this.Points.Length == 0) return; InternalPath = new GraphicsPath(); InternalPath.AddCurve(this.Points); Matrix mtx = new Matrix(); mtx.RotateAt(this.Rotation, InternalRotationBasePoint); InternalPath.Transform(mtx); }
private GraphicsPath CreatePath(Rectangle rect) { GraphicsPath path = new GraphicsPath(); path.AddArc(rect.X, rect.Y + 30, 8, 8, 180, 90); path.AddCurve(new Point[] { new Point(rect.X + rect.Width/2 + 5,rect.Y + 30), new Point(rect.X + rect.Width/2,rect.Y + 15), new Point(rect.X + rect.Width/2 - 10,rect.Y)}, 1f); path.AddCurve(new Point[] { new Point(rect.X + rect.Width/2 - 10,rect.Y), new Point(rect.X + rect.Width/2+ 10,rect.Y + 15), new Point(rect.X + rect.Width/2 + 20,rect.Y + 30)}, 1f); path.AddArc(rect.Right - 9, rect.Y + 30, 8, 8, 270, 90); path.AddArc(rect.Right - 9, rect.Bottom - 9, 8, 8, 0, 90); path.AddArc(rect.X, rect.Bottom - 9, 8, 8, 90, 90); path.CloseFigure(); return path; }
public static GraphicsPath GetArcPath(RectangleF container, double dStartDegrees, double dArcLengthDegrees) { GraphicsPath arcPath = new GraphicsPath(); int nPoints = 100; double dEachPointDelta = dArcLengthDegrees / (double)(nPoints); List<PointF> arcPts = new List<PointF>(); for (int i = 0; i <= nPoints; i++) { double curDeg = dStartDegrees - (i * dEachPointDelta); arcPts.Add(GetPointInArc(container, curDeg, 0)); } arcPath.AddCurve(arcPts.ToArray()); return arcPath; }
public override void DrawYourSelf(Graphics graphics) { if (pointsList.Count < 4) return; Point[] points = (Point[])pointsList.ToArray(typeof(Point)); GraphicsPath path = new GraphicsPath(); path.AddCurve(points,1); path.Transform(this.TMatrix.TransformationMatrix); Pen pen = new Pen(this.BorderColor, this.BorderWidth); graphics.DrawPath(pen, path); if (this.Selected) { this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds())); this.selectionUnit.DrawYourSelf(graphics); } }
public static void GenerateLineGraph(int width, int height, int maxValue, int[] values, string saveLocation, int leftBuffer, int bottomBuffer, int low) { Bitmap bm = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bm); SolidBrush brush = new SolidBrush(Color.Aquamarine); graphics.FillRectangle(brush, leftBuffer, 0, width, height - bottomBuffer); brush.Dispose(); SolidBrush foreground = new SolidBrush(Color.DarkCyan); Pen p = new Pen(foreground); Point lastp = new Point(leftBuffer, (height - bottomBuffer) - (int)(((float)values[0] / maxValue) * (height - bottomBuffer))); GraphicsPath gp = new GraphicsPath(); gp.AddLine(new Point(leftBuffer, height - bottomBuffer), lastp); Point[] curve = new Point[values.Length]; curve[0] = lastp; for (int x = 0; x < values.Length; x++) { Point top = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), 0); Point bottom = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), height); graphics.DrawLine(p, top, bottom); Point pnt = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x), (height - bottomBuffer) - (int)(((float)values[x] / maxValue) * (height - bottomBuffer))); curve[x] = pnt; lastp = pnt; } curve[values.Length - 1] = new Point(width, (height - bottomBuffer) - (int)(((float)values[values.Length - 1] / maxValue) * (height - bottomBuffer))); gp.AddCurve(curve); gp.AddLine(curve[values.Length - 1], new Point(width, (height - bottomBuffer))); gp.AddLine(new Point(leftBuffer, height), new Point(width, (height - bottomBuffer))); LinearGradientBrush lgb = new LinearGradientBrush(new Point(width / 2, (height - bottomBuffer)), new Point(width / 2, 0), Color.DarkBlue, Color.Cyan); graphics.FillRegion(lgb, new Region(gp)); for (int x = 0; x < values.Length; x++) { SizeF stringSize = new SizeF(); Font arial = new Font("Monospace", 12); stringSize = graphics.MeasureString(x.ToString(), arial); int shift = (int)(((float)(width - leftBuffer) / (float)(values.Length)) / 2) - (int)(stringSize.Width / 2); Point bottom = new Point(leftBuffer + (int)(((float)(width - leftBuffer) / (float)(values.Length)) * x) + shift, height - bottomBuffer); graphics.DrawString(x.ToString(), arial, foreground, bottom); } p.Dispose(); foreground.Dispose(); bm.Save(saveLocation, ImageFormat.Bmp); }
/// <summary> /// Проверяет попадание точки в фигуру /// </summary> /// <param name="p"></param> /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns> public int ContainsPoint(Point p) { if (this.IsSelected) { for (int i = 1; i <= KeyPoints.Length; i++) { if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p)) return i; } } var path = new GraphicsPath(); Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness); path.AddCurve(points.ToArray()); path.Widen(pen); Region region = new Region(path); pen.Dispose(); if (region.IsVisible(p)) return 0; return -1; }
private const double ROUNDED_RECT_RAD_PERCENT = .05d; //5 percent #endregion Fields #region Methods public static GraphicsPath Get3DShinePath(Rectangle container, ControlShape shape) { GraphicsPath path = new GraphicsPath(); Rectangle pathRect = container; pathRect.Width -= 1; pathRect.Height -= 1; RectangleF halfRect = new RectangleF(pathRect.X, pathRect.Y, pathRect.Width, pathRect.Height / 2f); if (pathRect.Height > 0 && pathRect.Width > 0) { switch (shape) { case ControlShape.Rect: path.AddRectangle(halfRect); break; case ControlShape.RoundedRect: //radius is 10% of smallest side int rad = (int)(Math.Min(halfRect.Height, halfRect.Width) * ROUNDED_RECT_RAD_PERCENT); path.AddRoundedRectangle(halfRect, rad); break; case ControlShape.Circular: path.AddArc(pathRect, 180, 142); PointF[] pts = new PointF[] { path.GetLastPoint(), new PointF(container.Width * .70f, container.Height * .33f), new PointF(container.Width * .25f, container.Height * .5f), path.PathPoints[0] }; path.AddCurve(pts); path.CloseFigure(); break; } } return path; }
private static void AddSmoothPath(GraphicsPath borderPath, VisualOrientation orientation, Rectangle rect, bool forBorder) { // The tension of the lines depends on the width/height int minLength = Math.Min(rect.Width, rect.Height); int calcLength = Math.Min(minLength, 50); float tension = Math.Max(0.5f - (0.5f / 50 * calcLength), 0.05f); int indentW = Math.Min(5, rect.Width / 10); int indentH = Math.Min(5, rect.Height / 10); switch (orientation) { case VisualOrientation.Top: // If there is not enough room for the rounded style then use the rounded if (rect.Width < 14) AddRoundedPath(borderPath, orientation, rect, forBorder); else { if (!forBorder) borderPath.AddLine(rect.Right, rect.Bottom, rect.Left, rect.Bottom); // Find way points along the width int x2T = rect.Width / 2; int x6T = rect.Width / 6; borderPath.AddCurve(new Point[]{new Point(rect.Left, rect.Bottom), new Point(rect.Left + indentW, rect.Top + 5), new Point(rect.Left + x6T, rect.Top + 2), new Point(rect.Left + x2T, rect.Top), new Point(rect.Right - x6T, rect.Top + 2), new Point(rect.Right - indentW, rect.Top + 5), new Point(rect.Right, rect.Bottom)}, tension); } break; case VisualOrientation.Bottom: // If there is not enough room for the rounded style then use the rounded if (rect.Width < 14) AddRoundedPath(borderPath, orientation, rect, forBorder); else { if (!forBorder) borderPath.AddLine(rect.Right, rect.Top, rect.Left, rect.Top); // Find way points along the width int x2B = rect.Width / 2; int x6B = rect.Width / 6; borderPath.AddCurve(new Point[]{new Point(rect.Left, rect.Top), new Point(rect.Left + indentW, rect.Bottom - 5), new Point(rect.Left + x6B, rect.Bottom - 2), new Point(rect.Left + x2B, rect.Bottom), new Point(rect.Right - x6B, rect.Bottom - 2), new Point(rect.Right - indentW, rect.Bottom - 5), new Point(rect.Right, rect.Top)}, tension); } break; case VisualOrientation.Left: // If there is not enough room for the rounded style then use the rounded if (rect.Height < 14) AddRoundedPath(borderPath, orientation, rect, forBorder); else { if (!forBorder) borderPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom); // Find way points along the width int y2L = rect.Height / 2; int y6L = rect.Height / 6; borderPath.AddCurve(new Point[]{new Point(rect.Right, rect.Bottom), new Point(rect.Left + 5, rect.Bottom - indentH), new Point(rect.Left + 2, rect.Bottom - y6L), new Point(rect.Left, rect.Bottom - y2L), new Point(rect.Left + 2, rect.Top + y6L), new Point(rect.Left + 5, rect.Top + indentH), new Point(rect.Right, rect.Top)}, tension); } break; case VisualOrientation.Right: // If there is not enough room for the rounded style then use the rounded if (rect.Height < 14) AddRoundedPath(borderPath, orientation, rect, forBorder); else { if (!forBorder) borderPath.AddLine(rect.Left, rect.Top, rect.Left, rect.Bottom); // Find way points along the width int y2R = rect.Height / 2; int y6R = rect.Height / 6; borderPath.AddCurve(new Point[]{new Point(rect.Left, rect.Bottom), new Point(rect.Right - 5, rect.Bottom - indentH), new Point(rect.Right - 2, rect.Bottom - y6R), new Point(rect.Right, rect.Bottom - y2R), new Point(rect.Right - 2, rect.Top + y6R), new Point(rect.Right - 5, rect.Top + indentH), new Point(rect.Left, rect.Top)}, tension); } break; } }
public void Reverse_Curve () { using (GraphicsPath gp = new GraphicsPath ()) { Point[] beziers = new Point[] { new Point (1,2), new Point (3,4), new Point (5,6), new Point (7,8), new Point (9,10), new Point (11,12), new Point (13,14) }; gp.AddCurve (beziers); Reverse (gp); } }
public void StartClose_AddCurve () { GraphicsPath path = new GraphicsPath (); path.AddLine (1, 1, 2, 2); path.AddCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) }); path.AddLine (10, 10, 20, 20); byte[] types = path.PathTypes; // check first types Assert.AreEqual (0, types[0], "start/Line"); Assert.AreEqual (1, types[2], "start/Curve"); // check last types Assert.AreEqual (3, types[path.PointCount - 3], "end/Curve"); Assert.AreEqual (1, types[path.PointCount - 1], "end/Line"); }
public void Flatten_Curve () { GraphicsPath path = new GraphicsPath (); path.AddCurve (new Point[4] { new Point (0, 0), new Point (40, 20), new Point (20, 40), new Point (40, 40) }); GraphicsPath clone = (GraphicsPath) path.Clone (); path.Flatten (); CompareFlats (path, clone); }
public void AddCurve () { PointF [] points = new PointF [] { new PointF (37f, 185f), new PointF (99f, 185f), new PointF (161f, 159f), new PointF (223f, 185f), new PointF (285f, 54f), }; int[] count = { 4, 7, 10, 13 }; using (GraphicsPath gp = new GraphicsPath ()) { for (int i = 0; i < points.Length - 1; i++) { gp.AddCurve (points, i, 1, 0.5f); // all non-curves points are compressed expect the first one (positioning) Assert.AreEqual (count [i], gp.PointCount, i.ToString ()); } Assert.AreEqual (0, gp.PathData.Types [0], "Types[0]"); Assert.AreEqual (37f, gp.PathData.Points [0].X, 0.001, "Points[0].X"); Assert.AreEqual (185f, gp.PathData.Points [1].Y, 0.001, "Points[0].Y"); Assert.AreEqual (3, gp.PathData.Types [1], "Types[1]"); Assert.AreEqual (47.3334f, gp.PathData.Points [1].X, 0.001, "Points[1].X"); Assert.AreEqual (185f, gp.PathData.Points [1].Y, 0.001, "Points[1].Y"); Assert.AreEqual (3, gp.PathData.Types [2], "Types[2]"); Assert.AreEqual (78.33333f, gp.PathData.Points [2].X, 0.001, "Points[2].X"); Assert.AreEqual (189.3333f, gp.PathData.Points [2].Y, 0.001, "Points[2].Y"); Assert.AreEqual (3, gp.PathData.Types [3], "Types[3]"); Assert.AreEqual (99f, gp.PathData.Points [3].X, 0.001, "Points[3].X"); Assert.AreEqual (185f, gp.PathData.Points [3].Y, 0.001, "Points[3].Y"); Assert.AreEqual (3, gp.PathData.Types [4], "Types[4]"); Assert.AreEqual (119.6667f, gp.PathData.Points [4].X, 0.001, "Points[4].X"); Assert.AreEqual (180.6667f, gp.PathData.Points [4].Y, 0.001, "Points[4].Y"); Assert.AreEqual (3, gp.PathData.Types [5], "Types[5]"); Assert.AreEqual (140.3333f, gp.PathData.Points [5].X, 0.001, "Points[5].X"); Assert.AreEqual (159f, gp.PathData.Points [5].Y, 0.001, "Points[5].Y"); Assert.AreEqual (3, gp.PathData.Types [6], "Types[6]"); Assert.AreEqual (161f, gp.PathData.Points [6].X, 0.001, "Points[6].X"); Assert.AreEqual (159f, gp.PathData.Points [6].Y, 0.001, "Points[6].Y"); Assert.AreEqual (3, gp.PathData.Types [7], "Types[7]"); Assert.AreEqual (181.6667f, gp.PathData.Points [7].X, 0.001, "Points[7].X"); Assert.AreEqual (159f, gp.PathData.Points [7].Y, 0.001, "Points[7].Y"); Assert.AreEqual (3, gp.PathData.Types [8], "Types[8]"); Assert.AreEqual (202.3333f, gp.PathData.Points [8].X, 0.001, "Points[8].X"); Assert.AreEqual (202.5f, gp.PathData.Points [8].Y, 0.001, "Points[8].Y"); Assert.AreEqual (3, gp.PathData.Types [9], "Types[9]"); Assert.AreEqual (223f, gp.PathData.Points [9].X, 0.001, "Points[9].X"); Assert.AreEqual (185f, gp.PathData.Points [9].Y, 0.001, "Points[9].Y"); Assert.AreEqual (3, gp.PathData.Types [10], "Types[10]"); Assert.AreEqual (243.6667f, gp.PathData.Points [10].X, 0.001, "Points[10].X"); Assert.AreEqual (167.5f, gp.PathData.Points [10].Y, 0.001, "Points[10].Y"); Assert.AreEqual (3, gp.PathData.Types [11], "Types[11]"); Assert.AreEqual (274.6667f, gp.PathData.Points [11].X, 0.001, "Points[11].X"); Assert.AreEqual (75.83334f, gp.PathData.Points [11].Y, 0.001, "Points[11].Y"); Assert.AreEqual (3, gp.PathData.Types [12], "Types[12]"); Assert.AreEqual (285f, gp.PathData.Points [12].X, 0.001, "Points[12].X"); Assert.AreEqual (54f, gp.PathData.Points [12].Y, 0.001, "Points[12].Y"); } }
public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds) { int spread = 0; int eigth = 0; int sixth = 0; int quarter = 0; if (this._TabControl.Alignment <= TabAlignment.Bottom) { spread = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Height) * 2 / 3))); eigth = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Height) * 1 / 8))); sixth = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Height) * 1 / 6))); quarter = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Height) * 1 / 4))); } else { spread = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Width) * 2 / 3))); eigth = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Width) * 1 / 8))); sixth = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Width) * 1 / 6))); quarter = Convert.ToInt32(Math.Truncate(Math.Floor(Convert.ToDecimal(tabBounds.Width) * 1 / 4))); } switch (this._TabControl.Alignment) { case TabAlignment.Top: path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Bottom), new Point(tabBounds.X + sixth, tabBounds.Bottom - eigth), new Point(tabBounds.X + spread - quarter, tabBounds.Y + eigth), new Point(tabBounds.X + spread, tabBounds.Y) }); path.AddLine(tabBounds.X + spread, tabBounds.Y, tabBounds.Right - spread, tabBounds.Y); path.AddCurve(new Point[] { new Point(tabBounds.Right - spread, tabBounds.Y), new Point(tabBounds.Right - spread + quarter, tabBounds.Y + eigth), new Point(tabBounds.Right - sixth, tabBounds.Bottom - eigth), new Point(tabBounds.Right, tabBounds.Bottom) }); break; // TODO: might not be correct. Was : Exit Select case TabAlignment.Bottom: path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Y), new Point(tabBounds.Right - sixth, tabBounds.Y + eigth), new Point(tabBounds.Right - spread + quarter, tabBounds.Bottom - eigth), new Point(tabBounds.Right - spread, tabBounds.Bottom) }); path.AddLine(tabBounds.Right - spread, tabBounds.Bottom, tabBounds.X + spread, tabBounds.Bottom); path.AddCurve(new Point[] { new Point(tabBounds.X + spread, tabBounds.Bottom), new Point(tabBounds.X + spread - quarter, tabBounds.Bottom - eigth), new Point(tabBounds.X + sixth, tabBounds.Y + eigth), new Point(tabBounds.X, tabBounds.Y) }); break; // TODO: might not be correct. Was : Exit Select case TabAlignment.Left: path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom), new Point(tabBounds.Right - eigth, tabBounds.Bottom - sixth), new Point(tabBounds.X + eigth, tabBounds.Bottom - spread + quarter), new Point(tabBounds.X, tabBounds.Bottom - spread) }); path.AddLine(tabBounds.X, tabBounds.Bottom - spread, tabBounds.X, tabBounds.Y + spread); path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y + spread), new Point(tabBounds.X + eigth, tabBounds.Y + spread - quarter), new Point(tabBounds.Right - eigth, tabBounds.Y + sixth), new Point(tabBounds.Right, tabBounds.Y) }); break; // TODO: might not be correct. Was : Exit Select case TabAlignment.Right: path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y), new Point(tabBounds.X + eigth, tabBounds.Y + sixth), new Point(tabBounds.Right - eigth, tabBounds.Y + spread - quarter), new Point(tabBounds.Right, tabBounds.Y + spread) }); path.AddLine(tabBounds.Right, tabBounds.Y + spread, tabBounds.Right, tabBounds.Bottom - spread); path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom - spread), new Point(tabBounds.Right - eigth, tabBounds.Bottom - spread + quarter), new Point(tabBounds.X + eigth, tabBounds.Bottom - sixth), new Point(tabBounds.X, tabBounds.Bottom) }); break; // TODO: might not be correct. Was : Exit Select } }
/// <summary> /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/> /// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>). /// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>; /// the symbols are drawn by the <see cref="Symbol.Draw"/> method. This method /// is normally only called by the Draw method of the /// <see cref="CurveItem"/> object. Note that the <see cref="StepType"/> property /// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true). /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="curve">A <see cref="LineItem"/> representing this /// curve.</param> public void DrawSmoothFilledCurve( Graphics g, GraphPane pane, CurveItem curve, float scaleFactor ) { Line source = this; if ( curve.IsSelected ) source = Selection.Line; PointF[] arrPoints; int count; IPointList points = curve.Points; if ( this.IsVisible && !this.Color.IsEmpty && points != null && BuildPointsArray( pane, curve, out arrPoints, out count ) && count > 2 ) { float tension = _isSmooth ? _smoothTension : 0f; // Fill the curve if needed if ( this.Fill.IsVisible ) { Axis yAxis = curve.GetYAxis( pane ); using ( GraphicsPath path = new GraphicsPath( FillMode.Winding ) ) { path.AddCurve( arrPoints, 0, count - 2, tension ); double yMin = yAxis._scale._min < 0 ? 0.0 : yAxis._scale._min; CloseCurve( pane, curve, arrPoints, count, yMin, path ); RectangleF rect = path.GetBounds(); using ( Brush brush = source._fill.MakeBrush( rect ) ) { if ( pane.LineType == LineType.Stack && yAxis.Scale._min < 0 && this.IsFirstLine( pane, curve ) ) { float zeroPix = yAxis.Scale.Transform( 0 ); RectangleF tRect = pane.Chart._rect; tRect.Height = zeroPix - tRect.Top; if ( tRect.Height > 0 ) { Region reg = g.Clip; g.SetClip( tRect ); g.FillPath( brush, path ); g.SetClip( pane.Chart._rect ); } } else g.FillPath( brush, path ); //brush.Dispose(); } // restore the zero line if needed (since the fill tends to cover it up) yAxis.FixZeroLine( g, pane, scaleFactor, rect.Left, rect.Right ); } } // If it's a smooth curve, go ahead and render the path. Otherwise, use the // standard drawcurve method just in case there are missing values. if ( _isSmooth ) { using ( Pen pen = GetPen( pane, scaleFactor ) ) { // Stroke the curve g.DrawCurve( pen, arrPoints, 0, count - 2, tension ); //pen.Dispose(); } } else DrawCurve( g, pane, curve, scaleFactor ); } }
public void Curve_GetRegionScans () { Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) }; GraphicsPath gp = new GraphicsPath (); gp.AddCurve (points); Region region = new Region (gp); // too big, returns 0 Assert.AreEqual (0, region.GetRegionScans (matrix).Length, "GetRegionScans"); }
/// <summary> /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/> /// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>). /// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>; /// the symbols are drawn by the <see cref="Symbol.Draw"/> method. This method /// is normally only called by the Draw method of the /// <see cref="CurveItem"/> object. Note that the <see cref="StepType"/> property /// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true). /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="points">A <see cref="PointPairList"/> of point values representing this /// curve.</param> /// <param name="isY2Axis">A value indicating to which Y axis this curve is assigned. /// true for the "Y2" axis, false for the "Y" axis.</param> public void DrawSmoothFilledCurve( Graphics g, GraphPane pane, PointPairList points, bool isY2Axis, double scaleFactor) { PointF[] arrPoints; int count; if ( this.IsVisible && !this.Color.IsEmpty && points != null && BuildPointsArray( pane, points, isY2Axis, out arrPoints, out count ) && count > 2 ) { Pen pen = new Pen(this.Color, pane.ScaledPenWidth(width, scaleFactor)); pen.DashStyle = this.Style; float tension = this.isSmooth ? this.smoothTension : 0f; // Fill the curve if needed if ( this.Fill.IsVisible ) { GraphicsPath path = new GraphicsPath( FillMode.Winding ); path.AddCurve( arrPoints, 0, count-2, tension ); double yMin = pane.YAxis.Min < 0 ? 0.0 : pane.YAxis.Min; //double yMin = pane.YAxis.Min; CloseCurve( pane, arrPoints, isY2Axis, count, yMin, path ); Brush brush = this.fill.MakeBrush( path.GetBounds() ); g.FillPath( brush, path ); brush.Dispose(); } // Stroke the curve g.DrawCurve( pen, arrPoints, 0, count-2, tension ); } }
private GraphicsPath CreateQuickAccessPath(Point a, Point b, Point c, Point d, Point e, Rectangle bounds, int offsetx, int offsety, Ribbon ribbon) { a.Offset(offsetx, offsety); b.Offset(offsetx, offsety); c.Offset(offsetx, offsety); d.Offset(offsetx, offsety); e.Offset(offsetx, offsety); GraphicsPath path = new GraphicsPath(); if (ribbon.RightToLeft == RightToLeft.No) { path.AddLine(a, b); path.AddArc(new Rectangle(b.X - bounds.Height / 2, b.Y, bounds.Height, bounds.Height), -90, 180); path.AddLine(d, c); if (ribbon.OrbVisible) { path.AddCurve(new Point[] { c, e, a }); } else { path.AddArc(new Rectangle(a.X - bounds.Height / 2, a.Y, bounds.Height, bounds.Height), 90, 180); } } else { /// a-----b a-----b /// | z | z /// c---d c-----d path.AddLine(d, c); path.AddArc(new Rectangle(a.X - bounds.Height / 2, a.Y, bounds.Height, bounds.Height), 90, 180); path.AddLine(a, b); if (ribbon.OrbVisible) { path.AddCurve(new Point[] { b, e, d }); } else { path.AddArc(new Rectangle(b.X - bounds.Height / 2, b.Y, bounds.Height, bounds.Height), -90, 180); } } return path; }
/// <summary> /// Draws the orb on the specified state /// </summary> /// <param name="g">Device to draw</param> /// <param name="ribbon">Ribbon that the orb belongs to</param> /// <param name="r">Layout rectangle for the orb</param> /// <param name="selected">Specifies if the orb should be drawn as selected</param> /// <param name="pressed">Specifies if the orb should be drawn as pressed</param> public void DrawOrb(Graphics g, Rectangle r, Image image, bool selected, bool pressed) { int sweep, start; Point p1, p2, p3; Color bgdark, bgmed, bglight, light; Rectangle rinner = r; rinner.Inflate(-1, -1); Rectangle shadow = r; shadow.Offset(1, 1); shadow.Inflate(2, 2); #region Color Selection if (pressed) { bgdark = ColorTable.OrbPressedBackgroundDark; bgmed = ColorTable.OrbPressedBackgroundMedium; bglight = ColorTable.OrbPressedBackgroundLight; light = ColorTable.OrbPressedLight; } else if (selected) { bgdark = ColorTable.OrbSelectedBackgroundDark; bgmed = ColorTable.OrbSelectedBackgroundDark; bglight = ColorTable.OrbSelectedBackgroundLight; light = ColorTable.OrbSelectedLight; } else { bgdark = ColorTable.OrbBackgroundDark; bgmed = ColorTable.OrbBackgroundMedium; bglight = ColorTable.OrbBackgroundLight; light = ColorTable.OrbLight; } #endregion #region Shadow using (GraphicsPath p = new GraphicsPath()) { p.AddEllipse(shadow); using (PathGradientBrush gradient = new PathGradientBrush(p)) { gradient.WrapMode = WrapMode.Clamp; gradient.CenterPoint = new PointF(shadow.Left + shadow.Width / 2, shadow.Top + shadow.Height / 2); gradient.CenterColor = Color.FromArgb(180, Color.Black); gradient.SurroundColors = new Color[] { Color.Transparent }; Blend blend = new Blend(3); blend.Factors = new float[] { 0f, 1f, 1f }; blend.Positions = new float[] { 0, 0.2f, 1f }; gradient.Blend = blend; g.FillPath(gradient, p); } } #endregion #region Orb Background using (Pen p = new Pen(bgdark, 1)) { g.DrawEllipse(p, r); } using (GraphicsPath p = new GraphicsPath()) { p.AddEllipse(r); using (PathGradientBrush gradient = new PathGradientBrush(p)) { gradient.WrapMode = WrapMode.Clamp; gradient.CenterPoint = new PointF(Convert.ToSingle(r.Left + r.Width / 2), Convert.ToSingle(r.Bottom)); gradient.CenterColor = bglight; gradient.SurroundColors = new Color[] { bgmed }; Blend blend = new Blend(3); blend.Factors = new float[] { 0f, .8f, 1f }; blend.Positions = new float[] { 0, 0.50f, 1f }; gradient.Blend = blend; g.FillPath(gradient, p); } } #endregion #region Bottom round shine Rectangle bshine = new Rectangle(0, 0, r.Width / 2, r.Height / 2); bshine.X = r.X + (r.Width - bshine.Width) / 2; bshine.Y = r.Y + r.Height / 2; using (GraphicsPath p = new GraphicsPath()) { p.AddEllipse(bshine); using (PathGradientBrush gradient = new PathGradientBrush(p)) { gradient.WrapMode = WrapMode.Clamp; gradient.CenterPoint = new PointF(Convert.ToSingle(r.Left + r.Width / 2), Convert.ToSingle(r.Bottom)); gradient.CenterColor = Color.White; gradient.SurroundColors = new Color[] { Color.Transparent }; g.FillPath(gradient, p); } } #endregion #region Upper Glossy using (GraphicsPath p = new GraphicsPath()) { sweep = 160; start = 180 + (180 - sweep) / 2; p.AddArc(rinner, start, sweep); p1 = Point.Round(p.PathData.Points[0]); p2 = Point.Round(p.PathData.Points[p.PathData.Points.Length - 1]); p3 = new Point(rinner.Left + rinner.Width / 2, p2.Y - 3); p.AddCurve(new Point[] { p2, p3, p1 }); using (PathGradientBrush gradient = new PathGradientBrush(p)) { gradient.WrapMode = WrapMode.Clamp; gradient.CenterPoint = p3; gradient.CenterColor = Color.Transparent; gradient.SurroundColors = new Color[] { light }; Blend blend = new Blend(3); blend.Factors = new float[] { .3f, .8f, 1f }; blend.Positions = new float[] { 0, 0.50f, 1f }; gradient.Blend = blend; g.FillPath(gradient, p); } using (LinearGradientBrush b = new LinearGradientBrush(new Point(r.Left, r.Top), new Point(r.Left, p1.Y), Color.White, Color.Transparent)) { Blend blend = new Blend(4); blend.Factors = new float[] { 0f, .4f, .8f, 1f }; blend.Positions = new float[] { 0f, .3f, .4f, 1f }; b.Blend = blend; g.FillPath(b, p); } } #endregion #region Upper Shine /////Lower gloss //using (GraphicsPath p = new GraphicsPath()) //{ // sweep = 140; // start = (180 - sweep) / 2; // p.AddArc(rinner, start, sweep); // p1 = Point.Round(p.PathData.Points[0]); // p2 = Point.Round(p.PathData.Points[p.PathData.Points.Length - 1]); // p3 = new Point(rinner.Left + rinner.Width / 2, p1.Y + 3); // p.AddCurve(new Point[] { p2, p3, p1 }); // g.FillPath(Brushes.White, p); //} ///Upper shine using (GraphicsPath p = new GraphicsPath()) { sweep = 160; start = 180 + (180 - sweep) / 2; p.AddArc(rinner, start, sweep); using (Pen pen = new Pen(Color.White)) { g.DrawPath(pen, p); } } #endregion #region Lower Shine using (GraphicsPath p = new GraphicsPath()) { sweep = 160; start = (180 - sweep) / 2; p.AddArc(rinner, start, sweep); Point pt = Point.Round(p.PathData.Points[0]); Rectangle rrinner = rinner; rrinner.Inflate(-1, -1); sweep = 160; start = (180 - sweep) / 2; p.AddArc(rrinner, start, sweep); using (LinearGradientBrush b = new LinearGradientBrush( new Point(rinner.Left, rinner.Bottom), new Point(rinner.Left, pt.Y - 1), light, Color.FromArgb(50, light))) { g.FillPath(b, p); } //p1 = Point.Round(p.PathData.Points[0]); //p2 = Point.Round(p.PathData.Points[p.PathData.Points.Length - 1]); //p3 = new Point(rinner.Left + rinner.Width / 2, rinner.Bottom - 1); //p.AddCurve(new Point[] { p2, p3, p1 }); //using (LinearGradientBrush b = new LinearGradientBrush( // new Point(rinner.Left, rinner.Bottom + 1), // new Point(rinner.Left, p1.Y), // Color.FromArgb(200, Color.White), Color.Transparent)) //{ // g.FillPath(b, p); //} } #endregion #region Orb Icon if (image != null) { Rectangle irect = new Rectangle(Point.Empty, image.Size); irect.X = r.X + (r.Width - irect.Width) / 2; irect.Y = r.Y + (r.Height - irect.Height) / 2; g.DrawImage(image, irect); } #endregion }
public void AddCurve_LargeTension () { GraphicsPath gp = new GraphicsPath (); gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 0, 2, Single.MaxValue); Assert.AreEqual (7, gp.PointCount, "PointCount"); gp.Dispose (); }
public void Region_Curve_IsInfinite () { Point[] points = new Point[2] { new Point (-4194304, -4194304), new Point (4194304, 4194304) }; GraphicsPath gp = new GraphicsPath (); gp.AddCurve (points); CheckInfiniteBounds (gp); Region region = new Region (gp); Assert.IsFalse (region.IsInfinite (graphic), "IsInfinite"); // note: infinity isn't based on the bounds }
public void AddCurve_NegativeSegments () { GraphicsPath gp = new GraphicsPath (); gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, -1, 0.5f); }
/// <summary> /// The add tab border. /// </summary> /// <param name="path"> /// The path. /// </param> /// <param name="tabBounds"> /// The tab bounds. /// </param> private void AddTabBorder(GraphicsPath path, Rectangle tabBounds) { int spread; int eigth; int sixth; int quarter; if (this.Alignment <= TabAlignment.Bottom) { spread = (int)Math.Floor((decimal)tabBounds.Height * 2 / 3); eigth = (int)Math.Floor((decimal)tabBounds.Height * 1 / 8); sixth = (int)Math.Floor((decimal)tabBounds.Height * 1 / 6); quarter = (int)Math.Floor((decimal)tabBounds.Height * 1 / 4); } else { spread = (int)Math.Floor((decimal)tabBounds.Width * 2 / 3); eigth = (int)Math.Floor((decimal)tabBounds.Width * 1 / 8); sixth = (int)Math.Floor((decimal)tabBounds.Width * 1 / 6); quarter = (int)Math.Floor((decimal)tabBounds.Width * 1 / 4); } switch (this.Alignment) { case TabAlignment.Top: path.AddCurve( new[] { new Point(tabBounds.X, tabBounds.Bottom), new Point(tabBounds.X + sixth, tabBounds.Bottom - eigth), new Point(tabBounds.X + spread - quarter, tabBounds.Y + eigth), new Point(tabBounds.X + spread, tabBounds.Y) }); path.AddLine(tabBounds.X + spread, tabBounds.Y, tabBounds.Right - spread, tabBounds.Y); path.AddCurve( new[] { new Point(tabBounds.Right - spread, tabBounds.Y), new Point(tabBounds.Right - spread + quarter, tabBounds.Y + eigth), new Point(tabBounds.Right - sixth, tabBounds.Bottom - eigth), new Point(tabBounds.Right, tabBounds.Bottom) }); break; case TabAlignment.Bottom: path.AddCurve( new[] { new Point(tabBounds.Right, tabBounds.Y), new Point(tabBounds.Right - sixth, tabBounds.Y + eigth), new Point(tabBounds.Right - spread + quarter, tabBounds.Bottom - eigth), new Point(tabBounds.Right - spread, tabBounds.Bottom) }); path.AddLine(tabBounds.Right - spread, tabBounds.Bottom, tabBounds.X + spread, tabBounds.Bottom); path.AddCurve( new[] { new Point(tabBounds.X + spread, tabBounds.Bottom), new Point(tabBounds.X + spread - quarter, tabBounds.Bottom - eigth), new Point(tabBounds.X + sixth, tabBounds.Y + eigth), new Point(tabBounds.X, tabBounds.Y) }); break; case TabAlignment.Left: path.AddCurve( new[] { new Point(tabBounds.Right, tabBounds.Bottom), new Point(tabBounds.Right - eigth, tabBounds.Bottom - sixth), new Point(tabBounds.X + eigth, tabBounds.Bottom - spread + quarter), new Point(tabBounds.X, tabBounds.Bottom - spread) }); path.AddLine(tabBounds.X, tabBounds.Bottom - spread, tabBounds.X, tabBounds.Y + spread); path.AddCurve( new[] { new Point(tabBounds.X, tabBounds.Y + spread), new Point(tabBounds.X + eigth, tabBounds.Y + spread - quarter), new Point(tabBounds.Right - eigth, tabBounds.Y + sixth), new Point(tabBounds.Right, tabBounds.Y) }); break; case TabAlignment.Right: path.AddCurve( new[] { new Point(tabBounds.X, tabBounds.Y), new Point(tabBounds.X + eigth, tabBounds.Y + sixth), new Point(tabBounds.Right - eigth, tabBounds.Y + spread - quarter), new Point(tabBounds.Right, tabBounds.Y + spread) }); path.AddLine(tabBounds.Right, tabBounds.Y + spread, tabBounds.Right, tabBounds.Bottom - spread); path.AddCurve( new[] { new Point(tabBounds.Right, tabBounds.Bottom - spread), new Point(tabBounds.Right - eigth, tabBounds.Bottom - spread + quarter), new Point(tabBounds.X + eigth, tabBounds.Bottom - sixth), new Point(tabBounds.X, tabBounds.Bottom) }); break; } }
public void AddCurve_OffsetTooLarge () { GraphicsPath gp = new GraphicsPath (); gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 1, 2, 0.5f); }
/// <summary> /// Close off a <see cref="GraphicsPath"/> that defines a curve /// </summary> /// <param name="pane">A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object.</param> /// <param name="curve">A <see cref="LineItem"/> representing this /// curve.</param> /// <param name="arrPoints">An array of <see cref="PointF"/> values in screen pixel /// coordinates representing the current curve.</param> /// <param name="count">The number of points contained in the "arrPoints" /// parameter.</param> /// <param name="yMin">The Y axis value location where the X axis crosses.</param> /// <param name="path">The <see cref="GraphicsPath"/> class that represents the curve.</param> public void CloseCurve( GraphPane pane, CurveItem curve, PointF[] arrPoints, int count, double yMin, GraphicsPath path ) { // For non-stacked lines, the fill area is just the area between the curve and the X axis if ( pane.LineType != LineType.Stack ) { // Determine the current value for the bottom of the curve (usually the Y value where // the X axis crosses) float yBase; Axis yAxis = curve.GetYAxis( pane ); yBase = yAxis.Scale.Transform( yMin ); // Add three points to the path to move from the end of the curve (as defined by // arrPoints) to the X axis, from there to the start of the curve at the X axis, // and from there back up to the beginning of the curve. path.AddLine( arrPoints[count - 1].X, arrPoints[count - 1].Y, arrPoints[count - 1].X, yBase ); path.AddLine( arrPoints[count - 1].X, yBase, arrPoints[0].X, yBase ); path.AddLine( arrPoints[0].X, yBase, arrPoints[0].X, arrPoints[0].Y ); } // For stacked line types, the fill area is the area between this curve and the curve below it else { PointF[] arrPoints2; int count2; float tension = _isSmooth ? _smoothTension : 0f; // Find the next lower curve in the curveList that is also a LineItem type, and use // its smoothing properties for the lower side of the filled area. int index = pane.CurveList.IndexOf( curve ); if ( index > 0 ) { CurveItem tmpCurve; for ( int i = index - 1; i >= 0; i-- ) { tmpCurve = pane.CurveList[i]; if ( tmpCurve is LineItem ) { tension = ( (LineItem)tmpCurve ).Line.IsSmooth ? ( (LineItem)tmpCurve ).Line.SmoothTension : 0f; break; } } } // Build another points array consisting of the low points (which are actually the points for // the curve below the current curve) BuildLowPointsArray( pane, curve, out arrPoints2, out count2 ); // Add the new points to the GraphicsPath path.AddCurve( arrPoints2, 0, count2 - 2, tension ); } }
public void AddCurve_Offset () { GraphicsPath gp = new GraphicsPath (); gp.AddCurve (new PointF[4] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f), new PointF (0f, 10f) }, 1, 2, 0.5f); Assert.AreEqual (7, gp.PointCount, "PointCount"); gp.Dispose (); }
public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds) { int spread; int eigth; int sixth; int quarter; if (this._TabControl.Alignment <= TabAlignment.Bottom) { spread = (int)Math.Floor((decimal)tabBounds.Height * 2 / 3); eigth = (int)Math.Floor((decimal)tabBounds.Height * 1 / 8); sixth = (int)Math.Floor((decimal)tabBounds.Height * 1 / 6); quarter = (int)Math.Floor((decimal)tabBounds.Height * 1 / 4); } else { spread = (int)Math.Floor((decimal)tabBounds.Width * 2 / 3); eigth = (int)Math.Floor((decimal)tabBounds.Width * 1 / 8); sixth = (int)Math.Floor((decimal)tabBounds.Width * 1 / 6); quarter = (int)Math.Floor((decimal)tabBounds.Width * 1 / 4); } switch (this._TabControl.Alignment) { case TabAlignment.Top: path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Bottom) , new Point(tabBounds.X + sixth, tabBounds.Bottom - eigth) , new Point(tabBounds.X + spread - quarter, tabBounds.Y + eigth) , new Point(tabBounds.X + spread, tabBounds.Y) }); path.AddLine(tabBounds.X + spread, tabBounds.Y, tabBounds.Right - spread, tabBounds.Y); path.AddCurve(new Point[] { new Point(tabBounds.Right - spread, tabBounds.Y) , new Point(tabBounds.Right - spread + quarter, tabBounds.Y + eigth) , new Point(tabBounds.Right - sixth, tabBounds.Bottom - eigth) , new Point(tabBounds.Right, tabBounds.Bottom) }); break; case TabAlignment.Bottom: path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Y) , new Point(tabBounds.Right - sixth, tabBounds.Y + eigth) , new Point(tabBounds.Right - spread + quarter, tabBounds.Bottom - eigth) , new Point(tabBounds.Right - spread, tabBounds.Bottom) }); path.AddLine(tabBounds.Right - spread, tabBounds.Bottom, tabBounds.X + spread, tabBounds.Bottom); path.AddCurve(new Point[] { new Point(tabBounds.X + spread, tabBounds.Bottom) , new Point(tabBounds.X + spread - quarter, tabBounds.Bottom - eigth) , new Point(tabBounds.X + sixth, tabBounds.Y + eigth) , new Point(tabBounds.X, tabBounds.Y) }); break; case TabAlignment.Left: path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom) , new Point(tabBounds.Right - eigth, tabBounds.Bottom - sixth) , new Point(tabBounds.X + eigth, tabBounds.Bottom - spread + quarter) , new Point(tabBounds.X, tabBounds.Bottom - spread) }); path.AddLine(tabBounds.X, tabBounds.Bottom - spread, tabBounds.X, tabBounds.Y + spread); path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y + spread) , new Point(tabBounds.X + eigth, tabBounds.Y + spread - quarter) , new Point(tabBounds.Right - eigth, tabBounds.Y + sixth) , new Point(tabBounds.Right, tabBounds.Y) }); break; case TabAlignment.Right: path.AddCurve(new Point[] { new Point(tabBounds.X, tabBounds.Y) , new Point(tabBounds.X + eigth, tabBounds.Y + sixth) , new Point(tabBounds.Right - eigth, tabBounds.Y + spread - quarter) , new Point(tabBounds.Right, tabBounds.Y + spread) }); path.AddLine(tabBounds.Right, tabBounds.Y + spread, tabBounds.Right, tabBounds.Bottom - spread); path.AddCurve(new Point[] { new Point(tabBounds.Right, tabBounds.Bottom - spread) , new Point(tabBounds.Right - eigth, tabBounds.Bottom - spread + quarter) , new Point(tabBounds.X + eigth, tabBounds.Bottom - sixth) , new Point(tabBounds.X, tabBounds.Bottom) }); break; } }
public void AddCurve_SamePointF () { PointF [] points = new PointF [2] { new PointF (1f, 1f), new PointF (1f, 1f) }; GraphicsPath gp = new GraphicsPath (); gp.AddCurve (points); Assert.AreEqual (4, gp.PointCount, "1-PointCount"); gp.AddCurve (points); Assert.AreEqual (7, gp.PointCount, "2-PointCount"); }