上.net大局观这门课,只上了前后7,8个小时的课时,老师就让用.net语言编写一闹钟控件,
目前只会新建一个window控件库,如何往里面填加代码却是一点不会的.
    高手最好能手把手的教我~编写一闹铃控件,控件界面在默认情况下显示系统当前时间。格式:当前时间 时:分:秒。要求至少有如下接口:
属性:
Font:界面显示内容的字体
ForeColor:界面显示内容的前景色
BackColor:界面显示内容的背景色
BorderStyle:控件是否有可见的边框。(None、FixedSingle、Fixed3D)
Visible:控件是否可见。ShowCont:枚举类型。界面显示内容选择(当前时间(默认),定时时间(格式:定时 时:分:秒;差 时:分:秒),差表示与定时时间的间隔,无定时时间时显示” 无定时”)。
ShowTimers:正整型。在ShowCont为“当前时间”时无效。0表示ShowCont显示的是最近的定时时间或间隔,1表示次近,…,依次类推。默认为0。
ShowStyle:枚举类型(单个,循环)。界面显示样式。枚举值为循环时:当ShowCont为定时时间,且有多个定时,则循环显示各个定时时间和各个定时时间的间隔。默认为单个。
ShowInterval:ShowStyle属性的循环延迟(单位:毫秒)。默认为1000。
TimerEnable:定时是否启动。方法:
AddTime(DateTime pdteTime,string pstrMessage):设置(增加)定时(闹铃)时间。参数pdteTime为定时时间,参数pstrMessage为定时到时的提示,即产生事件OnTime中同名参数的返回信息。
RemoveTime(DateTime pdteTime):删除已设置的定时时间。
ListTimers(string [,] pdteTimers):列出已设置的定时时间。参数pdteTimers为2唯数组,第一唯为定时时间,第二唯为定时到时返回的信息。

事件:
OnTime(DateTime pdteTime,string pstrMessage):当设置的时间到时(正负1分钟),产生该事件。参数pdteTime为触发事件的定时时间,参数pstrMessage为事件的返回信息。编写一Windows应用程序,对你做的控件进行测试,写出实验报告。(实验报告中要包含如何测试及测试用例)

解决方案 »

  1.   

    参看别人写的
    http://www.codeproject.com/cs/miscctrl/clock.asp
    http://www.codeproject.com/cs/miscctrl/3ZoneWorldClock.asp
      

  2.   

    有人会告诉我一声[email protected]
      

  3.   

    我会做,给点提示好了,没什么耐心专门替楼主写这么多
    1.添加一个UserControl
    在通用区域声明:
    public t1,t2 as date,Tenabled as boolean
    2.添加一个Tstart事件:sub Tstart
    if isnothing(t1) or isnothing(t2) then   'end if
    end sub
    晕,没耐心写下去,自己写吧,主要是在循环中不断检测时间就行了。可以使用datediff函数,也可以使用api,方法多种也可以上网随便找一下程序
      

  4.   

    namespace clock
    {
    /// <summary>
    /// UserControl1 的摘要说明。
    /// </summary>
    public class UserControl1 : System.Windows.Forms.UserControl
    {
    private System.Windows.Forms.Label lbTime;
    private System.Windows.Forms.Timer timer1;
    private System.ComponentModel.IContainer components;       
    private Font myFont;
    private bool TimerEnable=false;
    private System.Windows.Forms.FontDialog fontDialog1;
    private string ShowCont; public UserControl1()
    {
    // 该调用是 Windows.Forms 窗体设计器所必需的。
    InitializeComponent();
    // TODO: 在 InitComponent 调用后添加任何初始化 } /// <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.lbTime = new System.Windows.Forms.Label();
    this.timer1 = new System.Windows.Forms.Timer(this.components);
    this.fontDialog1 = new System.Windows.Forms.FontDialog();
    this.SuspendLayout();
    // 
    // lbTime
    // 
    this.lbTime.AutoSize = true;
    this.lbTime.Font = new System.Drawing.Font("宋体", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
    this.lbTime.ForeColor = System.Drawing.SystemColors.HotTrack;
    this.lbTime.Location = new System.Drawing.Point(0, 8);
    this.lbTime.Name = "lbTime";
    this.lbTime.Size = new System.Drawing.Size(134, 37);
    this.lbTime.TabIndex = 0;
    this.lbTime.Text = "dd:dd:d2";
    // 
    // timer1
    // 
    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
    // 
    // UserControl1
    // 
    this.Controls.Add(this.lbTime);
    this.Name = "UserControl1";
    this.Size = new System.Drawing.Size(136, 56);
    this.ResumeLayout(false); }
    #endregion
    public string GetTime()
    {
    string TimeInString="";
    int hour=DateTime.Now.Hour;
    int min=DateTime.Now.Minute;
    int sec=DateTime.Now.Second; TimeInString=(hour < 10)?"0" + hour.ToString() :hour.ToString();
    TimeInString+=":" + ((min<10)?"0" + min.ToString() :min.ToString());
    TimeInString+=":" + ((sec<10)?"0" + sec.ToString() :sec.ToString());
    return TimeInString;
    }
    private void timer1_Tick(object sender, System.EventArgs e)
    {
    Text=GetTime(); 
    if (ShowCont!=""&& Text==ShowCont)
     OnTime(DateTime.Now,"时间到了");
    }
    //组件中的Text属性,是从标签的Text的属性派生而来
    public override string Text
    {
                get{  return lbTime.Text ;}
                set{  lbTime.Text = value;}
        }
    public bool Timer_Enable
    {
    get{  return TimerEnable ;}
    set
    {  TimerEnable = value;
       timer1.Enabled=TimerEnable;
    }
    }
    public  int Show_Interval  //只读
    {
    get{  return timer1.Interval ;}
    }
    public string Show_Cont
    {
    get{  return ShowCont ;}
    set
    {
    ShowCont= value;
    }
    }
    private void  OnTime(DateTime pdteTime,string pstrMessage)
    {
                    MessageBox.Show(pstrMessage);
    }
    }
      

  5.   

    private Font set_myFont
    {   
    get{  return myFont ;}
    set
    {
                    fontDialog1.ShowEffects=true;
    if(fontDialog1.ShowDialog()==DialogResult.OK)
    value=fontDialog1.Font;
    myFont= value;
    }
    似乎不对??