顾客显示屏(中文 数字)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO.Ports;
namespace 顾客显示屏_中文_数字_
{
public enum PoleDisplayType : uint
{
/// <summary>
/// 黑屏
/// </summary>
Dark = 0,
/// <summary>
/// 单价
/// </summary>
Price = 1,
/// <summary>
/// 合计
/// </summary>
Total = 2,
/// <summary>
/// 收款
/// </summary>
Payment = 3,
/// <summary>
/// 找零
/// </summary>
Change = 4
}
public class PoleDisplayer
{
private static string text;
private static PoleDisplayType type;
private static SerialPort serialPort = null;
private const string PORT_NAME = "COM3";
private const int BAUD_RATE = 2400;
/// <summary>
/// 传入显示的字符串与显示类型方法
/// </summary>
/// <param name="_text"></param>
/// <param name="_type"></param>
public static void Display(string _text, PoleDisplayType _type)
{
text = _text;
type = _type;
Thread thread = new Thread(new ThreadStart(Display));
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
private static void Display()
{
try
{
if (serialPort == null)
{
serialPort = new SerialPort(PORT_NAME, BAUD_RATE, Parity.None, 8);
serialPort.Open();
}
if (serialPort.IsOpen)
{
char esc = (char)27;
serialPort.Write(esc @"@");
serialPort.Write(esc @"s" Convert.ToInt32(type).ToString());
//serialPort.WriteLine(FillString(text));//填充八位数字,不建议使用
serialPort.WriteLine(text);
}
}
catch
{}
}
/// <summary>
/// 填充text,不含小数点的8位(不建议使用)
/// </summary>
/// <param name="text"></param>
private static string FillString(string text)
{
string temp = text.Replace(".", string.Empty);
for (int i = 0; i < 8 - temp.Length; i )
{
text = "0";
}
return text;
}
}
}
资源文件列表
顾客显示屏(中文+数字)/bin/Debug/顾客显示屏(中文+数字).exe , 10752
顾客显示屏(中文+数字)/bin/Debug/顾客显示屏(中文+数字).pdb , 24064
顾客显示屏(中文+数字)/bin/Debug/顾客显示屏(中文+数字).vshost.exe , 11600
顾客显示屏(中文+数字)/Form1.cs , 1661
顾客显示屏(中文+数字)/Form1.Designer.cs , 4374
顾客显示屏(中文+数字)/Form1.resx , 5817
顾客显示屏(中文+数字)/obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache , 1779
顾客显示屏(中文+数字)/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 7146
顾客显示屏(中文+数字)/obj/x86/Debug/GenerateResource.read.1.tlog , 252
顾客显示屏(中文+数字)/obj/x86/Debug/GenerateResource.write.1.tlog , 622
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).csproj.CoreCompileInputs.cache , 42
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).csproj.FileListAbsolute.txt , 2475
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).csproj.GenerateResource.cache , 939
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).csprojAssemblyReference.cache , 32234
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).exe , 10752
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏(中文+数字).pdb , 24064
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏_中文_数字_.Form1.resources , 180
顾客显示屏(中文+数字)/obj/x86/Debug/顾客显示屏_中文_数字_.Properties.Resources.resources , 180
顾客显示屏(中文+数字)/Program.cs , 511
顾客显示屏(中文+数字)/Properties/AssemblyInfo.cs , 1410
顾客显示屏(中文+数字)/Properties/Resources.Designer.cs , 2910
顾客显示屏(中文+数字)/Properties/Resources.resx , 5612
顾客显示屏(中文+数字)/Properties/Settings.Designer.cs , 1115
顾客显示屏(中文+数字)/Properties/Settings.settings , 249
顾客显示屏(中文+数字)/Type.cs , 2705
顾客显示屏(中文+数字)/顾客显示屏(中文+数字).csproj , 3758
顾客显示屏(中文+数字).sln , 932
