老大突然叫我做一个LED屏的项目,没办法,就写了一个简单的例子,然后附到项目中。
要求:实现左右上下都可以自动轮回转动,把所有内容都要显示出来。一个都不能落下。还要可以设置滚动的字幕的大小,字体,颜色等等。
图如:
滚动的控件
时间控件
代码如:
时间控件隔时发生事件代码:
左右滚动:
/// <summary>
/// 时间空间1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick_1(object sender, EventArgs e)
{
textBox9.Text = ClassVar.SystemNowTimeLong();
label1.Left = label1.Left - 2;
if (label1.Left < 0 - label1.Width)
{
label1.Left = 1050;
}
label25.Left = label25.Left - 2;
if (label25.Left > this.Width)
{
label25.Left = 135;
}
/// 时间空间1
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick_1(object sender, EventArgs e)
{
textBox9.Text = ClassVar.SystemNowTimeLong();
label1.Left = label1.Left - 2;
if (label1.Left < 0 - label1.Width)
{
label1.Left = 1050;
}
label25.Left = label25.Left - 2;
if (label25.Left > this.Width)
{
label25.Left = 135;
}
//label25.Right++;
//label24.Left++;
//if (label24.Left > this.Width)
//{
// label24.Left = 300;
//}
//label13.Left++;
//if (label13.Left > this.Width)
//{
// label13.Left = 300;
//}
//label19.Left++;
//if (label19.Left > this.Width)
//{
// label19.Left = 300;
//}
//label8.Left++;
//if (label8.Left > this.Width)
//{
// label8.Left = 300;
//}
//label9.Left++;
//if (label9.Left > this.Width)
//{
// label9.Left = 300;
//}
//label10.Left++;
//if (label10.Left > this.Width)
//{
// label10.Left = 300;
//}
//label11.Left++;
//if (label11.Left > this.Width)
//{
// label11.Left = 300;
//}
//label18.Left++;
//if (label18.Left > this.Width)
//{
// label18.Left = 300;
//}
//label24.Left++;
//if (label24.Left > this.Width)
//{
// label24.Left = 300;
//}
//label13.Left++;
//if (label13.Left > this.Width)
//{
// label13.Left = 300;
//}
//label19.Left++;
//if (label19.Left > this.Width)
//{
// label19.Left = 300;
//}
//label8.Left++;
//if (label8.Left > this.Width)
//{
// label8.Left = 300;
//}
//label9.Left++;
//if (label9.Left > this.Width)
//{
// label9.Left = 300;
//}
//label10.Left++;
//if (label10.Left > this.Width)
//{
// label10.Left = 300;
//}
//label11.Left++;
//if (label11.Left > this.Width)
//{
// label11.Left = 300;
//}
//label18.Left++;
//if (label18.Left > this.Width)
//{
// label18.Left = 300;
//}
上下滚动代码:
/// <summary>
/// 时间空间2
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer2_Tick(object sender, EventArgs e)
{
int top = label23.Top;
int bt = label23.Bottom;
top = top - 2;
if (bt <= this.Top)
{
top = 450;
}
label23.Top = top;
}
加载时代码:
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
做的粗糙,还有不足的地方还请大家多多指教指教。。。。小弟