private static void AddSegmentToPath(ICurve seg, ref System.Drawing.Drawing2D.GraphicsPath p) { const float radiansToDegrees = (float)(180.0 / Math.PI); LineSegment line = seg as LineSegment; if (line != null) p.AddLine(PointF(line.Start), PointF(line.End)); else { CubicBezierSegment cb = seg as CubicBezierSegment; if (cb != null) p.AddBezier(PointF(cb.B(0)), PointF(cb.B(1)), PointF(cb.B(2)), PointF(cb.B(3))); else { Ellipse ellipse = seg as Ellipse; if (ellipse != null) p.AddArc((float)(ellipse.Center.X - ellipse.AxisA.Length), (float)(ellipse.Center.Y - ellipse.AxisB.Length), (float)(2 * ellipse.AxisA.Length), (float)(2 * ellipse.AxisB.Length), (float)(ellipse.ParStart * radiansToDegrees), (float)((ellipse.ParEnd - ellipse.ParStart) * radiansToDegrees)); } } }
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath) { graphicsPath.AddLine(this.Start, this.End); }
public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds){ switch (this._TabControl.Alignment) { case TabAlignment.Top: path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y); path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right, tabBounds.Y); path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom); break; case TabAlignment.Bottom: path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom); path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom); path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y); break; case TabAlignment.Left: path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom); path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X, tabBounds.Y); path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right, tabBounds.Y); break; case TabAlignment.Right: path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right, tabBounds.Y); path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom); path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom); break; } }
public override void AddTabBorder(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Rectangle tabBounds){ switch (this._TabControl.Alignment) { case TabAlignment.Top: path.AddLine(tabBounds.X, tabBounds.Bottom, tabBounds.X + tabBounds.Height - 4, tabBounds.Y + 2); path.AddLine(tabBounds.X + tabBounds.Height, tabBounds.Y, tabBounds.Right - 3, tabBounds.Y); path.AddArc(tabBounds.Right - 6, tabBounds.Y, 6, 6, 270, 90); path.AddLine(tabBounds.Right, tabBounds.Y + 3, tabBounds.Right, tabBounds.Bottom); break; case TabAlignment.Bottom: path.AddLine(tabBounds.Right, tabBounds.Y, tabBounds.Right, tabBounds.Bottom - 3); path.AddArc(tabBounds.Right - 6, tabBounds.Bottom - 6, 6, 6, 0, 90); path.AddLine(tabBounds.Right - 3, tabBounds.Bottom, tabBounds.X + tabBounds.Height, tabBounds.Bottom); path.AddLine(tabBounds.X + tabBounds.Height - 4, tabBounds.Bottom - 2, tabBounds.X, tabBounds.Y); break; case TabAlignment.Left: path.AddLine(tabBounds.Right, tabBounds.Bottom, tabBounds.X + 3, tabBounds.Bottom); path.AddArc(tabBounds.X, tabBounds.Bottom - 6, 6, 6, 90, 90); path.AddLine(tabBounds.X, tabBounds.Bottom - 3, tabBounds.X, tabBounds.Y + tabBounds.Width); path.AddLine(tabBounds.X + 2, tabBounds.Y + tabBounds.Width - 4, tabBounds.Right, tabBounds.Y); break; case TabAlignment.Right: path.AddLine(tabBounds.X, tabBounds.Y, tabBounds.Right - 2, tabBounds.Y + tabBounds.Width - 4); path.AddLine(tabBounds.Right, tabBounds.Y + tabBounds.Width, tabBounds.Right, tabBounds.Bottom - 3); path.AddArc(tabBounds.Right - 6, tabBounds.Bottom - 6, 6, 6, 0, 90); path.AddLine(tabBounds.Right - 3, tabBounds.Bottom, tabBounds.X, tabBounds.Bottom); break; } }
public override void GetIsoline(System.Drawing.Drawing2D.GraphicsPath g, Logical3D r0, Logical3D r1) { double ax0, ax1, ay0, ay1; if (LogicalToLayerCoordinates(r0, out ax0, out ay0) && LogicalToLayerCoordinates(r1, out ax1, out ay1)) { // add a line when this is a radial ray if (((r0.RX == r1.RX) && !_isXYInterchanged) || ((r0.RY == r1.RY) && _isXYInterchanged)) { g.AddLine((float)ax0, (float)ay0, (float)ax1, (float)ay1); } // add an arc if this is a tangential ray else if (((r0.RY == r1.RY) && !_isXYInterchanged) || ((r0.RX == r1.RX) && _isXYInterchanged)) { double startAngle = 180 * Math.Atan2(_midY - ay0, ax0 - _midX) / Math.PI; double sweepAngle; if (_isXYInterchanged) { sweepAngle = (r1.RY - r0.RY) * 360; if (_isYreverse) sweepAngle = -sweepAngle; } else { sweepAngle = (r1.RX - r0.RX) * 360; if (_isXreverse) sweepAngle = -sweepAngle; } double r = Calc.RMath.Hypot(_midY - ay0, ax0 - _midX); if (r > 0) g.AddArc((float)(_midX - r), (float)(_midY - r), (float)(2 * r), (float)(2 * r), (float)-startAngle, (float)-sweepAngle); } else // if it is neither radial nor tangential { int points = _isXYInterchanged ? (int)(Math.Abs(r1.RY - r0.RY) * 360) : (int)(Math.Abs(r1.RX - r0.RX) * 360); points = Math.Max(1, Math.Min(points, 3600)); // in case there is a rotation more than one turn limit the number of points PointF[] pts = new PointF[points + 1]; for (int i = 0; i <= points; i++) { Logical3D r = new Logical3D(r0.RX + i * (r1.RX - r0.RX) / points, r0.RY + i * (r1.RY - r0.RY) / points); double ax, ay; LogicalToLayerCoordinates(r, out ax, out ay); pts[i] = new PointF((float)ax, (float)ay); } g.AddLines(pts); } } }
/// <summary> /// Resets the specified GraphicsPath object an adds a line to it with the specified values. /// </summary> /// <param name="linePath">The GraphicsPath object to reset.</param> /// <param name="x1">The x-coordinate of the starting point of the line.</param> /// <param name="y1">The y-coordinate of the starting point of the line.</param> /// <param name="x2">The x-coordinate of the endpoint of the line.</param> /// <param name="y2">The y-coordinate of the endpoint of the line.</param> public static void SetLine(System.Drawing.Drawing2D.GraphicsPath linePath, float x1, float y1, float x2, float y2) { linePath.Reset(); linePath.AddLine(x1, y1, x2, y2); }
/// <summary> /// Resets the specified GraphicsPath object an adds a line to it with the specified values. /// </summary> /// <param name="linePath">The GraphicsPath object to reset.</param> /// <param name="p1">The starting point of the line.</param> /// <param name="p2">The endpoint of the line.</param> public static void SetLine(System.Drawing.Drawing2D.GraphicsPath linePath, System.Drawing.PointF p1, System.Drawing.PointF p2) { linePath.Reset(); linePath.AddLine(p1, p2); }
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 static void PolyDraw( System.Drawing.Drawing2D.GraphicsPath pPath, POINT[] lppt, byte[] lpbTypes, int cCount) { int nIndex; POINT pptLastMoveTo = new POINT(); POINT pptPrev = new POINT(); bool bLastMoveToNull = true; // for each of the points we have... for (nIndex = 0; nIndex < cCount; nIndex++) { switch (lpbTypes[nIndex]) { case PT_MOVETO: if (bLastMoveToNull == false && nIndex > 0) { pPath.CloseFigure(); } pptLastMoveTo = lppt[nIndex]; bLastMoveToNull = false; pptPrev = lppt[nIndex]; break; case PT_LINETO | PT_CLOSEFIGURE: pPath.AddLine(pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y); pptPrev = lppt[nIndex]; if (bLastMoveToNull == false) { pPath.CloseFigure(); pptPrev = pptLastMoveTo; } bLastMoveToNull = true; break; case PT_LINETO: pPath.AddLine(pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y); pptPrev = lppt[nIndex]; break; case PT_BEZIERTO | PT_CLOSEFIGURE: //ASSERT(nIndex + 2 <= cCount); pPath.AddBezier( pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y, lppt[nIndex + 1].X, lppt[nIndex + 1].Y, lppt[nIndex + 2].X, lppt[nIndex + 2].Y); nIndex += 2; pptPrev = lppt[nIndex]; if (bLastMoveToNull == false) { pPath.CloseFigure(); pptPrev = pptLastMoveTo; } bLastMoveToNull = true; break; case PT_BEZIERTO: //ASSERT(nIndex + 2 <= cCount); pPath.AddBezier( pptPrev.X, pptPrev.Y, lppt[nIndex].X, lppt[nIndex].Y, lppt[nIndex + 1].X, lppt[nIndex + 1].Y, lppt[nIndex + 2].X, lppt[nIndex + 2].Y); nIndex += 2; pptPrev = lppt[nIndex]; break; } } // If the figure was never closed and should be, // close it now. if (bLastMoveToNull == false && nIndex > 1) { pPath.AddLine(pptPrev.X, pptPrev.Y, pptLastMoveTo.X, pptLastMoveTo.Y); //pPath->CloseFigure(); } }
public override void GetIsoline(System.Drawing.Drawing2D.GraphicsPath path, Logical3D r0, Logical3D r1) { double x0, y0, x1, y1; LogicalToLayerCoordinates(r0, out x0, out y0); LogicalToLayerCoordinates(r1, out x1, out y1); path.AddLine((float)x0, (float)y0, (float)x1, (float)y1); }
public override void GetIsoline(System.Drawing.Drawing2D.GraphicsPath g, Logical3D r0, Logical3D r1) { double ax0, ax1, ay0, ay1; if (LogicalToLayerCoordinates(r0, out ax0, out ay0) && LogicalToLayerCoordinates(r1, out ax1, out ay1)) { g.AddLine((float)ax0, (float)ay0, (float)ax1, (float)ay1); } }
public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath path, EPoint ptStart, float scale) { EPoint ptEnd = ptStart + this._ptTarget; path.AddLine(ptStart.X*scale, ptStart.Y*scale, ptEnd.X*scale, ptEnd.Y*scale); }