本文整理汇总了C#中System.Drawing.Graphics.DrawArc方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.DrawArc方法的具体用法?C# Graphics.DrawArc怎么用?C# Graphics.DrawArc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.DrawArc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
/// <summary>
/// Draw rectangle
/// </summary>
/// <param name="g"></param>
public override void Draw(Graphics g)
{
Pen pen = new Pen(Color, PenWidth);
Rectangle _rect = new Rectangle();
_rect = DrawRectangle.GetNormalizedRectangle(Rectangle);
int x = _rect.X;
int y = _rect.Y;
int w = _rect.Width;
int h = _rect.Height;
int hElipse = (w/5);
int hArco = hElipse / 2;
int hReta = h - hArco;
// g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
g.DrawArc(pen, x, y, w, hElipse, 0, 360);
g.DrawArc(pen, x, y + hReta - hArco , w, hElipse, 360, 180);
Point SE = new Point(x, y + hArco); //SuperiorEsquerdo
Point IE = new Point(x, y + hReta); //InferioriEsquerdo
Point SD = new Point(x + w, y + hArco); //SuperiorDireito
Point ID = new Point(x + w, y + hReta); //InferiorDireito
g.DrawLine(pen, SE, IE);
g.DrawLine(pen, SD, ID);
//g.DrawRectangle(pen, x, y, w, h);
pen.Dispose();
}
示例2: Draw
/// <summary>
/// Draw rectangle
/// </summary>
/// <param name="g"></param>
public override void Draw(Graphics g)
{
Pen pen = new Pen(Color, PenWidth);
Rectangle _rect = new Rectangle();
_rect = DrawRectangle.GetNormalizedRectangle(Rectangle);
int x = _rect.X;
int y = _rect.Y;
int w = _rect.Width;
int h = _rect.Height;
int wArc = (w/6);
int wArc2 = wArc * 2;
int wReta = w - wArc;
// g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);
Point SE = new Point(x, y); //SuperiorEsquerdo
Point SD = new Point(x + wReta, y); //SuperiorDireito
Point IE = new Point(x, y + h); //InferioriEsquerdo
Point ID = new Point(x + wReta, y + h); //InferiorDireito
g.DrawLine(pen, SE, SD);
g.DrawLine(pen, IE, ID);
//g.DrawRectangle(pen, x, y, w, h);
pen.Dispose();
}
示例3: RepertoryImage
public static void RepertoryImage(Graphics drawDestination)
{
StringFormat itemStringFormat = new StringFormat();
RectangleF itemBox = new RectangleF(15, 30, 50, 20);
itemStringFormat.Alignment = StringAlignment.Center;
itemStringFormat.LineAlignment = StringAlignment.Center;
drawDestination.DrawLine(Pens.LightGray,40,10,40,70);
if (mMscStyle == MscStyle.SDL){
PointF[] statePolygon = new PointF[6];
statePolygon[0] = new PointF(5,40);
statePolygon[1] = new PointF(15,30);
statePolygon[2] = new PointF(65,30);
statePolygon[3] = new PointF(75,40);
statePolygon[4] = new PointF(65,50);
statePolygon[5] = new PointF(15,50);
drawDestination.FillPolygon(Brushes.White,statePolygon);
drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
drawDestination.DrawPolygon(Pens.Black,statePolygon);
}
else if(mMscStyle == MscStyle.UML2){
drawDestination.FillRectangle(Brushes.White,itemBox);
drawDestination.FillEllipse(Brushes.White,5,30,20,20);
drawDestination.FillEllipse(Brushes.White,55,30,20,20);
drawDestination.DrawLine(Pens.Black,15,30,65,30);
drawDestination.DrawLine(Pens.Black,15,50,65,50);
drawDestination.DrawArc(Pens.Black,5,30,20,20,90,180);
drawDestination.DrawArc(Pens.Black,55,30,20,20,270,180);
drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
}
itemStringFormat.Dispose();
}
示例4: RenderClock
public static void RenderClock(RectangleF area, Graphics graphics, bool isPreview)
{
int tempBrushWeight = isPreview ? 2 : brushWeight;
int tempSpacing = isPreview ? 4 : spacing;
Pen penSecond = new Pen(new SolidBrush(Color.FromArgb(alpha, secondColor)), tempBrushWeight);
Pen penMinute = new Pen(new SolidBrush(Color.FromArgb(alpha, minuteColor)), tempBrushWeight);
Pen penHour = new Pen(new SolidBrush(Color.FromArgb(alpha, hourColor)), tempBrushWeight);
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
// Formula
// 1. Subdivide the circle by the total count of each sec, min or hours
// 2. Multiply the value from 1. by the current sec, min or hour
// 3. ==> For ex, for sec (360/60)*current second
DateTime now = DateTime.Now;
// Draw second arc
// For smooth animation consider the current seconds in terms of floating point number like below instead of this --> graphics.DrawArc(penSecond, area, -90f, 6*now.Second);
graphics.DrawArc(penSecond, area, -90f, 6F * ((now.Second + now.Millisecond / 1000F)));
// Draw minute arc
graphics.DrawArc(penMinute, new RectangleF(area.X + tempSpacing * 2, area.Y + tempSpacing * 2, area.Width - tempSpacing * 4, area.Height - tempSpacing * 4), -90f, 6F * (now.Minute + now.Second / 60F));
int hour = enable24HourFormat ? int.Parse(now.ToString("HH")) : int.Parse(now.ToString("%h"));
float hourMultiplier = enable24HourFormat ? 360 / 24f : 360 / 12f;
// Draw hour arc
graphics.DrawArc(penHour, new RectangleF(area.X + tempSpacing * 4, area.Y + tempSpacing * 4, area.Width - tempSpacing * 8, area.Height - tempSpacing * 8), -90f, hourMultiplier * (hour + now.Minute / 60F));
graphics.Flush();
}
示例5: DrawInsetCircle
public static void DrawInsetCircle(ref Graphics g, Rectangle r, Pen p)
{
Pen p1 = new Pen(getDarkColor(p.Color, 50));
Pen p2 = new Pen(getLightColor(p.Color, 50));
for (int i = 0; i < p.Width; i++) {
Rectangle r1 = new Rectangle(r.X + i, r.Y + i, r.Width - i * 2, r.Height - i * 2);
g.DrawArc(p2, r1, -45, 180);
g.DrawArc(p1, r1, 135, 180);
}
}
示例6: RepertoryImage
public static void RepertoryImage(Graphics drawDestination)
{
if (mMscStyle==MscStyle.UML2){
StringFormat itemStringFormat = new StringFormat();
RectangleF itemBox = new RectangleF(5, 20, 30, 15);
itemStringFormat.Alignment = StringAlignment.Near;
itemStringFormat.LineAlignment = StringAlignment.Near;
PointF[] statePolygon = new PointF[5];
statePolygon[0] = new PointF(5,20);
statePolygon[1] = new PointF(40,20);
statePolygon[2] = new PointF(40,30);
statePolygon[3] = new PointF(35,35);
statePolygon[4] = new PointF(5,35);
drawDestination.FillRectangle(Brushes.White,5,20,70,40);
drawDestination.DrawString("ref",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
drawDestination.DrawPolygon(Pens.Black,statePolygon);
itemBox = new RectangleF(5, 30, 70, 30);
itemStringFormat.Alignment = StringAlignment.Center;
itemStringFormat.LineAlignment = StringAlignment.Center;
drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
drawDestination.DrawRectangle(Pens.Black,5,20,70,40);
itemStringFormat.Dispose();
}
else if (mMscStyle==MscStyle.SDL){
StringFormat itemStringFormat = new StringFormat();
RectangleF itemBox = new RectangleF(10, 25, 60, 30);
itemStringFormat.Alignment = StringAlignment.Center;
itemStringFormat.LineAlignment = StringAlignment.Center;
drawDestination.FillPie(Brushes.White,5,20,10,10,180,90);
drawDestination.FillPie(Brushes.White,5,50,10,10,90,90);
drawDestination.FillPie(Brushes.White,65,20,10,10,270,90);
drawDestination.FillPie(Brushes.White,65,50,10,10,0,90);
drawDestination.FillRectangle(Brushes.White, 5, 25, 5, 30);
drawDestination.FillRectangle(Brushes.White, 70, 25, 5, 30);
drawDestination.FillRectangle(Brushes.White, 10, 20, 60, 40);
drawDestination.DrawLine(Pens.Black,10,20,70,20);
drawDestination.DrawLine(Pens.Black,5,25,5,55);
drawDestination.DrawLine(Pens.Black,10,60,70,60);
drawDestination.DrawLine(Pens.Black,75,25,75,55);
drawDestination.DrawArc(Pens.Black,5,20,10,10,180,90);
drawDestination.DrawArc(Pens.Black,5,50,10,10,90,90);
drawDestination.DrawArc(Pens.Black,65,20,10,10,270,90);
drawDestination.DrawArc(Pens.Black,65,50,10,10,0,90);
drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
}
}
示例7: DrawInsetCircle
public static void DrawInsetCircle(ref Graphics g, Rectangle r, Pen p)
{
Pen p1 = new Pen(getDarkColor(p.Color, 50));
Pen p2 = new Pen(getLightColor(p.Color, 50));
for (int i = 0; i < p.Width; i++)
{
Rectangle r1 = new Rectangle(r.X + i, r.Y + i, r.Width - i * 2, r.Height - i * 2);
g.DrawArc(p2, r1, -45, 180);
g.DrawArc(p1, r1, 135, 180);
SolidBrush pointer = new SolidBrush(Color.DarkSlateGray);
g.FillEllipse(pointer, r1);
}
}
示例8: DrawGearOutline
private void DrawGearOutline(Graphics g, PointF center, float scale, float radius,
float baseRadius, float addendum, float dedendum, int numTeeth, float toothPhase)
{
g.DrawArc(Pens.Yellow,
new RectangleF(
center.X - baseRadius * scale,
center.Y - baseRadius * scale,
baseRadius * 2 * scale,
baseRadius * 2 * scale),
0, 360);
g.DrawArc(Pens.Black,
new RectangleF(
center.X - radius * scale,
center.Y - radius * scale,
radius * 2 * scale,
radius * 2 * scale),
0, 360);
g.DrawArc(Pens.LightGray,
new RectangleF(
center.X - (radius - dedendum) * scale,
center.Y - (radius - dedendum) * scale,
(radius * 2 - dedendum * 2) * scale,
(radius * 2 - dedendum * 2) * scale),
0, 360);
g.DrawArc(Pens.LightGray,
new RectangleF(
center.X - (radius + addendum) * scale,
center.Y - (radius + addendum) * scale,
(radius * 2 + addendum * 2) * scale,
(radius * 2 + addendum * 2) * scale),
0, 360);
g.DrawLine(Pens.Magenta, new PointF(center.X - 3, center.Y - 3), new PointF(center.X + 3, center.Y + 3));
g.DrawLine(Pens.Magenta, new PointF(center.X - 3, center.Y + 3), new PointF(center.X + 3, center.Y - 3));
for (int i = 0; i < numTeeth; ++i)
{
double dx = Math.Sin((i + toothPhase) * Math.PI * 2 / numTeeth);
double dy = -Math.Cos((i + toothPhase) * Math.PI * 2 / numTeeth);
g.DrawLine(
Pens.LightGray,
new PointF(
(float)(center.X + dx * (radius - dedendum) * scale),
(float)(center.Y + dy * (radius - dedendum) * scale)),
new PointF(
(float)(center.X + dx * (radius + addendum) * scale),
(float)(center.Y + dy * (radius + addendum) * scale)));
}
}
示例9: OnRender
public override void OnRender(Graphics g)
{
base.OnRender(g);
if (wprad == 0 || Overlay.Control == null)
return;
// if we have drawn it, then keep that color
if (!initcolor.HasValue)
Color = Color.White;
//wprad = 300;
// undo autochange in mouse over
//if (Pen.Color == Color.Blue)
// Pen.Color = Color.White;
double width = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Width, 0)) * 1000.0);
double height = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Height, 0)) * 1000.0);
double m2pixelwidth = Overlay.Control.Width / width;
double m2pixelheight = Overlay.Control.Height / height;
GPoint loc = new GPoint((int)(LocalPosition.X - (m2pixelwidth * wprad * 2)), LocalPosition.Y);// MainMap.FromLatLngToLocal(wpradposition);
//if (m2pixelheight > 0.5)
g.DrawArc(Pen, new System.Drawing.Rectangle(LocalPosition.X - Offset.X - (int)(Math.Abs(loc.X - LocalPosition.X) / 2), LocalPosition.Y - Offset.Y - (int)Math.Abs(loc.X - LocalPosition.X) / 2, (int)Math.Abs(loc.X - LocalPosition.X), (int)Math.Abs(loc.X - LocalPosition.X)), 0, 360);
g.FillPie(new SolidBrush(Color.FromArgb(25,Color.Red)), LocalPosition.X - Offset.X - (int)(Math.Abs(loc.X - LocalPosition.X) / 2), LocalPosition.Y - Offset.Y - (int)Math.Abs(loc.X - LocalPosition.X) / 2, Math.Abs(loc.X - LocalPosition.X), Math.Abs(loc.X - LocalPosition.X), 0, 360);
}
示例10: DrawOn
public override void DrawOn(Graphics graphics)
{
// WARNING! If you end up using graphics.DrawArc() to draw your ovals,
// be careful that you don't give it a zero width and height. If you do,
// you'll see an ugly red "X" instead of your pretty drawing canvas.
graphics.DrawArc(_pen, _center.X - _radius, _center.Y - _radius, _diameter, _diameter, 0, 360);
}
示例11: Draw
public override void Draw(Graphics g)
{
using(Pen p = new Pen(penColor,penWidth))
{
g.DrawArc(p, bounding, angle1, angle2);
}
}
示例12: DrawArc
public static void DrawArc(Graphics G, Pen P, double X, double Y, double R, double beta0, double alpha)
{
RectangleF Rect = new RectangleF(
(float)(X - Math.Abs(R)), (float)(Y - Math.Abs(R)),
(float)(2 * Math.Abs(R)), (float)(2 * Math.Abs(R)));
G.DrawArc(P, Rect, (float)(beta0 * 180 / Math.PI), (float)(alpha * 180 / Math.PI));
}
示例13: Draw
public override void Draw(Graphics g)
{
RectangleF rect = rectComponent.TopLeftCorner.CloneAndAdd(0, offSet).MakeRectangleFTill(rectComponent.BottomRightCorner.CloneAndAdd(0, -offSet));
RectangleF upperRect = rectComponent.TopLeftCorner.MakeRectangleFTill(rectComponent.TopLeftCorner.CloneAndAdd(rectComponent.Width, 2 * offSet));
RectangleF lowerRect = rectComponent.BottomRightCorner.CloneAndAdd(-rectComponent.Width, -2 * offSet).MakeRectangleFTill(rectComponent.BottomRightCorner);
using (LinearGradientBrush brush =
new LinearGradientBrush(rect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
{
g.FillRectangle(brush, rect);
g.DrawRectangle(ViewFactory.BorderPen, rect.X, rect.Y, rect.Width, rect.Height);
}
using (LinearGradientBrush brush =
new LinearGradientBrush(upperRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
{
g.FillEllipse(brush, upperRect);
g.DrawEllipse(ViewFactory.BorderPen, upperRect.X, upperRect.Y, upperRect.Width, upperRect.Height);
}
using (LinearGradientBrush brush =
new LinearGradientBrush(lowerRect, ViewFactory.GradStartColor, ViewFactory.GradEndColor, 90.0f))
{
g.FillEllipse(brush, lowerRect);
g.DrawArc(ViewFactory.BorderPen, lowerRect, 0, 180);
}
base.Draw(g);
}
示例14: Draw
public override void Draw(RectangleF rect)
{
Graphics g = new Graphics();
//g.Clear(Color.White);
// Create a pen object:
Pen aPen = new Pen(Color.Blue, 1 / g.DpiX);
// Create a brush object with a transparent red color:
SolidBrush aBrush = new SolidBrush(Color.Red);
g.PageUnit = GraphicsUnit.Inch;
g.PageScale = 2;
g.RenderingOrigin = new PointF(0.5f,0.0f);
// Draw a rectangle:
g.DrawRectangle(aPen, .20f, .20f, 1.00f, .50f);
// Draw a filled rectangle:
g.FillRectangle(aBrush, .20f, .90f, 1.00f, .50f);
// Draw ellipse:
g.DrawEllipse(aPen, new RectangleF(.20f, 1.60f, 1.00f, .50f));
// Draw filled ellipse:
g.FillEllipse(aBrush, new RectangleF(1.70f, .20f, 1.00f, .50f));
// Draw arc:
g.DrawArc(aPen, new RectangleF(1.70f, .90f, 1.00f, .50f), -90, 180);
// Draw filled pie pieces
g.FillPie(aBrush, 1.70f, 1.60f, 1.00f, 1.00f, -90, 90);
g.FillPie(Brushes.Green, 1.70f, 1.60f, 1.00f, 1.00f, -90, -90);
g.Dispose();
}
示例15: Draw
public override void Draw(Graphics G)
{
SFPoint P1;
float rd1, rd2;
if (radPt.X == 0)
{
rd1 = Math.Abs(radius * ratio);
rd2 = radius;
}
else
{
rd1 = radius;
rd2 = Math.Abs(radius * ratio);
}
P1 = Converter.GetPoint(Point1);
rd1 = rd1 * Converter.FScale;
rd2 = rd2 * Converter.FScale;
P1.X = P1.X - rd1;
P1.Y = P1.Y - rd2;
Color RealColor = DXFConst.EntColor(this, Converter.FParams.Insert);
if (RealColor == DXFConst.clNone) RealColor = Color.Black;
float sA = startAngle, eA = endAngle;
//if(endAngle < startAngle) sA = Conversion_Angle(sA);
eA -= sA;
if (FVisible)
{
if (eA == 0) G.DrawEllipse(new Pen(RealColor, 1), P1.X, P1.Y, rd1 * 2, rd2 * 2);
else G.DrawArc(new Pen(RealColor, 1), P1.X, P1.Y, rd1 * 2, rd2 * 2, 0, 360);//sA, eA);
}
}