本文整理汇总了C#中GraphicsPath.StartFigure方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.StartFigure方法的具体用法?C# GraphicsPath.StartFigure怎么用?C# GraphicsPath.StartFigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.StartFigure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateRoundedRectangleRegion
private Region CreateRoundedRectangleRegion(int radius, Rectangle rectangle)
{
using (GraphicsPath Path = new GraphicsPath())
{
int Radius2 = (radius * 2);
Path.FillMode = FillMode.Winding;
Path.StartFigure();
Path.AddArc(rectangle.X, rectangle.Y, Radius2, Radius2, 180, 90);
Path.AddLine(rectangle.X + radius, rectangle.Y, rectangle.Right - radius, rectangle.Y);
Path.AddArc(rectangle.Right - Radius2 - 1, rectangle.Y, Radius2, Radius2, 270, 90);
Path.AddLine(rectangle.Right, rectangle.Y + radius, rectangle.Right, rectangle.Bottom - radius);
Path.AddArc(rectangle.Right - Radius2 - 1, rectangle.Bottom - Radius2 - 1, Radius2, Radius2, 0, 90);
Path.AddLine(rectangle.Right - radius, rectangle.Bottom, rectangle.X + radius, rectangle.Bottom);
Path.AddArc(rectangle.X, rectangle.Bottom - Radius2 - 1, Radius2, Radius2, 90, 90);
Path.AddLine(rectangle.X, rectangle.Bottom - radius, rectangle.X, rectangle.Y + radius);
Path.CloseFigure();
return new Region(Path);
}
}
示例2: RoundRect
public static GraphicsPath RoundRect(Rectangle Rect, int Rounding, RoundingStyle Style = RoundingStyle.All)
{
GraphicsPath GP = new GraphicsPath();
int AW = Rounding * 2;
GP.StartFigure();
if (Rounding == 0)
{
GP.AddRectangle(Rect);
GP.CloseAllFigures();
return GP;
}
switch (Style)
{
case RoundingStyle.All:
GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
break;
case RoundingStyle.Top:
GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
break;
case RoundingStyle.Bottom:
GP.AddLine(new Point(Rect.X, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
break;
case RoundingStyle.Left:
GP.AddArc(new Rectangle(Rect.X, Rect.Y, AW, AW), -180, 90);
GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
GP.AddArc(new Rectangle(Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 90, 90);
break;
case RoundingStyle.Right:
GP.AddLine(new Point(Rect.X, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y));
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
break;
case RoundingStyle.TopRight:
GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Y, AW, AW), -90, 90);
GP.AddLine(new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height - 1), new Point(Rect.X + Rect.Width, Rect.Y + Rect.Height));
GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
break;
case RoundingStyle.BottomRight:
GP.AddLine(new Point(Rect.X, Rect.Y + 1), new Point(Rect.X, Rect.Y));
GP.AddLine(new Point(Rect.X + Rect.Width - 1, Rect.Y), new Point(Rect.X + Rect.Width, Rect.Y));
GP.AddArc(new Rectangle(Rect.Width - AW + Rect.X, Rect.Height - AW + Rect.Y, AW, AW), 0, 90);
GP.AddLine(new Point(Rect.X + 1, Rect.Y + Rect.Height), new Point(Rect.X, Rect.Y + Rect.Height));
break;
}
GP.CloseAllFigures();
return GP;
}
示例3: panel1_Paint
public void panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.SmoothingMode = SmoothingMode.HighQuality;
Pen p = new Pen(c.GetPanel1().ForeColor, 3);
p.LineJoin = LineJoin.Bevel;
string selectedData = "" + c.GetComboBox1().SelectedItem;
SizeF stringsize = g.MeasureString(selectedData, c.GetPanel1().Font);
g.DrawString(selectedData, c.GetPanel1().Font, p.Brush, new Point(c.GetPanel1().Width - (int)stringsize.Width, 0));
Console.WriteLine(selectedData);
switch (c.GetComboBox1().SelectedIndex)
{
case 0:
{
g.TranslateTransform(0, c.GetPanel1().Height);
Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().heartRate / 1.5 + 5));
PointsHeartrate.Add(newPoint);
GraphicsPath path = new GraphicsPath();
path.StartFigure();
for (int i = 0; i < PointsHeartrate.Count; i++)
{
Point point = PointsHeartrate[i];
point.X -= 4;
path.AddLine(oldPoint, point);
oldPoint = point;
PointsHeartrate[i] = point;
}
for (int j = PointsHeartrate.Count - 1; j > 0; j--)
{
Point point = PointsHeartrate[j];
path.AddLine(oldPoint, point);
oldPoint = point;
PointsHeartrate[j] = point;
}
g.DrawPath(p, path);
for (int k = 0; k < PointsHeartrate.Count; k++)
{
if (PointsHeartrate[k].X < 0)
{
PointsHeartrate.RemoveAt(k);
}
}
break;
}
case 1:
{
g.TranslateTransform(0, c.GetPanel1().Height);
Point newPoint = new Point(c.GetPanel1().Width, (int)-(c.getData().RPM / 1.2 + 5));
this.PointsRPM.Add(newPoint);
GraphicsPath path = new GraphicsPath();
path.StartFigure();
for (int i = 0; i < this.PointsRPM.Count; i++)
{
Point point = this.PointsRPM[i];
point.X -= 4;
path.AddLine(oldPoint, point);
oldPoint = point;
this.PointsRPM[i] = point;
}
for (int j = this.PointsRPM.Count - 1; j > 0; j--)
{
Point point = this.PointsRPM[j];
path.AddLine(oldPoint, point);
oldPoint = point;
this.PointsRPM[j] = point;
}
g.DrawPath(p, path);
for (int k = 0; k < this.PointsRPM.Count; k++)
{
if (this.PointsRPM[k].X < 0)
{
this.PointsRPM.RemoveAt(k);
}
}
break;
}
case 2:
{
g.TranslateTransform(0, c.GetPanel1().Height);
Point newPoint = new Point(c.GetPanel1().Width, (int)-((int)c.getData().speed / (4.2 / 10) + 5));
this.PointsSpeed.Add(newPoint);
GraphicsPath path = new GraphicsPath();
path.StartFigure();
for (int i = 0; i < this.PointsSpeed.Count; i++)
{
Point point = this.PointsSpeed[i];
point.X -= 4;
path.AddLine(oldPoint, point);
oldPoint = point;
this.PointsSpeed[i] = point;
}
for (int j = this.PointsSpeed.Count - 1; j > 0; j--)
{
Point point = this.PointsSpeed[j];
path.AddLine(oldPoint, point);
oldPoint = point;
this.PointsSpeed[j] = point;
}
g.DrawPath(p, path);
//.........这里部分代码省略.........
示例4: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (IndicatorSizeValue > 0)
{
Region ControlRegion = null;
using (GraphicsPath Path = new GraphicsPath())
{
Rectangle OffsetRectangle = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height);
int IndicatorSizeValue2 = (IndicatorSizeValue * 2);
int IndicatorStart = 0;
if ((IndicatorAlignmentValue == TabAlignment.Left) || (IndicatorAlignmentValue == TabAlignment.Right))
{
IndicatorStart = this.Height;
}
else
{
IndicatorStart = this.Width;
}
IndicatorStart -= IndicatorSizeValue2;
IndicatorStart = ((IndicatorStart * IndicatorLocationValue) / 100);
Path.FillMode = FillMode.Winding;
Path.StartFigure();
int IndicatorMiddle = (IndicatorStart + IndicatorSizeValue);
int IndicatorEnd = (IndicatorStart + IndicatorSizeValue2);
if (IndicatorAlignmentValue == TabAlignment.Left)
{
OffsetRectangle.X += IndicatorSizeValue;
OffsetRectangle.Width -= IndicatorSizeValue;
Path.AddLine(OffsetRectangle.Left, IndicatorStart, OffsetRectangle.Left, IndicatorEnd);
Path.AddLine(OffsetRectangle.Left, IndicatorEnd, OffsetRectangle.Left - IndicatorSizeValue, IndicatorMiddle);
Path.AddLine(OffsetRectangle.Left - IndicatorSizeValue, IndicatorMiddle, OffsetRectangle.Left, IndicatorStart);
}
else if (IndicatorAlignmentValue == TabAlignment.Right)
{
OffsetRectangle.Width -= IndicatorSizeValue;
Path.AddLine(OffsetRectangle.Right, IndicatorStart, OffsetRectangle.Right + IndicatorSizeValue, IndicatorMiddle);
Path.AddLine(OffsetRectangle.Right + IndicatorSizeValue, IndicatorMiddle, OffsetRectangle.Right, IndicatorEnd);
Path.AddLine(OffsetRectangle.Right, IndicatorEnd, OffsetRectangle.Right, IndicatorStart);
}
else if (IndicatorAlignmentValue == TabAlignment.Top)
{
OffsetRectangle.Y += IndicatorSizeValue;
OffsetRectangle.Height -= IndicatorSizeValue;
Path.AddLine(IndicatorStart, OffsetRectangle.Top, IndicatorMiddle, OffsetRectangle.Top - IndicatorSizeValue);
Path.AddLine(IndicatorMiddle, OffsetRectangle.Top - IndicatorSizeValue, IndicatorEnd, OffsetRectangle.Top);
Path.AddLine(IndicatorEnd, OffsetRectangle.Top, IndicatorStart, OffsetRectangle.Top);
}
else if (IndicatorAlignmentValue == TabAlignment.Bottom)
{
OffsetRectangle.Height -= IndicatorSizeValue;
Path.AddLine(IndicatorStart, OffsetRectangle.Bottom, IndicatorEnd, OffsetRectangle.Bottom);
Path.AddLine(IndicatorEnd, OffsetRectangle.Bottom, IndicatorMiddle, OffsetRectangle.Bottom + IndicatorSizeValue);
Path.AddLine(IndicatorMiddle, OffsetRectangle.Bottom + IndicatorSizeValue, IndicatorStart, OffsetRectangle.Bottom);
}
Path.CloseFigure();
Region TabRegion = new Region(Path);
ControlRegion = new Region(OffsetRectangle);
ControlRegion.Union(TabRegion);
}
this.Region = ControlRegion;
}
}
示例5: RoundedRect
public static void RoundedRect(Graphics aGraph, Rectangle aRect, int aR, Pen aPen, Brush aBrush)
{
// First, build path:
GraphicsPath lPath = new GraphicsPath();
lPath.StartFigure();
lPath.AddArc(aRect.Left, aRect.Top, aR, aR, 180, 90);
lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top, aR, aR, 270, 90);
lPath.AddArc(aRect.Left + aRect.Width - aR, aRect.Top + aRect.Height - aR, aR, aR, 0, 90);
lPath.AddArc(aRect.Left + 0, aRect.Top + aRect.Height - aR, aR, aR, 90, 90);
lPath.CloseFigure();
if (aBrush != null)
aGraph.FillPath(aBrush, lPath);
if (aPen != null)
aGraph.DrawPath(aPen, lPath);
}