星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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