Chinaunix首页 | 论坛 | 博客
  • 博客访问: 183514
  • 博文数量: 34
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 183
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-21 09:49
个人简介

我会用牵强的微笑,活出无人能比的骄傲

文章分类

全部博文(34)

文章存档

2016年(3)

2015年(5)

2014年(25)

2013年(1)

分类: C#/.net

2014-12-29 11:18:55

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace Mouse
{
    public partial class Form1 : Form
    {
        Graphics FormCGI;
        int Index = 0;
        Image MyImage1 = Image.FromFile("F:\\1\\1.jpg");
        Image MyImage2 = Image.FromFile("F:\\1\\2.jpg");
        Image MyImage3 = Image.FromFile("F:\\1\\3.jpg");
        Image MyImage4 = Image.FromFile("F:\\1\\4.jpg");
        Image MyImage5 = Image.FromFile("F:\\1\\5.jpg");
        Image MyImage6 = Image.FromFile("F:\\1\\6.jpg");
        Image MyImage7 = Image.FromFile("F:\\1\\7.jpg");
        Image MyImage8 = Image.FromFile("F:\\1\\8.jpg");
        Image MyImage9 = Image.FromFile("F:\\1\\9.jpg");
        Image MyImage10 = Image.FromFile("F:\\1\\10.jpg");


        public Form1()
        {
            InitializeComponent();
            FormCGI = this .CreateGraphics();
        }


        private void button1_MouseEnter(object sender, EventArgs e)
        {
            label1.Text = "鼠标进来了";
        }


        private void button1_MouseLeave(object sender, EventArgs e)
        {
            label1.Text = "鼠标离开了";
        }


        private void button1_MouseMove(object sender, MouseEventArgs e)
        {
           // label2.Text = "鼠标在移动";
        }


        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = "点击鼠标";


            String x, y;
            MouseEventArgs e1 = (MouseEventArgs)e;
            x = e1.X.ToString();
            y = e1.Y.ToString();


            label2.Text = "X坐标" + x + "  Y坐标" + y;
        }


        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            FormCGI.Clear(Color.LightGray);        //画图像
            


            Rectangle MyRectangle = new Rectangle(e.X, e.Y, 200, 200);     //图像会自动缩放在矩形里


            if(Index % 10 == 0)
                FormCGI.DrawImage(MyImage1, MyRectangle);
            else if (Index % 10 == 1)
                FormCGI.DrawImage(MyImage2, MyRectangle);
            else if(Index % 10 == 2)
                FormCGI.DrawImage(MyImage3, MyRectangle);
            else if (Index % 10 == 3)
                FormCGI.DrawImage(MyImage4, MyRectangle);
            else if (Index % 10 == 4)
                FormCGI.DrawImage(MyImage5, MyRectangle);
            else if (Index % 10 == 5)
                FormCGI.DrawImage(MyImage6, MyRectangle);
            else if (Index % 10 == 6)
                FormCGI.DrawImage(MyImage7, MyRectangle);
            else if (Index % 10 == 7)
                FormCGI.DrawImage(MyImage8, MyRectangle);
            else if (Index % 10 == 8)
                FormCGI.DrawImage(MyImage9, MyRectangle);
            else 
                FormCGI.DrawImage(MyImage10, MyRectangle);
            Index++;


          /*  Point LineStart = new Point(500, 400);
            Point LineEnd = new Point(e.X, e.Y);
            Pen MyPen = new Pen(Color.Red, 5);


            FormCGI.DrawLine(MyPen, LineStart, LineEnd);*/
          
    //        Rectangle tempRec = new Rectangle(e.X-25, e.Y-25, 50, 50);//横纵坐标减去变长的一半,让他以鼠标为中心画圆
                      
     //       FormCGI.DrawEllipse(Mypen, tempRec);  //画圆
     /*       Pen MypenBlue = new Pen(Color.Blue, 5);    //pen是手绘铅笔


           Font myfont = new Font("隶书", 20);
            Brush mybrush = new SolidBrush(Color.Tomato);


            FormCGI.Clear(Color.LightGray); 
            FormCGI.DrawString("你好",myfont, mybrush,e.X ,e.Y);*/
        }


        private void songbutton_Click(object sender, EventArgs e)
        {
            Font myfont = new Font("宋体", 20);
            Brush mybrush = new SolidBrush(Color.Tomato);


            FormCGI.Clear(Color.LightGray);
            FormCGI.DrawString("你好", myfont, mybrush, 400,127);
        }


        private void xinweibutton_Click(object sender, EventArgs e)
        {
            Font myfont = new Font("华文彩云", 20);
            Brush mybrush = new SolidBrush(Color.Tomato);


            FormCGI.Clear(Color.LightGray);
            FormCGI.DrawString("你好", myfont, mybrush, 400, 170);
        }


        private void lishubutton_Click(object sender, EventArgs e)
        {
            Font myfont = new Font("隶书", 20);
            Brush mybrush = new SolidBrush(Color.Tomato);


            FormCGI.Clear(Color.LightGray);
            FormCGI.DrawString("你好", myfont, mybrush, 400, 210);
        }


        private void shutibutton_Click(object sender, EventArgs e)
        {
            Font myfont = new Font("方正舒体", 20);
            Brush mybrush = new SolidBrush(Color.Tomato);


            FormCGI.Clear(Color.LightGray);
            FormCGI.DrawString("你好", myfont, mybrush, 400, 250);
        }


        private void Startbutton_Click(object sender, EventArgs e)
        {
            if (timer1.Enabled == true)
            {
                timer1.Enabled = false;
                Startbutton.Text = "播放";
            }
            else
            {
                timer1.Enabled = true;
                Startbutton.Text = "暂停";
            }
        }


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


            Rectangle MyRectangle = new Rectangle(100, 100, 200, 200);     //图像会自动缩放在矩形里


            if (Index % 10 == 0)
                FormCGI.DrawImage(MyImage1, MyRectangle);
            else if (Index % 10 == 1)
                FormCGI.DrawImage(MyImage2, MyRectangle);
            else if (Index % 10 == 2)
                FormCGI.DrawImage(MyImage3, MyRectangle);
            else if (Index % 10 == 3)
                FormCGI.DrawImage(MyImage4, MyRectangle);
            else if (Index % 10 == 4)
                FormCGI.DrawImage(MyImage5, MyRectangle);
            else if (Index % 10 == 5)
                FormCGI.DrawImage(MyImage6, MyRectangle);
            else if (Index % 10 == 6)
                FormCGI.DrawImage(MyImage7, MyRectangle);
            else if (Index % 10 == 7)
                FormCGI.DrawImage(MyImage8, MyRectangle);
            else if (Index % 10 == 8)
                FormCGI.DrawImage(MyImage9, MyRectangle);
            else
                FormCGI.DrawImage(MyImage10, MyRectangle);
            Index++;
        }
    }
}

阅读(1796) | 评论(0) | 转发(0) |
0

上一篇:java之路,Class类

下一篇:C#操作数据库

给主人留下些什么吧!~~