C# 用Timer组件开发你的动感程序!!!,C# 用Time,# 用Timer, 用Timer组,用Timer组件,Timer组件开,imer组件开发,mer组件开发你,er组件开发你的,r组件开发你的动,组件开发你的动感,件开发你的动感程,开发你的动感程序,发你的动感程序!,你的动感程序!! C# 用Timer组件开发你的动感程序!!!----编程资料集中营--八角123--bajiao123.com
编程资料集中营
 | 网站首页 | 文章中心 | 编程资料2 | 软件下载 | BT下载 | 八卦星闻 | 音乐在线 | 在线游戏 | 免费电影 | 进入问吧 | 
C# 用Timer组件开发你的动感程序!!!,前面有朋友介绍了Timer组件的应用,发现有一些不详细的地方。为此特意上传了这段代码,希望能给各位一点启发!其详细的介绍可阅前面一位朋友提供的文章,在此不再重复。usingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Wind,
您现在的位置: 编程资料,学习资料,c,c++,vc,vc++,java,jsp,j2ee,j2me,asp,php >> 文章中心 >> .NET 专区 >> C# 技术 >> 文章正文
【字体:
C# 用Timer组件开发你的动感程序!!!   进入问吧

本站地址:http://www.bajiao123.com

作者:admin    文章来源:不详    点击数:    更新时间:2007-6-2    

C# 用Timer组件开发你的动感程序!!!

     前面有朋友介绍了Timer组件的应用,发现有一些不详细的地方。为此特意上传了这段代码,希望能给各位一点启发!
  其详细的介绍可阅前面一位朋友提供的文章,在此不再重复。
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsAp
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
public int x1=0,y1=0;
private System.Timers.Timer timer1;
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.timer1 = new System.Timers.Timer();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.timer1)).BeginInit();
this.SuspendLayout();
// 
// timer1
// 
this.timer1.Enabled = true;
this.timer1.SynchronizingObject = this;
this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed);
// 
// pictureBox1
// 
this.pictureBox1.BackgroundImage = ((System.Drawing.Bitmap)(resources.GetObject(pictureBox1.BackgroundImage)));
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject(pictureBox1.Image)));
this.pictureBox1.Name = pictureBox1;
this.pictureBox1.Size = new System.Drawing.Size(144, 128);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
// 
// Form1
// 
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(142, 123);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
  this.pictureBox1});
this.MaximizeBox = false;
this.Name = Form1;
this.Text = Form1;
this.TopMost = true;
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.timer1)).EndInit();
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main() 
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{
this.timer1.Enabled =true;
this.timer1.Interval =100;


}

private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
  x1+=1;
  y1+=1;
if (x1+10>=700)
x1=0;
if(y1+10>=500)
y1=0;
Point newxy=new Point ( x1,y1 );
this.DesktopLocation =newxy;

  

}

private void label1_Click(object sender, System.EventArgs e)
{

}
}
}

进入问吧

本站地址:http://www.bajiao123.com

文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 高级搜索
    编程资料集中营