|
|
|
using Functions.FileExt;
|
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
|
|
|
using System;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.IO;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Text;
|
|
|
|
//0816加实时报点
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
public struct TOUCH_INFO
|
|
|
|
{
|
|
|
|
public int X;
|
|
|
|
public int Y;
|
|
|
|
public int Pressure;
|
|
|
|
public int SN;
|
|
|
|
public int btnID;//5寸 确定 重签 取消按钮
|
|
|
|
}
|
|
|
|
namespace DevicesService.Devices
|
|
|
|
{
|
|
|
|
public class SignDll
|
|
|
|
{
|
|
|
|
public static PointF endPos;
|
|
|
|
public static PointF beginPos;
|
|
|
|
public static PointF frontPos;
|
|
|
|
private static int xypointcount = 0;
|
|
|
|
private static int[] lastpointx = new int[3];
|
|
|
|
private static int[] lastpointy = new int[3];
|
|
|
|
Point mPoint = new Point(-1, -1);
|
|
|
|
private static System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
|
|
|
|
//private Graphics mGraphicsBuffer;
|
|
|
|
private static Pen pen = new Pen(Color.Black); //
|
|
|
|
public static int status = -1;
|
|
|
|
private static Bitmap bitmap = new Bitmap(594, 392);
|
|
|
|
public SignDll()
|
|
|
|
{
|
|
|
|
endPos = new PointF(-1F, -1f);
|
|
|
|
beginPos = new PointF(-1F, -1f);
|
|
|
|
frontPos = new PointF(-1F, -1f);
|
|
|
|
lastpointx[0] = -1;
|
|
|
|
lastpointy[0] = -1;
|
|
|
|
lastpointx[1] = -1;
|
|
|
|
lastpointy[1] = -1;
|
|
|
|
lastpointx[2] = -1;
|
|
|
|
lastpointy[2] = -1;
|
|
|
|
xypointcount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void GetTouchNumber(int number)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//1 签字确定按钮 2签字取消按钮 3 签字重签按钮(清空界面)
|
|
|
|
if (number == 1)
|
|
|
|
{
|
|
|
|
int ret = FiveInchDll.ComSignOK();
|
|
|
|
Console.WriteLine("ComSignOK:" + ret);
|
|
|
|
FiveInchDll.ComSetBackGroundAdv();
|
|
|
|
}
|
|
|
|
else if (number == 3)
|
|
|
|
{
|
|
|
|
|
|
|
|
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
|
|
|
|
int ret = FiveInchDll.ComSetSignBackgroundImage(UIFile);
|
|
|
|
Console.WriteLine("ComSetSignBackgroundImage:" + ret);
|
|
|
|
}
|
|
|
|
//2023-02-27 通知返回获取SN
|
|
|
|
else if (number == 17) //返回设备SN
|
|
|
|
{
|
|
|
|
StringBuilder sbDevSN = new StringBuilder();
|
|
|
|
FiveInchDll.ComGetDevSN_Async(sbDevSN);
|
|
|
|
Console.WriteLine("ComGetDevSN:" + sbDevSN);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lastpointx[0] = -1;
|
|
|
|
lastpointy[0] = -1;
|
|
|
|
lastpointx[1] = -1;
|
|
|
|
lastpointy[1] = -1;
|
|
|
|
lastpointx[2] = -1;
|
|
|
|
lastpointy[2] = -1;
|
|
|
|
|
|
|
|
FiveInchDll.ComSetBackGroundAdv();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch { }
|
|
|
|
finally { }
|
|
|
|
}
|
|
|
|
|
|
|
|
//0816加报点
|
|
|
|
public static void GetTouchPoint(TOUCH_INFO[] info1)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
//打开签字版
|
|
|
|
public static int OpenComDevice()
|
|
|
|
{
|
|
|
|
int status = FiveInchDll.OpenComDevice(GetTouchNumber);
|
|
|
|
Console.WriteLine("OpenComDevice:" + status);
|
|
|
|
if (status == 0)
|
|
|
|
{
|
|
|
|
//2022-08-16 加实时报点
|
|
|
|
status = FiveInchDll.ComSendPoint(1, GetTouchPoint);
|
|
|
|
Console.WriteLine("ComSendPoint:" + status);
|
|
|
|
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg";
|
|
|
|
int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile);
|
|
|
|
Console.WriteLine("ComSendAdvantageImage:" + ret1);
|
|
|
|
FiveInchDll.ComSetBackGroundAdv();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (true)
|
|
|
|
{
|
|
|
|
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg";
|
|
|
|
int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile);
|
|
|
|
Console.WriteLine("ComSetSignBackgroundImage:" + ret1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
//关闭签字版
|
|
|
|
public static int CloseComDevice()
|
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
if (status == 0)
|
|
|
|
{
|
|
|
|
ret = FiveInchDll.CloseComDevice();
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
status = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
//保存签字版数据
|
|
|
|
public static string ComSetPictureSavePath()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
DateTime dateTime = DateTime.Now;
|
|
|
|
string time = DateTime.Now.ToString(
|
|
|
|
"yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
|
|
|
|
var dirpath = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Sign");
|
|
|
|
FileExt.MakeSureDirExist(dirpath);
|
|
|
|
var filepath = Path.Combine(dirpath, time);
|
|
|
|
string SignFile = dirpath + "\\" + time + ".png";
|
|
|
|
string sourcepaht = Environment.CurrentDirectory + "\\fiveInch.png";
|
|
|
|
int ret = FiveInchDll.ComSignOK();
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
return SignFile;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FiveInchDll
|
|
|
|
{
|
|
|
|
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
|
|
|
|
public delegate void GetTouchNumber(int number);
|
|
|
|
|
|
|
|
//0816加报点
|
|
|
|
[System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(System.Runtime.InteropServices.CallingConvention.StdCall)]
|
|
|
|
public delegate void TOUCH_INFO_FUNC([MarshalAs(UnmanagedType.LPArray, SizeConst = 160)] TOUCH_INFO[] info);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSendPoint(int nState, [MarshalAs(UnmanagedType.FunctionPtr)] TOUCH_INFO_FUNC callback); //0816加报点
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int OpenComDevice([MarshalAs(UnmanagedType.FunctionPtr)] GetTouchNumber callback);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int CloseComDevice();
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSetSignBackgroundImage(string UIFile);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSetPictureSavePath(string PicturePath, int PicturePathLen);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSignOK();
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSetPenStyle(int PenStyle);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComGetDevSN(StringBuilder pDevSN, int iSync);
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComGetDevSN_Async(StringBuilder pDevSN);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComWhiteScreen();
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSendAdvantageImage(string UIFile);
|
|
|
|
|
|
|
|
|
|
|
|
[DllImport("XTJZFiveInch.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
|
|
|
|
public static extern int ComSetBackGroundAdv();
|
|
|
|
}
|
|
|
|
}
|