本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddArc方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath.AddArc方法的具体用法?C# System.Drawing.Drawing2D.GraphicsPath.AddArc怎么用?C# System.Drawing.Drawing2D.GraphicsPath.AddArc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.AddArc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Round
// 圆角代码
public void Round(System.Drawing.Region region)
{
// -----------------------------------------------------------------------------------------------
// 已经是.net提供给我们的最容易的改窗体的属性了(以前要自己调API)
System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
int x = 0;
int y = 0;
int thisWidth = this.Width;
int thisHeight = this.Height;
int angle = _Radius;
if (angle > 0)
{
System.Drawing.Graphics g = CreateGraphics();
oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
// -----------------------------------------------------------------------------------------------
else
{
oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端
oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边
oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边
oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边
oPath.CloseAllFigures();
Region = new System.Drawing.Region(oPath);
}
}
示例2: DrawRoundRect
/// <summary>
/// 绘制圆角
/// </summary>
/// <param name="g"></param>
/// <param name="p"></param>
/// <param name="X"></param>
/// <param name="Y"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="radius"></param>
public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
gp.CloseFigure();
g.DrawPath(p, gp);
g.FillPath(brush, gp);
gp.Dispose();
}
示例3: DrawRoundRect
public static System.Drawing.Drawing2D.GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
{
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddArc(x, y, radius, radius, 180f, 90f);
path.AddArc(width - radius, y, radius, radius, 270f, 90f);
path.AddArc(width - radius, height - radius, radius, radius, 0f, 90f);
path.AddArc(x, height - radius, radius, radius, 90f, 90f);
path.CloseAllFigures();
return path;
}
示例4: Form1
public Form1(String ime, PocetnaForma pf)
{
InitializeComponent();
igracIme = ime;
this.igraci = pf.igraci;
fruits = new List<Fruit>();
toolStripStatusLabel1.Text = "";
this.DoubleBuffered = true;
selected = false;
pf = new PocetnaForma();
this.pf = pf;
i1 = new Igrac(igracIme);
timer1.Start();
timer2.Start();
//za kopceto da bide okruglo i bez border
System.Drawing.Drawing2D.GraphicsPath ag = new System.Drawing.Drawing2D.GraphicsPath();
ag.AddArc(0, 0, button1.Width, button1.Height, 0, 360);
button1.Region = new Region(ag);
button1.TabStop = false;
button1.FlatStyle = FlatStyle.Flat;
button1.FlatAppearance.BorderSize = 0;
//za play kopceto
System.Drawing.Drawing2D.GraphicsPath ag1 = new System.Drawing.Drawing2D.GraphicsPath();
ag1.AddArc(0, 0, button2.Width, button2.Height, 0, 360);
button2.Region = new Region(ag1);
button2.TabStop = false;
button2.FlatStyle = FlatStyle.Flat;
button2.FlatAppearance.BorderSize = 0;
}
示例5: DrawCurves
/// <summary>
/// Draw curves on graphics with transform and given pen
/// </summary>
static void DrawCurves(
Graphics graphics,
List<PointF[]> curves,
System.Drawing.Drawing2D.Matrix transform,
Pen pen)
{
foreach( PointF[] curve in curves )
{
System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath();
if( curve.Length == 0 )
{
break;
}
if( curve.Length == 1 )
{
gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI );
}
else
{
gPath.AddLines( curve );
}
if( transform != null )
gPath.Transform( transform );
graphics.DrawPath( pen, gPath );
}
}
示例6: DrawRoundRect
// Zeichnet das Rechteck mit abgerundeten Ecken der Termindetails
public void DrawRoundRect(Graphics g, Pen p, float x, float y, float width, float height, float radius)
{
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line
gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner
gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line
gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line
gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner
gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line
gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
gp.CloseFigure();
g.DrawPath(p, gp);
gp.Dispose();
}
示例7: DrawFrame
public static void DrawFrame(System.Drawing.Graphics dc, System.Drawing.RectangleF r, float cornerRadius, System.Drawing.Color color)
{
var pen = new System.Drawing.Pen(color);
if (cornerRadius <= 0)
{
dc.DrawRectangle(pen, ColorPickerUtil.Rect(r));
return;
}
cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Width) - 2);
cornerRadius = (float)System.Math.Min(cornerRadius, System.Math.Floor(r.Height) - 2);
var path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddArc(r.X, r.Y, cornerRadius, cornerRadius, 180, 90);
path.AddArc(r.Right - cornerRadius, r.Y, cornerRadius, cornerRadius, 270, 90);
path.AddArc(r.Right - cornerRadius, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 0, 90);
path.AddArc(r.X, r.Bottom - cornerRadius, cornerRadius, cornerRadius, 90, 90);
path.CloseAllFigures();
dc.DrawPath(pen, path);
}
示例8: ToGraphicsPath
/// <summary>
/// Converts this structure to a GraphicsPath object, used to draw to a Graphics device.
/// Consider that you can create a Region with a GraphicsPath object using one of the Region constructor.
/// </summary>
/// <returns></returns>
public System.Drawing.Drawing2D.GraphicsPath ToGraphicsPath()
{
if (mRectangle.IsEmpty)
return new System.Drawing.Drawing2D.GraphicsPath();
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
if (mRoundValue == 0)
{
//Remove 1 from height and width to draw the border in the right location
//path.AddRectangle(new Rectangle(new Point(mRectangle.X - 1, mRectangle.Y - 1), mRectangle.Size));
path.AddRectangle(mRectangle);
}
else
{
int x = mRectangle.X;
int y = mRectangle.Y;
int lineShift = 0;
int lineShiftX2 = 0;
//Basically the RoundValue is a percentage of the line to curve, so I simply multiply it with the lower side (height or width)
if (mRectangle.Height < mRectangle.Width)
{
lineShift = (int)((double)mRectangle.Height * mRoundValue);
lineShiftX2 = lineShift * 2;
}
else
{
lineShift = (int)((double)mRectangle.Width * mRoundValue);
lineShiftX2 = lineShift * 2;
}
//Top
path.AddLine(lineShift + x, 0 + y, (mRectangle.Width - lineShift) + x, 0 + y);
//Angle Top Right
path.AddArc((mRectangle.Width - lineShiftX2) + x, 0 + y,
lineShiftX2, lineShiftX2,
270, 90);
//Right
path.AddLine(mRectangle.Width + x, lineShift + y, mRectangle.Width + x, (mRectangle.Height - lineShift) + y);
//Angle Bottom Right
path.AddArc((mRectangle.Width - lineShiftX2) + x, (mRectangle.Height - lineShiftX2) + y,
lineShiftX2, lineShiftX2,
0, 90);
//Bottom
path.AddLine((mRectangle.Width - lineShift) + x, mRectangle.Height + y, lineShift + x, mRectangle.Height + y);
//Angle Bottom Left
path.AddArc(0 + x, (mRectangle.Height - lineShiftX2) + y,
lineShiftX2, lineShiftX2,
90, 90);
//Left
path.AddLine(0 + x, (mRectangle.Height - lineShift) + y, 0 + x, lineShift + y);
//Angle Top Left
path.AddArc(0 + x, 0 + y,
lineShiftX2, lineShiftX2,
180, 90);
}
return path;
}
示例9: DrawRoundedRectangleOutlined
public static void DrawRoundedRectangleOutlined(Graphics gfxObj, Pen penObj, float X, float Y, float RectWidth, float RectHeight, float CornerRadius)
{
RectWidth--;
RectHeight--;
System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
gfxPath.AddLine(X + CornerRadius, Y, X + RectWidth - (CornerRadius * 2), Y);
gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y, CornerRadius * 2, CornerRadius * 2, 270, 90);
gfxPath.AddLine(X + RectWidth, Y + CornerRadius, X + RectWidth, Y + RectHeight - (CornerRadius * 2));
gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 0, 90);
gfxPath.AddLine(X + RectWidth - (CornerRadius * 2), Y + RectHeight, X + CornerRadius, Y + RectHeight);
gfxPath.AddArc(X, Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 90, 90);
gfxPath.AddLine(X, Y + RectHeight - (CornerRadius * 2), X, Y + CornerRadius);
gfxPath.AddArc(X, Y, CornerRadius * 2, CornerRadius * 2, 180, 90);
gfxPath.CloseFigure();
gfxObj.DrawPath(penObj, gfxPath);
gfxPath.Dispose();
}
示例10: GetRoundedRect
/// <summary>
/// Creates a rounded corner rectangle from a regular rectangel
/// </summary>
/// <param name="baseRect"></param>
/// <param name="radius"></param>
/// <returns></returns>
private System.Drawing.Drawing2D.GraphicsPath GetRoundedRect(RectangleF baseRect, float radius)
{
if ((radius <= 0.0F) || radius >= ((Math.Min(baseRect.Width, baseRect.Height)) / 2.0))
{
System.Drawing.Drawing2D.GraphicsPath mPath = new System.Drawing.Drawing2D.GraphicsPath();
mPath.AddRectangle(baseRect);
mPath.CloseFigure();
return mPath;
}
float diameter = radius * 2.0F;
SizeF sizeF = new SizeF(diameter, diameter);
RectangleF arc = new RectangleF(baseRect.Location, sizeF);
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
// top left arc
path.AddArc(arc, 180, 90);
// top right arc
arc.X = baseRect.Right - diameter;
path.AddArc(arc, 270, 90);
// bottom right arc
arc.Y = baseRect.Bottom - diameter;
path.AddArc(arc, 0, 90);
// bottom left arc
arc.X = baseRect.Left;
path.AddArc(arc, 90, 90);
path.CloseFigure();
return path;
}
示例11: Fill
/// <summary>
/// Fill a closed path composed of several drawing operations
/// </summary>
/// <param name="canvas"></param>
public void Fill(System.Drawing.Graphics canvas)
{
System.Drawing.Drawing2D.GraphicsPath path;
path = new System.Drawing.Drawing2D.GraphicsPath();
for (int i = 0; i < m_drawings.Count; i++)
{
switch (m_drawings[i].Type)
{
case DrawingType.Line:
{
path.AddLine(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[1].x, m_drawings[i].Points[1].y);
break;
}
case DrawingType.Arc:
{
double startAngle, endAngle;
startAngle = System.Math.Atan2(m_drawings[i].Points[2].y - (m_drawings[i].Points[1].y + m_drawings[i].Points[0].y) / 2, m_drawings[i].Points[2].x - (m_drawings[i].Points[1].x + m_drawings[i].Points[0].x) / 2);
if (startAngle < 0)
{
startAngle += System.Math.PI * 2;
}
startAngle = (startAngle / Math.PI) * 180;
endAngle = System.Math.Atan2(m_drawings[i].Points[3].y - (m_drawings[i].Points[1].y + m_drawings[i].Points[0].y) / 2, m_drawings[i].Points[3].x - (m_drawings[i].Points[1].x + m_drawings[i].Points[0].x) / 2);
if (endAngle < 0)
{
endAngle += System.Math.PI * 2;
}
endAngle = (endAngle / Math.PI) * 180;
path.AddArc(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[1].x - m_drawings[i].Points[0].x, m_drawings[i].Points[1].y - m_drawings[i].Points[0].y, (float)startAngle, Math.Abs((float)(endAngle - startAngle)));
break;
}
case DrawingType.Bezier:
{
path.AddBezier(m_drawings[i].Points[0].x, m_drawings[i].Points[0].y, m_drawings[i].Points[2].x, m_drawings[i].Points[2].y, m_drawings[i].Points[3].x, m_drawings[i].Points[3].y, m_drawings[i].Points[1].x, m_drawings[i].Points[1].y);
break;
}
}
}
canvas.FillPath(m_style.fillingStyle, path);
}
示例12: CreateArc2D
/// <summary>
/// Creates a GraphicsPath object and adds an arc to it with the specified arc values and closure type.
/// </summary>
/// <param name="x">The x coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
/// <param name="y">The y coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.</param>
/// <param name="height">The height of the rectangular region that defines the ellipse from which the arc is drawn.</param>
/// <param name="width">The width of the rectangular region that defines the ellipse from which the arc is drawn.</param>
/// <param name="start">The starting angle of the arc measured in degrees.</param>
/// <param name="extent">The angular extent of the arc measured in degrees.</param>
/// <param name="arcType">The closure type for the arc.</param>
/// <returns>Returns a new GraphicsPath object that contains the arc path.</returns>
public static System.Drawing.Drawing2D.GraphicsPath CreateArc2D(float x, float y, float height, float width, float start, float extent, int arcType)
{
System.Drawing.Drawing2D.GraphicsPath arc2DPath = new System.Drawing.Drawing2D.GraphicsPath();
switch (arcType)
{
case OPEN:
arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
break;
case CLOSED:
arc2DPath.AddArc(x, y, height, width, start * -1, extent * -1);
arc2DPath.CloseFigure();
break;
case PIE:
arc2DPath.AddPie(x, y, height, width, start * -1, extent * -1);
break;
default:
break;
}
return arc2DPath;
}
示例13: DrawFilled
/// <summary>
/// Draws a segment filled.
/// </summary>
public void DrawFilled(C2DSegment Segment, Graphics graphics, Brush brush)
{
C2DRect Rect = new C2DRect();
int nStartAngle = 0;
int nSweepAngle = 0;
GetArcParameters(Segment.Arc, Rect, ref nStartAngle, ref nSweepAngle);
if (nSweepAngle == 0)
nSweepAngle = 1;
int Width = (int)Rect.Width();
if (Width == 0)
Width = 1;
int Height = (int)Rect.Height();
if (Height == 0)
Height = 1;
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddArc((int)Rect.TopLeft.x, (int)Rect.BottomRight.y,
Width, Height, nStartAngle, nSweepAngle);
C2DPoint ptFrom = Segment.Arc.Line.GetPointFrom();
C2DPoint ptTo = Segment.Arc.Line.GetPointTo();
ScaleAndOffSet(ptFrom);
ScaleAndOffSet(ptTo);
gp.AddLine((int)ptTo.x, (int)ptTo.y, (int)ptFrom.x, (int)ptFrom.y);
graphics.FillPath(brush, gp);
}
示例14: CreateRoundedGraphicsPath
/// <summary>角の丸い矩形のGraphicsPathを生成する</summary>
public static System.Drawing.Drawing2D.GraphicsPath CreateRoundedGraphicsPath(RectangleF bounds, float xRadius, float yRadius) {
float left = bounds.X;
float top = bounds.Y;
float right = bounds.Right;
float bottom = bounds.Bottom;
var path = new System.Drawing.Drawing2D.GraphicsPath();
path.StartFigure();
path.AddArc(left, top, xRadius * 2, yRadius * 2, 180, 90);
path.AddArc(right - xRadius * 2, top, xRadius * 2, yRadius * 2, 270, 90);
path.AddArc(right - xRadius * 2, bottom - yRadius * 2, xRadius * 2, yRadius * 2, 0, 90);
path.AddArc(left, bottom - yRadius * 2, xRadius * 2, xRadius * 2, 90, 90);
path.CloseFigure();
return path;
}
示例15: DrawRoundedRectangle
public static void DrawRoundedRectangle(Graphics gfx, Rectangle Bounds, int CornerRadius, Pen DrawPen, Color FillColor)
{
System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
DrawPen.EndCap = DrawPen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
gfxPath.AddArc(Bounds.X, Bounds.Y, CornerRadius, CornerRadius, 180, 90);
gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y, CornerRadius, CornerRadius, 270, 90);
gfxPath.AddArc(Bounds.X + Bounds.Width - CornerRadius, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
gfxPath.AddArc(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
gfxPath.AddLine(Bounds.X, Bounds.Y + Bounds.Height - CornerRadius, Bounds.X, Bounds.Y + CornerRadius / 2);
gfx.FillPath(new SolidBrush(FillColor), gfxPath);
gfx.DrawPath(DrawPen, gfxPath);
}