Chinaunix首页 | 论坛 | 博客
  • 博客访问: 551500
  • 博文数量: 156
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1183
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-22 11:42
文章分类

全部博文(156)

文章存档

2015年(67)

2014年(89)

分类: C#/.net

2014-12-09 14:57:56


  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. namespace mou
  10. {
  11.     public partial class Form1 : Form
  12.     {
  13.         Graphics FormCGI;
  14.         int Index = 0;

  15.         Image MyImage0 = Image.FromFile("E:\\Image\\0.jpg");
  16.         Image MyImage1 = Image.FromFile("E:\\Image\\1.jpg");
  17.         Image MyImage2 = Image.FromFile("E:\\Image\\2.jpg");
  18.         Image MyImage3 = Image.FromFile("E:\\Image\\3.jpg");
  19.         Image MyImage4 = Image.FromFile("E:\\Image\\4.jpg");
  20.         Image MyImage5 = Image.FromFile("E:\\Image\\5.jpg");
  21.         Image MyImage6 = Image.FromFile("E:\\Image\\6.jpg");
  22.         Image MyImage7 = Image.FromFile("E:\\Image\\7.jpg");
  23.         Image MyImage8 = Image.FromFile("E:\\Image\\8.jpg");
  24.         Image MyImage9 = Image.FromFile("E:\\Image\\9.jpg");
  25.         Image MyImage10 = Image.FromFile("E:\\Image\\10.jpg");
  26.         Image MyImage11 = Image.FromFile("E:\\Image\\11.jpg");
  27.         Image MyImage12 = Image.FromFile("E:\\Image\\12.jpg");
  28.         Image MyImage13 = Image.FromFile("E:\\Image\\13.jpg");
  29.         Image MyImage14 = Image.FromFile("E:\\Image\\14.jpg");
  30.         Image MyImage15 = Image.FromFile("E:\\Image\\15.jpg");
  31.         Image MyImage16 = Image.FromFile("E:\\Image\\16.jpg");
  32.         Image MyImage17 = Image.FromFile("E:\\Image\\17.jpg");

  33.         public Form1()
  34.         {
  35.             InitializeComponent();
  36.             FormCGI = this.CreateGraphics();
  37.         }

  38.         private void Form1_MouseClick(object sender, MouseEventArgs e)
  39.         {
  40.             FormCGI.Clear(Color.LightGray);
  41.            
  42.             Rectangle MyRectangle = new Rectangle(e.X, e.Y, 200, 200); //起点是鼠标点击的位置

  43.             if(Index % 18 == 0)
  44.                 FormCGI.DrawImage(MyImage0, MyRectangle);
  45.             else if (Index % 18 == 1)
  46.                 FormCGI.DrawImage(MyImage1, MyRectangle);
  47.             else if (Index % 18 == 2)
  48.                 FormCGI.DrawImage(MyImage2, MyRectangle);
  49.             else if (Index % 18 == 3)
  50.                 FormCGI.DrawImage(MyImage3, MyRectangle);
  51.             else if (Index % 18 == 4)
  52.                 FormCGI.DrawImage(MyImage4, MyRectangle);
  53.             else if (Index % 18 == 5)
  54.                 FormCGI.DrawImage(MyImage5, MyRectangle);
  55.             else if (Index % 18 == 6)
  56.                 FormCGI.DrawImage(MyImage6, MyRectangle);
  57.             else if (Index % 18 == 7)
  58.                 FormCGI.DrawImage(MyImage7, MyRectangle);
  59.             else if (Index % 18 == 8)
  60.                 FormCGI.DrawImage(MyImage8, MyRectangle);
  61.             else if (Index % 18 == 9)
  62.                 FormCGI.DrawImage(MyImage9, MyRectangle);
  63.             else if (Index % 18 == 10)
  64.                 FormCGI.DrawImage(MyImage10, MyRectangle);
  65.             else if (Index % 18 == 11)
  66.                 FormCGI.DrawImage(MyImage11, MyRectangle);
  67.             else if (Index % 18 == 12)
  68.                 FormCGI.DrawImage(MyImage12, MyRectangle);
  69.             else if (Index % 18 == 13)
  70.                 FormCGI.DrawImage(MyImage13, MyRectangle);
  71.             else if (Index % 18 == 14)
  72.                 FormCGI.DrawImage(MyImage14, MyRectangle);
  73.             else if (Index % 18 == 15)
  74.                 FormCGI.DrawImage(MyImage15, MyRectangle);
  75.             else if (Index % 18 == 16)
  76.                 FormCGI.DrawImage(MyImage16, MyRectangle);
  77.             else
  78.                 FormCGI.DrawImage(MyImage17, MyRectangle);
  79.          
  80.             Index++;
  81.         }

  82.         private void timer1_Tick(object sender, EventArgs e)
  83.         {
  84.             FormCGI.Clear(Color.LightGray);

  85.             Rectangle MyRectangle = new Rectangle(100, 100, 300, 300); //起点是鼠标点击的位置

  86.             if (Index % 18 == 0)
  87.                 FormCGI.DrawImage(MyImage0, MyRectangle);
  88.             else if (Index % 18 == 1)
  89.                 FormCGI.DrawImage(MyImage1, MyRectangle);
  90.             else if (Index % 18 == 2)
  91.                 FormCGI.DrawImage(MyImage2, MyRectangle);
  92.             else if (Index % 18 == 3)
  93.                 FormCGI.DrawImage(MyImage3, MyRectangle);
  94.             else if (Index % 18 == 4)
  95.                 FormCGI.DrawImage(MyImage4, MyRectangle);
  96.             else if (Index % 18 == 5)
  97.                 FormCGI.DrawImage(MyImage5, MyRectangle);
  98.             else if (Index % 18 == 6)
  99.                 FormCGI.DrawImage(MyImage6, MyRectangle);
  100.             else if (Index % 18 == 7)
  101.                 FormCGI.DrawImage(MyImage7, MyRectangle);
  102.             else if (Index % 18 == 8)
  103.                 FormCGI.DrawImage(MyImage8, MyRectangle);
  104.             else if (Index % 18 == 9)
  105.                 FormCGI.DrawImage(MyImage9, MyRectangle);
  106.             else if (Index % 18 == 10)
  107.                 FormCGI.DrawImage(MyImage10, MyRectangle);
  108.             else if (Index % 18 == 11)
  109.                 FormCGI.DrawImage(MyImage11, MyRectangle);
  110.             else if (Index % 18 == 12)
  111.                 FormCGI.DrawImage(MyImage12, MyRectangle);
  112.             else if (Index % 18 == 13)
  113.                 FormCGI.DrawImage(MyImage13, MyRectangle);
  114.             else if (Index % 18 == 14)
  115.                 FormCGI.DrawImage(MyImage14, MyRectangle);
  116.             else if (Index % 18 == 15)
  117.                 FormCGI.DrawImage(MyImage15, MyRectangle);
  118.             else if (Index % 18 == 16)
  119.                 FormCGI.DrawImage(MyImage16, MyRectangle);
  120.             else
  121.                 FormCGI.DrawImage(MyImage17, MyRectangle);

  122.             Index++;
  123.         }

  124.         private void PlayButton_Click(object sender, EventArgs e)
  125.         {
  126.             if (timer1.Enabled == true)
  127.             {
  128.                 timer1.Enabled = false;
  129.                 PlayButton.Text = "播放";
  130.             }

  131.             else
  132.             {
  133.                 timer1.Enabled = true;
  134.                 PlayButton.Text = "暂停";
  135.             }
  136.         }     
  137.     }
  138. }

阅读(1782) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~