GeneralCountometerDialog.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.IO.Ports;
  6. using System.Windows.Forms;
  7. using PaintDotNet.Base.CommTool;
  8. using PaintDotNet.CustomControl;
  9. using PaintDotNet.GeneralAnalysis.Countometer;
  10. using PaintDotNet.ImageCollect;
  11. using PaintDotNet.Base.SettingModel;
  12. using StageController;
  13. using StageController.M3H;
  14. using PaintDotNet.Hardware;
  15. namespace PaintDotNet.GeneralAnalysis
  16. {
  17. /// <summary>
  18. /// 积数仪
  19. /// </summary>
  20. internal class GeneralCountometerDialog : FloatingToolForm
  21. {
  22. #region 控件相关
  23. private System.Windows.Forms.GroupBox groupBox1;
  24. private System.Windows.Forms.Button btnShowHistory;
  25. private System.Windows.Forms.Button btnSave;
  26. private System.Windows.Forms.Button btnHotKey;
  27. private System.Windows.Forms.Button btnAssay;
  28. private System.Windows.Forms.Button btnPreView;
  29. private System.Windows.Forms.Button btnSetting;
  30. private System.Windows.Forms.GroupBox groupBox2;
  31. private System.Windows.Forms.GroupBox groupBox3;
  32. private System.Windows.Forms.Label lblSummation;
  33. private System.Windows.Forms.DataGridView dgvKeyList;
  34. private System.Windows.Forms.GroupBox groupBox4;
  35. private System.Windows.Forms.GroupBox groupBox5;
  36. private System.Windows.Forms.GroupBox groupBox6;
  37. private System.Windows.Forms.Button btnTissueAdd;
  38. private System.Windows.Forms.Button btnTissueEdit;
  39. private System.Windows.Forms.Button btnTissueDelete;
  40. private System.Windows.Forms.ListBox lstTissuesList;
  41. private System.Windows.Forms.Panel panel1;
  42. private System.Windows.Forms.Label lblNull;
  43. private System.Windows.Forms.Panel panel2;
  44. private System.Windows.Forms.DataGridViewTextBoxColumn hotKey;
  45. private System.Windows.Forms.DataGridViewTextBoxColumn name;
  46. private System.Windows.Forms.DataGridViewTextBoxColumn count;
  47. private System.Windows.Forms.DataGridViewTextBoxColumn ratio;
  48. private System.ComponentModel.IContainer components;
  49. private System.Windows.Forms.DataVisualization.Charting.Chart chart1;
  50. private System.Windows.Forms.ToolTip toolTip1;
  51. private void InitializeLanguageText()
  52. {
  53. this.lblNull.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Nostatistics.text");
  54. this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.X,Yaxiscontrol.text");
  55. this.groupBox6.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.imitatelensarea.text");
  56. this.Text = PdnResources.GetString("Menu.GeneralAnalysis.Countometer.Text");
  57. this.lblSummation.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.total.text") + ":0";
  58. this.hotKey.HeaderText = PdnResources.GetString("Menu.icon.text");
  59. this.name.HeaderText = PdnResources.GetString("Menu.name.text");
  60. this.count.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Integrator.Quantity.text");
  61. this.ratio.HeaderText = PdnResources.GetString("Menu.proportion.text");
  62. this.groupBox4.Text = PdnResources.GetString("Menu.Organizationinformation.text");
  63. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  64. this.btnShowHistory.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.HistoryView.text");
  65. this.btnSave.Text = PdnResources.GetString("Menu.File.Save.Text");
  66. this.btnHotKey.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Definekey.text");
  67. this.btnAssay.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.ensure.text");
  68. this.btnPreView.Text = PdnResources.GetString("Menu.Preview.text");
  69. this.btnSetting.Text = PdnResources.GetString("Menu.Setting.Text");
  70. this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.Measuringtissue.text");
  71. this.groupBox3.Text = PdnResources.GetString("Menu.Organizationinformation.text");
  72. }
  73. private void InitializeComponent()
  74. {
  75. this.components = new System.ComponentModel.Container();
  76. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  77. System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
  78. System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
  79. System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
  80. this.groupBox1 = new System.Windows.Forms.GroupBox();
  81. this.btnShowHistory = new System.Windows.Forms.Button();
  82. this.btnSave = new System.Windows.Forms.Button();
  83. this.btnHotKey = new System.Windows.Forms.Button();
  84. this.btnAssay = new System.Windows.Forms.Button();
  85. this.btnPreView = new System.Windows.Forms.Button();
  86. this.btnSetting = new System.Windows.Forms.Button();
  87. this.groupBox2 = new System.Windows.Forms.GroupBox();
  88. this.lstTissuesList = new System.Windows.Forms.ListBox();
  89. this.btnTissueEdit = new System.Windows.Forms.Button();
  90. this.btnTissueDelete = new System.Windows.Forms.Button();
  91. this.btnTissueAdd = new System.Windows.Forms.Button();
  92. this.groupBox3 = new System.Windows.Forms.GroupBox();
  93. this.lblSummation = new System.Windows.Forms.Label();
  94. this.dgvKeyList = new System.Windows.Forms.DataGridView();
  95. this.hotKey = new System.Windows.Forms.DataGridViewTextBoxColumn();
  96. this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  97. this.count = new System.Windows.Forms.DataGridViewTextBoxColumn();
  98. this.ratio = new System.Windows.Forms.DataGridViewTextBoxColumn();
  99. this.groupBox4 = new System.Windows.Forms.GroupBox();
  100. this.lblNull = new System.Windows.Forms.Label();
  101. this.groupBox5 = new System.Windows.Forms.GroupBox();
  102. this.panel1 = new System.Windows.Forms.Panel();
  103. this.groupBox6 = new System.Windows.Forms.GroupBox();
  104. this.panel2 = new System.Windows.Forms.Panel();
  105. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  106. this.chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();
  107. this.groupBox1.SuspendLayout();
  108. this.groupBox2.SuspendLayout();
  109. this.groupBox3.SuspendLayout();
  110. ((System.ComponentModel.ISupportInitialize)(this.dgvKeyList)).BeginInit();
  111. this.groupBox4.SuspendLayout();
  112. this.groupBox5.SuspendLayout();
  113. this.groupBox6.SuspendLayout();
  114. ((System.ComponentModel.ISupportInitialize)(this.chart1)).BeginInit();
  115. this.SuspendLayout();
  116. //
  117. // groupBox1
  118. //
  119. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  120. | System.Windows.Forms.AnchorStyles.Right)));
  121. this.groupBox1.Controls.Add(this.btnShowHistory);
  122. this.groupBox1.Controls.Add(this.btnSave);
  123. this.groupBox1.Controls.Add(this.btnHotKey);
  124. this.groupBox1.Controls.Add(this.btnAssay);
  125. this.groupBox1.Controls.Add(this.btnPreView);
  126. this.groupBox1.Controls.Add(this.btnSetting);
  127. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  128. this.groupBox1.Name = "groupBox1";
  129. this.groupBox1.Size = new System.Drawing.Size(1216, 79);
  130. this.groupBox1.TabIndex = 2;
  131. this.groupBox1.TabStop = false;
  132. this.groupBox1.Text = "操作";
  133. //
  134. // btnShowHistory
  135. //
  136. this.btnShowHistory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  137. this.btnShowHistory.Location = new System.Drawing.Point(905, 24);
  138. this.btnShowHistory.Name = "btnShowHistory";
  139. this.btnShowHistory.Size = new System.Drawing.Size(96, 37);
  140. this.btnShowHistory.TabIndex = 5;
  141. this.btnShowHistory.Text = "历史查看";
  142. this.btnShowHistory.UseVisualStyleBackColor = true;
  143. this.btnShowHistory.Click += new System.EventHandler(this.btnShowHistory_Click);
  144. //
  145. // btnSave
  146. //
  147. this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  148. this.btnSave.Location = new System.Drawing.Point(808, 24);
  149. this.btnSave.Name = "btnSave";
  150. this.btnSave.Size = new System.Drawing.Size(96, 37);
  151. this.btnSave.TabIndex = 4;
  152. this.btnSave.Text = "保存";
  153. this.btnSave.UseVisualStyleBackColor = true;
  154. this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
  155. //
  156. // btnHotKey
  157. //
  158. this.btnHotKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  159. this.btnHotKey.Location = new System.Drawing.Point(711, 24);
  160. this.btnHotKey.Name = "btnHotKey";
  161. this.btnHotKey.Size = new System.Drawing.Size(96, 37);
  162. this.btnHotKey.TabIndex = 3;
  163. this.btnHotKey.Text = "定义键";
  164. this.btnHotKey.UseVisualStyleBackColor = true;
  165. this.btnHotKey.Click += new System.EventHandler(this.btnHotKey_Click);
  166. //
  167. // btnAssay
  168. //
  169. this.btnAssay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  170. this.btnAssay.Location = new System.Drawing.Point(614, 24);
  171. this.btnAssay.Name = "btnAssay";
  172. this.btnAssay.Size = new System.Drawing.Size(96, 37);
  173. this.btnAssay.TabIndex = 2;
  174. this.btnAssay.Text = "测定";
  175. this.btnAssay.UseVisualStyleBackColor = true;
  176. this.btnAssay.Click += new System.EventHandler(this.btnAssay_Click);
  177. //
  178. // btnPreView
  179. //
  180. this.btnPreView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  181. this.btnPreView.Location = new System.Drawing.Point(1099, 24);
  182. this.btnPreView.Name = "btnPreView";
  183. this.btnPreView.Size = new System.Drawing.Size(96, 37);
  184. this.btnPreView.TabIndex = 1;
  185. this.btnPreView.Text = "预览";
  186. this.btnPreView.UseVisualStyleBackColor = true;
  187. this.btnPreView.Click += new System.EventHandler(this.btnPreView_Click);
  188. //
  189. // btnSetting
  190. //
  191. this.btnSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  192. this.btnSetting.Location = new System.Drawing.Point(1002, 24);
  193. this.btnSetting.Name = "btnSetting";
  194. this.btnSetting.Size = new System.Drawing.Size(96, 37);
  195. this.btnSetting.TabIndex = 0;
  196. this.btnSetting.Text = "设置";
  197. this.btnSetting.UseVisualStyleBackColor = true;
  198. this.btnSetting.Click += new System.EventHandler(this.btnSetting_Click);
  199. //
  200. // groupBox2
  201. //
  202. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  203. | System.Windows.Forms.AnchorStyles.Left)));
  204. this.groupBox2.Controls.Add(this.lstTissuesList);
  205. this.groupBox2.Controls.Add(this.btnTissueEdit);
  206. this.groupBox2.Controls.Add(this.btnTissueDelete);
  207. this.groupBox2.Controls.Add(this.btnTissueAdd);
  208. this.groupBox2.Location = new System.Drawing.Point(12, 97);
  209. this.groupBox2.Name = "groupBox2";
  210. this.groupBox2.Size = new System.Drawing.Size(287, 567);
  211. this.groupBox2.TabIndex = 3;
  212. this.groupBox2.TabStop = false;
  213. //
  214. // lstTissuesList
  215. //
  216. this.lstTissuesList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  217. | System.Windows.Forms.AnchorStyles.Left)));
  218. this.lstTissuesList.FormattingEnabled = true;
  219. this.lstTissuesList.ItemHeight = 12;
  220. this.lstTissuesList.Location = new System.Drawing.Point(15, 60);
  221. this.lstTissuesList.Name = "lstTissuesList";
  222. this.lstTissuesList.Size = new System.Drawing.Size(258, 484);
  223. this.lstTissuesList.TabIndex = 0;
  224. this.lstTissuesList.SelectedIndexChanged += new System.EventHandler(this.lstTissuesList_SelectedIndexChanged);
  225. //
  226. // btnTissueEdit
  227. //
  228. this.btnTissueEdit.Location = new System.Drawing.Point(184, 24);
  229. this.btnTissueEdit.Name = "btnTissueEdit";
  230. this.btnTissueEdit.Size = new System.Drawing.Size(41, 26);
  231. this.btnTissueEdit.TabIndex = 10;
  232. this.btnTissueEdit.UseVisualStyleBackColor = true;
  233. this.btnTissueEdit.Click += new System.EventHandler(this.btnTissueEdit_Click);
  234. //
  235. // btnTissueDelete
  236. //
  237. this.btnTissueDelete.Location = new System.Drawing.Point(232, 24);
  238. this.btnTissueDelete.Name = "btnTissueDelete";
  239. this.btnTissueDelete.Size = new System.Drawing.Size(41, 26);
  240. this.btnTissueDelete.TabIndex = 9;
  241. this.btnTissueDelete.UseVisualStyleBackColor = true;
  242. this.btnTissueDelete.Click += new System.EventHandler(this.btnTissueDelete_Click);
  243. //
  244. // btnTissueAdd
  245. //
  246. this.btnTissueAdd.Location = new System.Drawing.Point(136, 24);
  247. this.btnTissueAdd.Name = "btnTissueAdd";
  248. this.btnTissueAdd.Size = new System.Drawing.Size(41, 26);
  249. this.btnTissueAdd.TabIndex = 8;
  250. this.btnTissueAdd.UseVisualStyleBackColor = true;
  251. this.btnTissueAdd.Click += new System.EventHandler(this.btnTissueAdd_Click);
  252. //
  253. // groupBox3
  254. //
  255. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  256. | System.Windows.Forms.AnchorStyles.Left)));
  257. this.groupBox3.Controls.Add(this.lblSummation);
  258. this.groupBox3.Controls.Add(this.dgvKeyList);
  259. this.groupBox3.Location = new System.Drawing.Point(305, 97);
  260. this.groupBox3.Name = "groupBox3";
  261. this.groupBox3.Size = new System.Drawing.Size(516, 321);
  262. this.groupBox3.TabIndex = 4;
  263. this.groupBox3.TabStop = false;
  264. this.groupBox3.Text = "组织信息";
  265. //
  266. // lblSummation
  267. //
  268. this.lblSummation.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  269. this.lblSummation.AutoSize = true;
  270. this.lblSummation.Location = new System.Drawing.Point(6, 294);
  271. this.lblSummation.Name = "lblSummation";
  272. this.lblSummation.Size = new System.Drawing.Size(41, 12);
  273. this.lblSummation.TabIndex = 1;
  274. this.lblSummation.Text = "合计:";
  275. //
  276. // dgvKeyList
  277. //
  278. this.dgvKeyList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  279. | System.Windows.Forms.AnchorStyles.Left)
  280. | System.Windows.Forms.AnchorStyles.Right)));
  281. this.dgvKeyList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  282. this.dgvKeyList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  283. this.hotKey,
  284. this.name,
  285. this.count,
  286. this.ratio});
  287. this.dgvKeyList.Location = new System.Drawing.Point(6, 24);
  288. this.dgvKeyList.Name = "dgvKeyList";
  289. this.dgvKeyList.RowHeadersVisible = false;
  290. this.dgvKeyList.RowHeadersWidth = 51;
  291. this.dgvKeyList.RowTemplate.Height = 27;
  292. this.dgvKeyList.Size = new System.Drawing.Size(502, 255);
  293. this.dgvKeyList.TabIndex = 0;
  294. this.dgvKeyList.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvKeyList_CellClick);
  295. //
  296. // hotKey
  297. //
  298. this.hotKey.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
  299. this.hotKey.DataPropertyName = "hotKey";
  300. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  301. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  302. this.hotKey.DefaultCellStyle = dataGridViewCellStyle1;
  303. this.hotKey.MinimumWidth = 6;
  304. this.hotKey.Name = "hotKey";
  305. this.hotKey.ReadOnly = true;
  306. this.hotKey.Resizable = System.Windows.Forms.DataGridViewTriState.True;
  307. this.hotKey.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
  308. //
  309. // name
  310. //
  311. this.name.DataPropertyName = "name";
  312. this.name.MinimumWidth = 6;
  313. this.name.Name = "name";
  314. this.name.ReadOnly = true;
  315. this.name.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
  316. this.name.Width = 125;
  317. //
  318. // count
  319. //
  320. this.count.MinimumWidth = 6;
  321. this.count.Name = "count";
  322. this.count.ReadOnly = true;
  323. this.count.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
  324. this.count.Width = 125;
  325. //
  326. // ratio
  327. //
  328. this.ratio.MinimumWidth = 6;
  329. this.ratio.Name = "ratio";
  330. this.ratio.ReadOnly = true;
  331. this.ratio.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
  332. this.ratio.Width = 125;
  333. //
  334. // groupBox4
  335. //
  336. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  337. this.groupBox4.Controls.Add(this.lblNull);
  338. this.groupBox4.Controls.Add(this.chart1);
  339. this.groupBox4.Location = new System.Drawing.Point(305, 424);
  340. this.groupBox4.Name = "groupBox4";
  341. this.groupBox4.Size = new System.Drawing.Size(266, 240);
  342. this.groupBox4.TabIndex = 5;
  343. this.groupBox4.TabStop = false;
  344. this.groupBox4.Text = "组织信息";
  345. //
  346. // lblNull
  347. //
  348. this.lblNull.AutoSize = true;
  349. this.lblNull.Location = new System.Drawing.Point(84, 99);
  350. this.lblNull.Name = "lblNull";
  351. this.lblNull.Size = new System.Drawing.Size(0, 12);
  352. this.lblNull.TabIndex = 1;
  353. //
  354. // groupBox5
  355. //
  356. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  357. this.groupBox5.Controls.Add(this.panel1);
  358. this.groupBox5.Location = new System.Drawing.Point(577, 424);
  359. this.groupBox5.Name = "groupBox5";
  360. this.groupBox5.Size = new System.Drawing.Size(243, 240);
  361. this.groupBox5.TabIndex = 6;
  362. this.groupBox5.TabStop = false;
  363. this.groupBox5.Text = "X、Y轴控制";
  364. //
  365. // panel1
  366. //
  367. this.panel1.Location = new System.Drawing.Point(22, 24);
  368. this.panel1.Name = "panel1";
  369. this.panel1.Size = new System.Drawing.Size(215, 210);
  370. this.panel1.TabIndex = 0;
  371. //
  372. // groupBox6
  373. //
  374. this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  375. | System.Windows.Forms.AnchorStyles.Left)
  376. | System.Windows.Forms.AnchorStyles.Right)));
  377. this.groupBox6.Controls.Add(this.panel2);
  378. this.groupBox6.Location = new System.Drawing.Point(827, 97);
  379. this.groupBox6.Name = "groupBox6";
  380. this.groupBox6.Size = new System.Drawing.Size(401, 567);
  381. this.groupBox6.TabIndex = 7;
  382. this.groupBox6.TabStop = false;
  383. this.groupBox6.Text = "模拟镜头区域";
  384. //
  385. // panel2
  386. //
  387. this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  388. | System.Windows.Forms.AnchorStyles.Left)
  389. | System.Windows.Forms.AnchorStyles.Right)));
  390. this.panel2.BackColor = System.Drawing.SystemColors.Control;
  391. this.panel2.Location = new System.Drawing.Point(13, 90);
  392. this.panel2.MinimumSize = new System.Drawing.Size(100, 100);
  393. this.panel2.Name = "panel2";
  394. this.panel2.Size = new System.Drawing.Size(374, 471);
  395. this.panel2.TabIndex = 0;
  396. this.panel2.SizeChanged += new System.EventHandler(this.panel2_SizeChanged);
  397. //
  398. // chart1
  399. //
  400. this.chart1.BackColor = System.Drawing.SystemColors.Control;
  401. chartArea1.BackColor = System.Drawing.SystemColors.Control;
  402. chartArea1.Name = "ChartArea1";
  403. this.chart1.ChartAreas.Add(chartArea1);
  404. legend1.BackColor = System.Drawing.SystemColors.Control;
  405. legend1.Name = "Legend1";
  406. this.chart1.Legends.Add(legend1);
  407. this.chart1.Location = new System.Drawing.Point(18, 34);
  408. this.chart1.Name = "chart1";
  409. series1.ChartArea = "ChartArea1";
  410. series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
  411. series1.Color = System.Drawing.SystemColors.Control;
  412. series1.LabelBackColor = System.Drawing.SystemColors.Control;
  413. series1.Legend = "Legend1";
  414. series1.Name = "Series1";
  415. this.chart1.Series.Add(series1);
  416. this.chart1.Size = new System.Drawing.Size(230, 183);
  417. this.chart1.TabIndex = 0;
  418. this.chart1.Text = "chart1";
  419. //
  420. // GeneralCountometerDialog
  421. //
  422. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  423. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  424. this.ClientSize = new System.Drawing.Size(1240, 676);
  425. this.Controls.Add(this.groupBox6);
  426. this.Controls.Add(this.groupBox5);
  427. this.Controls.Add(this.groupBox4);
  428. this.Controls.Add(this.groupBox3);
  429. this.Controls.Add(this.groupBox2);
  430. this.Controls.Add(this.groupBox1);
  431. this.Location = new System.Drawing.Point(0, 0);
  432. this.Name = "GeneralCountometerDialog";
  433. this.Text = "积数仪";
  434. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GeneralCountometerDialog_FormClosing);
  435. this.Load += new System.EventHandler(this.GeneralCountometerDialog_Load);
  436. this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GeneralCountometerDialog_KeyDown);
  437. this.Controls.SetChildIndex(this.groupBox1, 0);
  438. this.Controls.SetChildIndex(this.groupBox2, 0);
  439. this.Controls.SetChildIndex(this.groupBox3, 0);
  440. this.Controls.SetChildIndex(this.groupBox4, 0);
  441. this.Controls.SetChildIndex(this.groupBox5, 0);
  442. this.Controls.SetChildIndex(this.groupBox6, 0);
  443. this.groupBox1.ResumeLayout(false);
  444. this.groupBox2.ResumeLayout(false);
  445. this.groupBox3.ResumeLayout(false);
  446. this.groupBox3.PerformLayout();
  447. ((System.ComponentModel.ISupportInitialize)(this.dgvKeyList)).EndInit();
  448. this.groupBox4.ResumeLayout(false);
  449. this.groupBox4.PerformLayout();
  450. this.groupBox5.ResumeLayout(false);
  451. this.groupBox6.ResumeLayout(false);
  452. ((System.ComponentModel.ISupportInitialize)(this.chart1)).EndInit();
  453. this.ResumeLayout(false);
  454. }
  455. #endregion
  456. protected AppWorkspace m_appWorkspace;
  457. protected AxisController m_Stage;
  458. private SQLiteHelper m_sqlHelper;
  459. private DataTable m_tissuesList;
  460. private DataTable m_hotKeyList;
  461. private string m_tissuesId;
  462. private int m_total = 0;
  463. private int m_selectedIndex = 0;
  464. private bool m_isAssay;
  465. private string m_bgColor = "#ffffffff";
  466. private string m_lensColor = "#ffffffff";
  467. private string m_lensBgColor = "#ffffffff";
  468. private string m_gridsColor = "#ffffffff";
  469. private string m_blocksColor = "#ffffffff";
  470. private string m_portName;
  471. private int m_baudRate;
  472. private string m_checkBits;
  473. private int m_step = 1000;
  474. private int m_pointRatio;
  475. private double m_pointX;
  476. private double m_pointY;
  477. private int m_rangeRatio;
  478. private double m_rangeX;
  479. private double m_rangeY;
  480. private AssayUserControl m_assayControl;
  481. private int m_assayRectX = 0;
  482. private int m_assayRectY = 0;
  483. private List<Dictionary<string, object>> m_rectList;
  484. private bool m_isFinish = false;
  485. public GeneralCountometerDialog(AppWorkspace appWorkspace)
  486. {
  487. m_appWorkspace = appWorkspace;
  488. InitializeComponent();
  489. InitializeLanguageText();
  490. InitializeButtonBackgroudImage();
  491. InitializeToolTip();
  492. InitializeData();
  493. this.panel1.Controls.Add(initSportCircal(100));
  494. SettingLoad();
  495. }
  496. public void InitStage()
  497. {
  498. m_Stage = AxisController.GetInstance();
  499. if (!m_Stage.IsOpen)
  500. {
  501. MessageBox.Show(PdnResources.GetString("Message.AxisController.NotConnected"));
  502. this.Close();
  503. }
  504. }
  505. private void InitializeButtonBackgroudImage()
  506. {
  507. this.btnTissueAdd.FlatStyle = FlatStyle.Flat;
  508. this.btnTissueAdd.FlatAppearance.BorderSize = 0;
  509. this.btnTissueAdd.BackgroundImageLayout = ImageLayout.Center;
  510. this.btnTissueAdd.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
  511. this.btnTissueEdit.FlatStyle = FlatStyle.Flat;
  512. this.btnTissueEdit.FlatAppearance.BorderSize = 0;
  513. this.btnTissueEdit.BackgroundImageLayout = ImageLayout.Center;
  514. this.btnTissueEdit.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
  515. this.btnTissueDelete.FlatStyle = FlatStyle.Flat;
  516. this.btnTissueDelete.FlatAppearance.BorderSize = 0;
  517. this.btnTissueDelete.BackgroundImageLayout = ImageLayout.Center;
  518. this.btnTissueDelete.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
  519. }
  520. private void InitializeToolTip()
  521. {
  522. this.toolTip1 = new ToolTip();
  523. this.toolTip1.SetToolTip(this.btnTissueAdd, PdnResources.GetString("Menu.New.text"));
  524. this.toolTip1.SetToolTip(this.btnTissueEdit, PdnResources.GetString("Menu.modify.Text"));
  525. this.toolTip1.SetToolTip(this.btnTissueDelete, PdnResources.GetString("Menu.Edit.Delete.Text"));
  526. this.toolTip1.ShowAlways = true;
  527. }
  528. private void InitializeData()
  529. {
  530. m_rectList = new List<Dictionary<string, object>>();
  531. m_sqlHelper = new SQLiteHelper(); //连接数据库
  532. m_sqlHelper.Connect();
  533. TissuesListLoad();
  534. }
  535. private void init()
  536. {
  537. btnHotKey.Enabled = true;
  538. btnSetting.Enabled = true;
  539. m_isAssay = false;
  540. btnAssay.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.ensure.text");
  541. m_isFinish = false;
  542. m_total = 0;
  543. m_assayRectX = 0;
  544. m_assayRectY = 0;
  545. UpdateCenterCatalog();
  546. m_rectList.Clear();
  547. AssayUIRefresh();
  548. }
  549. /// <summary>
  550. /// 运动模式操作台
  551. /// </summary>
  552. public CircleControl initSportCircal(int size)
  553. {
  554. var circleSportControl = new CircleControl(size);
  555. circleSportControl.mouseUp += new EventHandler(sportMouseUp);
  556. circleSportControl.mouseDown += new EventHandler(sportMouseDown);
  557. return circleSportControl;
  558. }
  559. #region 运动圆环
  560. protected virtual void sportMouseDown(object sender, EventArgs e)
  561. {
  562. var circleSportControl = (CircleControl)sender;
  563. if (circleSportControl._position < 8)
  564. {
  565. var p = circleSportControl._position;
  566. if (p < 0 || p > 7)
  567. return;
  568. var map = circleSportControl.positionMap[p];
  569. m_Stage.Move(1000 * map[0], 1000 * map[1]);
  570. }
  571. else
  572. {
  573. var direction = circleSportControl._position - 8;
  574. m_Stage.Split(direction);
  575. }
  576. }
  577. // 运动圆环外层按钮弹起
  578. protected virtual void sportMouseUp(object sender, EventArgs e)
  579. {
  580. var circleSportControl = (CircleControl)sender;
  581. if (circleSportControl._position > 7)
  582. m_Stage.FreeStage();
  583. }
  584. #endregion
  585. public void SettingLoad()
  586. {
  587. string select_sql = "select * from mic_countometer_setting "; //查询的SQL语句
  588. DataTable dt = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  589. if (dt != null && dt.Rows.Count > 0)
  590. {
  591. m_bgColor = dt.Rows[0]["bg_color"].ToString();
  592. m_lensColor = dt.Rows[0]["lens_color"].ToString();
  593. m_lensBgColor = dt.Rows[0]["lens_bg_color"].ToString();
  594. m_gridsColor = dt.Rows[0]["grids_color"].ToString();
  595. m_blocksColor = dt.Rows[0]["blocks_color"].ToString();
  596. m_portName = dt.Rows[0]["com_port"].ToString();
  597. m_baudRate = int.Parse(dt.Rows[0]["base_bps"].ToString());
  598. m_checkBits = dt.Rows[0]["base_check_bits"].ToString();
  599. m_step = int.Parse(dt.Rows[0]["step"].ToString());
  600. m_pointRatio = int.Parse(dt.Rows[0]["point_ratio"].ToString());
  601. m_pointX = int.Parse(dt.Rows[0]["point_x"].ToString());
  602. m_pointY = int.Parse(dt.Rows[0]["point_y"].ToString());
  603. m_rangeRatio = int.Parse(dt.Rows[0]["range_ratio"].ToString());
  604. m_rangeX = int.Parse(dt.Rows[0]["range_x"].ToString());
  605. m_rangeY = int.Parse(dt.Rows[0]["range_y"].ToString());
  606. AssayUIRefresh();
  607. }
  608. }
  609. public void TissuesListLoad()
  610. {
  611. SelectTissuesList();
  612. TissuesKeyRefresh();
  613. }
  614. private void SelectTissuesList()
  615. {
  616. // 组织列表
  617. string select_sql = "select * from mic_tissues "; //查询的SQL语句
  618. m_tissuesList = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  619. }
  620. public void TissuesKeyRefresh()
  621. {
  622. dgvKeyList.AutoGenerateColumns = false;
  623. dgvKeyList.AllowUserToAddRows = false;
  624. this.lstTissuesList.Items.Clear();
  625. if (m_tissuesList.Rows.Count > 0)
  626. {
  627. for (int i = 0; i < m_tissuesList.Rows.Count; ++i)
  628. {
  629. lstTissuesList.Items.Add(m_tissuesList.Rows[i]["tissue_name"].ToString());
  630. }
  631. if (m_selectedIndex > m_tissuesList.Rows.Count - 1)
  632. {
  633. m_selectedIndex = m_tissuesList.Rows.Count - 1;
  634. }
  635. lstTissuesList.SelectedIndex = m_selectedIndex;
  636. }
  637. else
  638. {
  639. m_tissuesId = null;
  640. }
  641. }
  642. /// <summary>
  643. /// 定义键
  644. /// </summary>
  645. /// <param name="sender"></param>
  646. /// <param name="e"></param>
  647. private void btnHotKey_Click(object sender, EventArgs e)
  648. {
  649. if (m_tissuesId == null)
  650. {
  651. MessageBox.Show(PdnResources.GetString("Menu.ddorganizationalinformationfirst.Text"));
  652. return;
  653. }
  654. HotKeySetingDialog dg = new HotKeySetingDialog(this, m_tissuesId);
  655. dg.ShowDialog();
  656. }
  657. /// <summary>
  658. /// 设置
  659. /// </summary>
  660. /// <param name="sender"></param>
  661. /// <param name="e"></param>
  662. private void btnSetting_Click(object sender, EventArgs e)
  663. {
  664. SettingDialog dg = new SettingDialog(this);
  665. dg.ShowDialog();
  666. }
  667. /// <summary>
  668. /// 查看历史
  669. /// </summary>
  670. /// <param name="sender"></param>
  671. /// <param name="e"></param>
  672. private void btnShowHistory_Click(object sender, EventArgs e)
  673. {
  674. HistoryDialog dg = new HistoryDialog(m_tissuesId);
  675. dg.ShowDialog();
  676. }
  677. /// <summary>
  678. /// 保存
  679. /// </summary>
  680. /// <param name="sender"></param>
  681. /// <param name="e"></param>
  682. private void btnSave_Click(object sender, EventArgs e)
  683. {
  684. if (m_rectList.Count <= 0)
  685. {
  686. MessageBox.Show(PdnResources.GetString("Menu.renorecordedchangesandnoneedt.Text"));
  687. return;
  688. }
  689. SavingDialog dg = new SavingDialog(m_tissuesId, m_hotKeyList);
  690. dg.ShowDialog();
  691. // 重新初始化
  692. init();
  693. }
  694. /// <summary>
  695. /// 组织 添加
  696. /// </summary>
  697. /// <param name="sender"></param>
  698. /// <param name="e"></param>
  699. private void btnTissueAdd_Click(object sender, EventArgs e)
  700. {
  701. TissuesDialog dg = new TissuesDialog(this, true, null);
  702. dg.ShowDialog();
  703. }
  704. /// <summary>
  705. /// 组织 修改
  706. /// </summary>
  707. /// <param name="sender"></param>
  708. /// <param name="e"></param>
  709. private void btnTissueEdit_Click(object sender, EventArgs e)
  710. {
  711. if (m_tissuesId == null)
  712. {
  713. MessageBox.Show(PdnResources.GetString("Menu.ddorganizationalinformationfirst.Text"));
  714. return;
  715. }
  716. TissuesDialog dg = new TissuesDialog(this, false, m_tissuesId);
  717. dg.ShowDialog();
  718. }
  719. /// <summary>
  720. /// 组织 删除
  721. /// </summary>
  722. /// <param name="sender"></param>
  723. /// <param name="e"></param>
  724. private void btnTissueDelete_Click(object sender, EventArgs e)
  725. {
  726. this.SavingYesOrNo();
  727. if (btnAssay.Text == PdnResources.GetString("Menu.stop.text"))
  728. {
  729. MessageBox.Show("正在测定,不可删除!");
  730. return;
  731. }
  732. if (m_tissuesId == null)
  733. {
  734. MessageBox.Show(PdnResources.GetString("Menu.heorganizationinformationtodelete.Text"));
  735. return;
  736. }
  737. DialogResult result = MessageBox.Show(PdnResources.GetString("Menu.surewanttodeleteheselect.Text") + "?", PdnResources.GetString("Menu.Tips.text"), MessageBoxButtons.OKCancel);
  738. if (result == DialogResult.OK)
  739. {
  740. // 删除组织信息
  741. string delete_sql = "delete from mic_tissues where id = '" + m_tissuesId + "'";
  742. m_sqlHelper.ExecuteNonQuery(delete_sql, null); //执行删除操作
  743. // 删除定义键
  744. delete_sql = "delete from mic_tissues_key where tissue_id = '" + m_tissuesId + "'";
  745. m_sqlHelper.ExecuteNonQuery(delete_sql, null); //执行删除操作
  746. this.TissuesListLoad();
  747. //MessageBox.Show(PdnResources.GetString("Menu.successfullydeleted.text"));
  748. }
  749. }
  750. private void btnPreView_Click(object sender, EventArgs e)
  751. {
  752. Form form = Application.OpenForms["CameraPreviewDialog"];//尝试获取已经弹出的窗口对象
  753. FloatingFormMethod.ShowFloatForm(form, form == null ? new CameraPreviewDialog(m_appWorkspace)/*没有弹出的窗口对象则创建*/ : null, m_appWorkspace);
  754. }
  755. private void lstTissuesList_SelectedIndexChanged(object sender, EventArgs e)
  756. {
  757. this.SavingYesOrNo();
  758. m_selectedIndex = this.lstTissuesList.SelectedIndex;
  759. m_tissuesId = m_tissuesList.Rows[m_selectedIndex]["id"].ToString();
  760. UpdateCenterCatalog();
  761. }
  762. private bool SavingYesOrNo()
  763. {
  764. bool save = false;
  765. if (m_rectList.Count > 0)
  766. {
  767. DialogResult result = MessageBox.Show(PdnResources.GetString("Menu.thertheaccumulatorhaarecordsave.Text") + "?", PdnResources.GetString("Menu.Tips.text"), MessageBoxButtons.OKCancel);
  768. if (result == DialogResult.OK)
  769. {
  770. //打开保存窗口
  771. SavingDialog savingDialog = new SavingDialog(m_tissuesId, m_hotKeyList);
  772. savingDialog.ShowDialog();
  773. save = true;
  774. }
  775. // 重新初始化数据
  776. init();
  777. }
  778. return save;
  779. }
  780. /// <summary>
  781. /// 更新中间key设置
  782. /// </summary>
  783. private void UpdateCenterCatalog()
  784. {
  785. // 组织列表
  786. string select_sql = "select * from mic_tissues_key where delete_flag = 0 and tissue_id = '" + m_tissuesId + "'"; //查询的SQL语句
  787. m_hotKeyList = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中
  788. if (m_hotKeyList != null)
  789. {
  790. m_hotKeyList.Columns.Add("count");
  791. m_hotKeyList.Columns.Add("ratio");
  792. }
  793. this.DrawDgvKeyList();
  794. this.DawPieChart();
  795. }
  796. private void DrawDgvKeyList()
  797. {
  798. this.dgvKeyList.Rows.Clear();
  799. if (m_hotKeyList == null)
  800. {
  801. return;
  802. }
  803. if (m_hotKeyList.Rows.Count > 0)
  804. {
  805. dgvKeyList.Rows.Add(m_hotKeyList.Rows.Count);
  806. for (int i = 0; i < m_hotKeyList.Rows.Count; ++i)
  807. {
  808. Color bgColor = ColorTranslator.FromHtml(m_hotKeyList.Rows[i]["color"].ToString());
  809. dgvKeyList.Rows[i].Cells["hotKey"].Value = m_hotKeyList.Rows[i]["hot_key"].ToString();
  810. dgvKeyList.Rows[i].Cells["hotKey"].Style.BackColor = bgColor;
  811. dgvKeyList.Rows[i].Cells["hotKey"].Style.ForeColor = Color.White;
  812. dgvKeyList.Rows[i].Cells["hotKey"].Style.SelectionBackColor = bgColor;
  813. dgvKeyList.Rows[i].Cells["hotKey"].Style.SelectionForeColor = Color.White;
  814. dgvKeyList.Rows[i].Cells["name"].Value = m_hotKeyList.Rows[i]["name"].ToString();
  815. string count = m_hotKeyList.Rows[i]["count"].ToString();
  816. if (string.IsNullOrEmpty(count))
  817. {
  818. count = "0";
  819. }
  820. m_hotKeyList.Rows[i]["count"] = count;
  821. dgvKeyList.Rows[i].Cells["count"].Value = count;
  822. string ratio = m_hotKeyList.Rows[i]["ratio"].ToString();
  823. if (string.IsNullOrEmpty(ratio))
  824. {
  825. ratio = "0";
  826. }
  827. m_hotKeyList.Rows[i]["ratio"] = ratio;
  828. dgvKeyList.Rows[i].Cells["ratio"].Value = ratio;
  829. }
  830. }
  831. }
  832. private void dgvKeyList_CellClick(object sender, DataGridViewCellEventArgs e)
  833. {
  834. if (!m_isAssay)
  835. {
  836. return;
  837. }
  838. if (m_isFinish)
  839. {
  840. MessageBox.Show(PdnResources.GetString("Menu.measurementshaveallbeencom.Text"));
  841. return;
  842. }
  843. // 点击图标
  844. if (dgvKeyList.Columns[e.ColumnIndex].Name == "hotKey" && e.RowIndex >= 0)
  845. {
  846. int value = int.Parse(dgvKeyList.Rows[e.RowIndex].Cells["count"].Value.ToString()) + 1;
  847. m_hotKeyList.Rows[e.RowIndex]["count"] = value;
  848. dgvKeyList.Rows[e.RowIndex].Cells["count"].Value = value;
  849. if (m_hotKeyList.Rows[e.RowIndex]["is_count"].ToString().Equals("1"))
  850. {
  851. m_total += 1;
  852. CalcRatio();
  853. }
  854. this.PrintToControl(m_hotKeyList.Rows[e.RowIndex]);
  855. this.DawPieChart();
  856. }
  857. }
  858. private void CalcRatio()
  859. {
  860. for (int i = 0; i < m_hotKeyList.Rows.Count; ++i)
  861. {
  862. if (m_hotKeyList.Rows[i]["is_count"].ToString().Equals("1"))
  863. {
  864. int count = int.Parse(m_hotKeyList.Rows[i]["count"].ToString());
  865. decimal ratio = 0;
  866. if (m_total > 0)
  867. {
  868. string t = (count * 1.0 / m_total).ToString();
  869. ratio = decimal.Round(decimal.Parse(t) * 100, 2);
  870. }
  871. string ratioStr = ratio + "%";
  872. m_hotKeyList.Rows[i]["ratio"] = ratioStr;
  873. dgvKeyList.Rows[i].Cells["ratio"].Value = ratioStr;
  874. }
  875. }
  876. }
  877. private void ResetCount(string keyString)
  878. {
  879. for (int i = 0; i < m_hotKeyList.Rows.Count; ++i)
  880. {
  881. if (keyString.Equals(m_hotKeyList.Rows[i]["hot_key"].ToString()))
  882. {
  883. int count = int.Parse(m_hotKeyList.Rows[i]["count"].ToString()) - 1;
  884. m_hotKeyList.Rows[i]["count"] = count;
  885. dgvKeyList.Rows[i].Cells["count"].Value = count;
  886. if (m_hotKeyList.Rows[i]["is_count"].ToString().Equals("1"))
  887. {
  888. m_total -= 1;
  889. }
  890. break;
  891. }
  892. }
  893. CalcRatio();
  894. }
  895. private void PrintToControl(DataRow data)
  896. {
  897. double x = 0, y = 0;
  898. if (PdnResources.GetString("Menu.Weightmeasurement.Text").Equals(data["direction"].ToString()))
  899. {
  900. // 全部重测回到开始位置了
  901. if (m_rectList.Count == 0)
  902. {
  903. return;
  904. }
  905. if (m_assayRectY % 2 == 0) // 向右走
  906. {
  907. if (m_assayRectX == 0)
  908. {
  909. m_assayRectY -= 1;
  910. y = m_rangeY;
  911. }
  912. else
  913. {
  914. m_assayRectX -= 1;
  915. x = -m_rangeX;
  916. }
  917. }
  918. else // 向左走
  919. {
  920. if (m_assayRectX == m_pointX - 1)
  921. {
  922. m_assayRectY -= 1;
  923. y = m_rangeY;
  924. }
  925. else
  926. {
  927. m_assayRectX += 1;
  928. x = m_rangeX;
  929. }
  930. }
  931. m_Stage.Move(x, y);
  932. Dictionary<String, object> lastRect = m_rectList[m_rectList.Count - 1];
  933. ResetCount(lastRect["key"].ToString());
  934. m_rectList.RemoveAt(m_rectList.Count - 1);
  935. Dictionary<String, object> rect1 = new Dictionary<String, object>
  936. {
  937. { "x", m_assayRectX },
  938. { "y", m_assayRectY },
  939. { "color", ColorTranslator.FromHtml(m_lensColor) },
  940. { "key", data["hot_key"].ToString() }
  941. };
  942. m_assayControl.DrawRectAssay(rect1);
  943. return;
  944. }
  945. Dictionary<String, object> rect = new Dictionary<String, object>
  946. {
  947. { "x", m_assayRectX },
  948. { "y", m_assayRectY },
  949. { "color", ColorTranslator.FromHtml(data["color"].ToString()) },
  950. { "key", data["hot_key"].ToString() }
  951. };
  952. m_rectList.Add(rect);
  953. m_assayControl.DrawRectAssay(rect);
  954. if (m_rectList.Count == m_pointX * m_pointY)
  955. {
  956. m_isFinish = true;
  957. UpdateAssayState();
  958. MessageBox.Show(PdnResources.GetString("Menu.measurementshaveallbeencom.Text"));
  959. return;
  960. }
  961. x = 0; y = 0;
  962. if (m_assayRectY % 2 == 0) // 向右走
  963. {
  964. if (m_assayRectX + 1 >= m_pointX)
  965. {
  966. m_assayRectY += 1;
  967. y = -m_rangeY;
  968. }
  969. else
  970. {
  971. m_assayRectX += 1;
  972. x = m_rangeX;
  973. }
  974. }
  975. else
  976. {
  977. if (m_assayRectX == 0)
  978. {
  979. m_assayRectY += 1;
  980. y = -m_rangeY;
  981. }
  982. else
  983. {
  984. m_assayRectX -= 1;
  985. x = -m_rangeX;
  986. }
  987. }
  988. m_Stage.Move(x, y);
  989. }
  990. private void DawPieChart()
  991. {
  992. lblSummation.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.total.text") + ":" + m_total.ToString();
  993. if (m_total <= 0)
  994. {
  995. lblNull.Visible = true;
  996. chart1.Visible = false;
  997. return;
  998. }
  999. lblNull.Visible = false;
  1000. chart1.Visible = true;
  1001. // 饼图
  1002. List<string> xData = new List<string>();
  1003. List<decimal> yData = new List<decimal>();
  1004. DataRow[] dr = m_hotKeyList.Select("is_count = '1'");
  1005. for (int i = 0; i < dr.Length; ++i)
  1006. {
  1007. string name = dr[i]["name"].ToString();
  1008. decimal count = (decimal.Parse(dr[i]["count"].ToString()));
  1009. string ratio = dr[i]["ratio"].ToString();
  1010. xData.Add(name + "(" + ratio + ")");
  1011. yData.Add(count);
  1012. }
  1013. chart1.Series[0]["PieLabelStyle"] = "Disabled";//将文字移到外侧Outside Inside
  1014. chart1.Series[0].Points.DataBindXY(xData, yData);
  1015. for (int i = 0; i < dr.Length; ++i)
  1016. {
  1017. Color color = ColorTranslator.FromHtml(dr[i]["color"].ToString());
  1018. chart1.Series[0].Points[i].Color = color;
  1019. }
  1020. }
  1021. private void UpdateAssayState()
  1022. {
  1023. if (m_isAssay)
  1024. {
  1025. btnHotKey.Enabled = true;
  1026. btnSetting.Enabled = true;
  1027. m_isAssay = false;
  1028. btnAssay.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.ensure.text");
  1029. }
  1030. else
  1031. {
  1032. // 开始测定前检查前一次测定是否已保存
  1033. bool save = this.SavingYesOrNo();
  1034. if (save)
  1035. {
  1036. btnHotKey.Enabled = true;
  1037. btnSetting.Enabled = true;
  1038. m_isAssay = false;
  1039. btnAssay.Text = PdnResources.GetString("Menu.Generalanalysis.Integrator.ensure.text");
  1040. }
  1041. else
  1042. {
  1043. btnHotKey.Enabled = false;
  1044. btnSetting.Enabled = false;
  1045. m_isAssay = true;
  1046. btnAssay.Text = PdnResources.GetString("Menu.stop.text");
  1047. }
  1048. }
  1049. }
  1050. private void btnAssay_Click(object sender, EventArgs e)
  1051. {
  1052. if (m_tissuesId == null)
  1053. {
  1054. MessageBox.Show(PdnResources.GetString("Menu.ddorganizationalinformationfirst.Text"));
  1055. return;
  1056. }
  1057. UpdateAssayState();
  1058. }
  1059. private void panel2_SizeChanged(object sender, EventArgs e)
  1060. {
  1061. if (this.WindowState != FormWindowState.Minimized)
  1062. {
  1063. AssayUIRefresh();
  1064. }
  1065. }
  1066. private void AssayUIRefresh()
  1067. {
  1068. m_assayControl = new AssayUserControl(panel2.Width, panel2.Height, m_pointX, m_pointY, m_rangeX, m_rangeY, m_rectList, m_rangeRatio);
  1069. m_assayControl.BgColor = ColorTranslator.FromHtml(m_bgColor);
  1070. m_assayControl.LensBgColor = ColorTranslator.FromHtml(m_lensBgColor);
  1071. m_assayControl.LensColor = ColorTranslator.FromHtml(m_lensColor);
  1072. m_assayControl.GridsColor = ColorTranslator.FromHtml(m_gridsColor);
  1073. //assay.LensColor = ColorTranslator.FromHtml(m_lensColor);
  1074. m_assayControl.initialize();
  1075. this.panel2.Controls.Clear();
  1076. this.panel2.Controls.Add(m_assayControl);
  1077. }
  1078. private void GeneralCountometerDialog_KeyDown(object sender, KeyEventArgs e)
  1079. {
  1080. if (m_isAssay)
  1081. {
  1082. if (m_isFinish)
  1083. {
  1084. MessageBox.Show(PdnResources.GetString("Menu.measurementshaveallbeencom.Text"));
  1085. return;
  1086. }
  1087. e.Handled = true;
  1088. string keyString = e.KeyCode.ToString();
  1089. if (keyString.Equals("ControlKey"))
  1090. {
  1091. keyString = "Control";
  1092. }
  1093. if (keyString.Equals("Menu"))
  1094. {
  1095. keyString = "Alt";
  1096. }
  1097. if (!keyString.Equals(""))
  1098. {
  1099. for (int i = 0; i < m_hotKeyList.Rows.Count; ++i)
  1100. {
  1101. if (keyString.Equals(m_hotKeyList.Rows[i]["hot_key"].ToString()))
  1102. {
  1103. int value = int.Parse(dgvKeyList.Rows[i].Cells["count"].Value.ToString()) + 1;
  1104. m_hotKeyList.Rows[i]["count"] = value;
  1105. dgvKeyList.Rows[i].Cells["count"].Value = value;
  1106. if (m_hotKeyList.Rows[i]["is_count"].ToString().Equals("1"))
  1107. {
  1108. m_total += 1;
  1109. CalcRatio();
  1110. }
  1111. PrintToControl(m_hotKeyList.Rows[i]);
  1112. this.DawPieChart();
  1113. break;
  1114. }
  1115. }
  1116. }
  1117. }
  1118. }
  1119. private void GeneralCountometerDialog_FormClosing(object sender, FormClosingEventArgs e)
  1120. {
  1121. this.SavingYesOrNo(); // 检查测定是否已保存
  1122. m_sqlHelper.DisConnect();
  1123. m_Stage.FreeStage();
  1124. }
  1125. private void GeneralCountometerDialog_Load(object sender, EventArgs e)
  1126. {
  1127. InitStage();
  1128. }
  1129. }
  1130. }