C#Winform–翻翻乐

作者心得
我记得是某个假期没事与俄罗斯方块一起弄的
你别说
还挺好玩的,当是和我爸一起比赛时间,哈哈哈

源代码

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.Threading;namespace FFL
{public partial class Form1 : Form{bool q = true;int o = 0;int l = 0;int f;int h;string n;string m;int r = 1;string[] c = new string[100];Button[] b = new Button[100];int x = 0, y = 0; int p = 1;public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){for (int i = 0; i < 100; i++){Button button = new Button();button.Location = new Point(0, 0);button.Size = new Size(40, 40);button.Click += new EventHandler(button1_Click);if (i % 10 == 0 && i != 0){x = 0;y += 40;}else if (i % 10 != 0 && i != 0){x += 40;}button.Location = new Point(x, y);b[i] = button;Controls.Add(b[i]);}end(false);Random o = new Random();for (int i = 0; i < 100; i++){if (i == 50)p = 1;int g = o.Next(0, 99);CheakNull(g);}for (int i = 0; i < 100; i++){c[i] = b[i].Text;b[i].Text = "";}test();}public void CheakNull(int g){if (b[g].Text == ""){b[g].Text = Convert.ToString(p);p++;}else if (g != 99){g += 1;CheakNull(g);}else{g = 0;CheakNull(g);}}private void timer1_Tick(object sender, EventArgs e){if (r == 3){if (n == m){b[f].BackColor = Color.Red;b[h].BackColor = Color.Red;b[f].Enabled = false;b[h].Enabled = false;l += 2;label2.Text = Convert.ToString(l);}for (int i = 0; i < 100; i++){if (b[h].BackColor != Color.Red && b[f].BackColor != Color.Red){b[i].Text = "";b[f].Enabled = true;b[f].BackColor = Color.Black;b[h].Enabled = true;b[h].BackColor = Color.Black;}}r = 1;}}private void timer2_Tick(object sender, EventArgs e){o++;label4.Text = Convert.ToString(o);}private void button1_Click_1(object sender, EventArgs e){timer2.Enabled = true;end(true);}public void button1_Click(object sender, EventArgs e){if (r == 1){int a; int d;Button button = (Button)sender;Point g = new Point();g = button.Location;a = g.X;d = g.Y;int u = (a / 40) + (d / 40) * 10;button.Text = c[u];n = c[u];f = u;button.Enabled = false;button.BackColor = Color.Yellow;timer1.Enabled = true;cheak_all();}if (r == 2){int a; int d;Button button = (Button)sender;Point g = new Point();g = button.Location;a = g.X;d = g.Y;int u = (a / 40) + (d / 40) * 10;button.Text = c[u];m = c[u];h = u;button.Enabled = false;button.BackColor = Color.Yellow;timer1.Enabled = true;}if (r == 1 || r == 2)r++;}public void end(bool c){for (int i = 0; i < 100; i++){b[i].Enabled = c;}}public void cheak_all(){if (label2.Text == "100"){end(false);timer2.Enabled = false;button1.Enabled = false;MessageBox.Show("恭喜,总共花费时间:" + Convert.ToString(o));}}private void button2_Click(object sender, EventArgs e){if (q == true){textBox1.Visible = true;this.Size = new Size(1031, 434);q = false;}else{textBox1.Visible = false;this.Size = new Size(559, 434);q = true;}}private void button3_Click(object sender, EventArgs e){this.Close();}public void test(){int i = 0;foreach (string k in c){if (i % 10 == 0)textBox1.Text = textBox1.Text + "\r\n\r\n\r\n" + k;elsetextBox1.Text = textBox1.Text + "\t" + k;i++;}}}}

效果截图


作者的话
可以看的出
技术越来越成熟,即将开始走向面相对象时代!

【橙子】C#Winform--翻翻乐相关推荐

  1. Log4Net的控制台,WinForm,WebApplication使用

    一.Log4Net的控制台,WinForm,WebApplication使用 1.首先使用nuget 添加log4Net 到控制台项目中 log4j每个符号的具体含义:%d %5p %c{1}:%L ...

  2. C#中Winform程序中如何实现多维表头【不通过第三方报表程序】

    问题:C#中Winform程序中如何实现多维表头. 在网上搜了很多方法,大多数方法对于我这种新手,看的都不是很懂.最后在新浪博客看到了一篇比较易懂的文章:[DataGridView二维表头与合并单元格 ...

  3. C#WinForm的线程及Invoke应用(转)

    C#多线程异步访问winform中控件 http://zwkufo.blog.163.com/blog/static/25882512009111453957552/?fromdm&fromS ...

  4. (转)WinForm控件使用文章收藏整理完成

    http://home.cnblogs.com/group/topic/29829.html 对C# WinForm开发系列收集的控件使用方面进行整理, 加入了一些文章, 不断补充充实, 完善这方面. ...

  5. FastReport.net 使用 Winform WebForm打印

    delphi用的fastreport比较多 所以.net中也研究一下用法,这个打印控件还是很简单的 只要手动设计一下写少许代码就可以打印了 甚至可以写成通用代码 以后就可以不用写代码 安装demo会同 ...

  6. WinForm绘制带有升序、降序的柱形图

    WinForm绘制带有升序.降序的柱形图 private void HuiZhiTu( string strPaiXu){//初始数据int[] nums = { 150, 89, 200, 60, ...

  7. 一个winform带你玩转rabbitMQ

    源码已放出 https://github.com/dubing/MaoyaRabbit 本章分3部分 一.安装部署初探 二.进阶 三.api相关 安装 部署 初探 先上图 一. 安装部署 下载 rab ...

  8. winform配置文件的简单使用(转载)

    1. 首先创建一个winform解决方案 2. 与添加类文件相同的方法添加配置文件,比如:右击解决方案下的项目名称->添加->新建项->选择 "应用程序配置文件" ...

  9. dev treeview控件_在Winform开发框架中使用DevExpress的TreeList和TreeListLookupEdit控件

    DevExpress提供的树形列表控件TreeList和树形下拉列表控件TreeListLookupEdit都是非常强大的一个控件,它和我们传统Winform的TreeView控件使用上有所不同,我一 ...

最新文章

  1. CF1082E Increasing Frequency
  2. Java深度历险(五)——Java泛型
  3. 如何用模型分析中国经济?
  4. C++ primer——vector
  5. STM32 USART1 USART2 UASRT3 UART4 UART5串口通信测试程序
  6. 大力出奇迹!6144块TPU,5400亿参数,会改bug、解读笑话,谷歌刚刚用Pathways训练了一个大模型...
  7. android itool 备份,教您如何将Android SMS导入iPhone
  8. ATTCK实战系列三(msf域渗透)
  9. 阿里的数据同步神器——Canal
  10. python123月份名称缩写_月份及其缩写
  11. hdu 6638 Snowy Smile
  12. 阿里云服务器安全组放行宝塔端口8888|888|80|443|20|21教程
  13. 探讨:Mac真的有必要安装双系统吗
  14. Webshell的预防措施
  15. 联想拯救者Y7000系列黑苹果MacOS 12.3.1 Monterey详细安装教程记录
  16. oracle 的exp是什么,oracle中exp和imp是什么,oracle中exp和imp有何区别 | 学步园
  17. Linux中使用gzip来压缩/解压 *.gz文件
  18. 教你如何用Python追踪快递信息
  19. Camera图像处理原理及实例分析 - 色彩篇
  20. thinkphp6 think-queue消息队列

热门文章

  1. ELKF搭建详细步骤(Elasticsearch+logstash+kibana+filebeat)
  2. Raster §3 Raster Algebra
  3. STM32CUBEMX学习笔记——陶晶驰串口屏中断接收数据
  4. Ubuntu基本使用
  5. 2018ACM-ICPC弱校弱队蒟蒻们的焦作之旅
  6. Profibus DP/PA/FMS
  7. JS使用正则表达式校验手机号码
  8. 【新年字体素材合集】2022年元旦新年艺术字体素材合集,元旦快乐呀
  9. ElasticSearch系列 - SpringBoot整合ES:实现分页搜索 from+size、search after、scroll
  10. CCES 生产和调用静态库