图片随机显示器(C#)
来源:互联网 发布:ubuntu可以用来做什么 编辑:程序博客网 时间:2024/05/18 00:04
//源代码如下:
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;using System.IO;namespace picture{ public partial class Form1 : Form { static int count0 = 0; static int count1 = 0; static int count2 = 0; static int count3 = 0; static int count4 = 0; static int count5 = 0; static int count6 = 0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Random r = new Random(); int i = r.Next(7); switch (i) { case 0: pictureBox1.Image = Properties.Resources.carmelo; count0++; label1.Text = "显示次数:" + count0 + "次"; break; case 1: pictureBox1.Image = Properties.Resources.me; count1++; label1.Text = "显示次数:" + count1 + "次"; break; case 2: pictureBox1.Image = Properties.Resources.stephen; count2++; label1.Text = "显示次数:" + count2 + "次"; break; case 3: pictureBox1.Image = Properties.Resources.gdp; count3++; label1.Text = "显示次数:" + count3 + "次"; break; case 4: pictureBox1.Image = Properties.Resources.irving; count4++; label1.Text = "显示次数:" + count4 + "次"; break; case 5: pictureBox1.Image = Properties.Resources.银尼玛; count5++; label1.Text = "显示次数:" + count5 + "次"; break; case 6: pictureBox1.Image = Properties.Resources.curry; count6++; label1.Text = "显示次数:" + count6 + "次"; break; } FileStream saveFile = new FileStream("显示结果.txt", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(saveFile); sw.WriteLine("carmelo.jpg 显示了{0}次\n", count0); sw.WriteLine("me.jpg 显示了{0}次\n", count1); sw.WriteLine("stephen.jpg 显示了{0}次\n", count2); sw.WriteLine("gdp.jpg 显示了{0}次\n", count3); sw.WriteLine("irving.jpg 显示了{0}次\n", count4); sw.WriteLine("银尼玛.jpg 显示了{0}次\n", count5); sw.WriteLine("curry.jpg 显示了{0}次\n", count6); sw.Close(); } }}
功能:
1. 按下随机显示按钮,随机显示图片
2. 计算每张图片显示的次数
3. 把显示次数的结果保存到文件里
原始界面:
显示一定次数后的界面:
把显示次数的结果保存到 ——显示结果.txt 文件中
0 0
- 图片随机显示器(C#)
- “随机图片显示器”开发(WPF)
- 第二次作业:WinForm程序设计-随机图片显示器
- android 图片显示器
- 作业:顺序图片显示器
- 图片显示器(Java+Python)
- C#——随机显示图片
- 随机图片
- 随机图片
- css实现图片显示器功能
- asp.net(C#)图片随机验证码的代码!
- 显示器
- 显示器
- 显示器
- 显示器
- 显示器
- C#第二次作业:顺序图片显示器开发
- C#第二次作业--顺序图片显示器
- POJ1611(并查集)
- HDU4114 Disney's FastPass(floyd+状态压缩DP)旅游问题升级(难)
- Step into MongoDB - 03 - Database & Collection & Document
- 基金都快放假吗,可感受到
- bzoj 3993: [Sdoi2015]星际战争
- 图片随机显示器(C#)
- openstack学习笔记----KVM
- nodejs笔记
- JSP Xxx cannot be resolved to a type
- Ubuntu的复制粘贴操作及常用快捷键
- cocos2d-x项目在eclipse打开空指针问题An internal error occurred during: "Android Library Update". java.lang.Nul
- POJ题目1330 Nearest Common Ancestors(LCA)
- Android 自定义View (二) 进阶
- 详解Windows平台搭建Androiod开发环境