基本信息
源码名称:三可变编码器触发(C#源码)
源码大小:0.12M
文件格式:.rar
开发语言:C#
更新时间:2020-03-26
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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 PortW
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.btn_Close.Enabled = false;
}
public Port port { get; set; }
public string stopStr = "FF 01 00 00 00 00 01";
public string GOpenStr = "FF 01 02 00 00 00 03";
public string GCloseStr = "FF 01 04 00 00 00 05";
public string BOpenStr = "FF 01 00 40 00 00 41";
public string BCloseStr = "FF 01 00 20 00 00 21";
public string JOpenStr = "FF 01 00 80 00 00 81";
public string JCloseStr = "FF 01 01 20 00 00 02";
private void btn_Open_Click(object sender, EventArgs e)
{
port = new Port(tb_COM.Text);
if (port.Open())
{
this.btn_Close.Enabled = true;
this.btn_Open.Enabled = false;
}
else
MessageBox.Show("NO");
}
private void btn_Close_Click(object sender, EventArgs e)
{
port.Close();
this.btn_Open.Enabled = true;
this.btn_Close.Enabled = false;
}
private void btn_Send_Click(object sender, EventArgs e)
{
if (cb_Opertaor.Checked)
{
if (port!=null)
{
port.Send_data(tb_send.Text);
}
}
}
private void Button1_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(GOpenStr);
}
else
{
tb_send.Text = GOpenStr;
}
}
private void Button2_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(GCloseStr);
}
else
{
tb_send.Text = GCloseStr;
}
}
private void Button4_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(BOpenStr);
}
else
{
tb_send.Text = BOpenStr;
}
}
private void Button3_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(BCloseStr);
}
else
{
tb_send.Text = BCloseStr;
}
}
private void Button6_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(JOpenStr);
}
else
{
tb_send.Text = JOpenStr;
}
}
private void Button5_MouseDown(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(JCloseStr);
}
else
{
tb_send.Text = JCloseStr;
}
}
private void Button5_MouseLeave(object sender, EventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
tb_send.Text = stopStr;
}
private void Button5_MouseLeave(object sender, MouseEventArgs e)
{
if (!cb_Opertaor.Checked)
{
if (port != null)
port.Send_data(stopStr);
}
}
}
}