⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 C#程序开发范例宝典 图书光盘附带源码 第五章
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Ex05_18
{
    public partial class Form1 : Form
    {
        int width=0, heigh=0;
        string strpath;
        public Form1()
        {
            InitializeComponent();
           
        }

        private void Form1_Load(object sender, EventArgs e)
        { 
            strpath = Environment.SystemDirectory+"\\Image";
            Cursor.Hide();
            this.timer1.Enabled = true;
            width = this.Width;
            heigh = this.Height;
            drowImage();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.timer1.Interval = new Random().Next(500, 2000);
            drowImage();
        }

        private void drowImage()
        {
            Graphics myGraphics = this.CreateGraphics();
            myGraphics.Clear(Color.Black);
            Bitmap myBitmap = new Bitmap(strpath+"\\"+new Random().Next(1,10).ToString()+".jpg");
            myGraphics.DrawImage(myBitmap, new Random().Next(0,width - myBitmap.Width), new Random().Next(0,heigh - myBitmap.Height));
        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            ExitWindows();
        }

        private void Form1_Click(object sender, EventArgs e)
        {
            ExitWindows();
        }

        private void ExitWindows()
        {
            this.timer1.Enabled = false;
            Application.Exit();
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -