|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using DevicesService.Commen; |
|
|
|
|
using DevicesService.Common; |
|
|
|
|
using Functions.FileExt; |
|
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; |
|
|
|
|
using System; |
|
|
|
@ -7,6 +8,7 @@ using System.Globalization;
|
|
|
|
|
using System.IO; |
|
|
|
|
using System.Runtime.InteropServices; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
//0816加实时报点 |
|
|
|
|
[StructLayout(LayoutKind.Sequential)] |
|
|
|
|
public struct TOUCH_INFO |
|
|
|
@ -19,40 +21,42 @@ public struct TOUCH_INFO
|
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
//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); // |
|
|
|
|
// private static Pen pen = new Pen(Color.Black); // |
|
|
|
|
public static int status = -1; |
|
|
|
|
private static Bitmap bitmap = new Bitmap(594, 392); |
|
|
|
|
//private static Bitmap bitmap = new Bitmap(594, 392); |
|
|
|
|
public SignDll() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { Log.Info(ex.Message); } |
|
|
|
|
//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; |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { } |
|
|
|
|
finally { } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void GetTouchNumber(int number) |
|
|
|
|
public static void DevGetTouchNumber(int number) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
@ -63,6 +67,12 @@ namespace DevicesService.Devices
|
|
|
|
|
int ret = FiveInchDll.ComSignOK(); |
|
|
|
|
Console.WriteLine("ComSignOK:" + ret); |
|
|
|
|
FiveInchDll.ComSetBackGroundAdv(); |
|
|
|
|
Task.Run(() => { |
|
|
|
|
ScriptCallbackObject script = new ScriptCallbackObject(); |
|
|
|
|
string str = script.GetSignData("","'"); |
|
|
|
|
str = "@" + str; |
|
|
|
|
TcpServer.SendImages(str); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
else if (number == 3) |
|
|
|
|
{ |
|
|
|
@ -72,17 +82,16 @@ namespace DevicesService.Devices
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
lastpointx[0] = -1; |
|
|
|
|
lastpointy[0] = -1; |
|
|
|
|
lastpointx[1] = -1; |
|
|
|
|
lastpointy[1] = -1; |
|
|
|
|
lastpointx[2] = -1; |
|
|
|
|
lastpointy[2] = -1; |
|
|
|
|
|
|
|
|
|
//lastpointx[0] = -1; |
|
|
|
|
//lastpointy[0] = -1; |
|
|
|
|
//lastpointx[1] = -1; |
|
|
|
|
//lastpointy[1] = -1; |
|
|
|
|
//lastpointx[2] = -1; |
|
|
|
|
//lastpointy[2] = -1; |
|
|
|
|
FiveInchDll.ComSetBackGroundAdv(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) { Log.Info(ex.Message); } |
|
|
|
|
catch { } |
|
|
|
|
finally { } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -90,142 +99,172 @@ namespace DevicesService.Devices
|
|
|
|
|
public static void GetTouchPoint(TOUCH_INFO[] info1) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
int x = 0, y = 0; |
|
|
|
|
int pressurevl; |
|
|
|
|
int dx = 0, dy = 0; |
|
|
|
|
|
|
|
|
|
for (int k = 0; k < 80; k++) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
x = info1[k].X; |
|
|
|
|
y = info1[k].Y; |
|
|
|
|
|
|
|
|
|
//落笔 |
|
|
|
|
if (info1[k].Pressure > 0) |
|
|
|
|
{ |
|
|
|
|
if (info1[k].Pressure > 0 && info1[k].Pressure < 500) |
|
|
|
|
{ |
|
|
|
|
pressurevl = 1; |
|
|
|
|
pen.Width = 1; |
|
|
|
|
} |
|
|
|
|
else if (info1[k].Pressure >= 500 && info1[k].Pressure < 1000) |
|
|
|
|
{ |
|
|
|
|
pressurevl = 2; |
|
|
|
|
pen.Width = 2; |
|
|
|
|
} |
|
|
|
|
else if (info1[k].Pressure >= 1000 && info1[k].Pressure < 1500) |
|
|
|
|
{ |
|
|
|
|
pressurevl = 3; |
|
|
|
|
pen.Width = 3; |
|
|
|
|
} |
|
|
|
|
else if (info1[k].Pressure >= 1500 && info1[k].Pressure < 2048) |
|
|
|
|
{ |
|
|
|
|
pressurevl = 4; |
|
|
|
|
pen.Width = 4; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
pressurevl = 0; |
|
|
|
|
pen.Width = 1; |
|
|
|
|
} |
|
|
|
|
//int x = 0, y = 0; |
|
|
|
|
//int pressurevl; |
|
|
|
|
//int dx = 0, dy = 0; |
|
|
|
|
|
|
|
|
|
//for (int k = 0; k < 80; k++) |
|
|
|
|
//{ |
|
|
|
|
|
|
|
|
|
// x = info1[k].X; |
|
|
|
|
// y = info1[k].Y; |
|
|
|
|
|
|
|
|
|
// //落笔 |
|
|
|
|
// if (info1[k].Pressure > 0) |
|
|
|
|
// { |
|
|
|
|
// if (info1[k].Pressure > 0 && info1[k].Pressure < 500) |
|
|
|
|
// { |
|
|
|
|
// pressurevl = 1; |
|
|
|
|
// pen.Width = 1; |
|
|
|
|
// } |
|
|
|
|
// else if (info1[k].Pressure >= 500 && info1[k].Pressure < 1000) |
|
|
|
|
// { |
|
|
|
|
// pressurevl = 2; |
|
|
|
|
// pen.Width = 2; |
|
|
|
|
// } |
|
|
|
|
// else if (info1[k].Pressure >= 1000 && info1[k].Pressure < 1500) |
|
|
|
|
// { |
|
|
|
|
// pressurevl = 3; |
|
|
|
|
// pen.Width = 3; |
|
|
|
|
// } |
|
|
|
|
// else if (info1[k].Pressure >= 1500 && info1[k].Pressure < 2048) |
|
|
|
|
// { |
|
|
|
|
// pressurevl = 4; |
|
|
|
|
// pen.Width = 4; |
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// pressurevl = 0; |
|
|
|
|
// pen.Width = 1; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// //抬笔 |
|
|
|
|
// pressurevl = 0; |
|
|
|
|
|
|
|
|
|
// lastpointx[0] = -1; |
|
|
|
|
// lastpointy[0] = -1; |
|
|
|
|
// lastpointx[1] = -1; |
|
|
|
|
// lastpointy[1] = -1; |
|
|
|
|
// lastpointx[2] = -1; |
|
|
|
|
// lastpointy[2] = -1; |
|
|
|
|
// continue; |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// if (info1[k].Pressure > 10) //有画线宽度 |
|
|
|
|
// { |
|
|
|
|
// lastpointx[2] = x; |
|
|
|
|
// lastpointy[2] = y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (lastpointx[2] != -1) |
|
|
|
|
// { |
|
|
|
|
// if (lastpointx[1] != -1 && lastpointx[0] != -1) |
|
|
|
|
// { |
|
|
|
|
// //float dx = Math.Abs(lastpointx[2] - beginPos.X); |
|
|
|
|
// //float dy = Math.Abs(endPos.Y - beginPos.Y); |
|
|
|
|
|
|
|
|
|
// dx = Math.Abs(lastpointx[2] - lastpointx[1]); |
|
|
|
|
// dy = Math.Abs(lastpointy[2] - lastpointy[1]); |
|
|
|
|
// if ((dx != 0) && (dy != 0)) |
|
|
|
|
// { |
|
|
|
|
|
|
|
|
|
// if (lastpointy[1] != -1 && lastpointy[2] != -1) //y轴相同的点不画,直接跳过 |
|
|
|
|
// { |
|
|
|
|
// if (lastpointx[1] != -1 && lastpointx[2] != -1) //第3个点和第二个点比较是否x坐标在同一个位置,不是就执行画第一个点到第二个点的线 |
|
|
|
|
// { |
|
|
|
|
// //painter->drawLine(frontPos, beginPos); //画线 |
|
|
|
|
// //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[1], lastpointy[1]); |
|
|
|
|
// //painter->drawPoint(beginPos); //画点 |
|
|
|
|
// //frontPos = beginPos; |
|
|
|
|
// //beginPos = endPos; |
|
|
|
|
// lastpointx[0] = lastpointx[1]; |
|
|
|
|
// lastpointy[0] = lastpointy[1]; |
|
|
|
|
// lastpointx[1] = lastpointx[2]; |
|
|
|
|
// lastpointy[1] = lastpointy[2]; |
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// //是就执行画第一个点到第三个点的线 |
|
|
|
|
// //painter->drawLine(frontPos, endPos); |
|
|
|
|
// //g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[2], lastpointy[2]); |
|
|
|
|
// //frontPos = endPos; //第三个点赋值第一个点 |
|
|
|
|
// //beginPos = QPointF(0, 0); //第二个点置空 |
|
|
|
|
// //beginPos.X = -1; |
|
|
|
|
// //beginPos.Y = -1; |
|
|
|
|
// lastpointx[0] = lastpointx[2]; |
|
|
|
|
// lastpointy[0] = lastpointy[2]; |
|
|
|
|
// lastpointx[1] = -1; |
|
|
|
|
// lastpointy[1] = -1; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// }// |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// if (lastpointx[1] != -1) //不为空在赋值,防止丢弃点时赋空值 |
|
|
|
|
// { |
|
|
|
|
// lastpointx[0] = lastpointx[1]; |
|
|
|
|
// lastpointy[0] = lastpointy[1]; |
|
|
|
|
// } |
|
|
|
|
// lastpointx[1] = lastpointx[2]; |
|
|
|
|
// lastpointy[1] = lastpointy[2]; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
// else |
|
|
|
|
// { |
|
|
|
|
// dx = dy = 0; |
|
|
|
|
// lastpointx[0] = -1; |
|
|
|
|
// lastpointy[0] = -1; |
|
|
|
|
// lastpointx[1] = -1; |
|
|
|
|
// lastpointy[1] = -1; |
|
|
|
|
// lastpointx[2] = -1; |
|
|
|
|
// lastpointy[2] = -1; |
|
|
|
|
|
|
|
|
|
// } |
|
|
|
|
//} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//抬笔 |
|
|
|
|
pressurevl = 0; |
|
|
|
|
|
|
|
|
|
lastpointx[0] = -1; |
|
|
|
|
lastpointy[0] = -1; |
|
|
|
|
lastpointx[1] = -1; |
|
|
|
|
lastpointy[1] = -1; |
|
|
|
|
lastpointx[2] = -1; |
|
|
|
|
lastpointy[2] = -1; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (info1[k].Pressure > 10) //有画线宽度 |
|
|
|
|
{ |
|
|
|
|
lastpointx[2] = x; |
|
|
|
|
lastpointy[2] = y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lastpointx[2] != -1) |
|
|
|
|
{ |
|
|
|
|
if (lastpointx[1] != -1 && lastpointx[0] != -1) |
|
|
|
|
{ |
|
|
|
|
//float dx = Math.Abs(lastpointx[2] - beginPos.X); |
|
|
|
|
//float dy = Math.Abs(endPos.Y - beginPos.Y); |
|
|
|
|
|
|
|
|
|
dx = Math.Abs(lastpointx[2] - lastpointx[1]); |
|
|
|
|
dy = Math.Abs(lastpointy[2] - lastpointy[1]); |
|
|
|
|
if ((dx != 0) && (dy != 0)) |
|
|
|
|
//打开签字版 |
|
|
|
|
public static int OpenComDevice() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (lastpointy[1] != -1 && lastpointy[2] != -1) //y轴相同的点不画,直接跳过 |
|
|
|
|
//GetTouchNumber m_GetTouchCB = new(DevGetTouchNumber); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (lastpointx[1] != -1 && lastpointx[2] != -1) //第3个点和第二个点比较是否x坐标在同一个位置,不是就执行画第一个点到第二个点的线 |
|
|
|
|
status = FiveInchDll.OpenComDevice(DevGetTouchNumber); |
|
|
|
|
if (status == -1) |
|
|
|
|
{ |
|
|
|
|
//painter->drawLine(frontPos, beginPos); //画线 |
|
|
|
|
//g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[1], lastpointy[1]); |
|
|
|
|
//painter->drawPoint(beginPos); //画点 |
|
|
|
|
//frontPos = beginPos; |
|
|
|
|
//beginPos = endPos; |
|
|
|
|
lastpointx[0] = lastpointx[1]; |
|
|
|
|
lastpointy[0] = lastpointy[1]; |
|
|
|
|
lastpointx[1] = lastpointx[2]; |
|
|
|
|
lastpointy[1] = lastpointy[2]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
//是就执行画第一个点到第三个点的线 |
|
|
|
|
//painter->drawLine(frontPos, endPos); |
|
|
|
|
//g.DrawLine(pen, lastpointx[0], lastpointy[0], lastpointx[2], lastpointy[2]); |
|
|
|
|
//frontPos = endPos; //第三个点赋值第一个点 |
|
|
|
|
//beginPos = QPointF(0, 0); //第二个点置空 |
|
|
|
|
//beginPos.X = -1; |
|
|
|
|
//beginPos.Y = -1; |
|
|
|
|
lastpointx[0] = lastpointx[2]; |
|
|
|
|
lastpointy[0] = lastpointy[2]; |
|
|
|
|
lastpointx[1] = -1; |
|
|
|
|
lastpointy[1] = -1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}// |
|
|
|
|
else |
|
|
|
|
status = FiveInchDll.OpenComDevice(DevGetTouchNumber); |
|
|
|
|
Console.WriteLine("OpenComDevice:" + status); |
|
|
|
|
//清空界面 |
|
|
|
|
// GetTouchNumber(2); |
|
|
|
|
if (status == 0) |
|
|
|
|
{ |
|
|
|
|
if (lastpointx[1] != -1) //不为空在赋值,防止丢弃点时赋空值 |
|
|
|
|
//关闭报点 |
|
|
|
|
int ret = FiveInchDll.ComSendPoint(0, GetTouchPoint); |
|
|
|
|
if (true) |
|
|
|
|
{ |
|
|
|
|
lastpointx[0] = lastpointx[1]; |
|
|
|
|
lastpointy[0] = lastpointy[1]; |
|
|
|
|
} |
|
|
|
|
lastpointx[1] = lastpointx[2]; |
|
|
|
|
lastpointy[1] = lastpointy[2]; |
|
|
|
|
} |
|
|
|
|
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\adv_ui.jpg"; |
|
|
|
|
int ret1 = FiveInchDll.ComSendAdvantageImage(UIFile); |
|
|
|
|
Console.WriteLine("ComSendAdvantageImage:" + ret1); |
|
|
|
|
FiveInchDll.ComSetBackGroundAdv(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
if (true) |
|
|
|
|
{ |
|
|
|
|
dx = dy = 0; |
|
|
|
|
lastpointx[0] = -1; |
|
|
|
|
lastpointy[0] = -1; |
|
|
|
|
lastpointx[1] = -1; |
|
|
|
|
lastpointy[1] = -1; |
|
|
|
|
lastpointx[2] = -1; |
|
|
|
|
lastpointy[2] = -1; |
|
|
|
|
|
|
|
|
|
string UIFile = System.IO.Directory.GetCurrentDirectory() + "\\sign_ui.jpg"; |
|
|
|
|
int ret1 = FiveInchDll.ComSetSignBackgroundImage(UIFile); |
|
|
|
|
Console.WriteLine("ComSetSignBackgroundImage:" + ret1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//打开签字版 |
|
|
|
|
public static int OpenComDevice() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
status = FiveInchDll.OpenComDevice(GetTouchNumber); |
|
|
|
|
Console.WriteLine("OpenComDevice:" + status); |
|
|
|
|
//清空界面 |
|
|
|
|
//GetTouchNumber(2); |
|
|
|
|
if (status == 0) |
|
|
|
|
{ |
|
|
|
|
//关闭报点 |
|
|
|
@ -246,7 +285,9 @@ namespace DevicesService.Devices
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch(Exception ex) { Log.Info(ex.Message); } |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
catch { } |
|
|
|
|
finally { } |
|
|
|
|
return status; |
|
|
|
|
} |
|
|
|
@ -272,7 +313,7 @@ namespace DevicesService.Devices
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存签字版数据 |
|
|
|
|
public static string ComSetPictureSavePath() |
|
|
|
|
public string ComSetPictureSavePath() |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
@ -303,9 +344,9 @@ namespace DevicesService.Devices
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|