ArtworkSettingEditDialog.cs 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using OpenCvSharp;
  13. using OpenCvSharp.Extensions;
  14. using PaintDotNet.Annotation;
  15. using PaintDotNet.Annotation.Enum;
  16. using PaintDotNet.Base;
  17. using PaintDotNet.Base.CommTool;
  18. using PaintDotNet.Base.Functionodel;
  19. using PaintDotNet.Base.SettingModel;
  20. using PaintDotNet.CustomControl;
  21. using PaintDotNet.Data.Param;
  22. using PaintDotNet.GeneralAnalysis.Artwork;
  23. using PaintDotNet.Processing;
  24. using static PaintDotNet.GeneralAnalysis.Artwork.ImageTools;
  25. namespace PaintDotNet.GeneralAnalysis
  26. {
  27. internal class ArtworkSettingEditDialog : PdnBaseForm
  28. {
  29. #region
  30. /// <summary>
  31. /// Required designer variable.
  32. /// </summary>
  33. private System.ComponentModel.IContainer components = null;
  34. /// <summary>
  35. /// Clean up any resources being used.
  36. /// </summary>
  37. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  38. protected override void Dispose(bool disposing)
  39. {
  40. if (disposing && (components != null))
  41. {
  42. components.Dispose();
  43. }
  44. base.Dispose(disposing);
  45. }
  46. #region Windows Form Designer generated code
  47. private void InitializeLanguageText()
  48. {
  49. this.Text = PdnResources.GetString("Menu.Setting.Text");
  50. this.label5.Text = PdnResources.GetString("Menu.Thecoordinateofthecenterpoin.Text") + ":";
  51. this.label4.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Xcoordinateofcenterpoint.text") + ":";
  52. this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Position.text") + "2";
  53. this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
  54. this.label8.Text = PdnResources.GetString("Menu.Thecoordinateofthecenterpoin.Text") + ":";
  55. this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Xcoordinateofcenterpoint.text") + ":";
  56. this.groupBox6.Text = PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text");
  57. this.chkScrapIsDel.Text = PdnResources.GetString("Menu.Clasticdelete.text") + ":";
  58. this.label12.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
  59. this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Extractionrange.text") + ":";
  60. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  61. this.btnSave.Text = PdnResources.GetString("Menu.imagecapture.timelapse.SaveSettings.text");
  62. this.btnFromDisk.Text = PdnResources.GetString("Menu.harddisk.text");
  63. this.btnFromGallery.Text = PdnResources.GetString("Menu.Gallery.text");
  64. this.label1.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Processdrawingname.text") + ":";
  65. this.groupBox2.Text = PdnResources.GetString("Menu.Previewpicture.Text");
  66. this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Definetheshape.text");
  67. this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  68. this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Sidelength.text") + ":";
  69. this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Processmparison.Position.text") + "1";
  70. this.label6.Text = PdnResources.GetString("Menu.color.text") + ":";
  71. }
  72. /// <summary>
  73. /// Required method for Designer support - do not modify
  74. /// the contents of this method with the code editor.
  75. /// </summary>
  76. private void InitializeComponent()
  77. {
  78. this.groupBox1 = new System.Windows.Forms.GroupBox();
  79. this.btnSave = new System.Windows.Forms.Button();
  80. this.btnFromDisk = new System.Windows.Forms.Button();
  81. this.btnFromGallery = new System.Windows.Forms.Button();
  82. this.txtName = new System.Windows.Forms.TextBox();
  83. this.label1 = new System.Windows.Forms.Label();
  84. this.groupBox2 = new System.Windows.Forms.GroupBox();
  85. this.pnlTools = new System.Windows.Forms.Panel();
  86. this.panel4 = new System.Windows.Forms.Panel();
  87. this.groupBox3 = new System.Windows.Forms.GroupBox();
  88. this.nudLineWidth = new System.Windows.Forms.NumericUpDown();
  89. this.nudSide = new System.Windows.Forms.NumericUpDown();
  90. this.label3 = new System.Windows.Forms.Label();
  91. this.label2 = new System.Windows.Forms.Label();
  92. this.groupBox4 = new System.Windows.Forms.GroupBox();
  93. this.nudPoint1Y = new System.Windows.Forms.NumericUpDown();
  94. this.nudPoint1X = new System.Windows.Forms.NumericUpDown();
  95. this.panel1 = new System.Windows.Forms.Panel();
  96. this.label6 = new System.Windows.Forms.Label();
  97. this.label5 = new System.Windows.Forms.Label();
  98. this.label4 = new System.Windows.Forms.Label();
  99. this.groupBox5 = new System.Windows.Forms.GroupBox();
  100. this.nudPoint2Y = new System.Windows.Forms.NumericUpDown();
  101. this.nudPoint2X = new System.Windows.Forms.NumericUpDown();
  102. this.panel2 = new System.Windows.Forms.Panel();
  103. this.label7 = new System.Windows.Forms.Label();
  104. this.label8 = new System.Windows.Forms.Label();
  105. this.label9 = new System.Windows.Forms.Label();
  106. this.groupBox6 = new System.Windows.Forms.GroupBox();
  107. this.panel3 = new System.Windows.Forms.Panel();
  108. this.label13 = new System.Windows.Forms.Label();
  109. this.nudScrapMax = new System.Windows.Forms.NumericUpDown();
  110. this.nudScrapMin = new System.Windows.Forms.NumericUpDown();
  111. this.chkScrapIsDel = new System.Windows.Forms.CheckBox();
  112. this.label12 = new System.Windows.Forms.Label();
  113. this.label11 = new System.Windows.Forms.Label();
  114. this.nudTowValueMax = new System.Windows.Forms.NumericUpDown();
  115. this.nudTowValueMin = new System.Windows.Forms.NumericUpDown();
  116. this.label10 = new System.Windows.Forms.Label();
  117. this.groupBox1.SuspendLayout();
  118. this.groupBox2.SuspendLayout();
  119. this.groupBox3.SuspendLayout();
  120. ((System.ComponentModel.ISupportInitialize)(this.nudLineWidth)).BeginInit();
  121. ((System.ComponentModel.ISupportInitialize)(this.nudSide)).BeginInit();
  122. this.groupBox4.SuspendLayout();
  123. ((System.ComponentModel.ISupportInitialize)(this.nudPoint1Y)).BeginInit();
  124. ((System.ComponentModel.ISupportInitialize)(this.nudPoint1X)).BeginInit();
  125. this.groupBox5.SuspendLayout();
  126. ((System.ComponentModel.ISupportInitialize)(this.nudPoint2Y)).BeginInit();
  127. ((System.ComponentModel.ISupportInitialize)(this.nudPoint2X)).BeginInit();
  128. this.groupBox6.SuspendLayout();
  129. ((System.ComponentModel.ISupportInitialize)(this.nudScrapMax)).BeginInit();
  130. ((System.ComponentModel.ISupportInitialize)(this.nudScrapMin)).BeginInit();
  131. ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMax)).BeginInit();
  132. ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMin)).BeginInit();
  133. this.SuspendLayout();
  134. //
  135. // groupBox1
  136. //
  137. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  138. | System.Windows.Forms.AnchorStyles.Right)));
  139. this.groupBox1.Controls.Add(this.btnSave);
  140. this.groupBox1.Controls.Add(this.btnFromDisk);
  141. this.groupBox1.Controls.Add(this.btnFromGallery);
  142. this.groupBox1.Controls.Add(this.txtName);
  143. this.groupBox1.Controls.Add(this.label1);
  144. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  145. this.groupBox1.Name = "groupBox1";
  146. this.groupBox1.Size = new System.Drawing.Size(1018, 90);
  147. this.groupBox1.TabIndex = 0;
  148. this.groupBox1.TabStop = false;
  149. this.groupBox1.Text = "操作";
  150. //
  151. // btnSave
  152. //
  153. this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  154. this.btnSave.Location = new System.Drawing.Point(900, 33);
  155. this.btnSave.Name = "btnSave";
  156. this.btnSave.Size = new System.Drawing.Size(91, 31);
  157. this.btnSave.TabIndex = 4;
  158. this.btnSave.Text = "保存设置";
  159. this.btnSave.UseVisualStyleBackColor = true;
  160. this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
  161. //
  162. // btnFromDisk
  163. //
  164. this.btnFromDisk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  165. this.btnFromDisk.Location = new System.Drawing.Point(794, 33);
  166. this.btnFromDisk.Name = "btnFromDisk";
  167. this.btnFromDisk.Size = new System.Drawing.Size(75, 31);
  168. this.btnFromDisk.TabIndex = 3;
  169. this.btnFromDisk.Text = "硬盘";
  170. this.btnFromDisk.UseVisualStyleBackColor = true;
  171. this.btnFromDisk.Click += new System.EventHandler(this.btnFromDisk_Click);
  172. //
  173. // btnFromGallery
  174. //
  175. this.btnFromGallery.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  176. this.btnFromGallery.Location = new System.Drawing.Point(688, 33);
  177. this.btnFromGallery.Name = "btnFromGallery";
  178. this.btnFromGallery.Size = new System.Drawing.Size(75, 31);
  179. this.btnFromGallery.TabIndex = 2;
  180. this.btnFromGallery.Text = "图库";
  181. this.btnFromGallery.UseVisualStyleBackColor = true;
  182. this.btnFromGallery.Click += new System.EventHandler(this.btnFromGallery_Click);
  183. //
  184. // txtName
  185. //
  186. this.txtName.Location = new System.Drawing.Point(141, 37);
  187. this.txtName.Name = "txtName";
  188. this.txtName.Size = new System.Drawing.Size(218, 21);
  189. this.txtName.TabIndex = 1;
  190. //
  191. // label1
  192. //
  193. this.label1.AutoSize = true;
  194. this.label1.Location = new System.Drawing.Point(38, 44);
  195. this.label1.Name = "label1";
  196. this.label1.Size = new System.Drawing.Size(77, 12);
  197. this.label1.TabIndex = 0;
  198. this.label1.Text = "工艺图名称:";
  199. //
  200. // groupBox2
  201. //
  202. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  203. | System.Windows.Forms.AnchorStyles.Left)
  204. | System.Windows.Forms.AnchorStyles.Right)));
  205. this.groupBox2.Controls.Add(this.pnlTools);
  206. this.groupBox2.Controls.Add(this.panel4);
  207. this.groupBox2.Location = new System.Drawing.Point(12, 119);
  208. this.groupBox2.Name = "groupBox2";
  209. this.groupBox2.Size = new System.Drawing.Size(1018, 502);
  210. this.groupBox2.TabIndex = 1;
  211. this.groupBox2.TabStop = false;
  212. this.groupBox2.Text = "图片预览";
  213. //
  214. // pnlTools
  215. //
  216. this.pnlTools.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
  217. this.pnlTools.BackColor = System.Drawing.SystemColors.Control;
  218. this.pnlTools.Location = new System.Drawing.Point(433, 460);
  219. this.pnlTools.Name = "pnlTools";
  220. this.pnlTools.Size = new System.Drawing.Size(169, 36);
  221. this.pnlTools.TabIndex = 1;
  222. //
  223. // panel4
  224. //
  225. this.panel4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  226. | System.Windows.Forms.AnchorStyles.Left)
  227. | System.Windows.Forms.AnchorStyles.Right)));
  228. this.panel4.Location = new System.Drawing.Point(17, 24);
  229. this.panel4.Name = "panel4";
  230. this.panel4.Size = new System.Drawing.Size(984, 430);
  231. this.panel4.TabIndex = 0;
  232. //
  233. // groupBox3
  234. //
  235. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  236. this.groupBox3.Controls.Add(this.nudLineWidth);
  237. this.groupBox3.Controls.Add(this.nudSide);
  238. this.groupBox3.Controls.Add(this.label3);
  239. this.groupBox3.Controls.Add(this.label2);
  240. this.groupBox3.Location = new System.Drawing.Point(12, 636);
  241. this.groupBox3.Name = "groupBox3";
  242. this.groupBox3.Size = new System.Drawing.Size(191, 137);
  243. this.groupBox3.TabIndex = 2;
  244. this.groupBox3.TabStop = false;
  245. this.groupBox3.Text = "定义外形";
  246. //
  247. // nudLineWidth
  248. //
  249. this.nudLineWidth.Location = new System.Drawing.Point(76, 61);
  250. this.nudLineWidth.Maximum = new decimal(new int[] {
  251. 20,
  252. 0,
  253. 0,
  254. 0});
  255. this.nudLineWidth.Minimum = new decimal(new int[] {
  256. 1,
  257. 0,
  258. 0,
  259. 0});
  260. this.nudLineWidth.Name = "nudLineWidth";
  261. this.nudLineWidth.Size = new System.Drawing.Size(74, 21);
  262. this.nudLineWidth.TabIndex = 5;
  263. this.nudLineWidth.Value = new decimal(new int[] {
  264. 1,
  265. 0,
  266. 0,
  267. 0});
  268. this.nudLineWidth.ValueChanged += new System.EventHandler(this.nudLineWidth_ValueChanged);
  269. this.nudLineWidth.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudLineWidth_KeyUp);
  270. //
  271. // nudSide
  272. //
  273. this.nudSide.Location = new System.Drawing.Point(76, 28);
  274. this.nudSide.Minimum = new decimal(new int[] {
  275. 10,
  276. 0,
  277. 0,
  278. 0});
  279. this.nudSide.Name = "nudSide";
  280. this.nudSide.Size = new System.Drawing.Size(74, 21);
  281. this.nudSide.TabIndex = 3;
  282. this.nudSide.Value = new decimal(new int[] {
  283. 20,
  284. 0,
  285. 0,
  286. 0});
  287. this.nudSide.ValueChanged += new System.EventHandler(this.nudSide_ValueChanged);
  288. this.nudSide.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudSide_KeyUp);
  289. //
  290. // label3
  291. //
  292. this.label3.AutoSize = true;
  293. this.label3.Location = new System.Drawing.Point(18, 66);
  294. this.label3.Name = "label3";
  295. this.label3.Size = new System.Drawing.Size(41, 12);
  296. this.label3.TabIndex = 4;
  297. this.label3.Text = "线宽:";
  298. //
  299. // label2
  300. //
  301. this.label2.AutoSize = true;
  302. this.label2.Location = new System.Drawing.Point(18, 30);
  303. this.label2.Name = "label2";
  304. this.label2.Size = new System.Drawing.Size(41, 12);
  305. this.label2.TabIndex = 3;
  306. this.label2.Text = "边长:";
  307. //
  308. // groupBox4
  309. //
  310. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  311. this.groupBox4.Controls.Add(this.nudPoint1Y);
  312. this.groupBox4.Controls.Add(this.nudPoint1X);
  313. this.groupBox4.Controls.Add(this.panel1);
  314. this.groupBox4.Controls.Add(this.label6);
  315. this.groupBox4.Controls.Add(this.label5);
  316. this.groupBox4.Controls.Add(this.label4);
  317. this.groupBox4.Location = new System.Drawing.Point(220, 636);
  318. this.groupBox4.Name = "groupBox4";
  319. this.groupBox4.Size = new System.Drawing.Size(216, 137);
  320. this.groupBox4.TabIndex = 3;
  321. this.groupBox4.TabStop = false;
  322. this.groupBox4.Text = "定位1";
  323. //
  324. // nudPoint1Y
  325. //
  326. this.nudPoint1Y.Location = new System.Drawing.Point(123, 59);
  327. this.nudPoint1Y.Maximum = new decimal(new int[] {
  328. 99999999,
  329. 0,
  330. 0,
  331. 0});
  332. this.nudPoint1Y.Name = "nudPoint1Y";
  333. this.nudPoint1Y.Size = new System.Drawing.Size(78, 21);
  334. this.nudPoint1Y.TabIndex = 11;
  335. this.nudPoint1Y.ValueChanged += new System.EventHandler(this.nudPoint1Y_ValueChanged);
  336. this.nudPoint1Y.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint1Y_KeyUp);
  337. //
  338. // nudPoint1X
  339. //
  340. this.nudPoint1X.Location = new System.Drawing.Point(123, 24);
  341. this.nudPoint1X.Maximum = new decimal(new int[] {
  342. 999999999,
  343. 0,
  344. 0,
  345. 0});
  346. this.nudPoint1X.Name = "nudPoint1X";
  347. this.nudPoint1X.Size = new System.Drawing.Size(78, 21);
  348. this.nudPoint1X.TabIndex = 10;
  349. this.nudPoint1X.ValueChanged += new System.EventHandler(this.nudPoint1X_ValueChanged);
  350. this.nudPoint1X.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint1X_KeyUp);
  351. //
  352. // panel1
  353. //
  354. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  355. this.panel1.Location = new System.Drawing.Point(82, 95);
  356. this.panel1.Name = "panel1";
  357. this.panel1.Size = new System.Drawing.Size(105, 26);
  358. this.panel1.TabIndex = 9;
  359. this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged);
  360. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  361. //
  362. // label6
  363. //
  364. this.label6.AutoSize = true;
  365. this.label6.Location = new System.Drawing.Point(22, 99);
  366. this.label6.Name = "label6";
  367. this.label6.Size = new System.Drawing.Size(41, 12);
  368. this.label6.TabIndex = 8;
  369. this.label6.Text = "颜色:";
  370. //
  371. // label5
  372. //
  373. this.label5.AutoSize = true;
  374. this.label5.Location = new System.Drawing.Point(22, 64);
  375. this.label5.Name = "label5";
  376. this.label5.Size = new System.Drawing.Size(83, 12);
  377. this.label5.TabIndex = 6;
  378. this.label5.Text = "中心点Y坐标:";
  379. //
  380. // label4
  381. //
  382. this.label4.AutoSize = true;
  383. this.label4.Location = new System.Drawing.Point(22, 29);
  384. this.label4.Name = "label4";
  385. this.label4.Size = new System.Drawing.Size(83, 12);
  386. this.label4.TabIndex = 4;
  387. this.label4.Text = "中心点X坐标:";
  388. //
  389. // groupBox5
  390. //
  391. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
  392. this.groupBox5.Controls.Add(this.nudPoint2Y);
  393. this.groupBox5.Controls.Add(this.nudPoint2X);
  394. this.groupBox5.Controls.Add(this.panel2);
  395. this.groupBox5.Controls.Add(this.label7);
  396. this.groupBox5.Controls.Add(this.label8);
  397. this.groupBox5.Controls.Add(this.label9);
  398. this.groupBox5.Location = new System.Drawing.Point(458, 636);
  399. this.groupBox5.Name = "groupBox5";
  400. this.groupBox5.Size = new System.Drawing.Size(216, 137);
  401. this.groupBox5.TabIndex = 4;
  402. this.groupBox5.TabStop = false;
  403. this.groupBox5.Text = "定位2";
  404. //
  405. // nudPoint2Y
  406. //
  407. this.nudPoint2Y.Location = new System.Drawing.Point(132, 57);
  408. this.nudPoint2Y.Maximum = new decimal(new int[] {
  409. 99999999,
  410. 0,
  411. 0,
  412. 0});
  413. this.nudPoint2Y.Name = "nudPoint2Y";
  414. this.nudPoint2Y.Size = new System.Drawing.Size(78, 21);
  415. this.nudPoint2Y.TabIndex = 17;
  416. this.nudPoint2Y.ValueChanged += new System.EventHandler(this.nudPoint2Y_ValueChanged);
  417. this.nudPoint2Y.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint2Y_KeyUp);
  418. //
  419. // nudPoint2X
  420. //
  421. this.nudPoint2X.Location = new System.Drawing.Point(132, 23);
  422. this.nudPoint2X.Maximum = new decimal(new int[] {
  423. 99999999,
  424. 0,
  425. 0,
  426. 0});
  427. this.nudPoint2X.Name = "nudPoint2X";
  428. this.nudPoint2X.Size = new System.Drawing.Size(78, 21);
  429. this.nudPoint2X.TabIndex = 16;
  430. this.nudPoint2X.ValueChanged += new System.EventHandler(this.nudPoint2X_ValueChanged);
  431. this.nudPoint2X.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudPoint2X_KeyUp);
  432. //
  433. // panel2
  434. //
  435. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  436. this.panel2.Location = new System.Drawing.Point(86, 93);
  437. this.panel2.Name = "panel2";
  438. this.panel2.Size = new System.Drawing.Size(105, 26);
  439. this.panel2.TabIndex = 15;
  440. this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged);
  441. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  442. //
  443. // label7
  444. //
  445. this.label7.AutoSize = true;
  446. this.label7.Location = new System.Drawing.Point(26, 99);
  447. this.label7.Name = "label7";
  448. this.label7.Size = new System.Drawing.Size(41, 12);
  449. this.label7.TabIndex = 14;
  450. this.label7.Text = "颜色:";
  451. //
  452. // label8
  453. //
  454. this.label8.AutoSize = true;
  455. this.label8.Location = new System.Drawing.Point(26, 62);
  456. this.label8.Name = "label8";
  457. this.label8.Size = new System.Drawing.Size(83, 12);
  458. this.label8.TabIndex = 12;
  459. this.label8.Text = "中心点Y坐标:";
  460. //
  461. // label9
  462. //
  463. this.label9.AutoSize = true;
  464. this.label9.Location = new System.Drawing.Point(26, 27);
  465. this.label9.Name = "label9";
  466. this.label9.Size = new System.Drawing.Size(83, 12);
  467. this.label9.TabIndex = 10;
  468. this.label9.Text = "中心点X坐标:";
  469. //
  470. // groupBox6
  471. //
  472. this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  473. | System.Windows.Forms.AnchorStyles.Right)));
  474. this.groupBox6.Controls.Add(this.panel3);
  475. this.groupBox6.Controls.Add(this.label13);
  476. this.groupBox6.Controls.Add(this.nudScrapMax);
  477. this.groupBox6.Controls.Add(this.nudScrapMin);
  478. this.groupBox6.Controls.Add(this.chkScrapIsDel);
  479. this.groupBox6.Controls.Add(this.label12);
  480. this.groupBox6.Controls.Add(this.label11);
  481. this.groupBox6.Controls.Add(this.nudTowValueMax);
  482. this.groupBox6.Controls.Add(this.nudTowValueMin);
  483. this.groupBox6.Controls.Add(this.label10);
  484. this.groupBox6.Location = new System.Drawing.Point(691, 636);
  485. this.groupBox6.Name = "groupBox6";
  486. this.groupBox6.Size = new System.Drawing.Size(339, 137);
  487. this.groupBox6.TabIndex = 5;
  488. this.groupBox6.TabStop = false;
  489. this.groupBox6.Text = "二值提取";
  490. //
  491. // panel3
  492. //
  493. this.panel3.BackColor = System.Drawing.Color.Red;
  494. this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  495. this.panel3.Location = new System.Drawing.Point(136, 57);
  496. this.panel3.Name = "panel3";
  497. this.panel3.Size = new System.Drawing.Size(105, 26);
  498. this.panel3.TabIndex = 16;
  499. this.panel3.BackColorChanged += new System.EventHandler(this.panel3_BackColorChanged);
  500. this.panel3.Click += new System.EventHandler(this.panel3_Click);
  501. //
  502. // label13
  503. //
  504. this.label13.AutoSize = true;
  505. this.label13.Location = new System.Drawing.Point(223, 101);
  506. this.label13.Name = "label13";
  507. this.label13.Size = new System.Drawing.Size(11, 12);
  508. this.label13.TabIndex = 13;
  509. this.label13.Text = "~";
  510. //
  511. // nudScrapMax
  512. //
  513. this.nudScrapMax.Location = new System.Drawing.Point(252, 91);
  514. this.nudScrapMax.Maximum = new decimal(new int[] {
  515. 9999,
  516. 0,
  517. 0,
  518. 0});
  519. this.nudScrapMax.Name = "nudScrapMax";
  520. this.nudScrapMax.Size = new System.Drawing.Size(74, 21);
  521. this.nudScrapMax.TabIndex = 12;
  522. this.nudScrapMax.ValueChanged += new System.EventHandler(this.nudScrapMax_ValueChanged);
  523. this.nudScrapMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudScrapMax_KeyUp);
  524. //
  525. // nudScrapMin
  526. //
  527. this.nudScrapMin.Location = new System.Drawing.Point(136, 91);
  528. this.nudScrapMin.Maximum = new decimal(new int[] {
  529. 9999,
  530. 0,
  531. 0,
  532. 0});
  533. this.nudScrapMin.Name = "nudScrapMin";
  534. this.nudScrapMin.Size = new System.Drawing.Size(74, 21);
  535. this.nudScrapMin.TabIndex = 11;
  536. this.nudScrapMin.ValueChanged += new System.EventHandler(this.nudScrapMin_ValueChanged);
  537. this.nudScrapMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudScrapMin_KeyUp);
  538. //
  539. // chkScrapIsDel
  540. //
  541. this.chkScrapIsDel.AutoSize = true;
  542. this.chkScrapIsDel.Location = new System.Drawing.Point(26, 98);
  543. this.chkScrapIsDel.Name = "chkScrapIsDel";
  544. this.chkScrapIsDel.Size = new System.Drawing.Size(72, 16);
  545. this.chkScrapIsDel.TabIndex = 10;
  546. this.chkScrapIsDel.Text = "碎屑删除";
  547. this.chkScrapIsDel.UseVisualStyleBackColor = true;
  548. this.chkScrapIsDel.CheckedChanged += new System.EventHandler(this.chkScrapIsDel_CheckedChanged);
  549. //
  550. // label12
  551. //
  552. this.label12.AutoSize = true;
  553. this.label12.Location = new System.Drawing.Point(23, 61);
  554. this.label12.Name = "label12";
  555. this.label12.Size = new System.Drawing.Size(53, 12);
  556. this.label12.TabIndex = 9;
  557. this.label12.Text = "相颜色:";
  558. //
  559. // label11
  560. //
  561. this.label11.AutoSize = true;
  562. this.label11.Location = new System.Drawing.Point(223, 34);
  563. this.label11.Name = "label11";
  564. this.label11.Size = new System.Drawing.Size(11, 12);
  565. this.label11.TabIndex = 8;
  566. this.label11.Text = "~";
  567. //
  568. // nudTowValueMax
  569. //
  570. this.nudTowValueMax.Location = new System.Drawing.Point(252, 24);
  571. this.nudTowValueMax.Maximum = new decimal(new int[] {
  572. 255,
  573. 0,
  574. 0,
  575. 0});
  576. this.nudTowValueMax.Name = "nudTowValueMax";
  577. this.nudTowValueMax.Size = new System.Drawing.Size(74, 21);
  578. this.nudTowValueMax.TabIndex = 7;
  579. this.nudTowValueMax.ValueChanged += new System.EventHandler(this.nudTowValue_ValueChanged);
  580. this.nudTowValueMax.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudTowValueMax_KeyUp);
  581. //
  582. // nudTowValueMin
  583. //
  584. this.nudTowValueMin.Location = new System.Drawing.Point(136, 26);
  585. this.nudTowValueMin.Maximum = new decimal(new int[] {
  586. 255,
  587. 0,
  588. 0,
  589. 0});
  590. this.nudTowValueMin.Name = "nudTowValueMin";
  591. this.nudTowValueMin.Size = new System.Drawing.Size(74, 21);
  592. this.nudTowValueMin.TabIndex = 6;
  593. this.nudTowValueMin.ValueChanged += new System.EventHandler(this.nudTowValue_ValueChanged);
  594. this.nudTowValueMin.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudTowValueMin_KeyUp);
  595. //
  596. // label10
  597. //
  598. this.label10.AutoSize = true;
  599. this.label10.Location = new System.Drawing.Point(23, 30);
  600. this.label10.Name = "label10";
  601. this.label10.Size = new System.Drawing.Size(65, 12);
  602. this.label10.TabIndex = 0;
  603. this.label10.Text = "提取范围:";
  604. //
  605. // ArtworkSettingEditDialog
  606. //
  607. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  608. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  609. this.ClientSize = new System.Drawing.Size(1042, 785);
  610. this.Controls.Add(this.groupBox6);
  611. this.Controls.Add(this.groupBox5);
  612. this.Controls.Add(this.groupBox4);
  613. this.Controls.Add(this.groupBox3);
  614. this.Controls.Add(this.groupBox2);
  615. this.Controls.Add(this.groupBox1);
  616. this.Name = "ArtworkSettingEditDialog";
  617. this.Text = "工艺图设定";
  618. this.Resize += new System.EventHandler(this.ArtworkSettingEditDialog_Resize);
  619. this.Controls.SetChildIndex(this.groupBox1, 0);
  620. this.Controls.SetChildIndex(this.groupBox2, 0);
  621. this.Controls.SetChildIndex(this.groupBox3, 0);
  622. this.Controls.SetChildIndex(this.groupBox4, 0);
  623. this.Controls.SetChildIndex(this.groupBox5, 0);
  624. this.Controls.SetChildIndex(this.groupBox6, 0);
  625. this.groupBox1.ResumeLayout(false);
  626. this.groupBox1.PerformLayout();
  627. this.groupBox2.ResumeLayout(false);
  628. this.groupBox3.ResumeLayout(false);
  629. this.groupBox3.PerformLayout();
  630. ((System.ComponentModel.ISupportInitialize)(this.nudLineWidth)).EndInit();
  631. ((System.ComponentModel.ISupportInitialize)(this.nudSide)).EndInit();
  632. this.groupBox4.ResumeLayout(false);
  633. this.groupBox4.PerformLayout();
  634. ((System.ComponentModel.ISupportInitialize)(this.nudPoint1Y)).EndInit();
  635. ((System.ComponentModel.ISupportInitialize)(this.nudPoint1X)).EndInit();
  636. this.groupBox5.ResumeLayout(false);
  637. this.groupBox5.PerformLayout();
  638. ((System.ComponentModel.ISupportInitialize)(this.nudPoint2Y)).EndInit();
  639. ((System.ComponentModel.ISupportInitialize)(this.nudPoint2X)).EndInit();
  640. this.groupBox6.ResumeLayout(false);
  641. this.groupBox6.PerformLayout();
  642. ((System.ComponentModel.ISupportInitialize)(this.nudScrapMax)).EndInit();
  643. ((System.ComponentModel.ISupportInitialize)(this.nudScrapMin)).EndInit();
  644. ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMax)).EndInit();
  645. ((System.ComponentModel.ISupportInitialize)(this.nudTowValueMin)).EndInit();
  646. this.ResumeLayout(false);
  647. }
  648. #endregion
  649. private System.Windows.Forms.GroupBox groupBox1;
  650. private System.Windows.Forms.Button btnSave;
  651. private System.Windows.Forms.Button btnFromDisk;
  652. private System.Windows.Forms.Button btnFromGallery;
  653. private System.Windows.Forms.TextBox txtName;
  654. private System.Windows.Forms.Label label1;
  655. private System.Windows.Forms.GroupBox groupBox2;
  656. private System.Windows.Forms.GroupBox groupBox3;
  657. private System.Windows.Forms.NumericUpDown nudLineWidth;
  658. private System.Windows.Forms.NumericUpDown nudSide;
  659. private System.Windows.Forms.Label label3;
  660. private System.Windows.Forms.Label label2;
  661. private System.Windows.Forms.GroupBox groupBox4;
  662. private System.Windows.Forms.Label label5;
  663. private System.Windows.Forms.Label label4;
  664. private System.Windows.Forms.GroupBox groupBox5;
  665. private System.Windows.Forms.GroupBox groupBox6;
  666. private System.Windows.Forms.Panel panel1;
  667. private System.Windows.Forms.Label label6;
  668. private System.Windows.Forms.Panel panel2;
  669. private System.Windows.Forms.Label label7;
  670. private System.Windows.Forms.Label label8;
  671. private System.Windows.Forms.Label label9;
  672. private System.Windows.Forms.Label label11;
  673. private System.Windows.Forms.NumericUpDown nudTowValueMax;
  674. private System.Windows.Forms.NumericUpDown nudTowValueMin;
  675. private System.Windows.Forms.Label label10;
  676. private System.Windows.Forms.Label label13;
  677. private System.Windows.Forms.NumericUpDown nudScrapMax;
  678. private System.Windows.Forms.NumericUpDown nudScrapMin;
  679. private System.Windows.Forms.CheckBox chkScrapIsDel;
  680. private System.Windows.Forms.Label label12;
  681. private System.Windows.Forms.Panel panel3;
  682. private System.Windows.Forms.Panel panel4;
  683. private System.Windows.Forms.NumericUpDown nudPoint1Y;
  684. private System.Windows.Forms.NumericUpDown nudPoint1X;
  685. private System.Windows.Forms.NumericUpDown nudPoint2Y;
  686. private System.Windows.Forms.NumericUpDown nudPoint2X;
  687. private System.Windows.Forms.Panel pnlTools;
  688. #endregion
  689. private ArtworkModel m_artworkModel;
  690. private List<ArtworkModel.Item> m_artworkLists = new List<ArtworkModel.Item>();
  691. private ArtworkModel.Item m_artwork;
  692. /// <summary>
  693. /// 网格调色板
  694. /// </summary>
  695. PaintDotNet.ColorsForm colorsFormGrid;
  696. /// <summary>
  697. /// 图片选择窗口
  698. /// </summary>
  699. private InterImagePickerDialog imagePickerDialog;
  700. private string m_filePath = Application.StartupPath + "\\Artwork\\";
  701. private int m_index;
  702. private AppWorkspace m_appWorkspace;
  703. private DocumentWorkspaceWindow m_documentWorkspace;
  704. private ArtworkControlButtons m_controlButtons;
  705. private int m_width;
  706. private int m_height;
  707. private Bitmap m_bitmap;
  708. private string m_picName;
  709. private string m_originalPicName;
  710. private string m_thumbnailName;
  711. private object m_currentSender;
  712. private Form m_parentForm;
  713. /// <summary>
  714. /// 单位标尺
  715. /// </summary>
  716. private double unitLength = 1;
  717. /// <summary>
  718. /// 二值图像
  719. /// </summary>
  720. private Mat m_mat;
  721. /// <summary>
  722. /// 处理程序
  723. /// </summary>
  724. private ParamObject action = new Data.Action.Action901();
  725. /// <summary>
  726. /// 初始系统参数配置值
  727. /// </summary>
  728. private BinaryExtractionModel binaryExtractionModel;
  729. private int m_angle = 0;
  730. public ArtworkSettingEditDialog(Form form, AppWorkspace workspace, int index)
  731. {
  732. m_parentForm = form;
  733. m_appWorkspace = workspace;
  734. m_index = index;
  735. if (!Directory.Exists(m_filePath))
  736. {
  737. Directory.CreateDirectory(m_filePath);//不存在就创建目录
  738. }
  739. this.binaryExtractionModel = XmlSerializeHelper.DESerializer<BinaryExtractionModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryExtraction\\Default.xml", FileMode.Open));
  740. InitializeComponent();
  741. InitializeLanguageText();
  742. InitializeData();
  743. this.colorsFormGrid = new ColorsForm();
  744. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  745. InitializeTools();
  746. }
  747. private void InitializeData()
  748. {
  749. this.m_documentWorkspace = new DocumentWorkspaceWindow(m_appWorkspace);
  750. this.m_documentWorkspace.AppWorkspaceTop = m_appWorkspace;
  751. this.m_documentWorkspace.Visible = true;
  752. this.m_documentWorkspace.Dock = DockStyle.Fill;
  753. this.panel4.Controls.Add(this.m_documentWorkspace);
  754. //
  755. //初始化相
  756. //
  757. PhaseModel model = new PhaseModel();
  758. model.choise = true;
  759. model.mat = null;
  760. model.color = panel3.BackColor.ToArgb();
  761. model.position = this.m_documentWorkspace.PhaseModels.Count + 1;
  762. model.name = PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text");
  763. this.m_documentWorkspace.PhaseModels.Add(model);
  764. this.m_documentWorkspace.GraphicsList = new GraphicsList(this.m_documentWorkspace);
  765. this.m_documentWorkspace.GraphicsList.SelectChanged += GraphicsList_SelectChanged;
  766. m_artworkModel = Startup.instance.artworkModel;
  767. m_artworkLists = m_artworkModel.items;
  768. if (m_index == -1)
  769. {
  770. m_artwork = new ArtworkModel.Item();
  771. //m_bitmap = new Bitmap(100, 100);
  772. m_picName = System.Guid.NewGuid().ToString("N") + ".Png";
  773. m_thumbnailName = System.Guid.NewGuid().ToString("N") + ".Png";
  774. m_originalPicName = System.Guid.NewGuid().ToString("N") + ".Png";
  775. panel3.BackColor = Color.Blue;
  776. }
  777. else
  778. {
  779. m_artwork = m_artworkLists[m_index];
  780. if (System.IO.File.Exists(m_filePath + m_artwork.originalPic))
  781. {
  782. Image bitmap1 = Image.FromFile(m_filePath + m_artwork.originalPic);
  783. m_bitmap = new Bitmap(bitmap1);
  784. bitmap1.Dispose();
  785. }
  786. else
  787. {
  788. m_bitmap = new Bitmap(100, 100);
  789. }
  790. this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
  791. m_picName = m_artwork.pic;
  792. m_thumbnailName = m_artwork.thumbnail;
  793. m_originalPicName = m_artwork.originalPic;
  794. txtName.Text = m_artwork.artworkName;
  795. nudSide.Value = m_artwork.side;
  796. nudLineWidth.Value = m_artwork.lineWidth;
  797. nudPoint1X.Value = m_artwork.point1X;
  798. nudPoint1Y.Value = m_artwork.point1Y;
  799. panel1.BackColor = ColorTranslator.FromHtml(m_artwork.point1Color);
  800. nudPoint2X.Value = m_artwork.point2X;
  801. nudPoint2Y.Value = m_artwork.point2Y;
  802. panel2.BackColor = ColorTranslator.FromHtml(m_artwork.point2Color);
  803. nudTowValueMin.Value = m_artwork.twoValueGetMin;
  804. nudTowValueMax.Value = m_artwork.twoValueGetMax;
  805. panel3.BackColor = ColorTranslator.FromHtml(m_artwork.twoValueColor);
  806. chkScrapIsDel.Checked = m_artwork.scrapIsDel;
  807. nudScrapMin.Value = m_artwork.scrapMin;
  808. nudScrapMax.Value = m_artwork.scrapMax;
  809. }
  810. //先修改参数
  811. foreach (Args args in action.Lists)
  812. {
  813. switch (args.Key)
  814. {
  815. case "phaseColor":
  816. args.Value = panel3.BackColor.ToArgb();
  817. break;
  818. case "debrisRemoval":
  819. args.Value = chkScrapIsDel.Checked;
  820. break;
  821. case "scope1":
  822. ((List<double>)args.Value)[0] = (int)nudTowValueMin.Value;
  823. ((List<double>)args.Value)[1] = (int)nudTowValueMax.Value;
  824. break;
  825. case "scope4":
  826. ((List<double>)args.Value)[0] = (double)nudScrapMin.Value;
  827. ((List<double>)args.Value)[1] = (double)nudScrapMax.Value;
  828. break;
  829. }
  830. }
  831. this.binaryExtractionModel.DebrisRemoval = chkScrapIsDel.Checked;
  832. this.binaryExtractionModel.DebrisAreaStart = (int)nudScrapMin.Value;
  833. this.binaryExtractionModel.DebrisAreaEnd = (int)nudScrapMax.Value;
  834. this.binaryExtractionModel.ColorOneStart = (int)nudTowValueMin.Value;
  835. this.binaryExtractionModel.ColorOneEnd = (int)nudTowValueMax.Value;
  836. this.binaryExtractionModel.PhaseColor = panel3.BackColor.ToArgb();
  837. }
  838. private void GraphicsList_SelectChanged(object sender, EventArgs e)
  839. {
  840. GraphicsList graphicsList = (GraphicsList)sender;
  841. if (graphicsList.Count < 2)
  842. {
  843. return;
  844. }
  845. for (int i = 0; i < graphicsList.Count; i++)
  846. {
  847. RectangleF rectangle = graphicsList[i].GetBoundingBox();
  848. if (((DrawObject)graphicsList[i]).ID == 0)
  849. {
  850. nudPoint1X.Value = (int)rectangle.X + nudSide.Value / 2;
  851. nudPoint1Y.Value = (int)rectangle.Y + nudSide.Value / 2;
  852. }
  853. else
  854. {
  855. nudPoint2X.Value = (int)rectangle.X + nudSide.Value / 2;
  856. nudPoint2Y.Value = (int)rectangle.Y + nudSide.Value / 2;
  857. }
  858. }
  859. }
  860. private void InitializeTools()
  861. {
  862. this.m_controlButtons = new ArtworkControlButtons();
  863. this.m_controlButtons.Dock = DockStyle.Top;
  864. this.m_controlButtons.Height = 30;
  865. this.m_controlButtons.HideMovingDirection();
  866. this.m_controlButtons.turnLeftButton.Visible = true;
  867. this.m_controlButtons.turnRightButton.Visible = true;
  868. this.pnlTools.Controls.Add(m_controlButtons);
  869. this.m_controlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  870. this.m_controlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  871. this.m_controlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  872. this.m_controlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  873. this.m_controlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  874. this.m_controlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  875. this.m_controlButtons.turnLeftButton.Click += new EventHandler(turnLeftButton_Click);
  876. this.m_controlButtons.turnRightButton.Click += new EventHandler(turnRightButton_Click);
  877. //
  878. //获取系统标尺-微米
  879. //
  880. this.m_appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  881. //this.m_appWorkspace.ActiveDocumentWorkspace.GetRuler(MeasurementUnit.Micron);
  882. }
  883. private void turnRightButton_Click(object sender, EventArgs e)
  884. {
  885. if (m_bitmap == null)
  886. {
  887. return;
  888. }
  889. m_angle += 1;
  890. if(m_angle == 4)
  891. {
  892. m_angle = 0;
  893. }
  894. m_bitmap.RotateFlip(RotateFlipType.Rotate90FlipNone);
  895. this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
  896. this.applyButtonImpl();
  897. }
  898. private void turnLeftButton_Click(object sender, EventArgs e)
  899. {
  900. if (m_bitmap == null)
  901. {
  902. return;
  903. }
  904. m_angle -= 1;
  905. if (m_angle == -4)
  906. {
  907. m_angle = 0;
  908. }
  909. m_bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
  910. this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
  911. this.applyButtonImpl();
  912. }
  913. private void mobileModeButton_Click(object sender, EventArgs e)
  914. {
  915. this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  916. }
  917. private void pointerButton_Click(object sender, EventArgs e)
  918. {
  919. this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  920. }
  921. private void zoomToWindowButton_Click(object sender, EventArgs e)
  922. {
  923. if (this.m_documentWorkspace.CompositionSurface != null)
  924. {
  925. this.m_documentWorkspace.ZoomToWindow();
  926. }
  927. }
  928. private void actualSizeButton_Click(object sender, EventArgs e)
  929. {
  930. if (this.m_documentWorkspace.CompositionSurface != null)
  931. {
  932. this.m_documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  933. this.m_documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  934. }
  935. }
  936. private void zoomOutButton_Click(object sender, EventArgs e)
  937. {
  938. if (this.m_documentWorkspace.CompositionSurface != null)
  939. this.m_documentWorkspace.ZoomOut();
  940. }
  941. private void zoomInButton_Click(object sender, EventArgs e)
  942. {
  943. if (this.m_documentWorkspace.CompositionSurface != null)
  944. this.m_documentWorkspace.ZoomIn();
  945. }
  946. private void MovePointReceived(int index, int x, int y)
  947. {
  948. if(index ==0)
  949. {
  950. this.Invoke(new Action(() =>
  951. {
  952. nudPoint1X.Value = x;
  953. nudPoint1Y.Value = y;
  954. }));
  955. }
  956. else
  957. {
  958. this.Invoke(new Action(() =>
  959. {
  960. nudPoint2X.Value = x;
  961. nudPoint2Y.Value = y;
  962. }));
  963. }
  964. }
  965. private void SetBitmap(Bitmap bitmap)
  966. {
  967. m_bitmap = bitmap;
  968. m_width = bitmap.Width;
  969. m_height = bitmap.Height;
  970. this.m_documentWorkspace.Document = Document.FromImage(m_bitmap);
  971. this.applyButtonImpl();
  972. // 新添加
  973. if (m_index == -1)
  974. {
  975. int side = Convert.ToInt32(nudSide.Value / 2);
  976. Random ran = new Random();
  977. nudPoint1X.Value = ran.Next(side, m_width - side);
  978. nudPoint1Y.Value = ran.Next(side, m_height - side);
  979. nudPoint2X.Value = ran.Next(side, m_width - side);
  980. nudPoint2Y.Value = ran.Next(side, m_height - side);
  981. panel1.BackColor = Color.Green;
  982. panel2.BackColor = Color.Red;
  983. }
  984. }
  985. private void btnFromDisk_Click(object sender, EventArgs e)
  986. {
  987. Bitmap newBit1 = ChooseImageFromHardDisk();//暂时接收一下,如果为空则不替换原有的原图对象
  988. if (newBit1 != null)
  989. {
  990. this.SetBitmap(newBit1);
  991. }
  992. }
  993. /// <summary>
  994. /// 从硬盘选择图片
  995. /// </summary>
  996. /// <returns></returns>
  997. private Bitmap ChooseImageFromHardDisk()
  998. {
  999. OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "*.jpg,*jpeg,*.bmp,*.ico,*.png,*.tif,*.wmf|*.jpg;*jpeg;*.bmp;*.ico;*.png;*.tif;*.wmf" };
  1000. DialogResult result = openFileDialog.ShowDialog();
  1001. if (result == DialogResult.OK)
  1002. {
  1003. Image image = Image.FromFile(openFileDialog.FileName);
  1004. Bitmap newBit = new Bitmap(image);
  1005. return newBit;
  1006. }
  1007. else
  1008. {
  1009. return null;
  1010. }
  1011. }
  1012. private void btnFromGallery_Click(object sender, EventArgs e)
  1013. {
  1014. ImagePickerDialog(sender);
  1015. }
  1016. /// <summary>
  1017. /// 弹出图库选择窗口
  1018. /// </summary>
  1019. /// <param name="sender"></param>
  1020. private void ImagePickerDialog(object sender)
  1021. {
  1022. if (imagePickerDialog == null)
  1023. {
  1024. imagePickerDialog = new InterImagePickerDialog(m_appWorkspace);
  1025. imagePickerDialog.StartPosition = FormStartPosition.Manual;
  1026. if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
  1027. {
  1028. imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
  1029. }
  1030. else
  1031. {
  1032. imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
  1033. }
  1034. imagePickerDialog.Top = ((Button)sender).Bottom + 50 ;
  1035. imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
  1036. imagePickerDialog.Show();
  1037. }
  1038. else
  1039. {
  1040. if (!imagePickerDialog.IsDisposed)
  1041. {
  1042. imagePickerDialog.WindowState = FormWindowState.Normal;
  1043. }
  1044. else
  1045. {
  1046. imagePickerDialog = new InterImagePickerDialog(m_appWorkspace);
  1047. imagePickerDialog.StartPosition = FormStartPosition.Manual;
  1048. if (this.Right >= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width - 150)
  1049. {
  1050. imagePickerDialog.Left = Screen.PrimaryScreen.Bounds.Width - 500;
  1051. }
  1052. else
  1053. {
  1054. imagePickerDialog.Left = ((Button)sender).Left + 12 + this.Left;
  1055. }
  1056. imagePickerDialog.Top = ((Button)sender).Bottom + 50;
  1057. imagePickerDialog.ValueChanged += new System.EventHandler(this.inputMat_ValueChanged);
  1058. imagePickerDialog.Show();
  1059. }
  1060. }
  1061. }
  1062. /// <summary>
  1063. /// 从图库选择待对照图片
  1064. /// </summary>
  1065. /// <param name="sender"></param>
  1066. /// <param name="e"></param>
  1067. private void inputMat_ValueChanged(object sender, EventArgs e)
  1068. {
  1069. if (sender is DocumentWorkspace)
  1070. {
  1071. Bitmap bitmap1 = ((DocumentWorkspace)sender).CompositionSurface.CreateAliasedBitmap();
  1072. if (bitmap1 != null)
  1073. {
  1074. this.SetBitmap(bitmap1);
  1075. }
  1076. }
  1077. }
  1078. private void ShowColorsForm(object sender)
  1079. {
  1080. Panel panel = (Panel)sender;
  1081. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(panel.BackColor);
  1082. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  1083. this.colorsFormGrid.ShowDialog();
  1084. }
  1085. /// <summary>
  1086. /// 网格Panel的调色板颜色改变
  1087. /// </summary>
  1088. /// <param name="sender"></param>
  1089. /// <param name="e"></param>
  1090. private void gridColorChanged(object sender, EventArgs e)
  1091. {
  1092. Panel panel = (Panel)m_currentSender;
  1093. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  1094. panel.BackColor = color;
  1095. this.colorsFormGrid.Close();
  1096. }
  1097. /// <summary>
  1098. /// 定位1颜色
  1099. /// </summary>
  1100. /// <param name="sender"></param>
  1101. /// <param name="e"></param>
  1102. private void panel1_Click(object sender, EventArgs e)
  1103. {
  1104. m_currentSender = sender;
  1105. ShowColorsForm(sender);
  1106. }
  1107. /// <summary>
  1108. /// 定位2颜色
  1109. /// </summary>
  1110. /// <param name="sender"></param>
  1111. /// <param name="e"></param>
  1112. private void panel2_Click(object sender, EventArgs e)
  1113. {
  1114. m_currentSender = sender;
  1115. ShowColorsForm(sender);
  1116. }
  1117. /// <summary>
  1118. /// 二值提取颜色
  1119. /// </summary>
  1120. /// <param name="sender"></param>
  1121. /// <param name="e"></param>
  1122. private void panel3_Click(object sender, EventArgs e)
  1123. {
  1124. m_currentSender = sender;
  1125. ShowColorsForm(sender);
  1126. }
  1127. private void DrawRectangle(int index, Color color, int lineWidth, int x, int y, int width, int height)
  1128. {
  1129. for(int i= 0; i< this.m_documentWorkspace.GraphicsList.Count; i++)
  1130. {
  1131. if(((DrawObject)this.m_documentWorkspace.GraphicsList[i]).ID == index)
  1132. {
  1133. this.m_documentWorkspace.GraphicsList.RemoveObj((DrawObject)this.m_documentWorkspace.GraphicsList[i]);
  1134. }
  1135. }
  1136. Rectangle rectangle1 = new Rectangle(x, y, width, height);
  1137. Pen pen = new Pen(color, lineWidth);
  1138. this.m_documentWorkspace.ActiveTool = DrawToolType.DrawArtworkRectangle;
  1139. this.m_documentWorkspace.CreateArtworkRectangle(index, pen, rectangle1);
  1140. }
  1141. private void DrawPoint1()
  1142. {
  1143. Color color = panel1.BackColor;
  1144. int lineWidth = Convert.ToInt32(nudLineWidth.Value);
  1145. int X = Convert.ToInt32(nudPoint1X.Value);
  1146. int Y = Convert.ToInt32(nudPoint1Y.Value);
  1147. int width = Convert.ToInt32(nudSide.Value);
  1148. int height = width;
  1149. int x = X - width / 2;
  1150. int y = Y - height / 2;
  1151. DrawRectangle(0, color, lineWidth, x, y, width, height);
  1152. }
  1153. private void DrawPoint2()
  1154. {
  1155. Color color = panel2.BackColor;
  1156. int lineWidth = Convert.ToInt32(nudLineWidth.Value);
  1157. int X = Convert.ToInt32(nudPoint2X.Value);
  1158. int Y = Convert.ToInt32(nudPoint2Y.Value);
  1159. int width = Convert.ToInt32(nudSide.Value);
  1160. int height = width;
  1161. int x = X - width / 2;
  1162. int y = Y - height / 2;
  1163. DrawRectangle(1, color, lineWidth, x, y, width, height);
  1164. }
  1165. private void panel1_BackColorChanged(object sender, EventArgs e)
  1166. {
  1167. DrawPoint1();
  1168. }
  1169. private void nudPoint1X_ValueChanged(object sender, EventArgs e)
  1170. {
  1171. if (m_width <= 0 || m_height <= 0)
  1172. {
  1173. return;
  1174. }
  1175. int X = Convert.ToInt32(nudPoint1X.Value);
  1176. int width = Convert.ToInt32(nudSide.Value);
  1177. if (X - width / 2 < 0)
  1178. {
  1179. nudPoint1X.Value = width / 2;
  1180. }
  1181. else if (X + width / 2 > m_width)
  1182. {
  1183. nudPoint1X.Value = (m_width - width / 2);
  1184. }
  1185. DrawPoint1();
  1186. }
  1187. private void nudPoint1Y_ValueChanged(object sender, EventArgs e)
  1188. {
  1189. if (m_width <= 0 || m_height <= 0)
  1190. {
  1191. return;
  1192. }
  1193. int Y = Convert.ToInt32(nudPoint1Y.Value);
  1194. int height = Convert.ToInt32(nudSide.Value);
  1195. if (Y - height / 2 < 0)
  1196. {
  1197. nudPoint1Y.Value = (height / 2);
  1198. }
  1199. else if (Y + height / 2 > m_height)
  1200. {
  1201. nudPoint1Y.Value = (m_height - height / 2);
  1202. }
  1203. DrawPoint1();
  1204. }
  1205. private void panel2_BackColorChanged(object sender, EventArgs e)
  1206. {
  1207. DrawPoint2();
  1208. }
  1209. private void nudLineWidth_ValueChanged(object sender, EventArgs e)
  1210. {
  1211. DrawPoint1();
  1212. DrawPoint2();
  1213. }
  1214. private void nudSide_ValueChanged(object sender, EventArgs e)
  1215. {
  1216. DrawPoint1();
  1217. DrawPoint2();
  1218. }
  1219. private void nudPoint2X_ValueChanged(object sender, EventArgs e)
  1220. {
  1221. if (m_width <= 0 || m_height <= 0)
  1222. {
  1223. return;
  1224. }
  1225. int X = Convert.ToInt32(nudPoint2X.Value);
  1226. int width = Convert.ToInt32(nudSide.Value);
  1227. if (X - width / 2 < 0)
  1228. {
  1229. nudPoint2X.Value = (width / 2);
  1230. }
  1231. else if (X + width / 2 > m_width)
  1232. {
  1233. nudPoint2X.Value = (m_width - width / 2);
  1234. }
  1235. DrawPoint2();
  1236. }
  1237. private void nudPoint2Y_ValueChanged(object sender, EventArgs e)
  1238. {
  1239. if (m_width <= 0 || m_height <= 0)
  1240. {
  1241. return;
  1242. }
  1243. int Y = Convert.ToInt32(nudPoint2Y.Value);
  1244. int height = Convert.ToInt32(nudSide.Value);
  1245. if (Y - height / 2 < 0)
  1246. {
  1247. nudPoint2Y.Value = (height / 2);
  1248. }
  1249. else if (Y + height / 2 > m_height)
  1250. {
  1251. nudPoint2Y.Value = (m_height - height / 2);
  1252. }
  1253. DrawPoint2();
  1254. }
  1255. private void btnSave_Click(object sender, EventArgs e)
  1256. {
  1257. string artworkName = txtName.Text.Trim();
  1258. if (string.IsNullOrEmpty(artworkName))
  1259. {
  1260. MessageBox.Show(PdnResources.GetString("Menu.Pleasefillisdrawing.text"));
  1261. return;
  1262. }
  1263. if (m_bitmap == null)
  1264. {
  1265. MessageBox.Show(PdnResources.GetString("Menu.Pleaseaddaprocessdrawing.text"));
  1266. return;
  1267. }
  1268. if (System.IO.File.Exists(m_filePath + m_picName))
  1269. {
  1270. System.IO.File.Delete(m_filePath + m_picName);
  1271. }
  1272. if (System.IO.File.Exists(m_filePath + m_thumbnailName))
  1273. {
  1274. System.IO.File.Delete(m_filePath + m_thumbnailName);
  1275. }
  1276. if (System.IO.File.Exists(m_filePath + m_originalPicName))
  1277. {
  1278. System.IO.File.Delete(m_filePath + m_originalPicName);
  1279. }
  1280. m_bitmap.Save(m_filePath + m_originalPicName, System.Drawing.Imaging.ImageFormat.Png);
  1281. m_artwork.originalPic = m_originalPicName;
  1282. if (m_mat != null)
  1283. {
  1284. // 二值图像
  1285. Bitmap image1 = BitmapConverter.ToBitmap(m_mat);
  1286. Bitmap[] bitmaps = new Bitmap[2];
  1287. bitmaps[0] = m_bitmap;
  1288. bitmaps[1] = image1;
  1289. m_bitmap = ImageTools.Overlap(bitmaps, m_bitmap.Width, m_bitmap.Height, OverlapType.TOPLEFT);
  1290. image1.Dispose();
  1291. }
  1292. m_bitmap.Save(m_filePath + m_picName, System.Drawing.Imaging.ImageFormat.Png);
  1293. m_artwork.pic = m_picName;
  1294. Surface surface = Surface.CopyFromBitmap(m_bitmap);
  1295. surface.CreateThumbnail();
  1296. Bitmap image = surface.Thumbnail;
  1297. image.Save(m_filePath + m_thumbnailName, System.Drawing.Imaging.ImageFormat.Png);
  1298. m_artwork.thumbnail = m_thumbnailName;
  1299. m_artwork.artworkName = artworkName;
  1300. m_artwork.side = Convert.ToInt32(nudSide.Value);
  1301. m_artwork.lineWidth = Convert.ToInt32(nudLineWidth.Value);
  1302. m_artwork.point1X = Convert.ToInt32(nudPoint1X.Value);
  1303. m_artwork.point1Y = Convert.ToInt32(nudPoint1Y.Value);
  1304. m_artwork.point1Color = ColorTranslator.ToHtml(panel1.BackColor);
  1305. m_artwork.point2X = Convert.ToInt32(nudPoint2X.Value);
  1306. m_artwork.point2Y = Convert.ToInt32(nudPoint2Y.Value);
  1307. m_artwork.point2Color = ColorTranslator.ToHtml(panel2.BackColor);
  1308. m_artwork.twoValueGetMin = Convert.ToInt32(nudTowValueMin.Value);
  1309. m_artwork.twoValueGetMax = Convert.ToInt32(nudTowValueMax.Value);
  1310. m_artwork.twoValueColor = ColorTranslator.ToHtml(panel3.BackColor);
  1311. m_artwork.scrapIsDel = chkScrapIsDel.Checked;
  1312. m_artwork.scrapMin = Convert.ToInt32(nudScrapMin.Value);
  1313. m_artwork.scrapMax = Convert.ToInt32(nudScrapMax.Value);
  1314. if (m_index == -1)
  1315. {
  1316. m_artworkLists.Add(m_artwork);
  1317. }
  1318. string stageModelXml = XmlSerializeHelper.XmlSerialize<ArtworkModel>(m_artworkModel);
  1319. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\ArtworkModel.xml";
  1320. if (FileOperationHelper.WriteStringToFile(stageModelXml, filePath, FileMode.Create))
  1321. {
  1322. Startup.instance.artworkModel = m_artworkModel;
  1323. ((ArtworkSettingDialog)m_parentForm).ArtworkListLoad();
  1324. //MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text"));
  1325. m_bitmap.Dispose();
  1326. this.Close();
  1327. }
  1328. else
  1329. {
  1330. MessageBox.Show(PdnResources.GetString("Menu.Savefailed.text"));
  1331. }
  1332. }
  1333. private void applyButtonImpl()
  1334. {
  1335. if (m_bitmap == null)
  1336. {
  1337. return;
  1338. }
  1339. long start = Cv2.GetTickCount();
  1340. //判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
  1341. if (this.m_documentWorkspace.GraphicsList.IsExsitView())
  1342. {
  1343. this.m_documentWorkspace.PhaseModels[0].mat = action.PerformProcess(
  1344. PaintDotNet.Camera.Tools.ToMat(this.m_documentWorkspace.GetFullSizeWithRegion()),
  1345. PaintDotNet.Camera.Tools.ToMat(this.m_bitmap));
  1346. this.m_documentWorkspace.PhaseModels[0].color = this.panel3.BackColor.ToArgb();
  1347. this.m_documentWorkspace.Refresh();
  1348. }
  1349. else
  1350. {
  1351. m_mat = action.PerformProcess(PaintDotNet.Camera.Tools.ToMat(this.m_bitmap));
  1352. this.m_documentWorkspace.PhaseModels[0].mat = m_mat;
  1353. this.m_documentWorkspace.PhaseModels[0].color = this.panel3.BackColor.ToArgb();
  1354. this.m_documentWorkspace.Refresh();
  1355. }
  1356. double time = (Cv2.GetTickCount() - start) / Cv2.GetTickFrequency();
  1357. System.Console.WriteLine("执行时间:" + time);
  1358. }
  1359. private void panel3_BackColorChanged(object sender, EventArgs e)
  1360. {
  1361. Color color = this.panel3.BackColor;
  1362. //先修改参数
  1363. foreach (Args args in action.Lists)
  1364. {
  1365. if (args.Key == "phaseColor")
  1366. {
  1367. args.Value = color.ToArgb();
  1368. break;
  1369. }
  1370. }
  1371. //改变配置文件里面的相颜色
  1372. this.binaryExtractionModel.PhaseColor = color.ToArgb();
  1373. this.applyButtonImpl();
  1374. }
  1375. private void nudTowValue_ValueChanged(object sender, EventArgs e)
  1376. {
  1377. //参数改变
  1378. foreach (Args args in action.Lists)
  1379. {
  1380. if (args.Key == "scope1")
  1381. {
  1382. ((List<double>)args.Value)[0] = (int)this.nudTowValueMin.Value;
  1383. ((List<double>)args.Value)[1] = (int)this.nudTowValueMax.Value;
  1384. break;
  1385. }
  1386. }
  1387. this.binaryExtractionModel.ColorOneStart = (int)(this.nudTowValueMin.Value);
  1388. this.binaryExtractionModel.ColorOneEnd = (int)(this.nudTowValueMax.Value);
  1389. this.applyButtonImpl();
  1390. }
  1391. /// <summary>
  1392. /// 碎屑面积起始值
  1393. /// </summary>
  1394. /// <param name="sender"></param>
  1395. /// <param name="e"></param>
  1396. private void nudScrapMin_ValueChanged(object sender, EventArgs e)
  1397. {
  1398. nudScrapMax.Value = Math.Max(nudScrapMax.Value, nudScrapMin.Value);
  1399. //参数改变
  1400. foreach (Args args in action.Lists)
  1401. {
  1402. if (args.Key == "scope4")
  1403. {
  1404. ((List<double>)args.Value)[0] = (double)nudScrapMin.Value / unitLength / unitLength;
  1405. ((List<double>)args.Value)[1] = (double)nudScrapMax.Value / unitLength / unitLength;
  1406. break;
  1407. }
  1408. }
  1409. this.binaryExtractionModel.DebrisAreaStart = (int)((double)nudScrapMin.Value / unitLength / unitLength);
  1410. this.binaryExtractionModel.DebrisAreaEnd = (int)((double)nudScrapMax.Value / unitLength / unitLength);
  1411. this.applyButtonImpl();
  1412. }
  1413. /// <summary>
  1414. /// 碎屑面积截止值
  1415. /// </summary>
  1416. /// <param name="sender"></param>
  1417. /// <param name="e"></param>
  1418. private void nudScrapMax_ValueChanged(object sender, EventArgs e)
  1419. {
  1420. nudScrapMin.Value = Math.Min(nudScrapMin.Value, nudScrapMax.Value);
  1421. //参数改变
  1422. foreach (Args args in action.Lists)
  1423. {
  1424. if (args.Key == "scope4")
  1425. {
  1426. ((List<double>)args.Value)[0] = (double)nudScrapMin.Value / unitLength / unitLength;
  1427. ((List<double>)args.Value)[1] = (double)nudScrapMax.Value / unitLength / unitLength;
  1428. break;
  1429. }
  1430. }
  1431. this.binaryExtractionModel.DebrisAreaStart = (int)((double)nudScrapMin.Value / unitLength / unitLength);
  1432. this.binaryExtractionModel.DebrisAreaEnd = (int)((double)nudScrapMax.Value / unitLength / unitLength);
  1433. this.applyButtonImpl();
  1434. }
  1435. private void chkScrapIsDel_CheckedChanged(object sender, EventArgs e)
  1436. {
  1437. //参数改变
  1438. foreach (Args args in action.Lists)
  1439. {
  1440. if (args.Key == "debrisRemoval")
  1441. {
  1442. args.Value = this.chkScrapIsDel.Checked;
  1443. break;
  1444. }
  1445. }
  1446. this.binaryExtractionModel.DebrisRemoval = this.chkScrapIsDel.Checked;
  1447. this.applyButtonImpl();
  1448. }
  1449. private void ArtworkSettingEditDialog_Resize(object sender, EventArgs e)
  1450. {
  1451. this.pnlTools.Left = panel4.Left + (panel4.Width - pnlTools.Width) / 2;
  1452. }
  1453. private void nudTowValueMin_KeyUp(object sender, KeyEventArgs e)
  1454. {
  1455. try
  1456. {
  1457. nudTowValueMin.Value = Convert.ToInt32(this.nudTowValueMin.Text);
  1458. }
  1459. catch (Exception)
  1460. {
  1461. }
  1462. }
  1463. private void nudTowValueMax_KeyUp(object sender, KeyEventArgs e)
  1464. {
  1465. try
  1466. {
  1467. nudTowValueMax.Value = Convert.ToInt32(this.nudTowValueMax.Text);
  1468. }
  1469. catch (Exception)
  1470. {
  1471. }
  1472. }
  1473. private void nudScrapMin_KeyUp(object sender, KeyEventArgs e)
  1474. {
  1475. try
  1476. {
  1477. nudScrapMin.Value = Convert.ToInt32(this.nudScrapMin.Text);
  1478. }
  1479. catch (Exception)
  1480. {
  1481. }
  1482. }
  1483. private void nudScrapMax_KeyUp(object sender, KeyEventArgs e)
  1484. {
  1485. try
  1486. {
  1487. nudScrapMax.Value = Convert.ToInt32(this.nudScrapMax.Text);
  1488. }
  1489. catch (Exception)
  1490. {
  1491. }
  1492. }
  1493. private void nudSide_KeyUp(object sender, KeyEventArgs e)
  1494. {
  1495. try
  1496. {
  1497. nudSide.Value = Convert.ToInt32(this.nudSide.Text);
  1498. }
  1499. catch (Exception)
  1500. {
  1501. }
  1502. }
  1503. private void nudLineWidth_KeyUp(object sender, KeyEventArgs e)
  1504. {
  1505. try
  1506. {
  1507. nudLineWidth.Value = Convert.ToInt32(this.nudLineWidth.Text);
  1508. }
  1509. catch (Exception)
  1510. {
  1511. }
  1512. }
  1513. private void nudPoint1X_KeyUp(object sender, KeyEventArgs e)
  1514. {
  1515. try
  1516. {
  1517. nudPoint1X.Value = Convert.ToInt32(this.nudPoint1X.Text);
  1518. }
  1519. catch (Exception)
  1520. {
  1521. }
  1522. }
  1523. private void nudPoint1Y_KeyUp(object sender, KeyEventArgs e)
  1524. {
  1525. try
  1526. {
  1527. nudPoint1Y.Value = Convert.ToInt32(this.nudPoint1Y.Text);
  1528. }
  1529. catch (Exception)
  1530. {
  1531. }
  1532. }
  1533. private void nudPoint2X_KeyUp(object sender, KeyEventArgs e)
  1534. {
  1535. try
  1536. {
  1537. nudPoint2X.Value = Convert.ToInt32(this.nudPoint2X.Text);
  1538. }
  1539. catch (Exception)
  1540. {
  1541. }
  1542. }
  1543. private void nudPoint2Y_KeyUp(object sender, KeyEventArgs e)
  1544. {
  1545. try
  1546. {
  1547. nudPoint2Y.Value = Convert.ToInt32(this.nudPoint2Y.Text);
  1548. }
  1549. catch (Exception)
  1550. {
  1551. }
  1552. }
  1553. }
  1554. }