本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.AddLine方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.AddLine方法的具体用法?C# GraphicsPath.AddLine怎么用?C# GraphicsPath.AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.AddLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
GraphicsPath path = new GraphicsPath();
path.AddLine(20, 20, 170, 20);
path.AddLine(20, 20, 20, 100);
// рисуем новую фигуру
path.StartFigure();
path.AddLine(240, 140, 240, 50);
path.AddLine(240, 140, 80, 140);
path.AddRectangle(new Rectangle(30, 30, 200, 100));
// локальное преобразование траектории
//Matrix X = new Matrix();
//X.RotateAt(45, new PointF(60.0f, 100.0f));
//path.Transform(X);
// рисуем path
Pen redPen = new Pen(Color.Red, 2);
g.FillPath(new SolidBrush(Color.Bisque), path);
g.DrawPath(redPen, path);
}
}
示例2: DrawYourSelf
public override void DrawYourSelf(Graphics graphics)
{
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
path.CloseFigure();
path.StartFigure();
path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
path.CloseFigure();
path.AddEllipse(new RectangleF(Location, ModelSize));
path.CloseFigure();
path.Transform(this.TMatrix.TransformationMatrix);
Pen pen = new Pen(this.BorderColor, this.BorderWidth);
if (IS_FILLED)
{
SolidBrush brush = new SolidBrush(this.FillColor);
graphics.FillPath(brush, path);
}
graphics.DrawPath(pen, path);
if (this.Selected)
{
this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
this.selectionUnit.DrawYourSelf(graphics);
}
}
示例3: DrawRoundRect
public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
{
Y+=5;
X+=5;
width -= 12;
height -= 12;
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();
g.FillPath(Brushes.Transparent, gp);
gp.Dispose();
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();
g.DrawPath(p, gp);
gp.Dispose();
}
示例4: RecalcBrushes
protected virtual void RecalcBrushes(Rectangle position, Painter.State state)
{
if (_lastPosition == null || _lastPosition.Value != position || _lastState == null ||_lastState.Value != state)
{
_lastState = state;
if (state == State.Hover)
_borderPen = new Pen(Color.FromArgb(0x3c, 0x7f, 0xb1), 1);
else if (state == State.Pressed)
_borderPen = new Pen(Color.FromArgb(0x18, 0x59, 0x8a), 1);
else
_borderPen = new Pen(Color.FromArgb(0x9a, 0x9a, 0x9a), 1);
_leftBounds = new Rectangle(position.X, position.Y, 8, position.Height);
_leftBrush = CreateLeftBrush(_leftBounds, state);
_middleBounds = new Rectangle(_leftBounds.Right, _leftBounds.Y, (int)((float)position.Width - 16), position.Height);
_middleBrush = CreateMiddleBrush(_middleBounds, state);
_rightBounds = new Rectangle(_middleBounds.Right, _leftBounds.Y, 8, position.Height);
_rightBrush = CreateRightBrush(_rightBounds, state);
_upperGradientPath = new GraphicsPath();
_upperGradientPath.AddLine(position.X + 8, position.Y + 1, position.X + 8, position.Y + 5);
_upperGradientPath.AddLine(position.X + 8, position.Y + 5, _middleBounds.Right, position.Y + 5);
_upperGradientPath.AddLine(_middleBounds.Right, position.Y + 5, _rightBounds.Right - 1, position.Y + 1);
_upperGradientPath.CloseAllFigures();
_upperGradientRect = new Rectangle(position.X + 8, position.Y + 1, 10, 4);
_upperGradientBrush = new LinearGradientBrush(_upperGradientRect, Color.FromArgb(0xed, 0xed, 0xed), Color.FromArgb(0xdd, 0xdd, 0xe0), LinearGradientMode.Vertical);
_lastPosition = position;
}
}
示例5: CreateRoundedRectanglePath
// Create a rounded rectangle path with a given Rectangle and a given corner Diameter
public static GraphicsPath CreateRoundedRectanglePath(Rectangle rect, float diameter)
{
GraphicsPath path = new GraphicsPath ();
RectangleF arcrect = new RectangleF (rect.Location, new SizeF (diameter, diameter));
// Top left arc
path.AddArc (arcrect, 190, 90);
path.AddLine (rect.Left + (int)(diameter / 2), rect.Top, rect.Left + rect.Width - (int)(diameter / 2), rect.Top);
// Top right arc
arcrect.X = rect.Right - diameter;
path.AddArc (arcrect, 270, 90);
path.AddLine (rect.Left + rect.Width, rect.Top + (int)(diameter / 2), rect.Left + rect.Width, rect.Top + rect.Height - (int)(diameter / 2));
// Bottom right arc
arcrect.Y = rect.Bottom - diameter;
path.AddArc (arcrect, 0, 90);
// Bottom left arc
arcrect.X = rect.Left;
path.AddArc (arcrect, 90, 90);
path.CloseFigure ();
return path;
}
示例6: RoundRectangle
// paramters:
// pen 绘制边框。可以为null,那样就整体一个填充色,没有边框
// brush 绘制填充色。可以为null,那样就只有边框
public static void RoundRectangle(Graphics graphics,
Pen pen,
Brush brush,
float x,
float y,
float width,
float height,
float radius)
{
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(x + radius, y, x + width - (radius * 2), y);
path.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);
path.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
path.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
path.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
path.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
path.AddLine(x, y + height - (radius * 2), x, y + radius);
path.AddArc(x, y, radius * 2, radius * 2, 180, 90);
path.CloseFigure();
if (brush != null)
graphics.FillPath(brush, path);
if (pen != null)
graphics.DrawPath(pen, path);
}
}
示例7: RecreatePath
private void RecreatePath()
{
path = new GraphicsPath();
if (tlRad > 0)
path.AddArc(AbsoluteX, AbsoluteY, tlRad, tlRad, 180, 90);
else
path.AddLine(AbsoluteX, AbsoluteY, AbsoluteX, AbsoluteY);
if (trRad > 0)
path.AddArc(AbsoluteX + ActualWidth - trRad, AbsoluteY, trRad, trRad, 270, 90);
else
path.AddLine(AbsoluteX + ActualWidth, AbsoluteY, AbsoluteX + ActualWidth, AbsoluteY);
if (brRad > 0)
path.AddArc(AbsoluteX + ActualWidth - brRad, AbsoluteY + ActualHeight - brRad, brRad, brRad, 0, 90);
else
path.AddLine(AbsoluteX + ActualWidth, AbsoluteY + ActualHeight, AbsoluteX + ActualWidth, AbsoluteY + ActualHeight);
if (blRad > 0)
path.AddArc(AbsoluteX, AbsoluteY + ActualHeight - blRad, blRad, blRad, 90, 90);
else
path.AddLine(AbsoluteX, AbsoluteY + ActualHeight, AbsoluteX, AbsoluteY + ActualHeight);
path.CloseFigure();
}
示例8: DrawMarker
public void DrawMarker(DragDropMarkerRendererEventArgs e)
{
Graphics g = e.Graphics;
Rectangle bounds = e.Bounds;
if (bounds.IsEmpty || _MarkerColor.IsEmpty) return;
if (bounds.Width == AdvTree.DragInsertMarkSize) // Vertical insert mark
{
using (SolidBrush brush = new SolidBrush(_MarkerColor))
{
using (Pen pen = new Pen(brush, 1))
{
Point p = new Point(bounds.X + 4, bounds.Y);
g.DrawLine(pen, p.X, p.Y, p.X, bounds.Bottom - 1);
}
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(bounds.X, bounds.Y, bounds.X + 8, bounds.Y );
path.AddLine(bounds.X + 8, bounds.Y, bounds.X + 4, bounds.Y + 4);
path.CloseAllFigures();
g.FillPath(brush, path);
}
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(bounds.X, bounds.Bottom, bounds.X + 8, bounds.Bottom);
path.AddLine(bounds.X + 8, bounds.Bottom, bounds.X + 4, bounds.Bottom - 4);
path.CloseAllFigures();
g.FillPath(brush, path);
}
}
}
else
{
// Horizontal insert mark
using (SolidBrush brush = new SolidBrush(_MarkerColor))
{
using (Pen pen = new Pen(brush, 1))
{
Point p = new Point(bounds.X, bounds.Y + 4);
g.DrawLine(pen, p.X, p.Y, bounds.Right - 1, p.Y);
}
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(bounds.X, bounds.Y, bounds.X, bounds.Y + 8);
path.AddLine(bounds.X, bounds.Y + 8, bounds.X + 4, bounds.Y + 4);
path.CloseAllFigures();
g.FillPath(brush, path);
}
using (GraphicsPath path = new GraphicsPath())
{
path.AddLine(bounds.Right, bounds.Y, bounds.Right, bounds.Y + 8);
path.AddLine(bounds.Right, bounds.Y + 8, bounds.Right - 4, bounds.Y + 4);
path.CloseAllFigures();
g.FillPath(brush, path);
}
}
}
}
示例9: Path
public override GraphicsPath Path(SvgRenderer renderer)
{
if (_Path == null || this.IsPathDirty)
{
_Path = new GraphicsPath();
try
{
for (int i = 0; i < Points.Count; i += 2)
{
PointF endPoint = new PointF(Points[i].ToDeviceValue(renderer, UnitRenderingType.Horizontal, this),
Points[i + 1].ToDeviceValue(renderer, UnitRenderingType.Vertical, this));
// TODO: Remove unrequired first line
if (_Path.PointCount == 0)
{
_Path.AddLine(endPoint, endPoint);
}
else
{
_Path.AddLine(_Path.GetLastPoint(), endPoint);
}
}
}
catch (Exception exc)
{
Trace.TraceError("Error rendering points: " + exc.Message);
}
this.IsPathDirty = false;
}
return _Path;
}
示例10: CreateRoundedRectanglePath
public static GraphicsPath CreateRoundedRectanglePath(RectangleF rect, float radius)
{
GraphicsPath path = new GraphicsPath();
if (rect.Width <= 0.0f || rect.Height <= 0.0f) return path;
float x1 = rect.X;
float x2 = rect.X + rect.Width;
float y1 = rect.Y;
float y2 = rect.Y + rect.Height;
if (radius > rect.Width / 2) radius = rect.Width / 2;
if (radius > rect.Height / 2) radius = rect.Width / 2;
// Top left arc and top edge:
if (radius > 0.0) path.AddArc(new RectangleF(x1, y1, radius * 2, radius * 2), 180, 90);
path.AddLine(x1 + radius, y1, x2 - radius, y1);
// Top right arc and right edge:
if (radius > 0.0) path.AddArc(new RectangleF(x2 - radius * 2, y1, radius * 2, radius * 2), 270, 90);
path.AddLine(x2, y1 + radius, x2, y2 - radius);
// Bottom right arc and bottom edge:
if (radius > 0.0) path.AddArc(new RectangleF(x2 - radius * 2, y2 - radius * 2, radius * 2, radius * 2), 0, 90);
path.AddLine(x2 - radius, y2, x1 + radius, y2);
// Bottom left arc and left edge:
if (radius > 0.0) path.AddArc(new RectangleF(x1, y2 - radius * 2, radius * 2, radius * 2), 90, 90);
path.AddLine(x1, y2 - radius, x1, y1 + radius);
return path;
}
示例11: GetTopRoundedRect
//public static GraphicsPath GetBottomRoundRect(RectangleF r, int offset)
//{
// int left = Math.Min((int)r.Left, (int)r.Right);
// int right = Math.Max((int)r.Left, (int)r.Right);
// int top = Math.Min((int)r.Top, (int)r.Bottom);
// int bottom = Math.Max((int)r.Top, (int)r.Bottom);
// GraphicsPath path = new GraphicsPath();
// path.AddLine(r.Right, r.Top, r.Right, r.Top);
// path.AddArc(right - offset, bottom - offset, offset, offset, 0.0f, 90.0f);
// path.AddArc(left, bottom - offset, offset, offset, 90.0f, 90.0f);
// path.AddLine(r.Left, r.Top, r.Left, r.Top);
// path.CloseFigure();
// return path;
//}
public static GraphicsPath GetTopRoundedRect(RectangleF r, int offset)
{
int left = Math.Min((int)r.Left, (int)r.Right);
int right = Math.Max((int)r.Left, (int)r.Right);
int top = Math.Min((int)r.Top, (int)r.Bottom);
int bottom = Math.Max((int)r.Top, (int)r.Bottom);
GraphicsPath path = new GraphicsPath();
try
{
path.AddArc(right - offset, top, offset, offset, 270.0f, 90.0f);
path.AddLine(r.Right, r.Bottom, r.Right, r.Bottom);
path.AddLine(r.Left, r.Bottom, r.Left, r.Bottom);
path.AddArc(left, top, offset, offset, 180.0f, 90.0f);
path.CloseFigure();
return path;
}
catch
{
path.Dispose();
throw;
}
}
示例12: CreateRoundRect
private GraphicsPath CreateRoundRect(Rectangle rect, int radius)
{
GraphicsPath gp = new GraphicsPath();
int x = rect.X;
int y = rect.Y;
int width = rect.Width;
int height = rect.Height;
if (radius > 0)
{
radius = Math.Min(radius, height / 2 - 1);
radius = Math.Min(radius, width / 2 - 1);
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);
}
else
{
gp.AddRectangle(rect);
}
gp.CloseFigure();
return gp;
}
示例13: Draw
public override void Draw(Graphics g)
{
System.Drawing.Size st = g.MeasureString(Marker.ToolTipText, Font).ToSize();
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
rect.Offset(Offset.X, Offset.Y);
using(GraphicsPath objGP = new GraphicsPath())
{
objGP.AddLine(rect.X + 2 * Radius, rect.Y + rect.Height, rect.X + Radius, rect.Y + rect.Height + Radius);
objGP.AddLine(rect.X + Radius, rect.Y + rect.Height + Radius, rect.X + Radius, rect.Y + rect.Height);
objGP.AddArc(rect.X, rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 90, 90);
objGP.AddLine(rect.X, rect.Y + rect.Height - (Radius * 2), rect.X, rect.Y + Radius);
objGP.AddArc(rect.X, rect.Y, Radius * 2, Radius * 2, 180, 90);
objGP.AddLine(rect.X + Radius, rect.Y, rect.X + rect.Width - (Radius * 2), rect.Y);
objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y, Radius * 2, Radius * 2, 270, 90);
objGP.AddLine(rect.X + rect.Width, rect.Y + Radius, rect.X + rect.Width, rect.Y + rect.Height - (Radius * 2));
objGP.AddArc(rect.X + rect.Width - (Radius * 2), rect.Y + rect.Height - (Radius * 2), Radius * 2, Radius * 2, 0, 90); // Corner
objGP.CloseFigure();
g.FillPath(Fill, objGP);
g.DrawPath(Stroke, objGP);
}
#if !PocketPC
g.DrawString(Marker.ToolTipText, Font, Brushes.Navy, rect, Format);
#else
g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
#endif
}
示例14: DrawRoundedRectangle
/// <summary>
/// Draws a rounded rectangle on a bitmap
/// </summary>
/// <param name="Image">Image to draw on</param>
/// <param name="BoxColor">The color that the box should be</param>
/// <param name="XPosition">The upper right corner's x position</param>
/// <param name="YPosition">The upper right corner's y position</param>
/// <param name="Height">Height of the box</param>
/// <param name="Width">Width of the box</param>
/// <param name="CornerRadius">Radius of the corners</param>
/// <returns>The bitmap with the rounded box on it</returns>
public static Bitmap DrawRoundedRectangle(Bitmap Image, Color BoxColor, int XPosition, int YPosition,
int Height, int Width, int CornerRadius)
{
Bitmap NewBitmap = new Bitmap(Image, Image.Width, Image.Height);
using (Graphics NewGraphics = Graphics.FromImage(NewBitmap))
{
using (Pen BoxPen = new Pen(BoxColor))
{
using (GraphicsPath Path = new GraphicsPath())
{
Path.AddLine(XPosition + CornerRadius, YPosition, XPosition + Width - (CornerRadius * 2), YPosition);
Path.AddArc(XPosition + Width - (CornerRadius * 2), YPosition, CornerRadius * 2, CornerRadius * 2, 270, 90);
Path.AddLine(XPosition + Width, YPosition + CornerRadius, XPosition + Width, YPosition + Height - (CornerRadius * 2));
Path.AddArc(XPosition + Width - (CornerRadius * 2), YPosition + Height - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 0, 90);
Path.AddLine(XPosition + Width - (CornerRadius * 2), YPosition + Height, XPosition + CornerRadius, YPosition + Height);
Path.AddArc(XPosition, YPosition + Height - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 90, 90);
Path.AddLine(XPosition, YPosition + Height - (CornerRadius * 2), XPosition, YPosition + CornerRadius);
Path.AddArc(XPosition, YPosition, CornerRadius * 2, CornerRadius * 2, 180, 90);
Path.CloseFigure();
NewGraphics.DrawPath(BoxPen, Path);
}
}
}
return NewBitmap;
}
示例15: AddRoundedRectangle
public static GraphicsPath AddRoundedRectangle(GraphicsPath path, Rectangle bounds, int c1, int c2, int c3, int c4)
{
if (c1 > 0)
path.AddArc(bounds.Left, bounds.Top, c1, c1, 180, 90);
else
path.AddLine(bounds.Left, bounds.Top, bounds.Left, bounds.Top);
if (c2 > 0)
path.AddArc(bounds.Right - c2, bounds.Top, c2, c2, 270, 90);
else
path.AddLine(bounds.Right, bounds.Top, bounds.Right, bounds.Top);
if (c3 > 0)
path.AddArc(bounds.Right - c3, bounds.Bottom - c3, c3, c3, 0, 90);
else
path.AddLine(bounds.Right, bounds.Bottom, bounds.Right, bounds.Bottom);
if (c4 > 0)
path.AddArc(bounds.Left, bounds.Bottom - c4, c4, c4, 90, 90);
else
path.AddLine(bounds.Left, bounds.Bottom, bounds.Left, bounds.Bottom);
path.CloseFigure();
return path;
}