using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Management.Instrumentation;
namespace MyContrl
{
/// <summary>
/// 播放按钮
/// </summary>
public partial class PlayButton : ToolStripButton
{
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
Graphics g = pevent.Graphics;
g.SmoothingMode = SmoothingMode.AntiAlias; // 抗锯齿,使边缘平滑
SolidBrush sb = new SolidBrush(Color.Red); // 默认红色
RectangleF rect = new RectangleF(5, 4, (this.Height / 2) + 2, (this.Height / 2) + 2); // 圆或方形
List<PointF> pointFs = new List<PointF>();
pointFs.Add(new PointF(6,5));
pointFs.Add(new PointF(6, this.Height-5));
pointFs.Add(new PointF((this.Height / 2)+4, this.Height / 2));
// 填充控件内部
if (this.Tag != null && this.Tag.ToString().Contains("1")) // 1为绿
{
sb = new SolidBrush(Color.Red);
g.FillRectangle(sb, rect);
}
else if (this.Tag != null && this.Tag.ToString().Contains("2")) // 1为红/黄
{
sb = new SolidBrush(Color.Green);
g.FillPolygon(sb, pointFs.ToArray());
}
else
{
sb = new SolidBrush(Color.Green);
g.FillPolygon(sb, pointFs.ToArray());
}
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.
- 51.
- 52.
- 53.
- 54.
作者:꧁执笔小白꧂