吉吉于

free

C#每天抄一点(26):图像滚动展示

 

01 /*
02 * 由SharpDevelop创建。
03 * 用户: Lazynight
04 * 日期: 2011/10/25
05 * 时间: 19:04
06 *
07 * 要改变这种模板请点击 工具|选项|代码编写|编辑标准头文件
08 */
09 using System;
10 using System.Collections.Generic;
11 using System.Drawing;
12 using System.Windows.Forms;
13
14 namespace Lazy26_图像滚动效果
15 {
16
17     public partial class MainForm : Form
18     {
19         public MainForm()
20         {
21
22             InitializeComponent();
23
24         }
25
26         void MainFormLoad(object sender, EventArgs e)
27         {
28             this.timer1.Enabled=true;
29         }
30
31         void Timer1Tick(object sender, EventArgs e)
32         {
33             this.panel1.Left=this.panel1.Left+10;//每秒10个像素向右移动
34             if(this.panel1.Left>this.Width)
35             {
36                 this.panel1.Left=-this.Width;
37                 //循环一圈,将panel右端与窗口左端对齐,开始新的一轮
38             }
39         }
40
41         void PictureBox1MouseEnter(object sender, EventArgs e)
42         {
43             timer1.Enabled=false;
44         }
45
46         void PictureBox1MouseLeave(object sender, EventArgs e)
47         {
48             timer1.Enabled=true;
49         }
50
51         void PictureBox2MouseEnter(object sender, EventArgs e)
52         {
53             timer1.Enabled=false;
54         }
55
56         void PictureBox2MouseLeave(object sender, EventArgs e)
57         {
58             timer1.Enabled=true;
59         }
60
61         void PictureBox3MouseEnter(object sender, EventArgs e)
62         {
63             timer1.Enabled=false;
64         }
65
66         void PictureBox3MouseLeave(object sender, EventArgs e)
67         {
68             timer1.Enabled=true;
69         }
70     }
71 }

下载源码

转载请注明:于哲的博客 » C#每天抄一点(26):图像滚动展示