星火批注
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PenEvents.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using TQLComm;
  7. namespace XHPZ.Desktop
  8. {
  9. public class PenEvents : PenEvent
  10. {
  11. int SA = 0;
  12. int SB = 0;
  13. int SC = 0;
  14. int SD = 0;
  15. int Sindex = 0;
  16. int S = 0;
  17. int O = 0;
  18. int B = 0;
  19. int P = 0;
  20. public static bool ConnectPen = false;
  21. public bool ShowPointLog = false;
  22. public static bool DrawIngend = true;
  23. public PenCommManager Manager;
  24. /// <summary>
  25. /// TQL事件初始化,进入类型1录制2录屏
  26. /// </summary>
  27. /// <param name="type">进入类型1录制2录屏</param>
  28. public PenEvents()//(Form1 form)
  29. {
  30. //this.form = form;
  31. Manager = new PenCommManager(this);
  32. Manager.Init();
  33. }
  34. public void StartRecvDataTimer1()
  35. {
  36. DrawIngend = false;
  37. System.Timers.Timer t = new System.Timers.Timer(1000);
  38. t.Elapsed += new System.Timers.ElapsedEventHandler(timerCall);
  39. t.AutoReset = false;//设置是执行一次(false)还是一直执行(true);
  40. t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
  41. }
  42. //委托执行的方法
  43. private void timerCall(object source, System.Timers.ElapsedEventArgs e)
  44. {
  45. DrawIngend = true;
  46. //MessageBox.Show("ni");
  47. }
  48. public void OnGetOIDType(uint oType)
  49. {
  50. }
  51. public void OnSetOIDType(bool bSuccess)
  52. {
  53. }
  54. public void onConfirmReceiveOfflineData(bool bSuccess)
  55. {
  56. }
  57. /// <summary>
  58. /// 智能笔连接状态
  59. /// </summary>
  60. /// <param name="bConnected"></param>
  61. public void onConnectionStatus(bool bConnected)
  62. {
  63. ConnectPen = bConnected;
  64. try
  65. {
  66. if (bConnected)
  67. {
  68. APP.TQLPenStatus = true;
  69. //form.AddLog("智能笔已连接!");
  70. APP.W_mainWindow.UpdateDevStatus();
  71. }
  72. else
  73. {
  74. APP.TQLPenStatus = false;
  75. //form.DisConnect();
  76. //form.AddLog("智能笔已断开连接!");
  77. APP.W_mainWindow.UpdateDevStatus();
  78. }
  79. }
  80. catch (Exception)
  81. {
  82. }
  83. }
  84. public void onContinueOfflineData(bool bSuccess)
  85. {
  86. }
  87. /// <summary>
  88. /// 下载离线数据
  89. /// </summary>
  90. /// <param name="bEnd"></param>
  91. public void onEndOfDownloadOfflineData(bool bEnd)
  92. {
  93. if (bEnd)
  94. {
  95. //if (form.StartDownload) form.StartDownload = false;
  96. //form.StartOrStop(form.StartDownload);
  97. //form.DrawOffType = -1;
  98. //form.AddLog("下载离线数据成功!");
  99. //form.SetProGress(100);
  100. }
  101. else
  102. {
  103. //if (!form.StartDownload) form.StartDownload = true;
  104. //form.AddLog("下载离线数据失败!");
  105. }
  106. }
  107. public void onGetAutoPowerOffTime(short Data)
  108. {
  109. //if (form.PenAttribute != null) form.PenAttribute.SetoffTextString(Data.ToString());
  110. //form.AddLog("当前自动休眠时间:" + Data.ToString() + "!");
  111. }
  112. public void onGetAutoPowerOnMode(bool bSetOn)
  113. {
  114. //if (form.PenAttribute != null) form.PenAttribute.SetSevseepComBox(bSetOn);
  115. //form.AddLog("当前唤醒模式笔尖压力是否唤醒:" + bSetOn.ToString() + "!");
  116. }
  117. public void onGetBatteryPower(short Data)
  118. {
  119. //if (form.PenAttribute != null) form.PenAttribute.SetBatteryTextString(Data.ToString() + "%");
  120. //form.AddLog("当前剩余电量:" + Data.ToString() + "%!");
  121. }
  122. public void onGetBeepStatus(bool bSetOn)
  123. {
  124. //if (form.PenAttribute != null) form.PenAttribute.SetBeetComBox(bSetOn);
  125. //form.AddLog("当前蜂鸣器模式是否响动:" + bSetOn.ToString() + "!");
  126. }
  127. public void onGetCustomerID(uint ID1, uint ID2)
  128. {
  129. }
  130. public void onGetElementCode(uint OID, uint SID, int Size)
  131. {
  132. }
  133. public void onGetFWVersion(string strData)
  134. {
  135. //if (form.PenAttribute != null) form.PenAttribute.SetBTTextString(strData);
  136. //form.AddLog("当前蓝牙版本号:" + strData + "!");
  137. }
  138. public void onGetMCUFWVersion(string strData)
  139. {
  140. //if (form.PenAttribute != null) form.PenAttribute.SetMCUTextString(strData);
  141. //form.AddLog("当前MCU版本号:" + strData + "!");
  142. }
  143. public void onGetMacAddress(string macAddress)
  144. {
  145. //if (form.PenAttribute != null) form.PenAttribute.SetMAcTextString(macAddress);
  146. //form.AddLog("当前MAC:" + macAddress + "!");
  147. }
  148. public void onGetOID4ElementCode(int SA, int SB, int SC, int SD, int index)
  149. {
  150. //if (this.SA != SA || this.SB != SB || this.SC != SC || this.SD != SD || this.Sindex != index)
  151. //{
  152. // this.SA = SA; this.SB = SB; this.SC = SC; this.SD = SD; this.Sindex = index;
  153. // form.AddLog("SA:" + SA.ToString() + "," + "SB:" + SB.ToString() + "," + "SC:" + SC.ToString() + "," + "SD:" + SD.ToString() + "," + "index:" + index.ToString());
  154. //}
  155. }
  156. public void onGetOfflineDataNo(int Data)
  157. {
  158. //ConnectPen = true;
  159. //form.AddLog("当前离线数据量:" + Data.ToString() + "!");
  160. //if (Data == 0 && form.StartDownload == true)
  161. //{
  162. // form.StartDownload = false;
  163. // form.StartOrStop(form.StartDownload);
  164. // form.AddLog("下载离线数据成功!");
  165. //}
  166. }
  167. public void onGetPenColor(short Data)
  168. {
  169. //if (form.PenAttribute != null) form.PenAttribute.SetLEDComBox(Data);
  170. //switch (Data)
  171. //{
  172. // case 1:
  173. // form.timing.SetPenColor(Color.Blue);
  174. // break;
  175. // case 2:
  176. // form.timing.SetPenColor(Color.Green);
  177. // break;
  178. // case 3:
  179. // form.timing.SetPenColor(Color.Cyan);
  180. // break;
  181. // case 4:
  182. // form.timing.SetPenColor(Color.Red);
  183. // break;
  184. // case 5:
  185. // form.timing.SetPenColor(Color.Magenta);
  186. // break;
  187. // case 6:
  188. // form.timing.SetPenColor(Color.Yellow);
  189. // break;
  190. // case 7:
  191. // form.timing.SetPenColor(Color.Black);
  192. // break;
  193. // default:
  194. // break;
  195. //}
  196. }
  197. /// <summary>
  198. /// 获取笔名
  199. /// </summary>
  200. /// <param name="localName"></param>
  201. public void onGetPenLocalName(string localName)
  202. {
  203. //if (form.PenAttribute != null) form.PenAttribute.SetNameTextString(localName);
  204. //form.AddLog("当前笔名:" + localName + "!");
  205. }
  206. public void onGetPressureCalibrationData(uint LData, uint HData)
  207. {
  208. }
  209. private DateTime ConvertLongToDateTime(long d)
  210. {
  211. DateTime dtStart = Convert.ToDateTime("1970-1-1");
  212. long lTime = long.Parse(d.ToString());
  213. TimeSpan toNow = new TimeSpan(lTime);
  214. DateTime dtResult = dtStart.AddSeconds(lTime);
  215. return dtResult;
  216. // return dtResult;
  217. }
  218. public void onGetRTC(long Data)
  219. {
  220. //DateTime time = ConvertLongToDateTime(Data);
  221. //if (form.PenAttribute != null) form.PenAttribute.SetRTCTextString(time.ToString("yyyy-MM-dd HH:mm:ss"));
  222. //form.AddLog("当前RTC:" + time.ToString("yyyy-MM-dd HH:mm:ss") + "!");
  223. }
  224. public void onGetSensitivityLevel(short Data)
  225. {
  226. //ConnectPen = true;
  227. //if (form.PenAttribute != null) form.PenAttribute.SetSevComBox(Data);
  228. //form.AddLog("当前压力敏感度:" + Data.ToString() + "!");
  229. }
  230. /// <summary>
  231. /// 内存使用量
  232. /// </summary>
  233. /// <param name="Data"></param>
  234. public void onGetUsedMemory(short Data)
  235. {
  236. //if (form.PenAttribute != null) form.PenAttribute.SetmemTextString(Data.ToString());
  237. //form.AddLog("当前使用内存为:" + Data.ToString() + "!");
  238. }
  239. /// <summary>
  240. /// 获取蓝牙适配器连接状态
  241. /// </summary>
  242. /// <param name="bReady"></param>
  243. public void onHIDGetReady(bool bReady)
  244. {
  245. //if (bReady)
  246. //{
  247. // form.AddLog("蓝牙适配器已连接!");
  248. //}
  249. //else
  250. //{
  251. // form.AddLog("蓝牙适配器已断开连接!");
  252. //}
  253. }
  254. public void onPauseOfflineData(bool bSuccess)
  255. {
  256. }
  257. /// <summary>
  258. /// 书写点
  259. /// </summary>
  260. /// <param name="dot"></param>
  261. /// <param name="count"></param>
  262. public void onReceiveDot(Dot dot, int count)
  263. {
  264. //录屏模式
  265. if (dot.type == DotType.PEN_HOVER)
  266. {
  267. return;
  268. }
  269. else if (dot.type == DotType.PEN_DOWN)
  270. {
  271. APP.W_PracticeWindow.TQLDown();
  272. }
  273. else if (dot.type == DotType.PEN_UP)
  274. {
  275. APP.W_PracticeWindow.TQLUp();
  276. }
  277. else if (dot.type == DotType.PEN_MOVE)
  278. {
  279. double CX = (double)dot.x + (double)dot.fx / 100.00;
  280. double CY = (double)dot.y + (double)dot.fy / 100.00;
  281. APP.W_PracticeWindow.TQLPenWrite(CX, CY, dot.force);
  282. //form.AddLog("x:" + (dot.x + dot.fx / 100f).ToString() + ", " + "y:" + (dot.y + dot.fy / 100f).ToString());
  283. }
  284. }
  285. /// <summary>
  286. /// 接收脱机数据
  287. /// </summary>
  288. /// <param name="dot"></param>
  289. /// <param name="count"></param>
  290. public void onReceiveOfflineData(Dot dot, int count)
  291. {
  292. //if (form.StartDownload == false)
  293. //{
  294. // Manager.StopDownloadOfflineData();
  295. // return;
  296. //}
  297. //if (this.S != dot.sectionId || this.O != dot.ownerId || this.B != dot.noteId || this.P != dot.pageId)
  298. //{
  299. // this.S = dot.sectionId; this.O = dot.ownerId; this.B = dot.noteId; this.P = dot.pageId;
  300. // form.AddLog("Dot_S:" + this.S.ToString() + ", " + "Dot_O:" + this.O.ToString() + ", " + "Dot_B:" + this.B.ToString() + ", " + "Dot_P:" + this.P.ToString());
  301. //}
  302. ///*long unixTimeStamp = (long)(dot.timeLong - 28800000);//1478162177;
  303. //System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(2010, 1, 1)); // 当地时区
  304. //DateTime dt = startTime.AddMilliseconds(unixTimeStamp);
  305. //form.AddLog("OFF:" + dt.ToString("MM/dd HH:mm:ss.fff"));
  306. //*/
  307. ///* DateTime tmp = new System.DateTime(2010, 1, 1);
  308. // tmp.AddMilliseconds(dot.timeLong);
  309. // form.AddLog("TIME:" + tmp.ToString("MM/dd HH:mm:ss"));*/
  310. //// form.AddLog("TIME:" + dot.timeLong.ToString());
  311. //if (DrawingBox.DrawType != 2) DrawingBox.DrawType = 3;
  312. //form.Drawing(dot);
  313. }
  314. public void onReceiveOriginalDot(Dot dot, int count)
  315. {
  316. //form.Drawing(dot);
  317. }
  318. public void onRemoveOfflineData(bool bRemoved)
  319. {
  320. //if (bRemoved)
  321. //{
  322. // form.AddLog("删除离线数据成功!");
  323. // form.StartDownload = false;
  324. // form.ContinueDownload = true;
  325. // form.DrawOffType = -1;
  326. //}
  327. //else form.AddLog("删除离线数据失败!");
  328. }
  329. public void onSetAutoPowerOffTime(bool bsuccess)
  330. {
  331. //if (bsuccess) form.AddLog("设置自动休眠时间成功!");
  332. //else form.AddLog("设置自动休眠时间失败!");
  333. }
  334. public void onSetAutoPowerOnMode(bool bsuccess)
  335. {
  336. //if (bsuccess) form.AddLog("设置笔的唤醒模式成功!");
  337. //else form.AddLog("设置笔的唤醒模式失败!");
  338. }
  339. public void onSetBeepStatus(bool bsuccess)
  340. {
  341. //if (bsuccess) form.AddLog("设置蜂鸣器成功!");
  342. //else form.AddLog("设置蜂鸣器失败!");
  343. }
  344. public void onSetCustomerID(bool bsuccess)
  345. {
  346. }
  347. public void onSetElementCode(bool bSuccess)
  348. {
  349. }
  350. public void onSetPenColor(bool bsuccess)
  351. {
  352. //if (Form1.SetColor == false) return;
  353. //Form1.SetColor = false;
  354. //if (bsuccess) form.AddLog("设置笔LED灯颜色成功!");
  355. //else form.AddLog("设置笔LED灯颜色失败!");
  356. }
  357. public void onSetPenLocalName(bool bsuccess)
  358. {
  359. //if (bsuccess) form.AddLog("设置笔名成功!");
  360. //else form.AddLog("设置笔名失败!");
  361. }
  362. public void onSetSensitivityLevel(bool bsuccess)
  363. {
  364. //if (bsuccess) form.AddLog("设置压力敏感度成功!");
  365. //else form.AddLog("设置压力敏感度失败!");
  366. }
  367. public void onStartDownloadOfflineData(bool bStart)
  368. {
  369. }
  370. public void onStopDownloadOfflineData(bool bStart)
  371. {
  372. }
  373. public void onWriteRTC(bool bsuccess)
  374. {
  375. //if (bsuccess)
  376. //{
  377. // form.AddLog("设置RTC成功!");
  378. // Manager.GetRTC();
  379. //}
  380. //else form.AddLog("设置RTC失败!");
  381. }
  382. public void DownloadOfflineDataRate(float Rate)
  383. {
  384. //form.SetProGress(Rate);
  385. }
  386. public void onGetMCUFCode(string strData)
  387. {
  388. //if (form.PenAttribute != null) form.PenAttribute.SetMcuCodeTextString(strData);
  389. //form.AddLog("MCU序列号:" + strData + "!");
  390. }
  391. public void OnGetPenCodeType(uint oType)
  392. {
  393. }
  394. public void onSetPenHover(byte type)
  395. {
  396. //if (type == 1)
  397. //{
  398. // form.AddLog("设置悬浮打开!");
  399. // form.PenAttribute.SetHoverComBox(0);
  400. //}
  401. //else if (type == 0)
  402. //{
  403. // form.AddLog("设置悬浮关闭!");
  404. // form.PenAttribute.SetHoverComBox(1);
  405. //}
  406. }
  407. }
  408. }