当前位置:网站首页>C# 倒计时工具
C# 倒计时工具
2022-07-28 09:17:00 【biyusr】
最近一个朋友在玩一个网络游戏,游戏里有10多个小头目,小头目死后每10分钟刷新一次。有好多玩家抢着打怪,谁第一次有伤害,boss死后物品归谁,朋友苦于计算不到小头目boss准备刷新的时间。总是抢不赢别人。想由我帮他弄个多点计算倒计的时间软件。我无聊觉可行,说干就干。
软件界面由:2个按钮(添加、删除)、一个listView,一个pictureBox,一个timer时钟组成。

Dotnet工控
专注分享DotNET编程经验,挖掘程序员优秀的学习资源。
7篇原创内容
公众号

启动时需设计listView列: 只能选择整行需设计listView1.FullRowSelect为True,设计timer为计算倒计时,以秒为单位。
private void Form1_Load(object sender, EventArgs e){comboBox1.SelectedIndex = 0;listView1.Columns.Add("倒计时/秒",80,HorizontalAlignment.Left);listView1.Columns.Add("定时间");listView1.Columns.Add("图片地址", 100, HorizontalAlignment.Left);listView1.FullRowSelect = true;//只能选一行timer1.Interval = 1000;timer1.Start();}
2. 添加按钮,载图并且保存图片,方便下次查看。
private void button1_Click(object sender, EventArgs e){pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;//图片拉升或缩小,适应picture控件string url;保存图片地址pictureBox1.Image = GetScreenCapture(out url); //用方法载图ListViewItem listViewItem = new ListViewItem();string timeritem = System.Text.RegularExpressions.Regex.Replace(comboBox1.Text, @"[^0-9]+", ""); //求数字listViewItem.Text = (int.Parse(timeritem)*60).ToString();listViewItem.SubItems.Add($"{comboBox1.Text}");listViewItem.SubItems.Add(url);listView1.Items.Add(listViewItem);}private Bitmap GetScreenCapture(out string url){Rectangle tScreenRect = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);Bitmap tSrcBmp = new Bitmap(tScreenRect.Width, tScreenRect.Height); // 用于屏幕原始图片保存Graphics gp = Graphics.FromImage(tSrcBmp);gp.CopyFromScreen(0, 0, 0, 0, tScreenRect.Size);gp.DrawImage(tSrcBmp, 0, 0, tScreenRect, GraphicsUnit.Pixel);Random ran = new Random();url = @$"temp\{ran.Next(1, 999)}.jpg";tSrcBmp.Save(url);return tSrcBmp;}
3.需按秒更新倒计时,在timer时钟里更新全部的倒计时,
private void timer1_Tick(object sender, EventArgs e){this.listView1.BeginUpdate(); //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度foreach (ListViewItem item in listView1.Items){item.SubItems[0].Text = (int.Parse(item.SubItems[0].Text) - 1).ToString();}this.listView1.EndUpdate(); //结束数据处理,UI界面一次性绘制。}/// <summary>/// 双击显示图片/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void listView1_MouseDoubleClick(object sender, MouseEventArgs e){pictureBox1.ImageLocation = listView1.SelectedItems[0].SubItems[2].Text;}/// <summary>/// 删除/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void button2_Click(object sender, EventArgs e){File.Delete(listView1.SelectedItems[0].SubItems[2].Text);listView1.SelectedItems[0].Remove();}
4.效果图:朋友很满意,能计算到小头目秒刷新。快到倒计时为10秒时就赶快到那要刷新的地点等小头目。总是能抢到小头目

5.事后又找我能否帮他弄个自动打怪抢头目的脚本,我怕了他了

,直接跟他说不会。
边栏推荐
- Which system table is the keyword of SQL Server in?
- MATLAB启动慢解决措施
- Regular expressions are hexadecimal digits?
- Pytorch deep learning practice lesson 9 multi classification problems (handwritten numeral MNIST)
- LeetCode_ 406_ Rebuild the queue based on height
- ARouter源码解析(三)
- 《我的Vivado实战—单周期CPU指令分析》
- With such a simple verification, 80% of programmers can't do it, let alone understand it!
- 【日志】日志干什么的?日志工厂是什么?log4j 的配置和使用? log4j.properties 文件配置、log4j jar包坐标
- View的工作原理
猜你喜欢

软件测试与质量学习笔记2----黑盒测试

opencv安装配置测试
![[Download] several tools for brute force cracking and dictionary generation are recommended](/img/c6/f4a9c566ff21a8e133a8a991108201.png)
[Download] several tools for brute force cracking and dictionary generation are recommended

力扣376-摆动序列——贪心

Pytorch deep learning practice lesson 9 multi classification problems (handwritten numeral MNIST)

时序分析41 - 时序预测 TBATS模型

Detailed explanation of various types of files in MySQL

IJCAI 2022 | 图结构学习最新综述:研究进展与未来展望
![[high number] high number plane solid geometry](/img/fc/da6aefed48f4adbaf58995b5e8fa46.png)
[high number] high number plane solid geometry

数据库核心体系
随机推荐
力扣376-摆动序列——贪心
478-82(56、128、718、129)
21 day learning challenge - "AUTOSAR from introduction to mastery - practical part"
ArrayList内部原理解析
MATLAB的符号运算
opencv安装配置测试
股指期货开户的条件和流程
Buckle 376 swing sequence greedy
View的工作原理
The maximum recommended number of rows for MySQL is 2000W. Is it reliable?
[solution] error in [eslint] eslint is not a constructor
[vscode] vscode usage
什么是跨域?如何解决请跨域问题?
LeetCode(剑指 Offer)- 50. 第一个只出现一次的字符
Which system table is the keyword of SQL Server in?
Retrofit源码解析
Heuristic merging on tree
Dn-detr paper accuracy, and analyze its model structure & 2022 CVPR paper
【AUTOSAR-RTE】-3-Runnable及其Task Mapping映射
【AUTOSAR-RTE】-2-Composition,Component和VFB的介绍