MethodCutOffDialog.cs 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.SettingModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7. using GroupBox = System.Windows.Forms.GroupBox;
  8. using CheckBox = System.Windows.Forms.CheckBox;
  9. using Button = System.Windows.Forms.Button;
  10. using System.Data;
  11. using PaintDotNet.Base.CommTool;
  12. using System.Drawing.Drawing2D;
  13. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.ManualMethod
  14. {
  15. internal class MethodCutOffDialog : GrainSizeStandardDialog
  16. {
  17. /// <summary>
  18. /// 调色板
  19. /// </summary>
  20. private ColorsForm colorsFormGrid;
  21. private Panel panelC;
  22. /// <summary>
  23. /// 鼠标状态(0:添加 1:删除 2:选择)
  24. /// </summary>
  25. private int mouseStatus = -1;
  26. /// <summary>
  27. /// 测量线类型(0:全方位 1:水平 2:垂直)
  28. /// </summary>
  29. private int lineStyle = 0;
  30. /// <summary>
  31. /// 线条矩形
  32. /// </summary>
  33. private Dictionary<PointF[], int> rectangleFsLines = new Dictionary<PointF[], int>();
  34. private int selectLineIndex = -1;
  35. private PointF movePointStart;
  36. bool canMove = false;
  37. int movePointIndex = -1;
  38. bool canAdd = false;
  39. private int defaultIndex = -1;
  40. private bool canChange = false;
  41. /// <summary>
  42. /// 标尺
  43. /// </summary>
  44. private double unitLength;
  45. /// <summary>
  46. /// 数据展示
  47. /// </summary>
  48. private DataTable dataTable;
  49. /// <summary>
  50. /// 存在视场标记
  51. /// </summary>
  52. private bool existViewFlag = false;
  53. /// <summary>
  54. /// 线条绘制点矩形集合
  55. /// </summary>
  56. private Dictionary<RectangleF[], int> rectangleFs = new Dictionary<RectangleF[], int>();
  57. /// <summary>
  58. /// 线条绘制点矩形
  59. /// </summary>
  60. private RectangleF[] rectangleFsArr = new RectangleF[2];
  61. /// <summary>
  62. /// 线条矩形
  63. /// </summary>
  64. private PointF[] pointFsLine = new PointF[4];
  65. /// <summary>
  66. /// 测定结果暂存
  67. /// </summary>
  68. private List<DataTable> dataTable1s = new List<DataTable>();
  69. /// <summary>
  70. /// 储存点击保存结果后的所有原图与分析图
  71. /// </summary>
  72. private Dictionary<string, List<Bitmap>> bitCeDingDic = new Dictionary<string, List<Bitmap>>();
  73. protected static string ParamKey_MainFontSize = "MainFontSize";//字号
  74. protected static string ParamKey_MainFontColor = "MainFontColor"; // 字体颜色
  75. protected static string ParamKey_MainLineWidth = "MainLineWidth";
  76. protected static string ParamKey_MainLineColor = "MainLineColor";
  77. #region 组件
  78. private GroupBox groupBox11;
  79. private CheckBox checkBox3_0;
  80. private DataGridViewTextBoxColumn ColumnTotal1;
  81. private DataGridViewTextBoxColumn ColumnTotal2;
  82. private DataGridViewTextBoxColumn ColumnTotal3;
  83. private DataGridViewTextBoxColumn ColumnTotal4;
  84. private DataGridViewTextBoxColumn ColumnTotal5;
  85. private DataGridViewTextBoxColumn ColumnTotal6;
  86. private DataGridViewTextBoxColumn Column1;
  87. private DataGridViewTextBoxColumn Column2;
  88. private DataGridViewTextBoxColumn Column3;
  89. private DataGridViewTextBoxColumn Column4;
  90. private DataGridViewTextBoxColumn Column5;
  91. private DataGridViewTextBoxColumn Graisize;
  92. private DataGridViewTextBoxColumn Grainnumber;
  93. private DataGridViewTextBoxColumn Grainintercept;
  94. private DataGridViewTextBoxColumn Graingrade;
  95. private GroupBox groupBox1;
  96. private Button button10;
  97. private Button button7_0;
  98. private GroupBox groupBox2;
  99. private Label label4;
  100. private Label label3;
  101. private Label label5;
  102. private DataGridViewTextBoxColumn Column11;
  103. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  104. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  105. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
  106. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
  107. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
  108. private Label label8;
  109. private Label label7;
  110. private Label label6;
  111. private Label label1;
  112. private Panel panel2;
  113. private Panel panel1;
  114. private NumericUpDown numericUpDown3;
  115. private NumericUpDown numericUpDown4;
  116. private Button button2;
  117. private DataGridView dataGridView1;
  118. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
  119. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
  120. private Label labelNum;
  121. private Label labelMin;
  122. private Label labelMax;
  123. private DataGridViewTextBoxColumn Column6;
  124. #endregion 组件
  125. #region 构造函数
  126. public MethodCutOffDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, null, 0)
  127. {
  128. //
  129. //初始化色板
  130. //
  131. this.colorsFormGrid = new ColorsForm();
  132. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  133. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  134. getSonData();
  135. }
  136. #endregion 构造函数
  137. #region 初始化组件
  138. private void InitializeComponentText()
  139. {
  140. //this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
  141. }
  142. private void InitializeComponent()
  143. {
  144. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
  145. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
  146. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
  147. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
  148. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle();
  149. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle();
  150. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle();
  151. this.groupBox11 = new System.Windows.Forms.GroupBox();
  152. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  153. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  154. this.panel2 = new System.Windows.Forms.Panel();
  155. this.panel1 = new System.Windows.Forms.Panel();
  156. this.label8 = new System.Windows.Forms.Label();
  157. this.label7 = new System.Windows.Forms.Label();
  158. this.label6 = new System.Windows.Forms.Label();
  159. this.label1 = new System.Windows.Forms.Label();
  160. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  161. this.Graisize = new System.Windows.Forms.DataGridViewTextBoxColumn();
  162. this.Grainnumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
  163. this.Grainintercept = new System.Windows.Forms.DataGridViewTextBoxColumn();
  164. this.Graingrade = new System.Windows.Forms.DataGridViewTextBoxColumn();
  165. this.groupBox1 = new System.Windows.Forms.GroupBox();
  166. this.button2 = new System.Windows.Forms.Button();
  167. this.button10 = new System.Windows.Forms.Button();
  168. this.button7_0 = new System.Windows.Forms.Button();
  169. this.groupBox2 = new System.Windows.Forms.GroupBox();
  170. this.labelNum = new System.Windows.Forms.Label();
  171. this.labelMin = new System.Windows.Forms.Label();
  172. this.labelMax = new System.Windows.Forms.Label();
  173. this.label5 = new System.Windows.Forms.Label();
  174. this.label4 = new System.Windows.Forms.Label();
  175. this.label3 = new System.Windows.Forms.Label();
  176. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  177. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  178. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  179. this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  180. this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  181. this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  182. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  183. this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  184. this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  185. this.groupBox_analysisResult1.SuspendLayout();
  186. this.groupBox3.SuspendLayout();
  187. this.groupBox11.SuspendLayout();
  188. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  189. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  190. this.groupBox1.SuspendLayout();
  191. this.groupBox2.SuspendLayout();
  192. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  193. this.SuspendLayout();
  194. //
  195. // groupBox11
  196. //
  197. this.groupBox11.Controls.Add(this.numericUpDown4);
  198. this.groupBox11.Controls.Add(this.numericUpDown3);
  199. this.groupBox11.Controls.Add(this.panel2);
  200. this.groupBox11.Controls.Add(this.panel1);
  201. this.groupBox11.Controls.Add(this.label8);
  202. this.groupBox11.Controls.Add(this.label7);
  203. this.groupBox11.Controls.Add(this.label6);
  204. this.groupBox11.Controls.Add(this.label1);
  205. this.groupBox11.Controls.Add(this.checkBox3_0);
  206. this.groupBox11.Location = new System.Drawing.Point(178, 364);
  207. this.groupBox11.Name = "groupBox11";
  208. this.groupBox11.Size = new System.Drawing.Size(356, 83);
  209. this.groupBox11.TabIndex = 39;
  210. this.groupBox11.TabStop = false;
  211. //
  212. // numericUpDown4
  213. //
  214. this.numericUpDown4.Location = new System.Drawing.Point(60, 37);
  215. this.numericUpDown4.Maximum = new decimal(new int[] {
  216. 9999,
  217. 0,
  218. 0,
  219. 0});
  220. this.numericUpDown4.Minimum = new decimal(new int[] {
  221. 1,
  222. 0,
  223. 0,
  224. 0});
  225. this.numericUpDown4.Name = "numericUpDown4";
  226. this.numericUpDown4.Size = new System.Drawing.Size(55, 21);
  227. this.numericUpDown4.TabIndex = 30;
  228. this.numericUpDown4.Value = new decimal(new int[] {
  229. 20,
  230. 0,
  231. 0,
  232. 0});
  233. //
  234. // numericUpDown3
  235. //
  236. this.numericUpDown3.Location = new System.Drawing.Point(60, 59);
  237. this.numericUpDown3.Maximum = new decimal(new int[] {
  238. 9999,
  239. 0,
  240. 0,
  241. 0});
  242. this.numericUpDown3.Minimum = new decimal(new int[] {
  243. 1,
  244. 0,
  245. 0,
  246. 0});
  247. this.numericUpDown3.Name = "numericUpDown3";
  248. this.numericUpDown3.Size = new System.Drawing.Size(55, 21);
  249. this.numericUpDown3.TabIndex = 29;
  250. this.numericUpDown3.Value = new decimal(new int[] {
  251. 1,
  252. 0,
  253. 0,
  254. 0});
  255. //
  256. // panel2
  257. //
  258. this.panel2.BackColor = System.Drawing.Color.Blue;
  259. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  260. this.panel2.Location = new System.Drawing.Point(218, 60);
  261. this.panel2.Name = "panel2";
  262. this.panel2.Size = new System.Drawing.Size(49, 17);
  263. this.panel2.TabIndex = 28;
  264. this.panel2.Click += new System.EventHandler(this.panelC_Click);
  265. //
  266. // panel1
  267. //
  268. this.panel1.BackColor = System.Drawing.Color.Yellow;
  269. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  270. this.panel1.Location = new System.Drawing.Point(218, 39);
  271. this.panel1.Name = "panel1";
  272. this.panel1.Size = new System.Drawing.Size(49, 17);
  273. this.panel1.TabIndex = 27;
  274. this.panel1.Click += new System.EventHandler(this.panelC_Click);
  275. //
  276. // label8
  277. //
  278. this.label8.AutoSize = true;
  279. this.label8.Location = new System.Drawing.Point(147, 63);
  280. this.label8.Name = "label8";
  281. this.label8.Size = new System.Drawing.Size(65, 12);
  282. this.label8.TabIndex = 8;
  283. this.label8.Text = "截距颜色:";
  284. //
  285. // label7
  286. //
  287. this.label7.AutoSize = true;
  288. this.label7.Location = new System.Drawing.Point(147, 42);
  289. this.label7.Name = "label7";
  290. this.label7.Size = new System.Drawing.Size(65, 12);
  291. this.label7.TabIndex = 7;
  292. this.label7.Text = "字体颜色:";
  293. //
  294. // label6
  295. //
  296. this.label6.AutoSize = true;
  297. this.label6.Location = new System.Drawing.Point(13, 63);
  298. this.label6.Name = "label6";
  299. this.label6.Size = new System.Drawing.Size(41, 12);
  300. this.label6.TabIndex = 6;
  301. this.label6.Text = "线宽:";
  302. //
  303. // label1
  304. //
  305. this.label1.AutoSize = true;
  306. this.label1.Location = new System.Drawing.Point(13, 42);
  307. this.label1.Name = "label1";
  308. this.label1.Size = new System.Drawing.Size(41, 12);
  309. this.label1.TabIndex = 5;
  310. this.label1.Text = "字号:";
  311. //
  312. // checkBox3_0
  313. //
  314. this.checkBox3_0.AutoSize = true;
  315. this.checkBox3_0.Checked = true;
  316. this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
  317. this.checkBox3_0.Location = new System.Drawing.Point(15, 19);
  318. this.checkBox3_0.Name = "checkBox3_0";
  319. this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
  320. this.checkBox3_0.TabIndex = 0;
  321. this.checkBox3_0.UseVisualStyleBackColor = true;
  322. this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
  323. //
  324. // Graisize
  325. //
  326. this.Graisize.Name = "Graisize";
  327. this.Graisize.ReadOnly = true;
  328. //
  329. // Grainnumber
  330. //
  331. this.Grainnumber.Name = "Grainnumber";
  332. this.Grainnumber.ReadOnly = true;
  333. //
  334. // Grainintercept
  335. //
  336. this.Grainintercept.Name = "Grainintercept";
  337. this.Grainintercept.ReadOnly = true;
  338. //
  339. // Graingrade
  340. //
  341. this.Graingrade.Name = "Graingrade";
  342. this.Graingrade.ReadOnly = true;
  343. //
  344. // groupBox1
  345. //
  346. this.groupBox1.Controls.Add(this.button2);
  347. this.groupBox1.Controls.Add(this.button10);
  348. this.groupBox1.Controls.Add(this.button7_0);
  349. this.groupBox1.Location = new System.Drawing.Point(179, 315);
  350. this.groupBox1.Name = "groupBox1";
  351. this.groupBox1.Size = new System.Drawing.Size(356, 43);
  352. this.groupBox1.TabIndex = 40;
  353. this.groupBox1.TabStop = false;
  354. //
  355. // button2
  356. //
  357. this.button2.BackColor = System.Drawing.SystemColors.Control;
  358. this.button2.Location = new System.Drawing.Point(215, 12);
  359. this.button2.Name = "button2";
  360. this.button2.Size = new System.Drawing.Size(95, 26);
  361. this.button2.TabIndex = 14;
  362. this.button2.UseVisualStyleBackColor = false;
  363. this.button2.Click += new System.EventHandler(this.button2_Click);
  364. //
  365. // button10
  366. //
  367. this.button10.BackColor = System.Drawing.SystemColors.Control;
  368. this.button10.Location = new System.Drawing.Point(114, 12);
  369. this.button10.Name = "button10";
  370. this.button10.Size = new System.Drawing.Size(95, 26);
  371. this.button10.TabIndex = 13;
  372. this.button10.UseVisualStyleBackColor = false;
  373. this.button10.Click += new System.EventHandler(this.button10_Click);
  374. //
  375. // button7_0
  376. //
  377. this.button7_0.BackColor = System.Drawing.SystemColors.Control;
  378. this.button7_0.Location = new System.Drawing.Point(13, 12);
  379. this.button7_0.Name = "button7_0";
  380. this.button7_0.Size = new System.Drawing.Size(95, 26);
  381. this.button7_0.TabIndex = 12;
  382. this.button7_0.UseVisualStyleBackColor = false;
  383. this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
  384. this.button7_0.LostFocus += new System.EventHandler(this.button7_0_LostFocus);
  385. //
  386. // groupBox2
  387. //
  388. this.groupBox2.Controls.Add(this.labelNum);
  389. this.groupBox2.Controls.Add(this.labelMin);
  390. this.groupBox2.Controls.Add(this.labelMax);
  391. this.groupBox2.Controls.Add(this.label5);
  392. this.groupBox2.Controls.Add(this.label4);
  393. this.groupBox2.Controls.Add(this.label3);
  394. this.groupBox2.Location = new System.Drawing.Point(179, 446);
  395. this.groupBox2.Name = "groupBox2";
  396. this.groupBox2.Size = new System.Drawing.Size(356, 39);
  397. this.groupBox2.TabIndex = 41;
  398. this.groupBox2.TabStop = false;
  399. //
  400. // labelNum
  401. //
  402. this.labelNum.AutoSize = true;
  403. this.labelNum.Location = new System.Drawing.Point(309, 17);
  404. this.labelNum.Name = "labelNum";
  405. this.labelNum.Size = new System.Drawing.Size(0, 12);
  406. this.labelNum.TabIndex = 7;
  407. //
  408. // labelMin
  409. //
  410. this.labelMin.AutoSize = true;
  411. this.labelMin.Location = new System.Drawing.Point(176, 17);
  412. this.labelMin.Name = "labelMin";
  413. this.labelMin.Size = new System.Drawing.Size(0, 12);
  414. this.labelMin.TabIndex = 6;
  415. //
  416. // labelMax
  417. //
  418. this.labelMax.AutoSize = true;
  419. this.labelMax.Location = new System.Drawing.Point(57, 17);
  420. this.labelMax.Name = "labelMax";
  421. this.labelMax.Size = new System.Drawing.Size(0, 12);
  422. this.labelMax.TabIndex = 5;
  423. //
  424. // label5
  425. //
  426. this.label5.AutoSize = true;
  427. this.label5.Location = new System.Drawing.Point(13, 17);
  428. this.label5.Name = "label5";
  429. this.label5.Size = new System.Drawing.Size(41, 12);
  430. this.label5.TabIndex = 4;
  431. this.label5.Text = "最大:";
  432. //
  433. // label4
  434. //
  435. this.label4.AutoSize = true;
  436. this.label4.Location = new System.Drawing.Point(129, 17);
  437. this.label4.Name = "label4";
  438. this.label4.Size = new System.Drawing.Size(41, 12);
  439. this.label4.TabIndex = 3;
  440. this.label4.Text = "最小:";
  441. //
  442. // label3
  443. //
  444. this.label3.AutoSize = true;
  445. this.label3.Location = new System.Drawing.Point(262, 17);
  446. this.label3.Name = "label3";
  447. this.label3.Size = new System.Drawing.Size(41, 12);
  448. this.label3.TabIndex = 2;
  449. this.label3.Text = "数量:";
  450. //
  451. // Column11
  452. //
  453. this.Column11.Name = "Column11";
  454. //
  455. // dataGridViewTextBoxColumn1
  456. //
  457. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  458. //
  459. // dataGridViewTextBoxColumn2
  460. //
  461. dataGridViewCellStyle22.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  462. this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle22;
  463. this.dataGridViewTextBoxColumn2.HeaderText = "1";
  464. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  465. this.dataGridViewTextBoxColumn2.ReadOnly = true;
  466. this.dataGridViewTextBoxColumn2.Width = 50;
  467. //
  468. // dataGridViewTextBoxColumn3
  469. //
  470. dataGridViewCellStyle23.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  471. this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle23;
  472. this.dataGridViewTextBoxColumn3.HeaderText = ".5";
  473. this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
  474. this.dataGridViewTextBoxColumn3.ReadOnly = true;
  475. this.dataGridViewTextBoxColumn3.Width = 50;
  476. //
  477. // dataGridViewTextBoxColumn4
  478. //
  479. dataGridViewCellStyle24.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  480. this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle24;
  481. this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
  482. this.dataGridViewTextBoxColumn4.ReadOnly = true;
  483. this.dataGridViewTextBoxColumn4.Width = 55;
  484. //
  485. // dataGridViewTextBoxColumn5
  486. //
  487. dataGridViewCellStyle25.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  488. this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle25;
  489. this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
  490. this.dataGridViewTextBoxColumn5.ReadOnly = true;
  491. this.dataGridViewTextBoxColumn5.Width = 69;
  492. //
  493. // dataGridView1
  494. //
  495. this.dataGridView1.AllowUserToAddRows = false;
  496. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  497. dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  498. dataGridViewCellStyle26.BackColor = System.Drawing.SystemColors.Control;
  499. dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  500. dataGridViewCellStyle26.ForeColor = System.Drawing.SystemColors.WindowText;
  501. dataGridViewCellStyle26.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  502. dataGridViewCellStyle26.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  503. dataGridViewCellStyle26.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  504. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle26;
  505. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  506. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  507. this.dataGridViewTextBoxColumn9,
  508. this.dataGridViewTextBoxColumn10});
  509. this.dataGridView1.Location = new System.Drawing.Point(178, 487);
  510. this.dataGridView1.MultiSelect = false;
  511. this.dataGridView1.Name = "dataGridView1";
  512. this.dataGridView1.ReadOnly = true;
  513. this.dataGridView1.RowHeadersVisible = false;
  514. this.dataGridView1.RowTemplate.Height = 23;
  515. this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  516. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  517. this.dataGridView1.Size = new System.Drawing.Size(356, 101);
  518. this.dataGridView1.TabIndex = 42;
  519. this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged);
  520. //
  521. // dataGridViewTextBoxColumn9
  522. //
  523. dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  524. this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle27;
  525. this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
  526. this.dataGridViewTextBoxColumn9.ReadOnly = true;
  527. this.dataGridViewTextBoxColumn9.Width = 111;
  528. //
  529. // dataGridViewTextBoxColumn10
  530. //
  531. dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
  532. this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle28;
  533. this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
  534. this.dataGridViewTextBoxColumn10.ReadOnly = true;
  535. this.dataGridViewTextBoxColumn10.Width = 242;
  536. //
  537. // MethodCutOffDialog
  538. //
  539. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  540. this.ClientSize = new System.Drawing.Size(1127, 810);
  541. this.Controls.Add(this.dataGridView1);
  542. this.Controls.Add(this.groupBox1);
  543. this.Controls.Add(this.groupBox2);
  544. this.Controls.Add(this.groupBox11);
  545. this.Location = new System.Drawing.Point(0, 0);
  546. this.Name = "MethodCutOffDialog";
  547. this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
  548. this.Controls.SetChildIndex(this.groupBox11, 0);
  549. this.Controls.SetChildIndex(this.groupBox2, 0);
  550. this.Controls.SetChildIndex(this.groupBox3, 0);
  551. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  552. this.Controls.SetChildIndex(this.groupBox_img, 0);
  553. this.Controls.SetChildIndex(this.groupBox_review, 0);
  554. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  555. this.Controls.SetChildIndex(this.groupBox_report, 0);
  556. this.Controls.SetChildIndex(this.groupBox1, 0);
  557. this.Controls.SetChildIndex(this.dataGridView1, 0);
  558. this.groupBox_analysisResult1.ResumeLayout(false);
  559. this.groupBox3.ResumeLayout(false);
  560. this.groupBox11.ResumeLayout(false);
  561. this.groupBox11.PerformLayout();
  562. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  563. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  564. this.groupBox1.ResumeLayout(false);
  565. this.groupBox2.ResumeLayout(false);
  566. this.groupBox2.PerformLayout();
  567. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  568. this.ResumeLayout(false);
  569. }
  570. #endregion 初始化组件
  571. #region 需继承方法
  572. /// <summary>
  573. /// 保存参数
  574. /// </summary>
  575. protected override void saveSonData()
  576. {
  577. saveParamValue(ParamKey_displaygrainboundaries, checkBox3_0.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);
  578. saveParamValue(ParamKey_MainFontSize, numericUpDown4.Value.ToString(), (int)Base.Dtryt.Interger);
  579. saveParamValue(ParamKey_MainFontColor, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);
  580. saveParamValue(ParamKey_MainLineWidth, numericUpDown3.Value.ToString(), (int)Base.Dtryt.Interger);
  581. saveParamValue(ParamKey_MainLineColor, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger);
  582. }
  583. /// <summary>
  584. /// 获取参数
  585. /// </summary>
  586. protected override void getSonData()
  587. {
  588. object ShowGrainBoundry;
  589. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))
  590. checkBox3_0.Checked = Convert.ToInt32(ShowGrainBoundry) == 0 ? true : false;
  591. if (GetParamValue1(ParamKey_MainFontSize, out ShowGrainBoundry))
  592. numericUpDown4.Value = Convert.ToInt32(ShowGrainBoundry);
  593. if (GetParamValue1(ParamKey_MainFontColor, out ShowGrainBoundry))
  594. panel1.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
  595. if (GetParamValue1(ParamKey_MainLineWidth, out ShowGrainBoundry))
  596. numericUpDown3.Value = Convert.ToInt32(ShowGrainBoundry);
  597. if (GetParamValue1(ParamKey_MainLineColor, out ShowGrainBoundry))
  598. panel2.BackColor = Color.FromArgb(Convert.ToInt32(ShowGrainBoundry));
  599. }
  600. /// <summary>
  601. /// 保存结果
  602. /// </summary>
  603. protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
  604. {
  605. //if (this.listView1.SelectedItems.Count == 0)
  606. //{
  607. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  608. // return;
  609. //}
  610. //if (this.dataGridView1.Rows.Count == 0)
  611. //{
  612. // MessageBox.Show(PdnResources.GetString("Menu.Noresultdata.text") + "!");
  613. // return;
  614. //}
  615. //string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  616. //string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  617. //DataTable dataTable = new DataTable();
  618. //bool replace = false;
  619. //int add = 0;
  620. //foreach (ListViewItem item in this.listView2.Items)
  621. //{
  622. // if (item.Tag.Equals(tag))
  623. // {
  624. // add++;
  625. // DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  626. // if (dr == DialogResult.OK)
  627. // {
  628. // replace = true;
  629. // this.listView2.Items.Remove(item);
  630. // }
  631. // break;
  632. // }
  633. //}
  634. //if (replace || this.listView2.Items.Count == 0 || add == 0)
  635. //{
  636. // ListViewItem listViewItem = new ListViewItem();
  637. // listViewItem.SubItems[0].Text = imgName;
  638. // listViewItem.Tag = "" + tag;
  639. // if (this.listView2.Items.Count == 0)
  640. // this.listView2.Items.Add(listViewItem);
  641. // else
  642. // this.listView2.Items.Insert(0, listViewItem);
  643. // this.dataGridView4.Rows.Clear();
  644. // for (int i = 0; i < this.dataTable.Rows.Count; i++)
  645. // {
  646. // DataGridViewRow dgvr = new DataGridViewRow();
  647. // dgvr.Tag = tag;
  648. // foreach (DataGridViewColumn c in this.dataGridView4.Columns)
  649. // {
  650. // dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  651. // }
  652. // dgvr.Cells[0].Value = imgName;
  653. // dgvr.Cells[1].Value = this.dataTable.Rows[i][0];
  654. // dgvr.Cells[2].Value = Math.Round(Convert.ToDouble(this.dataTable.Rows[i][1]), Convert.ToInt32(this.numericUpDown1.Value));
  655. // this.dataGridView4.Rows.Add(dgvr);
  656. // }
  657. // dataTable.TableName = tag;
  658. // foreach (System.Data.DataTable dataTable1 in dataTables)
  659. // {
  660. // if (dataTable1.TableName.Equals(dataTable.TableName))
  661. // {
  662. // dataTables.Remove(dataTable1);
  663. // break;
  664. // }
  665. // }
  666. // foreach (DataGridViewColumn c in this.dataGridView4.Columns)
  667. // {
  668. // dataTable.Columns.Add(c.HeaderText);
  669. // }
  670. // for (int i = 0; i < this.dataTable.Rows.Count; i++)
  671. // {
  672. // DataRow dataRow = dataTable.NewRow();
  673. // dataRow[0] = imgName;
  674. // dataRow[1] = this.dataTable.Rows[i][0];
  675. // dataRow[2] = this.dataTable.Rows[i][1];
  676. // dataTable.Rows.Add(dataRow);
  677. // }
  678. // this.dataTables.Add(dataTable);
  679. // if (this.allShow)
  680. // AllShow();
  681. // this.listView2.Items[0].Selected = true;
  682. // if (this.documentWorkspace.PhaseModels[0].mat != null)
  683. // {
  684. // //保存处理后的图片
  685. // List<Bitmap> tempBit = new List<Bitmap>();
  686. // Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  687. // tempBit.Add(originalBit);
  688. // Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  689. // Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  690. // Graphics graphics = Graphics.FromImage(newBit);
  691. // graphics.DrawImage(processedBit, new PointF(0, 0));
  692. // Draw(graphics);
  693. // tempBit.Add(newBit);
  694. // if (bitDic.ContainsKey(tag))
  695. // bitDic[tag] = tempBit;
  696. // else
  697. // bitDic.Add(tag, tempBit);
  698. // }
  699. // //拼接中间数据
  700. // List<List<string>> dataList = new List<List<string>>();
  701. // List<string> columnName = new List<string>();
  702. // columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  703. // columnName.Add(PdnResources.GetString("Menu.Linelength.text") + "(μm)");
  704. // columnName.Add(PdnResources.GetString("Menu.Startingcoordinates.text"));
  705. // columnName.Add(PdnResources.GetString("Menu.Endpointcoordinates.Text"));
  706. // dataList.Add(columnName);
  707. // int no = 0;
  708. // foreach (var item in rectangleFs)
  709. // {
  710. // double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 10) * unitLength;
  711. // no++;
  712. // List<string> strList = new List<string>();
  713. // strList.Add("" + no);
  714. // strList.Add("" + length);
  715. // strList.Add("(" + (Convert.ToInt32(item.Key[0].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[0].Y) + 6).ToString() + ")");
  716. // strList.Add("(" + (Convert.ToInt32(item.Key[1].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[1].Y) + 6).ToString() + ")");
  717. // dataList.Add(strList);
  718. // }
  719. // bool isExist = false;//是否已存在进行替换
  720. // int modelIndex = -1;//要替换的下标
  721. // for (int j = 0; j < tempDataModel.Count; j++)
  722. // {
  723. // if (tempDataModel[j].tagName.Equals(tag))
  724. // {
  725. // isExist = true;
  726. // modelIndex = j;
  727. // break;
  728. // }
  729. // }
  730. // if (isExist && modelIndex > -1)
  731. // tempDataModel[modelIndex].dataList = dataList;
  732. // else
  733. // {
  734. // ExportProjectModel newModel = new ExportProjectModel();
  735. // newModel.tagName = tag;
  736. // newModel.picName = imgName;
  737. // newModel.dataList = dataList;
  738. // tempDataModel.Add(newModel);
  739. // }
  740. //}
  741. if (this.matOrg == null)
  742. {
  743. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  744. return;
  745. }
  746. if (this.dataGridView1.Rows.Count == 0)
  747. {
  748. MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  749. return;
  750. }
  751. //if (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
  752. //{
  753. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
  754. // return;
  755. //}
  756. double value4Total = this.dataGridView1.Rows.Count - 1;// 0;
  757. //foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  758. //{
  759. // value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
  760. //}
  761. if (value4Total < 1)
  762. {
  763. MessageBox.Show("请添加截距后保存结果");
  764. return;
  765. }
  766. string imgName = getCurrentWorkspace().GetFriendlyName();
  767. string tag = getCurrentWorkTag();
  768. DataTable dataTable = new DataTable();
  769. bool replace = false;
  770. int add = 0;
  771. foreach (ListViewItem item in this.listView2.Items)
  772. {
  773. if (item.Tag.Equals(tag))
  774. {
  775. add++;
  776. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  777. if (dr == DialogResult.OK)
  778. {
  779. replace = true;
  780. }
  781. break;
  782. }
  783. }
  784. if (replace || this.listView2.Items.Count == 0 || add == 0)
  785. {
  786. if (!replace)
  787. {
  788. ListViewItem listViewItem = new ListViewItem();
  789. listViewItem.SubItems[0].Text = imgName;
  790. listViewItem.Tag = "" + tag;
  791. if (this.listView2.Items.Count == 0)
  792. this.listView2.Items.Add(listViewItem);
  793. else
  794. this.listView2.Items.Insert(0, listViewItem);
  795. }
  796. this.dataGridView2.Rows.Clear();
  797. DataGridViewRow dgvr = new DataGridViewRow();
  798. dgvr.Tag = tag;
  799. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  800. {
  801. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  802. }
  803. dgvr.Cells[0].Value = imgName;
  804. //DataGridViewRow firRow = this.dataGridView1.Rows[0];
  805. //object value1 = firRow.Cells[0].Value;//网格
  806. //object value2 = firRow.Cells[1].Value;//网格长度
  807. //object value3 = firRow.Cells[2].Value;//网格条数
  808. //double value2Total = 0;
  809. //foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  810. //{
  811. // value2Total += (double.Parse(Row.Cells[1].Value.ToString()) * double.Parse(Row.Cells[2].Value.ToString()));//网格总长度
  812. //}
  813. ////double value4Total = 0;
  814. ////foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  815. ////{
  816. //// value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
  817. ////}
  818. ////if (value4Total == 0)//###20791
  819. ////{
  820. //// MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  821. //// return;
  822. ////}
  823. //////double value4Per = value4Total / this.dataGridView1.Rows.Count;
  824. dgvr.Cells[1].Value = this.labelNum.Text;// value1;
  825. dgvr.Cells[2].Value = this.labelMax.Text;// value2Total;
  826. dgvr.Cells[3].Value = this.labelMin.Text;// value4Total;
  827. //dgvr.Cells[4].Value = value4Per;//级别
  828. decimal M = 1;// this.getGainMultiple();
  829. DataGridViewRow lastRow = this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1];
  830. double small_l = double.Parse(lastRow.Cells[1].Value.ToString());// value2Total / (value4Total * (double)M);
  831. dgvr.Cells[4].Value = small_l;
  832. ////毫米转微米
  833. //decimal A = Convert.ToDecimal(small_l * 1);
  834. ////dgvr.Cells[4].Value = small_l;// Math.Round(A, Convert.ToInt32(this.numericUpDown1_0.Value));
  835. //double[] lengths = {453, 320 , 269, 226, 190, 177, 160, 135, 113, 106,
  836. // 95.0, 89.0, 80.0, 67.3, 62.0, 56.6, 53.2, 47.6, 44.3, 40.0, 35.4, 33.6, 31.0,
  837. // 28.3, 26.6 , 23.8, 22.2, 20.0, 17.7, 16.8, 14.1, 13.3, 11.9,
  838. // 10.0, 8.86, 8.41, 7.98, 7.07, 6.20, 5.95, 5.32, 5.00, 4.43, 4.20, 3.54, 2.97
  839. //, 2.66, 2.50, 2.22};
  840. //// 差值
  841. //decimal differenceNew;
  842. //decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 1.22, (double)A - 454)));
  843. //int first = 0;
  844. //if ((double)A < lengths[lengths.Length - 1])
  845. // first = lengths.Length - 1;
  846. //else
  847. // for (int firstI = 0; firstI < lengths.Length; firstI++)
  848. // {
  849. // double item = lengths[firstI];
  850. // differenceNew = Math.Abs(A - Convert.ToDecimal(item));
  851. // if (differenceNew < differenceOld)
  852. // {
  853. // differenceOld = Math.Abs(A - Convert.ToDecimal(item));
  854. // first = firstI;
  855. // }
  856. // }
  857. //string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5"/**/, "2.0", "2.5", "3.0", "3.0",
  858. // "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
  859. // "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
  860. // "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
  861. //, "13.5", "14.0", "14.0"};
  862. dgvr.Cells[5].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;// valueG[first];
  863. this.dataGridView2.Rows.Add(dgvr);
  864. dataTable.TableName = tag;
  865. foreach (System.Data.DataTable dataTable1 in dataTables)
  866. {
  867. if (dataTable1.TableName.Equals(dataTable.TableName))
  868. {
  869. dataTables.Remove(dataTable1);
  870. break;
  871. }
  872. }
  873. for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
  874. {
  875. dataTable.Columns.Add("" + i);
  876. }
  877. DataRow dataRow = dataTable.NewRow();
  878. dataRow["0"] = imgName;
  879. dataRow["1"] = dgvr.Cells[1].Value;// "网格1";
  880. dataRow["2"] = dgvr.Cells[2].Value;
  881. dataRow["3"] = dgvr.Cells[3].Value;
  882. dataRow["4"] = dgvr.Cells[4].Value;
  883. dataRow["5"] = dgvr.Cells[5].Value;
  884. //dataRow["6"] = dgvr.Cells[6].Value;
  885. dataTable.Rows.Add(dataRow);
  886. this.dataTables.Add(dataTable);
  887. if (this.allShow)
  888. AllShow();
  889. this.RefreshDataGridView4();
  890. //保存处理后的图片
  891. double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.selectPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  892. List<Bitmap> tempBit = new List<Bitmap>();
  893. Bitmap originalBit = this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  894. originalBit.Tag = pantographRatio;
  895. tempBit.Add(originalBit);
  896. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  897. Graphics graphics = Graphics.FromImage(newBit);
  898. //if (true)
  899. //{ }//0914###18810
  900. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  901. {
  902. Mat targetMat = this.PhaseModel0Mat;
  903. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  904. }
  905. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  906. {
  907. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  908. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  909. }
  910. if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null)
  911. {
  912. Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
  913. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  914. }
  915. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  916. drawSubclass/*Draw*/(graphics);
  917. newBit.Tag = pantographRatio;
  918. tempBit.Add(newBit);
  919. if (bitDic.ContainsKey(tag))
  920. bitDic[tag] = tempBit;
  921. else
  922. bitDic.Add(tag, tempBit);
  923. ////保存处理后的图片
  924. //List<Bitmap> tempBit = new List<Bitmap>();
  925. ////Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  926. ////tempBit.Add(originalBit);
  927. ////Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  928. ////Graphics graphics = Graphics.FromImage(newBit);
  929. ////Draw(graphics);
  930. ////tempBit.Add(newBit);
  931. //foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitCeDingDic)
  932. //{
  933. // tempBit.Add(kv.Value[0]);
  934. // tempBit.Add(kv.Value[1]);
  935. //}
  936. //if (bitDic.ContainsKey(tag))
  937. // bitDic[tag] = tempBit;
  938. //else
  939. // bitDic.Add(tag, tempBit);
  940. //中间数据-拼接中间数据
  941. List<List<string>> dataList = new List<List<string>>();
  942. List<string> columnName = new List<string>();
  943. columnName.Add("编号"/*PdnResources.GetString("Menu.Tools.GridLine.Text")*/);
  944. columnName.Add("截距长度"/*PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text")*/);
  945. //columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text"));
  946. //columnName.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
  947. dataList.Add(columnName);
  948. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  949. {
  950. List<string> strList = new List<string>();
  951. strList.Add(Row.Cells[0].Value.ToString());
  952. strList.Add(Row.Cells[1].Value.ToString());
  953. //strList.Add(Row.Cells[2].Value.ToString());
  954. //strList.Add(Row.Cells[3].Value.ToString());
  955. dataList.Add(strList);
  956. }
  957. bool isExist = false;//是否已存在进行替换
  958. int modelIndex = -1;//要替换的下标
  959. for (int j = 0; j < tempDataModel.Count; j++)
  960. {
  961. if (tempDataModel[j].tagName.Equals(tag))
  962. {
  963. isExist = true;
  964. modelIndex = j;
  965. break;
  966. }
  967. }
  968. if (isExist && modelIndex > -1)
  969. tempDataModel[modelIndex].dataList = dataList;
  970. else
  971. {
  972. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  973. newModel.tagName = tag;
  974. newModel.picName = imgName;
  975. newModel.dataList = dataList;
  976. tempDataModel.Add(newModel);
  977. }
  978. }
  979. }
  980. /// <summary>
  981. /// 是否显示晶界
  982. /// </summary>
  983. /// <returns></returns>
  984. protected override Boolean ShowGrainBoundryChecked()
  985. {
  986. return checkBox3_0.Checked;
  987. }
  988. //是否绘制辅助线
  989. protected override bool showGridChecked()
  990. {
  991. return false;// checkBox4.Checked;
  992. }
  993. //是否绘制截点
  994. protected override bool drawGuidePoints()
  995. {
  996. return false;// (matOrg != null && this.checkBox5_0.Checked);
  997. }
  998. //是否显示截点
  999. protected override Boolean drawDisplaySections()//##1
  1000. {
  1001. return false;// this.checkBox5_0.Checked;
  1002. }
  1003. //辅助线类型
  1004. protected override string[] getTypeNames()
  1005. {
  1006. return new string[] {
  1007. PdnResources.GetString("Menu.Verticalauxiliaryline.text"),
  1008. PdnResources.GetString("Menu.Horizontalauxiliaryline.text"),
  1009. PdnResources.GetString("Menu.Singlecircleauxiliaryline.text"),
  1010. PdnResources.GetString("Menu.Three-circleauxiliaryline.text"),
  1011. PdnResources.GetString("Menu.Compositeauxiliaryline.text")};
  1012. }
  1013. protected override string getTemplateName()
  1014. {
  1015. return "Template.Manager.item3.GrainSizeCutOffManualMethod";// "Template.Manager.item3.GrainSizeCutOff6394Method";
  1016. }
  1017. protected override string getProjectEngineeringName()
  1018. {
  1019. return "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text";
  1020. }
  1021. protected override string getModelName()
  1022. {
  1023. return "GrainSizeGuideStyleModel.xml";
  1024. }
  1025. protected override void SubclassInitialize()
  1026. {
  1027. InitializeComponent();
  1028. InitializeComponentText();
  1029. DetailListNotDoubleIndex.Add(0);
  1030. //DetailListNotDoubleIndex.Add(1);
  1031. IndexChangedFromIndex.Clear();
  1032. IndexChangedToIndex.Clear();
  1033. IndexChangedFromIndex.Add(1);
  1034. IndexChangedFromIndex.Add(2);
  1035. IndexChangedFromIndex.Add(3);
  1036. IndexChangedFromIndex.Add(4);
  1037. IndexChangedFromIndex.Add(5);
  1038. IndexChangedToIndex.Add(0, new int[] { 2, 0 });//平均
  1039. IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//求和
  1040. IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
  1041. IndexChangedToIndex.Add(3, new int[] { 2/*3*/, 3 });//级别
  1042. IndexChangedToIndex.Add(4, new int[] { 2, 4 });//平均
  1043. for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
  1044. {
  1045. this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  1046. }
  1047. //for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
  1048. //{
  1049. // this.dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  1050. //}
  1051. //for (int i = 0; i < this.dataGridView4.Columns.Count; i++)
  1052. //{
  1053. // this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  1054. //}
  1055. }
  1056. #endregion
  1057. private void MethodCutOffDialog_Load(object sender, EventArgs e)
  1058. {
  1059. this.button_ApplyToAll.Visible = false;
  1060. this.button_SaveAll.Visible = false;
  1061. this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
  1062. this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
  1063. object ShowGrainBoundry;
  1064. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
  1065. this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
  1066. //if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
  1067. // this.checkBox4.Checked = (bool)ShowGrainBoundry;
  1068. //if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
  1069. // this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
  1070. this.groupBox3.Visible = false;
  1071. this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1072. this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1073. this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1074. this.ColumnTotal4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1075. this.ColumnTotal5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1076. this.ColumnTotal6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1077. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1078. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1079. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1080. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1081. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1082. this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  1083. this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  1084. this.ColumnTotal2,
  1085. this.ColumnTotal3,
  1086. this.ColumnTotal4,
  1087. this.ColumnTotal5,
  1088. this.ColumnTotal6});
  1089. //
  1090. // ColumnTotal1
  1091. //
  1092. this.ColumnTotal1.Name = "ColumnTotal1";
  1093. this.ColumnTotal1.ReadOnly = true;
  1094. //
  1095. // ColumnTotal2
  1096. //
  1097. this.ColumnTotal2.Name = "ColumnTotal2";
  1098. this.ColumnTotal2.ReadOnly = true;
  1099. //
  1100. // ColumnTotal3
  1101. //
  1102. this.ColumnTotal3.Name = "ColumnTotal3";
  1103. this.ColumnTotal3.ReadOnly = true;
  1104. //
  1105. // ColumnTotal4
  1106. //
  1107. this.ColumnTotal4.Name = "ColumnTotal4";
  1108. this.ColumnTotal4.ReadOnly = true;
  1109. //
  1110. // ColumnTotal5
  1111. //
  1112. this.ColumnTotal5.Name = "ColumnTotal5";
  1113. this.ColumnTotal5.ReadOnly = true;
  1114. //
  1115. // ColumnTotal6
  1116. //
  1117. this.ColumnTotal6.Name = "ColumnTotal6";
  1118. this.ColumnTotal6.ReadOnly = true;
  1119. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  1120. this.Column1,
  1121. this.Column2,
  1122. this.Column3,
  1123. this.Column4,
  1124. this.Column5,
  1125. this.Column6});
  1126. //
  1127. // Column1
  1128. //
  1129. this.Column1.Name = "Column1";
  1130. this.Column1.ReadOnly = true;
  1131. //
  1132. // Column2
  1133. //
  1134. this.Column2.Name = "Column2";
  1135. this.Column2.ReadOnly = true;
  1136. //
  1137. // Column3
  1138. //
  1139. this.Column3.Name = "Graisize";
  1140. this.Column3.ReadOnly = true;
  1141. //
  1142. // Column4
  1143. //
  1144. this.Column4.Name = "Grainnumber";
  1145. this.Column4.ReadOnly = true;
  1146. //
  1147. // Column5
  1148. //
  1149. this.Column5.Name = "Grainintercept";
  1150. this.Column5.ReadOnly = true;
  1151. //
  1152. // Column6
  1153. //
  1154. this.Column6.Name = "Graingrade";
  1155. this.Column6.ReadOnly = true;
  1156. this.dataGridViewTextBoxColumn9.HeaderText = "编号";// PdnResources.GetString("Menu.packet.text");
  1157. this.dataGridViewTextBoxColumn10.HeaderText = "截距长度";// PdnResources.GetString("Menu.Depthofnitridinglayer.text");
  1158. //this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
  1159. //this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
  1160. this.button2.Text = "选择截距";
  1161. this.button10.Text = "删除截距";
  1162. this.button7_0.Text = "添加截距";
  1163. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  1164. //this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
  1165. //this.checkBox4.Text = PdnResources.GetString("Menu.displaygrid.text");
  1166. this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  1167. this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Intersectinggrainnumber.Text");
  1168. this.ColumnTotal2.HeaderText = "截距数量";//PdnResources.GetString("Menu.Numberofgrainsingrid.Text");
  1169. this.ColumnTotal3.HeaderText = "最大截距";// PdnResources.GetString("Menu.Totalmeshlength.Text") + "(μm)";
  1170. this.ColumnTotal4.HeaderText = "最小截距";// PdnResources.GetString("Menu.umberofpoints.Text");
  1171. this.ColumnTotal5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";
  1172. this.ColumnTotal6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  1173. this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  1174. this.Column2.HeaderText = "截距数量";// PdnResources.GetString("Menu.Tools.GridLine.Text");
  1175. this.Column3.HeaderText = "最大截距";// PdnResources.GetString("Menu.Gridlength.text") + "(μm)";
  1176. this.Column4.HeaderText = "最小截距";// PdnResources.GetString("Menu.Thenumberofsections.text");
  1177. this.Column5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";// "平均截距";//
  1178. this.Column6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");// "";//
  1179. this.Text = "手动测量";// "GBT6394_2017(" + PdnResources.GetString("Menu.sectionmethod.text") + ")";
  1180. //this.groupBox_img.Size = new System.Drawing.Size(158, 722);
  1181. //this.groupBox_review.Size = new System.Drawing.Size(575, 722);
  1182. //this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 800);
  1183. //this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 800);
  1184. //this.groupBox_report.Location = new System.Drawing.Point(974, 800);
  1185. }
  1186. ///// <summary>
  1187. ///// 是否显示网格
  1188. ///// </summary>
  1189. ///// <param name="sender"></param>
  1190. ///// <param name="e"></param>
  1191. //private void checkBox4_CheckedChanged(object sender, EventArgs e)
  1192. //{
  1193. // this.documentWorkspace.Refresh();
  1194. //}
  1195. ///// <summary>
  1196. ///// 是否显示截点
  1197. ///// </summary>
  1198. ///// <param name="sender"></param>
  1199. ///// <param name="e"></param>
  1200. //private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
  1201. //{
  1202. // if (!this.checkBox4.Checked)
  1203. // MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
  1204. // this.documentWorkspace.Refresh();
  1205. //}
  1206. /// <summary>
  1207. /// 是否显示晶界
  1208. /// </summary>
  1209. /// <param name="sender"></param>
  1210. /// <param name="e"></param>
  1211. private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
  1212. {
  1213. if (this.documentWorkspace.PhaseModels.Count > 0)
  1214. {
  1215. if (!bcOriginChecked() && getGrainBoundryChecked() && checkBox3_0.Checked)
  1216. {
  1217. this.documentWorkspace.PhaseModels[1].choise = true;
  1218. }
  1219. else
  1220. {
  1221. this.documentWorkspace.PhaseModels[1].choise = false;
  1222. }
  1223. }
  1224. this.documentWorkspace.Refresh();
  1225. }
  1226. protected override void refreshWhileImgChanged()
  1227. {
  1228. object ShowGrainBoundry;
  1229. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
  1230. this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
  1231. //base.refreshWhileImgChanged();
  1232. if (getCurrentWorkspace() != null/* && this.listView1.FocusedItem.Selected*/)
  1233. this.unitLength = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  1234. rectangleFs.Clear();
  1235. ////二值化集成4
  1236. //binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  1237. rectangleFsArr = new RectangleF[] { };
  1238. rectangleFs.Clear();
  1239. pointFsLine = new PointF[] { };
  1240. this.dataGridView1.Rows.Clear();
  1241. selectLineIndex = -1;
  1242. rectangleFsLines.Clear();
  1243. }
  1244. protected override void onMouseUp(object sender, MouseEventArgs e)
  1245. {
  1246. //base.onMouseUp(sender, e);
  1247. canAdd = false;
  1248. canMove = false;
  1249. movePointIndex = -1;
  1250. RefrashData();
  1251. if (mouseStatus == 2)
  1252. SelectDataRow();
  1253. }
  1254. /// <summary>
  1255. /// 相颜色点击事件
  1256. /// </summary>
  1257. /// <param name="sender"></param>
  1258. /// <param name="e"></param>
  1259. private void panelC_Click(object sender, EventArgs e)
  1260. {
  1261. this.panelC = (Panel)sender;
  1262. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
  1263. this.colorsFormGrid.ShowDialog();
  1264. }
  1265. /// <summary>
  1266. /// PanelC的调色板颜色改变
  1267. /// </summary>
  1268. /// <param name="sender"></param>
  1269. /// <param name="e"></param>
  1270. private void gridColorChanged(object sender, EventArgs e)
  1271. {
  1272. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  1273. //更改背景色,触发事件
  1274. this.panelC.BackColor = color;
  1275. this.documentWorkspace.Refresh();
  1276. //关闭色板
  1277. this.colorsFormGrid.Close();
  1278. }
  1279. private void SelectDataRow()
  1280. {
  1281. if (this.dataGridView1.Rows.Count > selectLineIndex && selectLineIndex >= 0)
  1282. this.dataGridView1.Rows[selectLineIndex].Selected = true;
  1283. if (dataGridView1.SelectedRows.Count > 0)
  1284. selectLineIndex = dataGridView1.SelectedRows[0].Index;
  1285. }
  1286. /// <summary>
  1287. /// 刷新数据展示
  1288. /// </summary>
  1289. private void RefrashData()
  1290. {
  1291. canChange = true;
  1292. if (this.rectangleFs.Count == 0)
  1293. return;
  1294. this.dataGridView1.Rows.Clear();
  1295. int count = 0;
  1296. double lengthMax = 0;
  1297. double lengthMin = 0;
  1298. if (rectangleFs.Count > 0)
  1299. {
  1300. foreach (var item in rectangleFs)
  1301. {
  1302. lengthMin = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
  1303. break;
  1304. }
  1305. }
  1306. foreach (var item in rectangleFs)
  1307. {
  1308. count++;
  1309. DataGridViewRow dgvr = new DataGridViewRow();
  1310. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  1311. {
  1312. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1313. }
  1314. double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
  1315. dgvr.Cells[0].Value = ""/*"L"*/ + count;
  1316. if (length < lengthMin)
  1317. lengthMin = length;
  1318. if (length > lengthMax)
  1319. lengthMax = length;
  1320. dgvr.Cells[1].Value = this.DecnumString(length.ToString());// Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value));
  1321. this.dataGridView1.Rows.Add(dgvr);
  1322. }
  1323. labelMax.Text = this.DecnumString(lengthMax.ToString());
  1324. labelMin.Text = this.DecnumString(lengthMin.ToString());
  1325. labelNum.Text = rectangleFs.Count.ToString();
  1326. dataTable = new DataTable();
  1327. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  1328. {
  1329. dataTable.Columns.Add(Column.HeaderText);
  1330. }
  1331. count = 0;
  1332. foreach (var item in rectangleFs)
  1333. {
  1334. count++;
  1335. DataRow dataRow = dataTable.NewRow();
  1336. double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new System.Drawing.Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength;
  1337. dataRow[0] = ""/*"L"*/ + count;
  1338. dataRow[1] = length;
  1339. this.dataTable.Rows.Add(dataRow);
  1340. }
  1341. double allLength = 0;
  1342. for (int i = 0; i < dataTable.Rows.Count; i++)
  1343. {
  1344. allLength += Convert.ToDouble(dataTable.Rows[i][1]);
  1345. }
  1346. DataGridViewRow dgvr1 = new DataGridViewRow();
  1347. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  1348. {
  1349. dgvr1.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1350. }
  1351. dgvr1.Cells[0].Value = PdnResources.GetString("Menu.Image.Average.Text");
  1352. dgvr1.Cells[1].Value = this.DecnumString(allLength / this.dataTable.Rows.Count + "");// Math.Round(allLength / this.dataTable.Rows.Count, Convert.ToInt32(this.numericUpDown1.Value));
  1353. this.dataGridView1.Rows.Add(dgvr1);
  1354. canChange = false;
  1355. if (this.dataGridView1.DisplayedRowCount(false) == this.dataGridView1.RowCount)//#####################
  1356. {
  1357. //没有
  1358. this.dataGridViewTextBoxColumn10.Width = 242;
  1359. }
  1360. else
  1361. {
  1362. //有
  1363. this.dataGridViewTextBoxColumn10.Width = 227;
  1364. }
  1365. }
  1366. PointF point1;
  1367. protected override void onMouseMove(object sender, MouseEventArgs e)
  1368. {
  1369. base.onMouseMove(sender, e);
  1370. // 换算后的点
  1371. this.point1 = documentWorkspace.GetScalePoint(e.Location);
  1372. // 全方位线
  1373. if (lineStyle == 0)
  1374. {
  1375. if (mouseStatus == 0 && canAdd)
  1376. {
  1377. rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
  1378. PointF startPoint = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + 6);
  1379. PointF endPoint = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + 6);
  1380. //计算需要旋转的角度
  1381. double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
  1382. double sAngle1 = 270 + angle;
  1383. double eAngle1 = 90 + angle;
  1384. System.Drawing.Point point3 = new System.Drawing.Point();
  1385. System.Drawing.Point point4 = new System.Drawing.Point();
  1386. System.Drawing.Point point5 = new System.Drawing.Point();
  1387. System.Drawing.Point point6 = new System.Drawing.Point();
  1388. if (sAngle1 is double.NaN && eAngle1 is double.NaN)
  1389. {
  1390. }
  1391. else
  1392. {
  1393. point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
  1394. point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
  1395. point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
  1396. point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
  1397. }
  1398. pointFsLine[0] = point3;
  1399. pointFsLine[1] = point4;
  1400. pointFsLine[2] = point6;
  1401. pointFsLine[3] = point5;
  1402. }
  1403. }
  1404. // 水平线
  1405. else if (lineStyle == 1)
  1406. {
  1407. if (mouseStatus == 0 && canAdd)
  1408. {
  1409. rectangleFsArr[1] = new RectangleF(point1.X - 6, rectangleFsArr[0].Y, 12, 12);
  1410. pointFsLine[0] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
  1411. pointFsLine[1] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
  1412. pointFsLine[3] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
  1413. pointFsLine[2] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
  1414. }
  1415. }
  1416. // 垂直线
  1417. else if (lineStyle == 2)
  1418. {
  1419. if (mouseStatus == 0 && canAdd)
  1420. {
  1421. rectangleFsArr[1] = new RectangleF(rectangleFsArr[0].X, point1.Y - 6, 12, 12);
  1422. pointFsLine[0] = new PointF(rectangleFsArr[0].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, rectangleFsArr[0].Y + 6);
  1423. pointFsLine[1] = new PointF(rectangleFsArr[0].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, rectangleFsArr[0].Y + 6);
  1424. pointFsLine[3] = new PointF(rectangleFsArr[1].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, rectangleFsArr[1].Y + 6);
  1425. pointFsLine[2] = new PointF(rectangleFsArr[1].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, rectangleFsArr[1].Y + 6);
  1426. }
  1427. }
  1428. if (this.mouseStatus == 2 && canMove)
  1429. {
  1430. if (this.selectLineIndex != -1)
  1431. {
  1432. int indexRectangleFs = -1;
  1433. foreach (var item in rectangleFs)
  1434. {
  1435. indexRectangleFs++;
  1436. if (selectLineIndex == indexRectangleFs)
  1437. {
  1438. // 全方位线
  1439. if (item.Value == 0)
  1440. {
  1441. // 线条起始点移动
  1442. if (movePointIndex == 0)
  1443. {
  1444. item.Key[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
  1445. }
  1446. else if (movePointIndex == 1)
  1447. {
  1448. item.Key[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
  1449. }
  1450. else if (movePointIndex == 2)
  1451. {
  1452. item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1453. item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1454. movePointStart = point1;
  1455. }
  1456. PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
  1457. PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
  1458. //计算需要旋转的角度
  1459. double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
  1460. double sAngle1 = 270 + angle;
  1461. double eAngle1 = 90 + angle;
  1462. System.Drawing.Point point3 = new System.Drawing.Point();
  1463. System.Drawing.Point point4 = new System.Drawing.Point();
  1464. System.Drawing.Point point5 = new System.Drawing.Point();
  1465. System.Drawing.Point point6 = new System.Drawing.Point();
  1466. if (sAngle1 is double.NaN && eAngle1 is double.NaN)
  1467. {
  1468. }
  1469. else
  1470. {
  1471. point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
  1472. point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
  1473. point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
  1474. point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
  1475. }
  1476. int indexRectangleFsLines = -1;
  1477. foreach (var item1 in rectangleFsLines)
  1478. {
  1479. indexRectangleFsLines++;
  1480. if (indexRectangleFsLines == indexRectangleFs)
  1481. {
  1482. item1.Key[0] = point3;
  1483. item1.Key[1] = point4;
  1484. item1.Key[2] = point6;
  1485. item1.Key[3] = point5;
  1486. }
  1487. }
  1488. }
  1489. // 水平线
  1490. else if (item.Value == 1)
  1491. {
  1492. // 线条起始点移动
  1493. if (movePointIndex == 0)
  1494. {
  1495. item.Key[0] = new RectangleF(point1.X - 6, item.Key[1].Y, 12, 12);
  1496. }
  1497. else if (movePointIndex == 1)
  1498. {
  1499. item.Key[1] = new RectangleF(point1.X - 6, item.Key[0].Y, 12, 12);
  1500. }
  1501. else if (movePointIndex == 2)
  1502. {
  1503. item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1504. item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1505. movePointStart = point1;
  1506. }
  1507. int selectIndex = -1;
  1508. foreach (var item1 in rectangleFsLines)
  1509. {
  1510. selectIndex++;
  1511. if (selectIndex == selectLineIndex)
  1512. {
  1513. item1.Key[0] = new PointF(item.Key[0].X + 6, item.Key[0].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
  1514. item1.Key[1] = new PointF(item.Key[0].X + 6, item.Key[0].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
  1515. item1.Key[3] = new PointF(item.Key[1].X + 6, item.Key[1].Y/* + (float)(this.numericUpDown3.Value / 2)*/ + 9);
  1516. item1.Key[2] = new PointF(item.Key[1].X + 6, item.Key[1].Y/* - (float)(this.numericUpDown3.Value / 2)*/ + 3);
  1517. }
  1518. }
  1519. }
  1520. // 垂直线
  1521. else if (item.Value == 2)
  1522. {
  1523. // 线条起始点移动
  1524. if (movePointIndex == 0)
  1525. {
  1526. item.Key[0] = new RectangleF(item.Key[1].X, point1.Y - 6, 12, 12);
  1527. }
  1528. else if (movePointIndex == 1)
  1529. {
  1530. item.Key[1] = new RectangleF(item.Key[0].X, point1.Y - 6, 12, 12);
  1531. }
  1532. else if (movePointIndex == 2)
  1533. {
  1534. item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1535. item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y);
  1536. movePointStart = point1;
  1537. }
  1538. int selectIndex = -1;
  1539. foreach (var item1 in rectangleFsLines)
  1540. {
  1541. selectIndex++;
  1542. if (selectIndex == selectLineIndex)
  1543. {
  1544. item1.Key[0] = new PointF(item.Key[0].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, item.Key[0].Y + 6);
  1545. item1.Key[1] = new PointF(item.Key[0].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, item.Key[0].Y + 6);
  1546. item1.Key[3] = new PointF(item.Key[1].X/* + (float)(this.numericUpDown3.Value / 2)*/ + 9, item.Key[1].Y + 6);
  1547. item1.Key[2] = new PointF(item.Key[1].X/* - (float)(this.numericUpDown3.Value / 2)*/ + 3, item.Key[1].Y + 6);
  1548. }
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. }
  1555. this.documentWorkspace.Refresh();
  1556. }
  1557. protected override void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
  1558. {
  1559. //base.drawSubclass(graphics);
  1560. Pen linePen = new Pen(this.panel2.BackColor, Convert.ToInt32(this.numericUpDown3.Value));
  1561. Pen linePen1 = new Pen(this.panel1.BackColor, Convert.ToInt32(this.numericUpDown3.Value));
  1562. //linePen.CustomStartCap = lineCap;
  1563. //linePen.CustomEndCap = lineCap;
  1564. int drawIndex = -1;
  1565. foreach (var item in rectangleFs)
  1566. {
  1567. drawIndex++;
  1568. if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
  1569. {
  1570. linePen.DashStyle = DashStyle.DashDot;
  1571. }
  1572. else
  1573. linePen.DashStyle = DashStyle.Solid;
  1574. graphics.DrawLine(linePen, new PointF(item.Key[0].X + 6, item.Key[0].Y + 6), new PointF(item.Key[1].X + 6, item.Key[1].Y + 6));
  1575. PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6);
  1576. PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6);
  1577. double length = BasicCalculationHelper.GetDistance(new System.Drawing.Point(Convert.ToInt32(startPoint.X) + 6, Convert.ToInt32(startPoint.Y) + 6), new System.Drawing.Point(Convert.ToInt32(endPoint.X) + 6, Convert.ToInt32(endPoint.Y) + 6), getNumericUpDown1Value()) * unitLength;
  1578. //计算需要旋转的角度
  1579. double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y));
  1580. if (item.Value == 0)
  1581. {
  1582. //
  1583. // 绘制两侧竖线
  1584. //
  1585. double sAngle1 = 270 + angle;
  1586. double eAngle1 = 90 + angle;
  1587. System.Drawing.Point point3 = new System.Drawing.Point();
  1588. System.Drawing.Point point4 = new System.Drawing.Point();
  1589. System.Drawing.Point point5 = new System.Drawing.Point();
  1590. System.Drawing.Point point6 = new System.Drawing.Point();
  1591. if (sAngle1 is double.NaN && eAngle1 is double.NaN)
  1592. {
  1593. }
  1594. else
  1595. {
  1596. point3 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1);
  1597. point4 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(startPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(startPoint.Y)), new System.Drawing.Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1);
  1598. point5 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1);
  1599. point6 = BasicCalculationHelper.GetAnglePoint(new System.Drawing.Point((Convert.ToInt32(endPoint.X)/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/), Convert.ToInt32(endPoint.Y)), new System.Drawing.Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1);
  1600. }
  1601. graphics.DrawLine(linePen1, point3, point4);
  1602. graphics.DrawLine(linePen1, point5, point6);
  1603. SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
  1604. PointF cen1 = new PointF((point3.X + point5.X) / 2, (point3.Y + point5.Y) / 2);
  1605. PointF cen2 = new PointF((point4.X + point6.X) / 2, (point4.Y + point6.Y) / 2);
  1606. PointF drawP1 = new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2);
  1607. PointF drawP2 = new PointF(cen2.X - sizeF.Width / 2, cen2.Y - sizeF.Height / 2);
  1608. PointF drawP3;
  1609. if (angle < 90)
  1610. drawP3 = drawP1;
  1611. else
  1612. drawP3 = drawP2;
  1613. Matrix mtxSave = graphics.Transform;
  1614. Matrix matrix = graphics.Transform;
  1615. // 画布旋转
  1616. if (angle < 90)
  1617. {
  1618. matrix.RotateAt((float)angle, new PointF(cen1.X, cen1.Y));
  1619. graphics.Transform = matrix;
  1620. }
  1621. else
  1622. {
  1623. angle = BasicCalculationHelper.Angle(endPoint, startPoint, new PointF(endPoint.X, startPoint.Y));
  1624. matrix.RotateAt((float)angle, new PointF(cen2.X, cen2.Y));
  1625. graphics.Transform = matrix;
  1626. }
  1627. graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(this.panel1.BackColor/*Color.Black*/), drawP3);
  1628. //还原为原始旋转矩阵
  1629. graphics.Transform = mtxSave;
  1630. matrix.Dispose();
  1631. }
  1632. else if (item.Value == 1)
  1633. {
  1634. graphics.DrawLine(linePen1, new PointF(startPoint.X, startPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/)
  1635. , new PointF(startPoint.X, startPoint.Y/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/));
  1636. graphics.DrawLine(linePen1, new PointF(endPoint.X, endPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/)
  1637. , new PointF(endPoint.X, endPoint.Y/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/));
  1638. SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
  1639. PointF cen1 = new PointF((startPoint.X + endPoint.X) / 2, startPoint.Y/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/);
  1640. graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
  1641. }
  1642. else if (item.Value == 2)
  1643. {
  1644. graphics.DrawLine(linePen1, new PointF(startPoint.X/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/, startPoint.Y)
  1645. , new PointF(startPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, startPoint.Y));
  1646. graphics.DrawLine(linePen1, new PointF(endPoint.X/* - Convert.ToInt32(this.numericUpDown2.Value / 2)*/, endPoint.Y)
  1647. , new PointF(endPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, endPoint.Y));
  1648. SizeF sizeF = graphics.MeasureString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)));
  1649. PointF cen1 = new PointF(startPoint.X/* + Convert.ToInt32(this.numericUpDown2.Value / 2)*/, (startPoint.Y + endPoint.Y) / 2);
  1650. Matrix mtxSave = graphics.Transform;
  1651. Matrix matrix = graphics.Transform;
  1652. matrix.RotateAt((float)90, new PointF(cen1.X, cen1.Y));
  1653. graphics.Transform = matrix;
  1654. graphics.DrawString(Math.Round(length, getNumericUpDown1Value()) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2));
  1655. //还原为原始旋转矩阵
  1656. graphics.Transform = mtxSave;
  1657. matrix.Dispose();
  1658. }
  1659. if (selectLineIndex != -1 && drawIndex == this.selectLineIndex)
  1660. {
  1661. graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[0]);
  1662. graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[1]);
  1663. }
  1664. }
  1665. System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
  1666. Region myRegion;
  1667. int selectIndex = -1;
  1668. foreach (var item in rectangleFsLines)
  1669. {
  1670. selectIndex++;
  1671. myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
  1672. myRegion = new Region();
  1673. myGraphicsPath.Reset();
  1674. myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
  1675. myRegion.MakeEmpty();
  1676. myRegion.Union(myGraphicsPath);
  1677. //graphics.FillRegion(new SolidBrush(Color.Black), myRegion);
  1678. }
  1679. linePen.Dispose();
  1680. linePen1.Dispose();
  1681. }
  1682. /// <summary>
  1683. /// 鼠标按下
  1684. /// </summary>
  1685. /// <param name="drawArea"></param>
  1686. /// <param name="e"></param>
  1687. protected override void OnMouseDown(object sender, MouseEventArgs e)
  1688. {
  1689. if (this.documentWorkspace.CompositionSurface == null)
  1690. return;
  1691. //// 换算后的点
  1692. //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  1693. //if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  1694. // && point1.X >= 0
  1695. // && point1.Y >= 0
  1696. // && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  1697. //{
  1698. // RectangleF rectangleF;
  1699. // // 复合辅助线
  1700. // int add = GSSClass.GuideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
  1701. // if (add == 0 && GSSClass.styleClass.PointKb > 0)
  1702. // rectangleF = GSSClass.GuideClass.RectangleFLine;
  1703. // //手动添加截点
  1704. // if (this.documentWorkspace.ActiveTool == Annotation.Enum.DrawToolType.InclusionNoEffect && GSSClass.styleClass.OnMouseDownNext(point1, sender, e))
  1705. // GSSClass.styleClass.OnMouseDownFirst(point1, rectangleF, GSSClass.linePointList, e);
  1706. //}
  1707. //if (GSSClass.styleClass.PointKb == 0)
  1708. //{
  1709. // //辅助线缩放
  1710. // GSSClass.GuideClass.OnMouseDown(point1, sender, e);
  1711. // //辅助线移动
  1712. // base.OnMouseDown(sender, e);//##
  1713. //}
  1714. if (e.Button == MouseButtons.Left)
  1715. {
  1716. // 换算后的点
  1717. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  1718. selectLineIndex = -1;
  1719. if (mouseStatus == 0)
  1720. {
  1721. canAdd = true;
  1722. rectangleFsArr = new RectangleF[2];
  1723. pointFsLine = new PointF[4];
  1724. rectangleFsArr[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
  1725. rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12);
  1726. Dictionary<RectangleF[], int> rectangleFs1 = new Dictionary<RectangleF[], int>();
  1727. foreach (var item in rectangleFs)
  1728. {
  1729. rectangleFs1.Add(item.Key, item.Value);
  1730. }
  1731. rectangleFs = new Dictionary<RectangleF[], int>();
  1732. rectangleFs = rectangleFs1;
  1733. if (lineStyle == 0)
  1734. rectangleFs.Add(rectangleFsArr, 0);
  1735. else if (lineStyle == 1)
  1736. rectangleFs.Add(rectangleFsArr, 1);
  1737. else if (lineStyle == 2)
  1738. rectangleFs.Add(rectangleFsArr, 2);
  1739. if (lineStyle == 0)
  1740. rectangleFsLines.Add(pointFsLine, 0);
  1741. else if (lineStyle == 1)
  1742. rectangleFsLines.Add(pointFsLine, 1);
  1743. else if (lineStyle == 2)
  1744. rectangleFsLines.Add(pointFsLine, 2);
  1745. }
  1746. if (mouseStatus == 2)
  1747. {
  1748. System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
  1749. Region myRegion;
  1750. int selectIndex = -1;
  1751. foreach (var item in rectangleFsLines)
  1752. {
  1753. selectIndex++;
  1754. myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
  1755. myRegion = new Region();
  1756. myGraphicsPath.Reset();
  1757. myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] });
  1758. myRegion.MakeEmpty();
  1759. myRegion.Union(myGraphicsPath);
  1760. //返回判断点是否在多边形里
  1761. //RectangleF rectangleF = myRegion.GetBounds(rag)
  1762. bool myPoint = myRegion.IsVisible(point1);
  1763. if (myPoint)
  1764. {
  1765. selectLineIndex = selectIndex;
  1766. break;
  1767. }
  1768. }
  1769. if (selectLineIndex == -1)
  1770. {
  1771. selectIndex = -1;
  1772. foreach (var item in rectangleFs)
  1773. {
  1774. selectIndex++;
  1775. if (item.Key[0].Contains(point1))
  1776. {
  1777. selectLineIndex = selectIndex;
  1778. break;
  1779. }
  1780. else if (item.Key[1].Contains(point1))
  1781. {
  1782. selectLineIndex = selectIndex;
  1783. break;
  1784. }
  1785. }
  1786. }
  1787. //else
  1788. // {
  1789. // if(this.dataGridView1.Rows.Count > selectLineIndex)
  1790. // this.dataGridView1.Rows[selectLineIndex].Selected = true;
  1791. //}
  1792. }
  1793. if (mouseStatus == 2)
  1794. {
  1795. int indexRectangleFs = -1;
  1796. foreach (var item in rectangleFs)
  1797. {
  1798. indexRectangleFs++;
  1799. System.Drawing.Drawing2D.GraphicsPath myGraphicsPath;
  1800. Region myRegion;
  1801. int indexRectangleFsLines = -1;
  1802. bool myPoint = false;
  1803. foreach (var item1 in rectangleFsLines)
  1804. {
  1805. indexRectangleFsLines++;
  1806. if (indexRectangleFs == indexRectangleFsLines)
  1807. {
  1808. myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
  1809. myRegion = new Region();
  1810. myGraphicsPath.Reset();
  1811. myGraphicsPath.AddPolygon(new PointF[] { item1.Key[0], item1.Key[1], item1.Key[2], item1.Key[3] });
  1812. myRegion.MakeEmpty();
  1813. myRegion.Union(myGraphicsPath);
  1814. //返回判断点是否在多边形里
  1815. myPoint = myRegion.IsVisible(point1);
  1816. if (myPoint)
  1817. {
  1818. break;
  1819. }
  1820. }
  1821. }
  1822. if (item.Key[0].Contains(point1))
  1823. {
  1824. movePointStart = point1;
  1825. movePointIndex = 0;
  1826. canMove = true;
  1827. }
  1828. else if (item.Key[1].Contains(point1))
  1829. {
  1830. movePointStart = point1;
  1831. movePointIndex = 1;
  1832. canMove = true;
  1833. }
  1834. else if (myPoint)
  1835. {
  1836. movePointStart = point1;
  1837. movePointIndex = 2;
  1838. canMove = true;
  1839. }
  1840. }
  1841. }
  1842. }
  1843. }
  1844. private void AllShow()
  1845. {
  1846. this.dataGridView2.Rows.Clear();
  1847. for (int i = 0; i < this.dataTables.Count; i++)
  1848. {
  1849. DataGridViewRow dgvr = new DataGridViewRow();
  1850. dgvr.Tag = this.dataTables[i].TableName;
  1851. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  1852. {
  1853. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1854. }
  1855. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  1856. {
  1857. //if (c > 2 && c < 4)
  1858. // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
  1859. //else
  1860. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  1861. }
  1862. this.dataGridView2.Rows.Add(dgvr);
  1863. }
  1864. }
  1865. private void button6_0_Click(object sender, EventArgs e)
  1866. {
  1867. if (this.matOrg != null)
  1868. {
  1869. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  1870. GSSClass.styleClass.PointKb = 1;
  1871. }
  1872. else
  1873. {
  1874. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1875. }
  1876. }
  1877. private void button7_0_LostFocus(object sender, EventArgs e)
  1878. {
  1879. this.mouseStatus = -1;
  1880. }
  1881. /// <summary>
  1882. /// 添加测量线
  1883. /// </summary>
  1884. /// <param name="sender"></param>
  1885. /// <param name="e"></param>
  1886. private void button7_0_Click(object sender, EventArgs e)
  1887. {
  1888. if (this.matOrg != null)
  1889. {
  1890. this.mouseStatus = 0;
  1891. this.selectLineIndex = -1;
  1892. }
  1893. else
  1894. {
  1895. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1896. }
  1897. }
  1898. private void button8_Click(object sender, EventArgs e)
  1899. {
  1900. if (this.matOrg != null)
  1901. {
  1902. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  1903. GSSClass.styleClass.PointKb = 3;
  1904. }
  1905. else
  1906. {
  1907. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1908. }
  1909. }
  1910. /// <summary>
  1911. /// 选择截距
  1912. /// </summary>
  1913. /// <param name="sender"></param>
  1914. /// <param name="e"></param>
  1915. private void button2_Click(object sender, EventArgs e)
  1916. {
  1917. this.mouseStatus = 2;
  1918. this.selectLineIndex = -1;
  1919. }
  1920. /// <summary>
  1921. /// 删除截距
  1922. /// </summary>
  1923. /// <param name="sender"></param>
  1924. /// <param name="e"></param>
  1925. private void button10_Click(object sender, EventArgs e)
  1926. {
  1927. this.mouseStatus = 1;
  1928. if (this.mouseStatus == 1)
  1929. {
  1930. if (selectLineIndex == -1)
  1931. {
  1932. MessageBox.Show("请先选择要删除的测量线!");
  1933. return;
  1934. }
  1935. int deleteIndex = -1;
  1936. foreach (var item in rectangleFs)
  1937. {
  1938. deleteIndex++;
  1939. if (deleteIndex == selectLineIndex)
  1940. {
  1941. rectangleFs.Remove(item.Key);
  1942. break;
  1943. }
  1944. }
  1945. deleteIndex = -1;
  1946. foreach (var item in rectangleFsLines)
  1947. {
  1948. deleteIndex++;
  1949. if (deleteIndex == selectLineIndex)
  1950. {
  1951. rectangleFsLines.Remove(item.Key);
  1952. break;
  1953. }
  1954. }
  1955. selectLineIndex--;
  1956. if (selectLineIndex < -1)
  1957. selectLineIndex = -1;
  1958. if (rectangleFs.Count == 0)
  1959. this.dataGridView1.Rows.Clear();
  1960. RefrashData();
  1961. if (mouseStatus == 2)
  1962. SelectDataRow();
  1963. this.documentWorkspace.Refresh();
  1964. }
  1965. }
  1966. private void dataGridView1_SelectionChanged(object sender, EventArgs e)
  1967. {
  1968. //canChange = true;
  1969. if (!canChange)
  1970. {
  1971. SelectDataRow();
  1972. this.documentWorkspace.Refresh();
  1973. }
  1974. }
  1975. /// <summary>
  1976. /// 获取参数
  1977. /// </summary>
  1978. protected override object saveRecordingData(string key)
  1979. {
  1980. object value = null;
  1981. switch (key)
  1982. {
  1983. case "MainFontSize":
  1984. value = numericUpDown4.Value;
  1985. break;
  1986. case "MainFontColor":
  1987. value = panel1.BackColor.ToArgb();
  1988. break;
  1989. case "MainLineWidth":
  1990. value = numericUpDown3.Value;
  1991. break;
  1992. case "MainLineColor":
  1993. value = panel2.BackColor.ToArgb();
  1994. break;
  1995. }
  1996. return value;
  1997. }
  1998. }
  1999. }