trinagle.cs
来自「CSharp的MDI窗口事例」· CS 代码 · 共 39 行
CS
39 行
using System;
using System.Drawing;
namespace MDICSharp
{
[Serializable]
public class Triangle : MDICSharp.Shape
{
public Triangle(Point st, Point ep)
{
StartPoint = st;
EndPoint = ep;
} // constructor
public override void DrawShape(Graphics dc, Pen drawPen, Brush brush)
{
Rectangle drawArea;
Size rectSize = new Size((EndPoint.X - StartPoint.X), (EndPoint.Y - StartPoint.Y));
drawArea = new Rectangle(StartPoint, rectSize);
Brush b = new SolidBrush(Color.Red);
Point[] pt;
pt = new Point[4];
pt[0].X = pt[3].X = EndPoint.X;
pt[0].Y = pt[3].Y = EndPoint.Y;
pt[1].X = StartPoint.X + rectSize.Width/2;
pt[1].Y = StartPoint.Y;
pt[2].X = StartPoint.X;
pt[2].Y = EndPoint.Y;
dc.DrawPolygon(drawPen, pt);
dc.FillPolygon(brush, pt);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?