在 C# 中使用画笔
【打印文章】
public class Rectangle : Shape
{
protected Point m_Start;
protected Point m_End;
public Rectangle(Point start, Point end, Color fgColor)
{
m_Start = start;
m_End = end;
m_Color = fgColor;
}
public override void Draw(Form canvas)
{
if (canvas == null)
{
return;
}
InitializeGraphics(canvas);
Point startPoint = canvas.PointToScreen(m_Start);
Point endPoint = canvas.PointToScreen(m_End);
MainForm mainForm = (MainForm)canvas;
Color bgColor = GetBackgroundColor(m_Color);
Size rectSize = new Size(m_End.X - m_Start.X, m_End.Y - m_Start.Y);
System.Drawing.Rectangle rectToDraw = new System.Drawing.Rectangle(startPoint, rectSize);
ControlPaint.DrawReversibleFrame(rectToDraw, bgColor, FrameStyle.Thick);
}
}
作者:jspfuns(原创)
{
protected Point m_Start;
protected Point m_End;
public Rectangle(Point start, Point end, Color fgColor)
{
m_Start = start;
m_End = end;
m_Color = fgColor;
}
public override void Draw(Form canvas)
{
if (canvas == null)
{
return;
}
InitializeGraphics(canvas);
Point startPoint = canvas.PointToScreen(m_Start);
Point endPoint = canvas.PointToScreen(m_End);
MainForm mainForm = (MainForm)canvas;
Color bgColor = GetBackgroundColor(m_Color);
Size rectSize = new Size(m_End.X - m_Start.X, m_End.Y - m_Start.Y);
System.Drawing.Rectangle rectToDraw = new System.Drawing.Rectangle(startPoint, rectSize);
ControlPaint.DrawReversibleFrame(rectToDraw, bgColor, FrameStyle.Thick);
}
}
作者:jspfuns(原创)
本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )
【编程爱好者论坛】