C#实现图片轮播功能的示例代码

  partial class Form1

  {

  ///

  /// 必需的设计器变量。

  ///

  private System.ComponentModel.IContainer components = null;

  ///

  /// 清理所有正在使用的资源。

  ///

  /// 如果应释放托管资源,为 true;否则为 false。

  protected override void Dispose(bool disposing)

  {

  if (disposing && (components != null))

  {

  components.Dispose();

  }

  base.Dispose(disposing);

  }

  #region Windows 窗体设计器生成的代码

  ///

  /// 设计器支持所需的方法 - 不要

  /// 使用代码编辑器修改此方法的内容。

  ///

  private void InitializeComponent()

  {

  this.components = new System.ComponentModel.Container();

  this.statusStrip1 = new System.Windows.Forms.StatusStrip();

  this.tssltotel = new System.Windows.Forms.ToolStripStatusLabel();

  this.tsslPath = new System.Windows.Forms.ToolStripStatusLabel();

  this.splitContainer1 = new System.Windows.Forms.SplitContainer();

  this.listBox1 = new System.Windows.Forms.ListBox();

  this.button6 = new System.Windows.Forms.Button();

  this.button5 = new System.Windows.Forms.Button();

  this.button3 = new System.Windows.Forms.Button();

  this.cbbShowType = new System.Windows.Forms.ComboBox();

  this.txtTime = new System.Windows.Forms.TextBox();

  this.label2 = new System.Windows.Forms.Label();

  this.button1 = new System.Windows.Forms.Button();

  this.txtPicPath = new System.Windows.Forms.TextBox();

  this.label1 = new System.Windows.Forms.Label();

  this.pictureBox1 = new System.Windows.Forms.PictureBox();

  this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();

  this.timer1 = new System.Windows.Forms.Timer(this.components);

  this.statusStrip1.SuspendLayout();

  this.splitContainer1.Panel1.SuspendLayout();

  this.splitContainer1.Panel2.SuspendLayout();

  this.splitContainer1.SuspendLayout();

  ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

  this.SuspendLayout();

  //

  // statusStrip1

  //

  this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {

  this.tssltotel,

  this.tsslPath});

  this.statusStrip1.Location = new System.Drawing.Point(0, 398);

  this.statusStrip1.Name = "statusStrip1";

  this.statusStrip1.Size = new System.Drawing.Size(616, 22);

  this.statusStrip1.TabIndex = 0;

  this.statusStrip1.Text = "statusStrip1";

  //

  // tssltotel

  //

  this.tssltotel.BackColor = System.Drawing.Color.Transparent;

  this.tssltotel.Name = "tssltotel";

  this.tssltotel.Size = new System.Drawing.Size(0, 17);

  //

  // tsslPath

  //

  this.tsslPath.BackColor = System.Drawing.Color.Transparent;

  this.tsslPath.Name = "tsslPath";

  this.tsslPath.Size = new System.Drawing.Size(0, 17);

  //

  // splitContainer1

  //

  this.splitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

  this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;

  this.splitContainer1.Location = new System.Drawing.Point(0, 0);

  this.splitContainer1.Name = "splitContainer1";

  //

  // splitContainer1.Panel1

  //

  this.splitContainer1.Panel1.Controls.Add(this.listBox1);

  this.splitContainer1.Panel1.Controls.Add(this.button6);

  this.splitContainer1.Panel1.Controls.Add(this.button5);

  this.splitContainer1.Panel1.Controls.Add(this.button3);

  this.splitContainer1.Panel1.Controls.Add(this.cbbShowType);

  this.splitContainer1.Panel1.Controls.Add(this.txtTime);

  this.splitContainer1.Panel1.Controls.Add(this.label2);

  this.splitContainer1.Panel1.Controls.Add(this.button1);

  this.splitContainer1.Panel1.Controls.Add(this.txtPicPath);

  this.splitContainer1.Panel1.Controls.Add(this.label1);

  //

  // splitContainer1.Panel2

  //

  this.splitContainer1.Panel2.Controls.Add(this.pictureBox1);

  this.splitContainer1.Size = new System.Drawing.Size(616, 398);

  this.splitContainer1.SplitterDistance = 205;

  this.splitContainer1.SplitterWidth = 1;

  this.splitContainer1.TabIndex = 1;

  //

  // listBox1

  //

  this.listBox1.FormattingEnabled = true;

  this.listBox1.ItemHeight = 12;

  this.listBox1.Location = new System.Drawing.Point(5, 148);

  this.listBox1.Name = "listBox1";

  this.listBox1.Size = new System.Drawing.Size(195, 244);

  this.listBox1.TabIndex = 0;

  this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);

  //

  // button6

  //

  this.button6.Location = new System.Drawing.Point(70, 119);

  this.button6.Name = "button6";

  this.button6.Size = new System.Drawing.Size(63, 23);

  this.button6.TabIndex = 9;

  this.button6.Text = "停止播放";

  this.button6.UseVisualStyleBackColor = true;

  this.button6.Click += new System.EventHandler(this.button6_Click);

  //

  // button5

  //

  this.button5.Location = new System.Drawing.Point(5, 119);

  this.button5.Name = "button5";

  this.button5.Size = new System.Drawing.Size(63, 23);

  this.button5.TabIndex = 8;

  this.button5.Text = "开始播放";

  this.button5.UseVisualStyleBackColor = true;

  this.button5.Click += new System.EventHandler(this.button5_Click);

  //

  // button3

  //

  this.button3.Location = new System.Drawing.Point(135, 119);

  this.button3.Name = "button3";

  this.button3.Size = new System.Drawing.Size(63, 23);

  this.button3.TabIndex = 6;

  this.button3.Text = "清除数据";

  this.button3.UseVisualStyleBackColor = true;

  this.button3.Click += new System.EventHandler(this.button3_Click);

  //

  // cbbShowType

  //

  this.cbbShowType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

  this.cbbShowType.FormattingEnabled = true;

  this.cbbShowType.Items.AddRange(new object[] {

  "原图大小显示",

  "适应窗口显示"});

  this.cbbShowType.Location = new System.Drawing.Point(5, 93);

  this.cbbShowType.Name = "cbbShowType";

  this.cbbShowType.Size = new System.Drawing.Size(195, 20);

  this.cbbShowType.TabIndex = 0;

  //

  // txtTime

  //

  this.txtTime.Location = new System.Drawing.Point(5, 63);

  this.txtTime.Name = "txtTime";

  this.txtTime.Size = new System.Drawing.Size(195, 21);

  this.txtTime.TabIndex = 4;

  this.txtTime.Text = "1000";

  this.txtTime.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtTime_KeyDown);

  this.txtTime.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtTime_KeyPress);

  //

  // label2

  //

  this.label2.AutoSize = true;

  this.label2.Location = new System.Drawing.Point(3, 48);

  this.label2.Name = "label2";

  this.label2.Size = new System.Drawing.Size(89, 12);

  this.label2.TabIndex = 3;

  this.label2.Text = "暂停时间(毫秒)";

  //

  // button1

  //

  this.button1.Location = new System.Drawing.Point(143, 20);

  this.button1.Name = "button1";

  this.button1.Size = new System.Drawing.Size(57, 23);

  this.button1.TabIndex = 2;

  this.button1.Text = "浏览...";

  this.button1.UseVisualStyleBackColor = true;

  this.button1.Click += new System.EventHandler(this.button1_Click);

  //

  // txtPicPath

  //

  this.txtPicPath.BackColor = System.Drawing.Color.White;

  this.txtPicPath.Location = new System.Drawing.Point(5, 21);

  this.txtPicPath.Name = "txtPicPath";

  this.txtPicPath.ReadOnly = true;

  this.txtPicPath.Size = new System.Drawing.Size(137, 21);

  this.txtPicPath.TabIndex = 1;

  //

  // label1

  //

  this.label1.AutoSize = true;

  this.label1.Location = new System.Drawing.Point(3, 6);

  this.label1.Name = "label1";

  this.label1.Size = new System.Drawing.Size(65, 12);

  this.label1.TabIndex = 0;

  this.label1.Text = "图片目录:";

  //

  // pictureBox1

  //

  this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill;

  this.pictureBox1.Location = new System.Drawing.Point(0, 0);

  this.pictureBox1.Name = "pictureBox1";

  this.pictureBox1.Size = new System.Drawing.Size(406, 394);

  this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;

  this.pictureBox1.TabIndex = 0;

  this.pictureBox1.TabStop = false;

  //

  // timer1

  //

  this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

  //

  // Form1

  //

  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

  this.BackColor = System.Drawing.Color.WhiteSmoke;

  this.ClientSize = new System.Drawing.Size(616, 420);

  this.Controls.Add(this.splitContainer1);

  this.Controls.Add(this.statusStrip1);

  this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

  this.MaximizeBox = false;

  this.Name = "Form1";

  this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

  this.Text = "图片自动播放器";

  this.Load += new System.EventHandler(this.Form1_Load);

  this.statusStrip1.ResumeLayout(false);

  this.statusStrip1.PerformLayout();

  this.splitContainer1.Panel1.ResumeLayout(false);

  this.splitContainer1.Panel1.PerformLayout();

  this.splitContainer1.Panel2.ResumeLayout(false);

  this.splitContainer1.ResumeLayout(false);

  ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

  this.ResumeLayout(false);

  this.PerformLayout();

  }

  #endregion

  private System.Windows.Forms.StatusStrip statusStrip1;

  private System.Windows.Forms.SplitContainer splitContainer1;

  private System.Windows.Forms.Button button1;

  private System.Windows.Forms.TextBox txtPicPath;

  private System.Windows.Forms.Label label1;

  private System.Windows.Forms.Label label2;

  private System.Windows.Forms.TextBox txtTime;

  private System.Windows.Forms.ListBox listBox1;

  private System.Windows.Forms.Button button6;

  private System.Windows.Forms.Button button5;

  private System.Windows.Forms.Button button3;

  private System.Windows.Forms.ComboBox cbbShowType;

  private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;

  private System.Windows.Forms.ToolStripStatusLabel tsslPath;

  private System.Windows.Forms.ToolStripStatusLabel tssltotel;

  private System.Windows.Forms.PictureBox pictureBox1;

  private System.Windows.Forms.Timer timer1;

  }