using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Caster
{
/// <summary>
/// MyMoveChar 的摘要说明。
/// </summary>
public class MyMoveChar : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.Label label;
private System.ComponentModel.IContainer components;
public MyMoveChar()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
timer.Tick+=new EventHandler(timer_Tick);
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label = new System.Windows.Forms.Label();
this.timer = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// label
//
this.label.AutoSize = true;
this.label.Location = new System.Drawing.Point(320, 0);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(0, 17);
this.label.TabIndex = 0;
//
// timer
//
this.timer.Enabled = true;
//
// MyMoveChar
//
this.Controls.Add(this.label);
this.Name = "MyMoveChar";
this.Size = new System.Drawing.Size(320, 32);
this.ResumeLayout(false);
}
#endregion
#region propertys
public new System.Drawing.Size Size
{
get
{
return base.Size;
}
set
{
base.Size=value;
label.Location= new System.Drawing.Point(label.Location.X,(Size.Height-label.Size.Height)/2);
}
}
public override System.Drawing.Font Font
{
get
{
return base.Font;
}
set
{
base.Font=value;
label.Font=value;
}
}
public override String Text
{
get
{
return label.Text;
}
set
{
label.Text=value;
label.Location=new System.Drawing.Point(this.Size.Width,label.Location.Y);
}
}
public override System.Drawing.Color ForeColor
{
get
{
return base.ForeColor;
}
set
{
base.ForeColor=value;
label.ForeColor=value;
}
}
public override System.Drawing.Color BackColor
{
get
{
return base.BackColor;
}
set
{
base.BackColor=value;
label.BackColor=value;
}
}
public int Interval
{
get
{
return timer.Interval;
}
set
{
timer.Interval=value;
}
}
#endregion
private void timer_Tick(object sender, EventArgs e)
{
if((label.Location.X+label.Size.Width)>0)
label.Location=new System.Drawing.Point(label.Location.X-1,label.Location.Y);
else
label.Location=new System.Drawing.Point(this.Size.Width,label.Location.Y);
}
}
}