C#窗体对接汉王ESP370签批板(电子签名)
来源:互联网 发布:好用的吹风机知乎 编辑:程序博客网 时间:2024/04/30 11:44
C#窗体对接汉王ESP370签批板(电子签名)
1,先安装驱动程序,
2,然后浏览目录,添加dll引用AxInterop.HWPenSignLib.dll3,项目编译为x86。
Form签批板.cs
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;namespace HanWangSM.汉王ESP370签批板{ public partial class Form签批板 : Form { //inform message definition static int complete_msg = 0x7ffe; static int cancel_msg = 0x7ffd; //return value of interface function /// <summary> /// 成功 /// </summary> static int HW_eOk = 0; //success /// <summary> /// 未找到对应的汉王手写设备 /// </summary> static int HW_eDeviceNotFound = -1; //no device /// <summary> /// 手写模块加载失败 /// </summary> static int HW_eFailedLoadModule = -2; //failed to load module /// <summary> /// 手写模块初始化失败 /// </summary> static int HW_eFailedInitModule = -3; //failed to inti module /// <summary> /// 不支持的图片格式 /// </summary> static int HW_eWrongImageFormat = -4; //do not support this image format /// <summary> /// 没有签名数据 /// </summary> static int HW_eNoSignData = -5; //no sign data /// <summary> /// 无效输入参数 /// </summary> static int HW_eInvalidInput = -6; //invalid input parameter /// <summary> /// 保存路径及文件名 /// </summary> static string savePath = Application.StartupPath + "hwsign"+DateTime.Now.ToString("yyyyMMdd")+".png"; /// <summary> /// 签名的图片对象 /// </summary> public Bitmap SavedBitmap; public Form签批板() { InitializeComponent(); axHWPenSign1.HWSetBkColor(0xE0F8E0); axHWPenSign1.HWSetCtlFrame(2, 0x000000); axHWPenSign1.HWSetFilePath(savePath); axHWPenSign1.HWSetExtWndHandle(this.Handle.ToInt32()); } protected override void WndProc(ref Message m) { if (m.Msg == complete_msg) { //MessageBox.Show("Confirm Sign"); SavedBitmap = new Bitmap(savePath); this.DialogResult = DialogResult.OK; this.Close(); } else if (m.Msg == cancel_msg) { //MessageBox.Show("Clear Sign"); } base.WndProc(ref m); } /// <summary> /// 打开设备 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button打开设备_Click(object sender, EventArgs e) { int res = axHWPenSign1.HWInitialize(); if (res != HW_eOk) { MessageBox.Show("Failed to open device"); } } /// <summary> /// 关闭设备 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button关闭设备_Click(object sender, EventArgs e) { axHWPenSign1.HWFinalize(); } /// <summary> /// 清除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button清除_Click(object sender, EventArgs e) { axHWPenSign1.HWClearPenSign(); } /// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button保存图像_Click(object sender, EventArgs e) { axHWPenSign1.HWSaveFile(); SavedBitmap = new Bitmap(savePath); this.DialogResult = DialogResult.OK; this.Close(); } /// <summary> /// 传当前需要签名的名字进来,防止签错别人的名字 /// </summary> /// <param name="signName"></param> public void setSignName(string signName) { if (string.IsNullOrWhiteSpace(signName)) { } else { this.button保存图像.Text = string.Format("保存{0}的签名", signName); this.button清除.Text = string.Format("重写{0}的签名", signName); } } private void button关闭_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } }}Form签批板.Designer.cs
namespace HanWangSM.汉王ESP370签批板{ partial class Form签批板 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form签批板)); this.axHWPenSign1 = new AxHWPenSignLib.AxHWPenSign(); this.button打开设备 = new System.Windows.Forms.Button(); this.button关闭设备 = new System.Windows.Forms.Button(); this.button清除 = new System.Windows.Forms.Button(); this.button保存图像 = new System.Windows.Forms.Button(); this.panel签名区 = new System.Windows.Forms.Panel(); this.panel确认区 = new System.Windows.Forms.Panel(); this.button关闭 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.axHWPenSign1)).BeginInit(); this.panel签名区.SuspendLayout(); this.panel确认区.SuspendLayout(); this.SuspendLayout(); // // axHWPenSign1 // this.axHWPenSign1.Dock = System.Windows.Forms.DockStyle.Fill; this.axHWPenSign1.Enabled = true; this.axHWPenSign1.Location = new System.Drawing.Point(0, 0); this.axHWPenSign1.Name = "axHWPenSign1"; this.axHWPenSign1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axHWPenSign1.OcxState"))); this.axHWPenSign1.Size = new System.Drawing.Size(603, 419); this.axHWPenSign1.TabIndex = 0; // // button打开设备 // this.button打开设备.Dock = System.Windows.Forms.DockStyle.Left; this.button打开设备.Location = new System.Drawing.Point(252, 0); this.button打开设备.Name = "button打开设备"; this.button打开设备.Size = new System.Drawing.Size(92, 24); this.button打开设备.TabIndex = 1; this.button打开设备.Text = "打开设备"; this.button打开设备.UseVisualStyleBackColor = true; this.button打开设备.Click += new System.EventHandler(this.button打开设备_Click); // // button关闭设备 // this.button关闭设备.Dock = System.Windows.Forms.DockStyle.Left; this.button关闭设备.Location = new System.Drawing.Point(162, 0); this.button关闭设备.Name = "button关闭设备"; this.button关闭设备.Size = new System.Drawing.Size(90, 24); this.button关闭设备.TabIndex = 2; this.button关闭设备.Text = "关闭设备"; this.button关闭设备.UseVisualStyleBackColor = true; this.button关闭设备.Click += new System.EventHandler(this.button关闭设备_Click); // // button清除 // this.button清除.Dock = System.Windows.Forms.DockStyle.Left; this.button清除.Location = new System.Drawing.Point(78, 0); this.button清除.Name = "button清除"; this.button清除.Size = new System.Drawing.Size(84, 24); this.button清除.TabIndex = 3; this.button清除.Text = "清除"; this.button清除.UseVisualStyleBackColor = true; this.button清除.Click += new System.EventHandler(this.button清除_Click); // // button保存图像 // this.button保存图像.Dock = System.Windows.Forms.DockStyle.Left; this.button保存图像.Location = new System.Drawing.Point(0, 0); this.button保存图像.Name = "button保存图像"; this.button保存图像.Size = new System.Drawing.Size(78, 24); this.button保存图像.TabIndex = 4; this.button保存图像.Text = "保存"; this.button保存图像.UseVisualStyleBackColor = true; this.button保存图像.Click += new System.EventHandler(this.button保存图像_Click); // // panel签名区 // this.panel签名区.Controls.Add(this.axHWPenSign1); this.panel签名区.Dock = System.Windows.Forms.DockStyle.Fill; this.panel签名区.Location = new System.Drawing.Point(0, 0); this.panel签名区.Name = "panel签名区"; this.panel签名区.Size = new System.Drawing.Size(603, 419); this.panel签名区.TabIndex = 0; // // panel确认区 // this.panel确认区.Controls.Add(this.button关闭); this.panel确认区.Controls.Add(this.button打开设备); this.panel确认区.Controls.Add(this.button关闭设备); this.panel确认区.Controls.Add(this.button清除); this.panel确认区.Controls.Add(this.button保存图像); this.panel确认区.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel确认区.Location = new System.Drawing.Point(0, 419); this.panel确认区.Name = "panel确认区"; this.panel确认区.Size = new System.Drawing.Size(603, 24); this.panel确认区.TabIndex = 5; // // button关闭 // this.button关闭.Dock = System.Windows.Forms.DockStyle.Left; this.button关闭.Location = new System.Drawing.Point(344, 0); this.button关闭.Name = "button关闭"; this.button关闭.Size = new System.Drawing.Size(84, 24); this.button关闭.TabIndex = 5; this.button关闭.Text = "关闭"; this.button关闭.UseVisualStyleBackColor = true; this.button关闭.Click += new System.EventHandler(this.button关闭_Click); // // Form签批板 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(603, 443); this.ControlBox = false; this.Controls.Add(this.panel签名区); this.Controls.Add(this.panel确认区); this.Name = "Form签批板"; this.Text = "签批板"; ((System.ComponentModel.ISupportInitialize)(this.axHWPenSign1)).EndInit(); this.panel签名区.ResumeLayout(false); this.panel确认区.ResumeLayout(false); this.ResumeLayout(false); } #endregion private AxHWPenSignLib.AxHWPenSign axHWPenSign1; private System.Windows.Forms.Button button打开设备; private System.Windows.Forms.Button button关闭设备; private System.Windows.Forms.Button button清除; private System.Windows.Forms.Button button保存图像; private System.Windows.Forms.Panel panel签名区; private System.Windows.Forms.Panel panel确认区; private System.Windows.Forms.Button button关闭; }}Form签批板.resx
<?xml version="1.0" encoding="utf-8"?><root> <!-- Microsoft ResX Schema Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the various data types are done through the TypeConverter classes associated with the data types. Example: ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple name/value pairs. Each data row contains a name, and value. The row also contains a type or mimetype. Type corresponds to a .NET class that support text/value conversion through the TypeConverter architecture. Classes that don't support this are serialized and stored with the mimetype set. The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: Note - application/x-microsoft.net.object.binary.base64 is the format that the ResXResourceWriter will generate, however the reader can read any of the formats listed below. mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element name="metadata"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="assembly"> <xsd:complexType> <xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" /> </xsd:complexType> </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:complexType> </xsd:element> </xsd:schema> <resheader name="resmimetype"> <value>text/microsoft-resx</value> </resheader> <resheader name="version"> <value>2.0</value> </resheader> <resheader name="reader"> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <data name="axHWPenSign1.OcxState" mimetype="application/x-microsoft.net.object.binary.base64"> <value> AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAJQAAAAIB AAAAAQAAAAAAAAAAAAAAABAAAAAAAAEAUj4AAE4rAAAAAAAACw==</value> </data></root>
项目代码下载:汉王签批板
解压密码:google
0 0
- C#窗体对接汉王ESP370签批板(电子签名)
- 汉王签批板ESP370U与C#窗体系统对接
- 什么是无纸化办公 |电子签批
- 手写电子签名板
- 电子签名的c#实现方法
- 电子签名
- 电子签名
- 电子签名
- 电子面单接口申请对接(返回电子面单模板)
- 中华人民共和国电子签名法
- [原创]认识电子签名
- 中华人民共和国电子签名法
- 电子签名与网上交易
- 电子签名和数字签名
- 简易电子签名插件
- 电子签名法全文
- 电子签名工具 SignatureTool
- 电子签名发展史
- 去掉Caption中的:
- Linux学习之CentOS--CentOS6.5下Mysql数据库的安装及C/C++连接使用Mysql
- bitbucket入门手册
- js 将日期转为多少分钟前
- DataWei免费的报表工具,大数据可视化平台
- C#窗体对接汉王ESP370签批板(电子签名)
- 解决fastjson、Jackson、Gson解析Json数据时,key为Java中关键字无法解析的问题
- Burpsuite - Extension: Import Links into Sitemap
- ajax请求,需要提交表单里面所有数据时的处理
- 插件封装(banner)
- 1033. To Fill or Not to Fill
- 执行存储过程
- 缓存LruCache类中sizeOf方法的含义
- 学习Java的第一天