代码拉取完成,页面将自动刷新
Lamp控件指定不闪烁时的颜色?查了源码并没有发现可以指定最终显示颜色方法(不闪烁)
初始设置2种颜色(RED,LIME)源码中使用了intColorIndex在onPaint用于实现每次闪烁时重绘颜色。当重新指定LampColor=new Color[]{ Color.RED } 为一种颜色时,因为intColorIndex可能会大于1,此时onPaint重绘方法获取的LampColor[intColorIndex]会提示数组越界。
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SetGDIHigh();
Color c1 = lampColor[intColorIndex];//这一行会数组越界
GraphicsPath path = new GraphicsPath();
path.AddLine(new Point(m_rectWorking.Left, m_rectWorking.Bottom), new Point(m_rectWorking.Left, m_rectWorking.Top + m_rectWorking.Width));
path.AddArc(new Rectangle(m_rectWorking.Left, m_rectWorking.Top, m_rectWorking.Width, m_rectWorking.Width), 180f, 180f);
path.AddLine(new Point(m_rectWorking.Right, m_rectWorking.Top + m_rectWorking.Width), new Point(m_rectWorking.Right, m_rectWorking.Bottom));
path.CloseAllFigures();
g.FillPath(new SolidBrush(c1), path);
g.FillRectangle(new SolidBrush(lampstand), new Rectangle(5, m_rectWorking.Bottom - 19, this.Width - 10, 10));
g.FillRectangle(new SolidBrush(lampstand), new Rectangle(0, m_rectWorking.Bottom - 10, this.Width, 10));
}
期待提供指定颜色(非闪烁时)的方法。