当前位置: 首页 > news >正文

用服务器做网站空间免费域名解析

用服务器做网站空间,免费域名解析,网站建设费用计入哪个科目,如何建设一家网站文章目录 1. 实现一个简单的倒计时器开始、暂停2. 串口助手开发 1. 实现一个简单的倒计时器开始、暂停 namespace Timer {public partial class Form1 : Form{int count;//用于定时器计数int time;//存储设定的定时值bool parse false;//控制暂停计时public Form1(){Initiali…

文章目录

    • 1. 实现一个简单的倒计时器开始、暂停
    • 2. 串口助手开发

1. 实现一个简单的倒计时器开始、暂停

namespace Timer
{public partial class Form1 : Form{int count;//用于定时器计数int time;//存储设定的定时值bool parse = false;//控制暂停计时public Form1(){InitializeComponent();}//窗口创建初始化函数private void Form1_Load(object sender, EventArgs e){//双击窗体后在这里给下拉框添加或者在属性items里添加都可以for(int i = 1; i < 100; i++){comboBox1.Items.Add(i.ToString() + "秒");}comboBox1.Text = "1秒";}private void timer1_Tick(object sender, EventArgs e){count++;//记录、当前秒label3.Text = (time - count).ToString() + "秒";//显示剩余时间progressBar1.Value = count;//设置进度条进度if(count == time){timer1.Stop();//时间到,停止计时System.Media.SystemSounds.Asterisk.Play();//提示音MessageBox.Show("时间到,停止计时","提示");//弹出提示框count = 0;progressBar1.Value = 0;comboBox1.Text = null;}}//开始计时按钮事件private void button1_Click(object sender, EventArgs e){if (parse == true){parse = false;timer1.Stop();return;}string str = comboBox1.Text; //将下拉框内容添加到一个变量中time = Convert.ToInt16(str.Substring(0,str.Length - 1)); //得到设定的定时值progressBar1.Maximum = time;//进度条最大数值parse = true;timer1.Start();//开始计时}}
}

在这里插入图片描述

2. 串口助手开发

创建项目的时候要选带(.NET Framework)的窗体应用

using System;
using System.IO.Ports;
using System.Text;
using System.Windows.Forms;namespace SerialCommunicate
{public partial class Form1 : Form{public Form1(){InitializeComponent();//串口数据接收事件serialPort1.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);//串口接收编码serialPort1.Encoding = Encoding.GetEncoding("UTF-8");System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;}private void Form1_Load(object sender, EventArgs e){for(int i = 1; i < 20; i++){comboBox1.Items.Add("COM" + i.ToString());}comboBox1.Text = "COM1";comboBox2.Text = "4800";//必须手动添加事件处理器serialPort1.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);}//串口数据接收事件private void port_DataReceived(object sender, SerialDataReceivedEventArgs e){if (!radioButton3.Checked)//如果为字符模式接收{string str = serialPort1.ReadExisting();//字符串方式读textBox1.AppendText(str);}else//数值接收{//定义缓冲区,因为串口事件触发时不是实时的byte[] data = new byte[serialPort1.BytesToRead];serialPort1.Read(data, 0, data.Length);foreach(byte Member in data){string str = Convert.ToString(Member, 16).ToUpper();//空位补0textBox1.AppendText("0x" + (str.Length == 1 ? "0" + str : str) + " ");}}}private void button1_Click(object sender, EventArgs e){try{serialPort1.PortName = comboBox1.Text;serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text);//十进制数据转换serialPort1.Open();button1.Enabled = false;//打开串口按钮不可用button2.Enabled = true;//关闭串口}catch{MessageBox.Show("端口错误,请检查串口", "错误");}}private void button2_Click(object sender, EventArgs e){try{serialPort1.Close();button1.Enabled = true;button2.Enabled = false;}catch(Exception err)//一般情况下关闭串口不会出错,所以不需要加处理程序{}}private void button3_Click(object sender, EventArgs e){byte[] Data = new byte[1];//判断串口是否打开if (serialPort1.IsOpen){if(textBox2.Text != ""){if (!radioButton1.Checked){try{serialPort1.WriteLine(textBox2.Text);}catch (Exception err){MessageBox.Show("串口数据写入错误", "错误");serialPort1.Close();button1.Enabled = true;button2.Enabled = false;}}else{//取余运算防止用户输入的字符为奇数个for(int i = 0; i < (textBox2.Text.Length - textBox2.Text.Length % 2) / 2; i++){Data[0] = Convert.ToByte(textBox2.Text.Substring(i * 2, 2), 16);serialPort1.Write(Data, 0, 1);}if(textBox2.Text.Length % 2 != 0){Data[0] = Convert.ToByte(textBox2.Text.Substring(textBox2.Text.Length - 1, 1), 16);serialPort1.Write(Data, 0, 1);}}}}}}
}

在这里插入图片描述

http://www.hkea.cn/news/421760/

相关文章:

  • 网站制作职业google入口
  • 广州网站 制作信科便宜网络营销软文范例500
  • 网站建设公开课长沙网站推广和优化
  • 建设网站的需求分析俄罗斯搜索引擎yandex推广入口
  • 可以做英文纵横字谜的网站搜狗网站收录入口
  • web前端开发是不是做网站百家号关键词排名优化
  • 夸克看网站要钱吗电商网站seo优化
  • 自己做网站排版138ip查询网域名解析
  • 东莞做网站 南城石佳2023网站推广入口
  • 广东省省建设厅网站郴州网站建设网络推广平台
  • 校园网站推广方案怎么做应用商店优化
  • 巩义网站建设网络营销公司是做什么的
  • 做网站基本教程一站式营销平台
  • 杭州模板网站建设电脑培训网上培训班
  • 大连做网站不错的公司怎样把广告放到百度
  • 网站上面带官网字样怎么做的网站设计的流程
  • 有个网站是做视频相册的网球排名即时最新排名
  • 论坛网站备案流程图优化大师怎么提交作业
  • 织梦政府网站模板百度在线入口
  • 专业做婚纱摄影网站会员制营销
  • 网站内容丰富互动营销平台
  • 阿里巴巴logo高清图谷歌seo网站推广
  • 网站如何做内链seo高手是怎样炼成的
  • 设计师个人网站建设怎样注册一个自己的平台
  • 徐州营销网站建设产品线上推广渠道
  • 绍兴市网站建设公司企业官网搭建
  • 关于网页设计的网站免费发布信息网站大全
  • 郑州新闻头条seo基础教程
  • 做网站比较大的公司朔州seo
  • 如何制作私人网站福州专业的seo软件