本文整理汇总了C#中GraphicsPath.CloseFigure方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.CloseFigure方法的具体用法?C# GraphicsPath.CloseFigure怎么用?C# GraphicsPath.CloseFigure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.CloseFigure方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm_Paint
void MainForm_Paint (object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
GraphicsPath path = new GraphicsPath ();
Rectangle borderect = new Rectangle (49, 49, 252, 252);
g.FillRectangle (new SolidBrush (Color.White), borderect);
int Diameter = 16;
Rectangle baserect = new Rectangle (50, 50, 249, 249);
Rectangle arcrect = new Rectangle (baserect.Location, new Size (Diameter, Diameter));
// handle top left corner
path.AddArc (arcrect, 180, 90);
// handle top right corner
arcrect.X = baserect.Right - Diameter;
path.AddArc (arcrect, 270, 90);
// handle baserect right corner
arcrect.Y = baserect.Bottom - Diameter;
path.AddArc (arcrect, 0, 90);
// handle bottom left corner
arcrect.X = baserect.Left;
path.AddArc (arcrect, 90, 90);
path.CloseFigure ();
g.DrawPath (Pens.SteelBlue, path);
}
示例2: CreateRound
static internal GraphicsPath CreateRound(Rectangle r, int slope)
{
CreateRoundPath = new GraphicsPath(FillMode.Winding);
CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180f, 90f);
CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270f, 90f);
CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0f, 90f);
CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90f, 90f);
CreateRoundPath.CloseFigure();
return CreateRoundPath;
}
示例3: CreateRoundRect
public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius)
{
GraphicsPath gp = new 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();
return gp;
}
示例4: CreateRoundedRectangle
public static GraphicsPath CreateRoundedRectangle(SizeF size, PointF location)
{
int cornerSize = (int)GraphConstants.CornerSize * 2;
var height = size.Height;
var width = size.Width;
var left = location.X;
var top = location.Y;
var right = location.X + width;
var bottom = location.Y + height;
var path = new GraphicsPath(FillMode.Winding);
path.AddArc(left, top, cornerSize, cornerSize, 180, 90);
path.AddArc(right - cornerSize, top, cornerSize, cornerSize, 270, 90);
path.AddArc(right - cornerSize, bottom - cornerSize, cornerSize, cornerSize, 0, 90);
path.AddArc(left, bottom - cornerSize, cornerSize, cornerSize, 90, 90);
path.CloseFigure();
return path;
}
示例5: DrawArrow
private GraphicsPath DrawArrow(int x, int y, bool flip)
{
GraphicsPath GP = new GraphicsPath();
int W = 5;
int H = 9;
if (flip)
{
GP.AddLine(x, y + 1, x, y + H + 1);
GP.AddLine(x, y + H, x + W - 1, y + W);
}
else
{
GP.AddLine(x + W, y, x + W, y + H);
GP.AddLine(x + W, y + H, x + 1, y + W);
}
GP.CloseFigure();
return GP;
}
示例6: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
g.Clear(Color.White);
using (var dataPointPath = new GraphicsPath())
using (var gridPen = new Pen(Color.FromArgb(20, Color.Black)))
using (var dashPen = new Pen(MainColor) { DashStyle = DashStyle.Dash })
using (var borderPen = new Pen(MainColor))
using (var fillBrush = new SolidBrush(Color.FromArgb(35, MainColor)))
using (var textBrush = new SolidBrush(MainColor))
{
if (DataPoints.Count > 1)
{
var infoRect = new Rectangle();
var highlightRect = new RectangleF();
var infoString = string.Empty;
dataPointPath.AddLine(Width + 10, Height + 10, Width + 10, Height + 10);
var offset = 0;
for (var i = DataPoints.Count - 1; i >= 1; i--)
{
if (DataPoints[i].Index % LineDensity == 0)
g.DrawLine(gridPen, Width - offset, 0, Width - offset, Height);
var scaledY = GetScaledPoint(DataPoints[i].Value);
dataPointPath.AddLine(Width - offset, scaledY, Width - offset - PointDensity,
GetScaledPoint(DataPoints[i - 1].Value));
if (HighlightPoint && new Rectangle(Width - offset - (PointDensity / 2), 0, PointDensity, Height).Contains(MouseLocation))
{
g.DrawLine(gridPen, 0, scaledY, Width, scaledY);
highlightRect = new RectangleF(Width - offset - 3, scaledY - 3, 6, 6);
infoString = DataPoints[i].Value.ToString(CultureInfo.InvariantCulture);
var infoStringSize = TextRenderer.MeasureText(infoString, Font);
infoRect = new Rectangle
{
Height = infoStringSize.Height + 2,
Width = infoStringSize.Width + 5
};
if (offset < infoStringSize.Width + 10)
infoRect.X = Width - offset - infoStringSize.Width - 10;
else
infoRect.X = Width - offset + 5;
if (scaledY > Height - infoStringSize.Height - 5)
infoRect.Y = (int)scaledY - infoStringSize.Height - 5;
else
infoRect.Y = (int)scaledY + 5;
}
offset += PointDensity;
}
dataPointPath.AddLine(-10, Height + 10, -10, Height + 10);
dataPointPath.CloseFigure();
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillPath(fillBrush, dataPointPath);
g.DrawPath(borderPen, dataPointPath);
g.SmoothingMode = SmoothingMode.None;
if (ShowAverage)
{
var average = GetScaledPoint(GetAverage());
g.DrawLine(dashPen, 0, average, Width, average);
g.FillRectangle(fillBrush, 0, average, Width, Height - average);
}
if (HighlightPoint)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillEllipse(Brushes.White, highlightRect);
g.DrawEllipse(borderPen, highlightRect);
g.SmoothingMode = SmoothingMode.None;
g.FillRectangle(Brushes.White, infoRect);
g.DrawRectangle(borderPen, infoRect);
g.DrawString(infoString, HighlightFont, textBrush, infoRect.X + 4, infoRect.Y + 1);
}
}
g.DrawRectangle(borderPen, new Rectangle(0, 0, Width - 1, Height - 1));
}
}
示例7: 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);
}
}
示例8: CreateRoundRect
internal GraphicsPath CreateRoundRect(Rectangle r, int curve)
{
// Draw a border radius
try
{
CreateRoundPath = new GraphicsPath(FillMode.Winding);
CreateRoundPath.AddArc(r.X, r.Y, curve, curve, 180f, 90f);
CreateRoundPath.AddArc(r.Right - curve, r.Y, curve, curve, 270f, 90f);
CreateRoundPath.AddArc(r.Right - curve, r.Bottom - curve, curve, curve, 0f, 90f);
CreateRoundPath.AddArc(r.X, r.Bottom - curve, curve, curve, 90f, 90f);
CreateRoundPath.CloseFigure();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + Environment.NewLine + Environment.NewLine + "Value must be either '1' or higher", "Invalid Integer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// Return to the default border curve if the parameter is less than "1"
_BorderCurve = 8;
BorderCurve = 8;
}
return CreateRoundPath;
}
示例9: DrawData
// REAL MAGIC HERE! y- B-
private void DrawData(Graphics g, float Xunit, float Yunit,int xstart )
{
PeptideMW PMW = new PeptideMW(PeptideSequence);
float[] Bs = PMW.GetPepFragmentBValues();
float[] Ys = PMW.GetPepFragmentYValues();
bool bPhos = PMW.IsPhosphorylation();
int Count = SpectrumData.Count;
int i = 0;
for (i = 0; i < Count; i++)
{
float mz = ((MZintensitiy )SpectrumData[i]).mz ;
float intensity = ((MZintensitiy )SpectrumData[i]).intensity ;
float x = (mz - xstart)*Xunit + NETAREALEFTMARGIN ;
float y;
if (bZoomOut)
{
if (intensity * 100 / MaxIntensitiy > DisplayMaxY)
{
y = NETAREATOPMARGIN ;
}
else
{
y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;
}
}
else
y = HEIGHT - NETAREABOTTOMMARGIN - intensity * 100 * Yunit / MaxIntensitiy;
Pen dataPen = new Pen (Brushes.Black ,1);
Pen BLinePen = new Pen(Brushes.Blue, 2);
Pen YLinePen = new Pen(Brushes.Red, 2);
Pen ALinePen = new Pen (Brushes.Green ,2);
Pen MLinePen = new Pen(Brushes.Gray , 2);
Font Numberfont = new Font("Arial", 9, FontStyle.Regular);
if (y < HEIGHT - NETAREABOTTOMMARGIN -20 && bShowLabel )
{
string strAnn = GetAnnotation(SpectrumData,i, Bs, Ys,PrecursorMZ,int.Parse (ChargeState ),bPhos );
if (strAnn.StartsWith("(b"))
{
g.DrawLine(BLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Blue , new PointF(x, y));
}
else if (strAnn.StartsWith("(y"))
{
g.DrawLine(YLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
}
else if (strAnn.StartsWith("(a"))
{
g.DrawLine(ALinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Green, new PointF(x, y));
}
else if (strAnn.StartsWith("(M") && y < HEIGHT - NETAREABOTTOMMARGIN -100)
{
g.DrawLine(MLinePen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
g.DrawString(strAnn, Numberfont, Brushes.Gray , new PointF(x, y));
}
else
{
g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
}
//g.DrawString(strAnn, Numberfont, Brushes.Red, new PointF(x, y));
}
else
g.DrawLine(dataPen, x, y, x, (float)HEIGHT - NETAREABOTTOMMARGIN);
if (intensity == MaxIntensitiy)
{
//peak value point
GraphicsPath p = new GraphicsPath();
p.AddLine(x, (float)HEIGHT - NETAREABOTTOMMARGIN, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
p.AddLine(x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength, x - XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN + XAxisScaleLength);
p.CloseFigure();
g.FillPath(Brushes.Red, p);
g.DrawString(mz.ToString(), Numberfont, Brushes.Red, x + XAxisScaleLength, (float)HEIGHT - NETAREABOTTOMMARGIN);
}
}
}
示例10: RoundRectangle
private GraphicsPath RoundRectangle(Rectangle r, int radius, GroupBoxCorners corners)
{
GraphicsPath path = new GraphicsPath();
if (r.Width <= 0 | r.Height <= 0)
return path;
int d = radius * 2;
int nw = ((corners & GroupBoxCorners.NorthWest) == GroupBoxCorners.NorthWest ? d : 0);
int ne = ((corners & GroupBoxCorners.NorthEast) == GroupBoxCorners.NorthEast ? d : 0);
int se = ((corners & GroupBoxCorners.SouthEast) == GroupBoxCorners.SouthEast ? d : 0);
int sw = ((corners & GroupBoxCorners.SouthWest) == GroupBoxCorners.SouthWest ? d : 0);
path.AddLine(r.Left + nw, r.Top, r.Right - ne, r.Top);
if (ne > 0)
{
path.AddArc(Rectangle.FromLTRB(r.Right - ne, r.Top, r.Right, r.Top + ne), -90, 90);
}
path.AddLine(r.Right, r.Top + ne, r.Right, r.Bottom - se);
if (se > 0)
{
path.AddArc(Rectangle.FromLTRB(r.Right - se, r.Bottom - se, r.Right, r.Bottom), 0, 90);
}
path.AddLine(r.Right - se, r.Bottom, r.Left + sw, r.Bottom);
if (sw > 0)
{
path.AddArc(Rectangle.FromLTRB(r.Left, r.Bottom - sw, r.Left + sw, r.Bottom), 90, 90);
}
path.AddLine(r.Left, r.Bottom - sw, r.Left, r.Top + nw);
if (nw > 0)
{
path.AddArc(Rectangle.FromLTRB(r.Left, r.Top, r.Left + nw, r.Top + nw), 180, 90);
}
path.CloseFigure();
return path;
}
示例11: 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;
}
}
示例12: Draw3DBorder
private void Draw3DBorder(Graphics g, float offset, Brush color, bool fill, float r, float percent)
{
int pen_width = 2;
float x = this.ClientRectangle.Left + (pen_width / 2) + offset;
float y = this.ClientRectangle.Top + (pen_width / 2) + offset;
float w = (this.ClientRectangle.Width - (pen_width / 2 + 2 + offset * 2)) * percent;
float h = this.ClientRectangle.Height - (pen_width / 2 + 2 + offset * 2);
Pen pen = new Pen(color, (float)pen_width);
GraphicsPath path = new GraphicsPath();
if (w < 2 * r) {
w = 2 * r;
}
path.AddLine(x + r, y, x + (w - r * 2), y);
path.AddArc(x + w - r * 2, y, r * 2, r * 2, 270, 90);
path.AddLine(x + w, y + r, x + w, y + h - r * 2);
path.AddArc(x + w - r * 2, y + h - r * 2, r * 2, r * 2, 0, 90);
path.AddLine(x + w - r * 2, y + h, x + r, y + h);
path.AddArc(x, y + h - r * 2, r * 2, r * 2, 90, 90);
path.AddLine(x, y + h - r * 2, x, y + r);
path.AddArc(x, y, r * 2, r * 2, 180, 90);
path.CloseFigure();
g.SmoothingMode = SmoothingMode.AntiAlias;
if (fill) {
g.FillPath(color, path);
} else {
g.DrawPath(pen, path);
}
}
示例13: GetPath
protected GraphicsPath GetPath()
{
GraphicsPath graphPath = new GraphicsPath();
if (_BorderStyle == BorderStyle.Fixed3D)
{
graphPath.AddRectangle(ClientRectangle);
}
else
{
try
{
int curve = 0;
Rectangle rect = ClientRectangle;
int offset = 0;
switch (_BorderStyle)
{
case BorderStyle.FixedSingle:
offset = (int) Math.Ceiling(BorderWidth / 2.0d);
curve = adjustedCurve;
break;
case BorderStyle.Fixed3D:
break;
case BorderStyle.None:
curve = adjustedCurve;
break;
}
if (curve == 0)
{
graphPath.AddRectangle(Rectangle.Inflate(rect, -offset, -offset));
}
else
{
int rectWidth = rect.Width - 1 - offset;
int rectHeight = rect.Height - 1 - offset;
int curveWidth;
if ((_CurveMode & CornerCurveMode.TopRight) != 0)
{
curveWidth = (curve * 2);
}
else
{
curveWidth = 1;
}
graphPath.AddArc(rectWidth - curveWidth, offset, curveWidth, curveWidth, 270, 90);
if ((_CurveMode & CornerCurveMode.BottomRight) != 0)
{
curveWidth = (curve * 2);
}
else
{
curveWidth = 1;
}
graphPath.AddArc(rectWidth - curveWidth, rectHeight - curveWidth, curveWidth, curveWidth, 0, 90);
if ((_CurveMode & CornerCurveMode.BottomLeft) != 0)
{
curveWidth = (curve * 2);
}
else
{
curveWidth = 1;
}
graphPath.AddArc(offset, rectHeight - curveWidth, curveWidth, curveWidth, 90, 90);
if ((_CurveMode & CornerCurveMode.TopLeft) != 0)
{
curveWidth = (curve * 2);
}
else
{
curveWidth = 1;
}
graphPath.AddArc(offset, offset, curveWidth, curveWidth, 180, 90);
graphPath.CloseFigure();
}
}
catch (Exception)
{
graphPath.AddRectangle(ClientRectangle);
}
}
return graphPath;
}
示例14: 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);
}