本文整理汇总了C#中System.Drawing.Pen.SetLineCap方法的典型用法代码示例。如果您正苦于以下问题:C# Pen.SetLineCap方法的具体用法?C# Pen.SetLineCap怎么用?C# Pen.SetLineCap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Pen
的用法示例。
在下文中一共展示了Pen.SetLineCap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCompass
public DrawCompass(Panel _panel)
: base(_panel, _panel.Height / 2 - 20, _panel.Height / 10)
{
arrowPen = new Pen(Color.DarkGreen, 3.0f);
LineCap lineCap = LineCap.ArrowAnchor;
arrowPen.SetLineCap(lineCap, LineCap.Flat, DashCap.Flat);
}
示例2: pnl_painter_MouseMove
private void pnl_painter_MouseMove(object sender, MouseEventArgs e)
{
Brush brush1 = new SolidBrush(Color.Black);
if (rdo_black.Checked) color = "black";
else if (rdo_blue.Checked) color = "blue";
else if (rdo_red.Checked) color = "red";
switch (color)
{
case "black": brush1 = new SolidBrush(Color.Black); break;
case "blue": brush1 = new SolidBrush(Color.Blue); break;
case "red": brush1 = new SolidBrush(Color.Red); break;
}
if (rdo_small.Checked) size = 4;
else if (rdo_middle.Checked) size = 8;
else if (rdo_large.Checked) size = 12;
x2 = e.X;
y2 = e.Y;
Pen pen1 = new Pen(brush1, size);
pen1.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Flat);
//pen1.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
if (shouldPaint)
{
Graphics graphics = pnl_painter.CreateGraphics();
//graphics.FillEllipse(brush1, e.X, e.Y, size, size);
graphics.DrawLine(pen1, x1, y1, x2, y2);
graphics.Dispose();
}
x1 = e.X;
y1 = e.Y;
}
示例3: OpenObject
public OpenObject(Form1 theForm)
{
callerForm = theForm;
alphaPen = new Pen(Color.Purple, 10);
alphaPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Flat);
InitializeComponent();
}
示例4: GetPen
public Pen GetPen()
{
Pen p = new Pen(this.Brush.GetBrush(), this.Width);
p.SetLineCap(this.StartCap, this.EndCap, this.DashCap);
p.DashStyle = this.DashStyle;
p.LineJoin = this.LineJoin;
return p;
}
示例5: Draw
public override void Draw(Graphics graphics)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
using (Pen p = new Pen(this.ForeColor,this.Thickness)) {
p.SetLineCap(this.StartLineCap,this.EndLineCap,this.DashLineCap);
graphics.DrawLine(p,this.fromPoint,this.toPoint);
}
}
示例6: Draw
public override void Draw(Graphics graphics)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
using (var p = new Pen(ForeColor,Thickness)) {
p.SetLineCap(StartLineCap,EndLineCap,DashLineCap);
graphics.DrawLine(p,fromPoint,toPoint);
}
}
示例7: Form1
public Form1()
{
InitializeComponent();
koef.Text = k.ToString();
x0 = 0;
y0 = 0;
bmp = new Bitmap(pictureBox1.Width,pictureBox1.Height);
bmp.MakeTransparent(Color.Black);
pictureBox1.Image = bmp;
MyPen = new System.Drawing.Pen(Color.Violet, 4);
MyPen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.
Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
time = System.DateTime.Now;
}
示例8: OnRender
protected override void OnRender(Graphics g, Point offset)
{
lock (this)
{
float ourSize = UI.ScaleWidth(Math.Min(Width, Height));
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TranslateTransform(-offset.X, -offset.Y, MatrixOrder.Append);
PointF ptF = (PointF)this.Location;
ptF = Utility.TransformOnePoint(this.transform, ptF);
ptF.X *= (float)OwnerList.ScaleFactor.Ratio;
ptF.Y *= (float)OwnerList.ScaleFactor.Ratio;
PointF[] pts = new PointF[8]
{
new PointF(-1, -1), // up+left
new PointF(+1, -1), // up+right
new PointF(+1, +1), // down+right
new PointF(-1, +1), // down+left
new PointF(-1, 0), // left
new PointF(+1, 0), // right
new PointF(0, -1), // up
new PointF(0, +1) // down
};
Utility.RotateVectors(pts, this.transformAngle);
Utility.NormalizeVectors(pts);
using (Pen white = new Pen(Color.FromArgb(this.alpha, Color.White), -1.0f),
black = new Pen(Color.FromArgb(this.alpha, Color.Black), -1.0f))
{
PixelOffsetMode oldPOM = g.PixelOffsetMode;
g.PixelOffsetMode = PixelOffsetMode.None;
if (this.shape != MoveNubShape.Circle)
{
PointF[] outer = new PointF[4]
{
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize))
};
PointF[] middle = new PointF[4]
{
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 1)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 1)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 1)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 1))
};
PointF[] inner = new PointF[4]
{
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 2)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 2)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 2)),
Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 2))
};
g.DrawPolygon(white, outer);
g.DrawPolygon(black, middle);
g.DrawPolygon(white, inner);
}
else if (this.shape == MoveNubShape.Circle)
{
RectangleF rect = new RectangleF(ptF, new SizeF(0, 0));
rect.Inflate(ourSize - 1, ourSize - 1);
g.DrawEllipse(white, rect);
rect.Inflate(-1.0f, -1.0f);
g.DrawEllipse(black, rect);
rect.Inflate(-1.0f, -1.0f);
g.DrawEllipse(white, rect);
}
if (this.shape == MoveNubShape.Compass)
{
black.SetLineCap(LineCap.Round, LineCap.DiamondAnchor, DashCap.Flat);
black.EndCap = LineCap.ArrowAnchor;
black.StartCap = LineCap.ArrowAnchor;
white.SetLineCap(LineCap.Round, LineCap.DiamondAnchor, DashCap.Flat);
white.EndCap = LineCap.ArrowAnchor;
white.StartCap = LineCap.ArrowAnchor;
PointF ul = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 1));
PointF ur = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 1));
PointF lr = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 1));
PointF ll = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 1));
PointF top = Utility.MultiplyVector(Utility.AddVectors(ul, ur), 0.5f);
PointF left = Utility.MultiplyVector(Utility.AddVectors(ul, ll), 0.5f);
PointF right = Utility.MultiplyVector(Utility.AddVectors(ur, lr), 0.5f);
PointF bottom = Utility.MultiplyVector(Utility.AddVectors(ll, lr), 0.5f);
using (SolidBrush whiteBrush = new SolidBrush(white.Color))
{
PointF[] poly = new PointF[] { ul, ur, lr, ll };
//.........这里部分代码省略.........
示例9: Begin
public void Begin()
{
m_pen = new Pen(System.Drawing.Color.Black, 2f);
m_pen.SetLineCap(System.Drawing.Drawing2D.LineCap.Square, System.Drawing.Drawing2D.LineCap.Square, System.Drawing.Drawing2D.DashCap.Flat);
}
示例10: CreateSolidPen
// Create a solid pen
public static Pen CreateSolidPen(Color color, float thickness, LineStyle style)
{
#if false
Pen pen = new Pen(new SolidColorBrush(color), thickness);
if (style == LineStyle.Rounded) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Round;
pen.LineJoin = PenLineJoin.Round;
}
else if (style == LineStyle.Beveled) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Bevel;
}
else if (style == LineStyle.Mitered) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Miter;
pen.MiterLimit = MITER_LIMIT;
}
else if (style == LineStyle.FlatRounded) {
pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
pen.LineJoin = PenLineJoin.Round;
}
pen.Freeze();
return pen;
#else
Pen pen = new Pen(color, thickness);
if (style == LineStyle.Rounded) {
pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Flat);
pen.LineJoin = LineJoin.Round;
}
else if (style == LineStyle.Beveled) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Bevel;
}
else if (style == LineStyle.Mitered) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Miter;
pen.MiterLimit = MITER_LIMIT;
}
else if (style == LineStyle.FlatRounded) {
pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
pen.LineJoin = LineJoin.Round;
}
return pen;
#endif
}
示例11: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
var g = e.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.CompositingQuality = CompositingQuality.HighQuality;
Pen p = new Pen(Brush, 4);
p.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
var gp = new GraphicsPath();
gp.AddLine(4, 10, 4, 40);
gp.AddArc(4, 5, 10, 10, 180, 90);
gp.AddLine(9, 5, 12, 5);
gp.AddArc(12, 5, 10, 10, 270, 90);
gp.AddLine(22, 10, 22, 30);
gp.AddArc(12, 34, 10, 10, 0, 90);
gp.AddLine(16, 44, 12, 44);
gp.AddArc(4, 34, 10, 10, 90, 90);
g.DrawPath(p, gp);
bool on = Value > 0.5;
if (Invert)
on = !on;
if (Mode == SwitchMode.Toggle)
on = on && MouseIsDown;
if(on)
g.FillRectangle(Brush, 9, 10, 8, 10);
else
g.FillRectangle(OffBrush, 9, 29, 8, 10);
}
示例12: PaintLine
private void PaintLine(Graphics g, SnapshotIcon icon, SnapshotIcon child, bool highlight)
{
if (child.Index == -1)
return;
try
{
Rectangle leftItemBounds = icon.GetBounds(ItemBoundsPortion.Entire);
Rectangle rightItemBounds = child.GetBounds(ItemBoundsPortion.Entire);
leftItemBounds.Size = icon.DefaultSize;
rightItemBounds.Size = child.DefaultSize;
int left = leftItemBounds.Right + 6;
int right = rightItemBounds.Left;
int mid = (left + right) / 2;
Point start = new Point(left, (leftItemBounds.Bottom + leftItemBounds.Top) / 2);
Point end = new Point(right, (rightItemBounds.Top + rightItemBounds.Bottom) / 2);
Point curveStart = start;
curveStart.Offset(straightLineLength, 0);
Point curveEnd = end;
curveEnd.Offset(-straightLineLength, 0);
Point control1 = new Point(mid + straightLineLength, start.Y);
Point control2 = new Point(mid - straightLineLength, end.Y);
Color lineColor = LinkLineColor;
float lineWidth = LinkLineWidth;
if (highlight)
{
lineColor = Color.ForestGreen;
lineWidth = 2.5f;
}
using (Pen p = new Pen(lineColor, lineWidth))
{
p.SetLineCap(LineCap.Round, LineCap.Custom, DashCap.Flat);
p.CustomEndCap = linkLineArrow;
g.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath path = new GraphicsPath();
path.AddLine(start, curveStart);
path.AddBezier(curveStart, control1, control2, curveEnd);
path.AddLine(curveEnd, end);
g.DrawPath(p, path);
}
}
catch (Exception)
{
//Debugger.Break();
}
}
示例13: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
Rectangle rcClient = ClientRectangle;
rcClient.Inflate(-4, -4);
Region originalClip = g.Clip;
g.Clip = new Region(rcClient);
g.SmoothingMode = SmoothingMode.AntiAlias;
Size szSpace = new Size(4, 3);
Rectangle rcItem;
Rectangle rcText = new Rectangle(0, 0, 0, 0);
Rectangle rcIcon = new Rectangle(0, 0, 0, 0);
StringFormat iconTextFormat = new StringFormat();
iconTextFormat.Alignment = StringAlignment.Center;
iconTextFormat.LineAlignment = StringAlignment.Center;
Color color1 = Color.White;
Color color2 = Color.White;
Brush textBrush = Brushes.Black;
Brush iconBrush = Brushes.White;
//First determine if the data will fit without the scrollbar
rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - szSpace.Width, 0);
for (int i = 0; i < Items.Count; i++) {
ListItem item = Items[i];
if (item.Icon != null) {
rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
rcText.X = rcIcon.Right + szSpace.Width;
rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
} else {
rcIcon = new Rectangle(0, 0, 0, 0);
rcText.X = ItemPadding.Left + rcItem.X;
rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
}
Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
item.Size = rcItem.Size;
item.Location.X = rcItem.Location.X;
item.Location.Y = rcItem.Location.Y + mCurrentY;
rcText.Height = rcItem.Height;
rcText.Y = rcItem.Y;
rcIcon.Y = rcItem.Y + ((rcItem.Height - rcIcon.Height) / 2);
rcItem.Offset(0, rcItem.Height + szSpace.Height);
}
mMaxScroll = ((rcItem.Bottom + mDefaultY) - (Height + mCurrentY));
if (mMaxScroll < 0) { // No scrolling needed
mMaxScroll = 0;
mCurrentY = mDefaultY;
mScrollBar = new Rectangle(0, 0, 0, 0);
} else {
mScrollBar = new Rectangle(rcClient.Right - 30, rcClient.Y, 30, rcClient.Height);
RoundRectPath thumbPath = new RoundRectPath(mScrollBar, mRounding, mRounding);
using (LinearGradientBrush b = new LinearGradientBrush(mScrollBar, Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
b.WrapMode = WrapMode.TileFlipX;
g.FillPath(b, thumbPath);
}
using (Pen p = new Pen(Color.DarkGray, 3)) {
p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
g.DrawLine(p, new Point(mScrollBar.X + 6, 18), new Point(mScrollBar.X + 15, 8));
g.DrawLine(p, new Point(mScrollBar.X + 24, 18), new Point(mScrollBar.X + 15, 8));
g.DrawLine(p, new Point(mScrollBar.X + 6, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
g.DrawLine(p, new Point(mScrollBar.X + 24, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
}
for (int l = 24; l < rcClient.Height - 24; l += 4) {
g.DrawLine(Pens.DarkGray, new Point(mScrollBar.Location.X + 6, l), new Point(mScrollBar.Location.X + 24, l));
}
g.DrawPath(Pens.Black, thumbPath);
thumbPath.Dispose();
}
rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - ((mScrollBar.Width > 0) ? mScrollBar.Width + szSpace.Width : 0), 0);
for (int i = 0; i < Items.Count; i++) {
ListItem item = Items[i];
if (item.Icon != null) {
rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
rcText.X = rcIcon.Right + szSpace.Width;
rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
} else {
rcIcon = new Rectangle(0, 0, 0, 0);
rcText.X = ItemPadding.Left + rcItem.X;
rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
}
Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
item.Size = rcItem.Size;
item.Location.X = rcItem.Location.X;
item.Location.Y = rcItem.Location.Y + mCurrentY;
rcText.Height = rcItem.Height;
//.........这里部分代码省略.........
示例14: Draw
public void Draw(Graphics g)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Pen axisPen = new Pen(AxisColor, AxisWidth))
using (Pen majorPen = new Pen(AxisColor, MajorTickWidth))
using (Pen minorPen = new Pen(AxisColor, MinorTickWidth))
using (Brush labelBrush = new SolidBrush(LabelColor))
{
axisPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
majorPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
minorPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
try
{
g.DrawPath(axisPen, m_arcPath);
g.DrawPath(majorPen, m_majorTicksPath);
g.DrawPath(minorPen, m_minorTicksPath);
g.FillPath(labelBrush, m_labelPath);
}
catch { }
}
//now these areas need to be redrawn if they change
m_redrawRegion.Dispose();
m_redrawRegion = new Region();
m_redrawRegion.Union(m_arcPath);
m_redrawRegion.Union(m_labelPath);
m_redrawRegion.Union(m_majorTicksPath);
m_redrawRegion.Union(m_minorTicksPath);
}
示例15: SetLineCap_InvalidEndCap
public void SetLineCap_InvalidEndCap ()
{
using (Pen p = new Pen (Brushes.Red)) {
p.SetLineCap (LineCap.Flat, (LineCap)Int32.MinValue, DashCap.Flat);
// no exception :( (reported as FDBK50057)
Assert.AreEqual (LineCap.Flat, p.StartCap, "StartCap");
Assert.AreEqual (Int32.MinValue, (int)p.EndCap, "EndCap");
Assert.AreEqual (DashCap.Flat, p.DashCap, "DashCap");
}
}