点不到的学习
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("当然是不学习啦");
this.Close();
}
private void button2_MouseEnter(object sender, EventArgs e)
{
int x = this.ClientSize.Width - button2.Width;
int y = this.ClientSize.Height - button2.Height;
Random r = new Random();
button2.Location = new Point(r.Next(0, x + 1), r.Next(0, y + 1));
}
}
}
灯+时间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text=label1.Text.Substring(1) + label1.Text.Substring(0, 1);
}
private void timer2_Tick(object sender, EventArgs e)
{
label2.Text=DateTime.Now.ToString();
if (DateTime.Now.Hour==13 && DateTime.Now.Minute==54 && DateTime.Now.Second==1)
{
MessageBox.Show("时间到了");
}
}
private void Form1_Load(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString();
}
}
}
切换图片上下一张
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
}
string[] path=Directory.GetFiles(@"C:\Users\Administrator\Desktop\DesktopWallpaper");
int i = 0;
private void button2_Click(object sender, EventArgs e)
{
i++;
if (i == path.Length)
{
i = 0;
}
pictureBox1.Image = Image.FromFile(path[i]);
}
private void button1_Click(object sender, EventArgs e)
{
i--;
if (i<0)
{
i = path.Length-1;
}
pictureBox1.Image = Image.FromFile(path[i]);
}
}
}
随机播放6张图片
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApp9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] path=Directory.GetFiles(@"C:\Users\Administrator\Desktop\DesktopWallpaper");
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox4.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox5.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox6.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
pictureBox2.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
pictureBox3.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
pictureBox4.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
pictureBox5.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
pictureBox6.Image = Image.FromFile(@"C:\Users\Administrator\Desktop\DesktopWallpaper\夜晚 星空 ɽ 光 · 一个人背影 4k唯美壁纸3840x2160_彼岸图网.jpg");
}
int i = 0;
Random r = new Random();
private void timer1_Tick(object sender, EventArgs e)
{
if (i==path.Length)
{
i = 0;
}
pictureBox1.Image = Image.FromFile(path[r.Next(0,path.Length)]);
pictureBox2.Image = Image.FromFile(path[r.Next(0, path.Length)]);
pictureBox3.Image = Image.FromFile(path[r.Next(0, path.Length)]);
pictureBox4.Image = Image.FromFile(path[r.Next(0, path.Length)]);
pictureBox5.Image = Image.FromFile(path[r.Next(0, path.Length)]);
pictureBox6.Image = Image.FromFile(path[r.Next(0, path.Length)]);
}
}
}