91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 76KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-06-16
  • 語言: C#
  • 標(biāo)簽: c#??com口??

資源簡(jiǎn)介

c# 串口掃描槍 com口 源碼 最簡(jiǎn)單的程序 可以選擇com口,點(diǎn)擊開始,開始進(jìn)入掃描模式,關(guān)閉則關(guān)閉。

資源截圖

代碼片段和文件信息

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.Ports;
using?System.IO;

namespace?SerialPortCommunication
{
????public?partial?class?Form1?:?Form
????{
????????private?SerialPort?sp?=?new?SerialPort();

????????public?Form1()
????????{
????????????InitializeComponent();
????????}

????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????string[]?PortName?=?SerialPort.GetPortNames();
????????????cbPortName.Items.Clear();
????????????foreach?(string?str?in?PortName)
????????????{
????????????????cbPortName.Items.Add(str);

????????????}
????????????cbPortName.SelectedIndex?=?0;
????????????cbBaudRate.SelectedIndex?=?1;
????????????cbDataBit.SelectedIndex?=?3;
????????????cbParityBit.SelectedIndex?=?0;
????????????cbStopBit.SelectedIndex?=?1;
????????????sp.Close();
????????????updateText?=?new?UpdateTextEventHandler(UpdateTextBox);??//實(shí)例化委托對(duì)象

????????????sp.DataReceived?+=?new?System.IO.Ports.SerialDataReceivedEventHandler(sp_DataReceived);
????????}

????????private?void?cbPortName_SelectedIndexChanged(object?sender?EventArgs?e)
????????{

????????????sp.PortName?=?cbPortName.Items[cbPortName.SelectedIndex].ToString();

????????}

????????private?void?cbBaudRate_SelectedIndexChanged(object?sender?EventArgs?e)
????????{

????????????sp.BaudRate?=?int.Parse(cbBaudRate.Items[cbBaudRate.SelectedIndex].ToString());

????????}

????????private?void?cbDataBit_SelectedIndexChanged(object?sender?EventArgs?e)
????????{

????????????sp.DataBits?=?int.Parse(cbDataBit.Items[cbDataBit.SelectedIndex].ToString());
????????}

????????private?void?cbStopBit_SelectedIndexChanged(object?sender?EventArgs?e)
????????{
????????????sp.StopBits?=?(StopBits)(cbStopBit.SelectedIndex);
????????}

????????private?void?cbParityBit_SelectedIndexChanged(object?sender?EventArgs?e)
????????{
????????????sp.Parity?=?(Parity)System.Enum.Parse(typeof(Parity)?(cbParityBit.SelectedIndex).ToString());
????????}



????????delegate?void?UpdateTextEventHandler(string?text);??//委托,此為重點(diǎn)
????????UpdateTextEventHandler?updateText;
???
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{??if(!sp.IsOpen)
????????????sp.Open();?
????????}

????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????sp.Close();
????????}
????????public?void?sp_DataReceived(object?senderSystem.IO.Ports.SerialDataReceivedEventArgs?e)
????????{
????????????System.Threading.Thread.Sleep(100);?
????????????string?readString?=?sp.ReadExisting();
????????????this.Invoke(updateText?new?string[]?{?readString?});
????????}

????????private?void?UpdateTextBox(string?text)
????????{
????????????textBox1.Text?=?text;
????????}

????????private?void?Form1_FormClosing(object?sender?FormClosingEventArgs?

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----

?????文件????????144??2014-01-06?18:13??SerialPort\SerialPort\app.config

?????文件??????13312??2014-01-06?19:02??SerialPort\SerialPort\bin\Debug\SCOM.exe

?????文件????????144??2014-01-06?18:13??SerialPort\SerialPort\bin\Debug\SCOM.exe.config

?????文件??????46592??2014-01-06?19:02??SerialPort\SerialPort\bin\Debug\SCOM.pdb

?????文件??????22472??2014-01-06?19:03??SerialPort\SerialPort\bin\Debug\SCOM.vshost.exe

?????文件????????144??2014-01-06?18:13??SerialPort\SerialPort\bin\Debug\SCOM.vshost.exe.config

?????文件????????490??2012-06-06?17:06??SerialPort\SerialPort\bin\Debug\SCOM.vshost.exe.manifest

?????文件???????3104??2014-01-06?19:02??SerialPort\SerialPort\Form1.cs

?????文件???????9860??2014-01-06?18:55??SerialPort\SerialPort\Form1.Designer.cs

?????文件???????5814??2014-01-06?18:55??SerialPort\SerialPort\Form1.resx

?????文件???????3887??2014-01-06?18:54??SerialPort\SerialPort\obj\Debug\DesignTimeResolveAssemblyReferences.cache

?????文件???????6777??2014-01-06?19:01??SerialPort\SerialPort\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

?????文件??????13312??2014-01-06?19:02??SerialPort\SerialPort\obj\Debug\SCOM.exe

?????文件????????180??2013-07-01?21:04??SerialPort\SerialPort\obj\Debug\SCOM.Form2.resources

?????文件??????46592??2014-01-06?19:02??SerialPort\SerialPort\obj\Debug\SCOM.pdb

?????文件????????180??2014-01-06?18:13??SerialPort\SerialPort\obj\Debug\SCOM.Properties.Resources.resources

?????文件???????5579??2014-01-06?19:03??SerialPort\SerialPort\obj\Debug\SerialPortCommunication.csproj.FileListAbsolute.txt

?????文件????????975??2014-01-06?18:55??SerialPort\SerialPort\obj\Debug\SerialPortCommunication.csproj.GenerateResource.Cache

?????文件??????11273??2014-01-06?18:13??SerialPort\SerialPort\obj\Debug\SerialPortCommunication.csprojResolveAssemblyReference.cache

?????文件????????180??2014-01-06?18:55??SerialPort\SerialPort\obj\Debug\SerialPortCommunication.Form1.resources

?????文件??????????0??2013-06-30?19:51??SerialPort\SerialPort\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

?????文件??????????0??2013-06-30?19:51??SerialPort\SerialPort\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

?????文件??????????0??2013-06-30?19:51??SerialPort\SerialPort\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

?????文件???????4608??2014-01-06?18:54??SerialPort\SerialPort\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

?????文件????????515??2012-05-09?15:48??SerialPort\SerialPort\Program.cs

?????文件???????1450??2012-05-09?15:40??SerialPort\SerialPort\Properties\AssemblyInfo.cs

?????文件???????2848??2014-01-06?18:13??SerialPort\SerialPort\Properties\Resources.Designer.cs

?????文件???????5612??2012-05-09?15:40??SerialPort\SerialPort\Properties\Resources.resx

?????文件???????1104??2014-01-06?18:13??SerialPort\SerialPort\Properties\Settings.Designer.cs

?????文件????????249??2012-05-09?15:40??SerialPort\SerialPort\Properties\Settings.settings

............此處省略18個(gè)文件信息

評(píng)論

共有 條評(píng)論