ObjectActionDialog.cs 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. using Metis.ParameterSet;
  2. using PaintDotNet.Adjust.BaseImage;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.Base.Functionodel;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Windows.Forms;
  9. namespace PaintDotNet.Binarization
  10. {
  11. /// <summary>
  12. /// 对象处理
  13. /// </summary>
  14. internal class ObjectActionDialog : FloatingToolForm//PdnBaseForm
  15. {
  16. #region 控件
  17. private GroupBox groupBox2;
  18. private GroupBox groupBox3;
  19. private GroupBox groupBox4;
  20. private GroupBox groupBox5;
  21. private GroupBox groupBox6;
  22. private Button button1;
  23. private Button button2;
  24. private Button button3;
  25. private Button button4;
  26. private Button button5;
  27. private Button button6;
  28. private Button button7;
  29. private Button button8;
  30. private Button button9;
  31. private Button button10;
  32. private RadioButton radioButton1;
  33. private RadioButton radioButton2;
  34. private RadioButton radioButton3;
  35. private Label label1;
  36. private Label label2;
  37. private RadioButton radioButton4;
  38. private RadioButton radioButton5;
  39. private RadioButton radioButton6;
  40. private RadioButton radioButton10;
  41. private RadioButton radioButton7;
  42. private RadioButton radioButton8;
  43. private RadioButton radioButton9;
  44. private RadioButton radioButton11;
  45. private RadioButton radioButton12;
  46. private RadioButton radioButton13;
  47. private RadioButton radioButton14;
  48. private RadioButton radioButton15;
  49. private RadioButton radioButton16;
  50. private RadioButton radioButton17;
  51. private RadioButton radioButton18;
  52. private GroupBox groupBox1;
  53. private NumericUpDown numericUpDown1;
  54. private NumericUpDown numericUpDown2;
  55. #endregion
  56. /// <summary>
  57. /// 主控件
  58. /// </summary>
  59. private AppWorkspace appWorkspace;
  60. /// <summary>
  61. /// 用来备份的相集合
  62. /// </summary>
  63. private List<PhaseModel> PhaseModelsBackUp = new List<PhaseModel>();
  64. /// <summary>
  65. /// 是否还原相
  66. /// </summary>
  67. private bool restore = true;
  68. private int menuId;
  69. #region 保存参数的model和key
  70. private GrainSizeAnalysisModel analysisModel;
  71. List<string> optionList = new List<string>();//选项名称集合
  72. private const string ParamKey_DivisionOption = "divisionOption";//分割选项
  73. private const string ParamKey_DivisionLineWidth = "divisionLineWidth";//分割线宽
  74. private const string ParamKey_ConnectOption = "connectOption";//连接选项
  75. private const string ParamKey_ConnectLineWidth = "connectLineWidth";//连接线宽
  76. private const string ParamKey_DeleteOption = "deleteOption";//删除选项
  77. private const string ParamKey_AddOption = "addOption";//添加选项
  78. private const string ParamKey_ChoiceOption = "choiceOption";//选择选项
  79. #endregion
  80. public List<PhaseModel> PhaseModelsBackUpForCopy
  81. {
  82. get
  83. {
  84. List<PhaseModel> list = new List<PhaseModel>();
  85. if (this.PhaseModelsBackUp != null && this.PhaseModelsBackUp.Count > 0)
  86. {
  87. foreach (PhaseModel phase in this.PhaseModelsBackUp)
  88. {
  89. PhaseModel phase1 = new PhaseModel();
  90. phase1.choise = phase.choise;
  91. phase1.color = phase.color;
  92. phase1.mat = new OpenCvSharp.Mat();
  93. phase.mat.CopyTo(phase1.mat);
  94. phase1.name = phase.name;
  95. phase1.position = phase.position;
  96. list.Add(phase1);
  97. }
  98. }
  99. return list;
  100. }
  101. }
  102. public ObjectActionDialog(AppWorkspace appWorkspace,int menuId)
  103. {
  104. this.menuId = menuId;
  105. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
  106. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  107. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  108. this.appWorkspace = appWorkspace;
  109. this.ShowInTaskbar = false;
  110. this.PhaseModelsBackUp = this.appWorkspace.ActiveDocumentWorkspace.PhaseModelsForCopy;
  111. this.appWorkspace.ActiveDocumentWorkspaceChanged += new EventHandler(this.ActiveDocumentWorkspaceChanged);
  112. InitializeComponent();
  113. InitializeLanguageText();
  114. this.numericUpDown1.Value = InvariantData.segmentation;
  115. this.numericUpDown2.Value = InvariantData.connection;
  116. GetListParamModel();
  117. }
  118. private void ActiveDocumentWorkspaceChanged(object sender, EventArgs e)
  119. {
  120. if(this.appWorkspace.ActiveDocumentWorkspace!=null)
  121. this.PhaseModelsBackUp = this.appWorkspace.ActiveDocumentWorkspace.PhaseModelsForCopy;
  122. }
  123. private void InitializeLanguageText()
  124. {
  125. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  126. this.button2.Text = PdnResources.GetString("Menu.ensure.text");
  127. this.button1.Text = PdnResources.GetString("Menu.cancel.text");
  128. this.groupBox2.Text = PdnResources.GetString("Menu.segment.text");
  129. this.label1.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  130. this.radioButton3.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  131. this.radioButton2.Text = PdnResources.GetString("Menu.LabelAction.DrawLine.Text");
  132. this.radioButton1.Text = PdnResources.GetString("Menu.MeasureAction.MeasureBrokenLine.Text");
  133. this.button3.Text = PdnResources.GetString("Menu.segment.text");
  134. this.groupBox3.Text = PdnResources.GetString("Menu.connect.text");
  135. this.radioButton4.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  136. this.radioButton5.Text = PdnResources.GetString("Menu.LabelAction.DrawLine.Text");
  137. this.radioButton6.Text = PdnResources.GetString("Menu.MeasureAction.MeasureBrokenLine.Text");
  138. this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  139. this.button4.Text = PdnResources.GetString("Menu.connect.text");
  140. this.groupBox4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  141. this.radioButton10.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
  142. this.radioButton7.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  143. this.radioButton8.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
  144. this.radioButton9.Text = PdnResources.GetString("Menu.single.text");
  145. this.button5.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  146. this.groupBox5.Text = PdnResources.GetString("Menu.Addto.text");
  147. this.radioButton11.Text = PdnResources.GetString("Menu.Binaryoperation.Objecthandling.Track.text");
  148. this.radioButton12.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
  149. this.radioButton13.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  150. this.radioButton14.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
  151. this.button6.Text = PdnResources.GetString("Menu.Addto.text");
  152. this.groupBox6.Text = PdnResources.GetString("Menu.MeasureAction.MeasureSelect.Text");
  153. this.radioButton15.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
  154. this.radioButton16.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
  155. this.radioButton17.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
  156. this.radioButton18.Text = PdnResources.GetString("Menu.single.text");
  157. this.button10.Text = PdnResources.GetString("Menu.inverse.text");
  158. this.button9.Text = PdnResources.GetString("Menu.Binaryoperation.Objecthandling.unselectall.text");
  159. this.button8.Text = PdnResources.GetString("Menu.application.text");
  160. this.button7.Text = PdnResources.GetString("Menu.MeasureAction.MeasureSelect.Text");
  161. this.Text = PdnResources.GetString("Menu.BinaryAction.ObjectAction.Text");
  162. }
  163. private void InitializeComponent()
  164. {
  165. this.groupBox1 = new System.Windows.Forms.GroupBox();
  166. this.button2 = new System.Windows.Forms.Button();
  167. this.button1 = new System.Windows.Forms.Button();
  168. this.groupBox2 = new System.Windows.Forms.GroupBox();
  169. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  170. this.label1 = new System.Windows.Forms.Label();
  171. this.radioButton3 = new System.Windows.Forms.RadioButton();
  172. this.radioButton2 = new System.Windows.Forms.RadioButton();
  173. this.radioButton1 = new System.Windows.Forms.RadioButton();
  174. this.button3 = new System.Windows.Forms.Button();
  175. this.groupBox3 = new System.Windows.Forms.GroupBox();
  176. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  177. this.radioButton4 = new System.Windows.Forms.RadioButton();
  178. this.radioButton5 = new System.Windows.Forms.RadioButton();
  179. this.radioButton6 = new System.Windows.Forms.RadioButton();
  180. this.label2 = new System.Windows.Forms.Label();
  181. this.button4 = new System.Windows.Forms.Button();
  182. this.groupBox4 = new System.Windows.Forms.GroupBox();
  183. this.radioButton10 = new System.Windows.Forms.RadioButton();
  184. this.radioButton7 = new System.Windows.Forms.RadioButton();
  185. this.radioButton8 = new System.Windows.Forms.RadioButton();
  186. this.radioButton9 = new System.Windows.Forms.RadioButton();
  187. this.button5 = new System.Windows.Forms.Button();
  188. this.groupBox5 = new System.Windows.Forms.GroupBox();
  189. this.radioButton11 = new System.Windows.Forms.RadioButton();
  190. this.radioButton12 = new System.Windows.Forms.RadioButton();
  191. this.radioButton13 = new System.Windows.Forms.RadioButton();
  192. this.radioButton14 = new System.Windows.Forms.RadioButton();
  193. this.button6 = new System.Windows.Forms.Button();
  194. this.groupBox6 = new System.Windows.Forms.GroupBox();
  195. this.radioButton15 = new System.Windows.Forms.RadioButton();
  196. this.radioButton16 = new System.Windows.Forms.RadioButton();
  197. this.radioButton17 = new System.Windows.Forms.RadioButton();
  198. this.radioButton18 = new System.Windows.Forms.RadioButton();
  199. this.button10 = new System.Windows.Forms.Button();
  200. this.button9 = new System.Windows.Forms.Button();
  201. this.button8 = new System.Windows.Forms.Button();
  202. this.button7 = new System.Windows.Forms.Button();
  203. this.groupBox1.SuspendLayout();
  204. this.groupBox2.SuspendLayout();
  205. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  206. this.groupBox3.SuspendLayout();
  207. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  208. this.groupBox4.SuspendLayout();
  209. this.groupBox5.SuspendLayout();
  210. this.groupBox6.SuspendLayout();
  211. this.SuspendLayout();
  212. //
  213. // groupBox1
  214. //
  215. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  216. | System.Windows.Forms.AnchorStyles.Right)));
  217. this.groupBox1.Controls.Add(this.button2);
  218. this.groupBox1.Controls.Add(this.button1);
  219. this.groupBox1.Location = new System.Drawing.Point(13, 13);
  220. this.groupBox1.Name = "groupBox1";
  221. this.groupBox1.Size = new System.Drawing.Size(396, 52);
  222. this.groupBox1.TabIndex = 1;
  223. this.groupBox1.TabStop = false;
  224. this.groupBox1.Text = "操作";
  225. //
  226. // button2
  227. //
  228. this.button2.Location = new System.Drawing.Point(315, 17);
  229. this.button2.Name = "button2";
  230. this.button2.Size = new System.Drawing.Size(75, 23);
  231. this.button2.TabIndex = 1;
  232. this.button2.Text = "确定";
  233. this.button2.UseVisualStyleBackColor = true;
  234. this.button2.Click += new System.EventHandler(this.button2_Click);
  235. //
  236. // button1
  237. //
  238. this.button1.Location = new System.Drawing.Point(234, 17);
  239. this.button1.Name = "button1";
  240. this.button1.Size = new System.Drawing.Size(75, 23);
  241. this.button1.TabIndex = 0;
  242. this.button1.Text = "取消";
  243. this.button1.UseVisualStyleBackColor = true;
  244. this.button1.Click += new System.EventHandler(this.button1_Click);
  245. //
  246. // groupBox2
  247. //
  248. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  249. | System.Windows.Forms.AnchorStyles.Right)));
  250. this.groupBox2.Controls.Add(this.numericUpDown1);
  251. this.groupBox2.Controls.Add(this.label1);
  252. this.groupBox2.Controls.Add(this.radioButton3);
  253. this.groupBox2.Controls.Add(this.radioButton2);
  254. this.groupBox2.Controls.Add(this.radioButton1);
  255. this.groupBox2.Controls.Add(this.button3);
  256. this.groupBox2.Location = new System.Drawing.Point(13, 72);
  257. this.groupBox2.Name = "groupBox2";
  258. this.groupBox2.Size = new System.Drawing.Size(396, 52);
  259. this.groupBox2.TabIndex = 2;
  260. this.groupBox2.TabStop = false;
  261. this.groupBox2.Text = "分割";
  262. //
  263. // numericUpDown1
  264. //
  265. this.numericUpDown1.Location = new System.Drawing.Point(234, 19);
  266. this.numericUpDown1.Minimum = new decimal(new int[] {
  267. 1,
  268. 0,
  269. 0,
  270. 0});
  271. this.numericUpDown1.Name = "numericUpDown1";
  272. this.numericUpDown1.Size = new System.Drawing.Size(75, 21);
  273. this.numericUpDown1.TabIndex = 5;
  274. this.numericUpDown1.Value = new decimal(new int[] {
  275. 1,
  276. 0,
  277. 0,
  278. 0});
  279. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  280. //
  281. // label1
  282. //
  283. this.label1.AutoSize = true;
  284. this.label1.Location = new System.Drawing.Point(197, 23);
  285. this.label1.Name = "label1";
  286. this.label1.Size = new System.Drawing.Size(41, 12);
  287. this.label1.TabIndex = 4;
  288. this.label1.Text = "线宽:";
  289. //
  290. // radioButton3
  291. //
  292. this.radioButton3.AutoSize = true;
  293. this.radioButton3.Location = new System.Drawing.Point(125, 21);
  294. this.radioButton3.Name = "radioButton3";
  295. this.radioButton3.Size = new System.Drawing.Size(47, 16);
  296. this.radioButton3.TabIndex = 3;
  297. this.radioButton3.TabStop = true;
  298. this.radioButton3.Text = "椭圆";
  299. this.radioButton3.UseVisualStyleBackColor = true;
  300. //
  301. // radioButton2
  302. //
  303. this.radioButton2.AutoSize = true;
  304. this.radioButton2.Location = new System.Drawing.Point(72, 21);
  305. this.radioButton2.Name = "radioButton2";
  306. this.radioButton2.Size = new System.Drawing.Size(47, 16);
  307. this.radioButton2.TabIndex = 2;
  308. this.radioButton2.TabStop = true;
  309. this.radioButton2.Text = "直线";
  310. this.radioButton2.UseVisualStyleBackColor = true;
  311. //
  312. // radioButton1
  313. //
  314. this.radioButton1.AutoSize = true;
  315. this.radioButton1.Checked = true;
  316. this.radioButton1.Location = new System.Drawing.Point(19, 21);
  317. this.radioButton1.Name = "radioButton1";
  318. this.radioButton1.Size = new System.Drawing.Size(47, 16);
  319. this.radioButton1.TabIndex = 1;
  320. this.radioButton1.TabStop = true;
  321. this.radioButton1.Text = "折线";
  322. this.radioButton1.UseVisualStyleBackColor = true;
  323. //
  324. // button3
  325. //
  326. this.button3.Location = new System.Drawing.Point(315, 18);
  327. this.button3.Name = "button3";
  328. this.button3.Size = new System.Drawing.Size(75, 23);
  329. this.button3.TabIndex = 0;
  330. this.button3.Text = "分割";
  331. this.button3.UseVisualStyleBackColor = true;
  332. this.button3.Click += new System.EventHandler(this.button3_Click);
  333. //
  334. // groupBox3
  335. //
  336. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  337. | System.Windows.Forms.AnchorStyles.Right)));
  338. this.groupBox3.Controls.Add(this.numericUpDown2);
  339. this.groupBox3.Controls.Add(this.radioButton4);
  340. this.groupBox3.Controls.Add(this.radioButton5);
  341. this.groupBox3.Controls.Add(this.radioButton6);
  342. this.groupBox3.Controls.Add(this.label2);
  343. this.groupBox3.Controls.Add(this.button4);
  344. this.groupBox3.Location = new System.Drawing.Point(13, 131);
  345. this.groupBox3.Name = "groupBox3";
  346. this.groupBox3.Size = new System.Drawing.Size(396, 52);
  347. this.groupBox3.TabIndex = 3;
  348. this.groupBox3.TabStop = false;
  349. this.groupBox3.Text = "连接";
  350. //
  351. // numericUpDown2
  352. //
  353. this.numericUpDown2.Location = new System.Drawing.Point(234, 18);
  354. this.numericUpDown2.Minimum = new decimal(new int[] {
  355. 1,
  356. 0,
  357. 0,
  358. 0});
  359. this.numericUpDown2.Name = "numericUpDown2";
  360. this.numericUpDown2.Size = new System.Drawing.Size(75, 21);
  361. this.numericUpDown2.TabIndex = 11;
  362. this.numericUpDown2.Value = new decimal(new int[] {
  363. 1,
  364. 0,
  365. 0,
  366. 0});
  367. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  368. //
  369. // radioButton4
  370. //
  371. this.radioButton4.AutoSize = true;
  372. this.radioButton4.Location = new System.Drawing.Point(125, 20);
  373. this.radioButton4.Name = "radioButton4";
  374. this.radioButton4.Size = new System.Drawing.Size(47, 16);
  375. this.radioButton4.TabIndex = 10;
  376. this.radioButton4.TabStop = true;
  377. this.radioButton4.Text = "椭圆";
  378. this.radioButton4.UseVisualStyleBackColor = true;
  379. //
  380. // radioButton5
  381. //
  382. this.radioButton5.AutoSize = true;
  383. this.radioButton5.Location = new System.Drawing.Point(72, 20);
  384. this.radioButton5.Name = "radioButton5";
  385. this.radioButton5.Size = new System.Drawing.Size(47, 16);
  386. this.radioButton5.TabIndex = 9;
  387. this.radioButton5.TabStop = true;
  388. this.radioButton5.Text = "直线";
  389. this.radioButton5.UseVisualStyleBackColor = true;
  390. //
  391. // radioButton6
  392. //
  393. this.radioButton6.AutoSize = true;
  394. this.radioButton6.Checked = true;
  395. this.radioButton6.Location = new System.Drawing.Point(19, 20);
  396. this.radioButton6.Name = "radioButton6";
  397. this.radioButton6.Size = new System.Drawing.Size(47, 16);
  398. this.radioButton6.TabIndex = 8;
  399. this.radioButton6.TabStop = true;
  400. this.radioButton6.Text = "折线";
  401. this.radioButton6.UseVisualStyleBackColor = true;
  402. //
  403. // label2
  404. //
  405. this.label2.AutoSize = true;
  406. this.label2.Location = new System.Drawing.Point(197, 21);
  407. this.label2.Name = "label2";
  408. this.label2.Size = new System.Drawing.Size(41, 12);
  409. this.label2.TabIndex = 6;
  410. this.label2.Text = "线宽:";
  411. //
  412. // button4
  413. //
  414. this.button4.Location = new System.Drawing.Point(315, 17);
  415. this.button4.Name = "button4";
  416. this.button4.Size = new System.Drawing.Size(75, 23);
  417. this.button4.TabIndex = 0;
  418. this.button4.Text = "连接";
  419. this.button4.UseVisualStyleBackColor = true;
  420. this.button4.Click += new System.EventHandler(this.button4_Click);
  421. //
  422. // groupBox4
  423. //
  424. this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  425. | System.Windows.Forms.AnchorStyles.Right)));
  426. this.groupBox4.Controls.Add(this.radioButton10);
  427. this.groupBox4.Controls.Add(this.radioButton7);
  428. this.groupBox4.Controls.Add(this.radioButton8);
  429. this.groupBox4.Controls.Add(this.radioButton9);
  430. this.groupBox4.Controls.Add(this.button5);
  431. this.groupBox4.Location = new System.Drawing.Point(13, 190);
  432. this.groupBox4.Name = "groupBox4";
  433. this.groupBox4.Size = new System.Drawing.Size(396, 52);
  434. this.groupBox4.TabIndex = 4;
  435. this.groupBox4.TabStop = false;
  436. this.groupBox4.Text = "删除";
  437. //
  438. // radioButton10
  439. //
  440. this.radioButton10.AutoSize = true;
  441. this.radioButton10.Location = new System.Drawing.Point(178, 21);
  442. this.radioButton10.Name = "radioButton10";
  443. this.radioButton10.Size = new System.Drawing.Size(59, 16);
  444. this.radioButton10.TabIndex = 14;
  445. this.radioButton10.TabStop = true;
  446. this.radioButton10.Text = "多边形";
  447. this.radioButton10.UseVisualStyleBackColor = true;
  448. //
  449. // radioButton7
  450. //
  451. this.radioButton7.AutoSize = true;
  452. this.radioButton7.Location = new System.Drawing.Point(125, 21);
  453. this.radioButton7.Name = "radioButton7";
  454. this.radioButton7.Size = new System.Drawing.Size(47, 16);
  455. this.radioButton7.TabIndex = 13;
  456. this.radioButton7.TabStop = true;
  457. this.radioButton7.Text = "椭圆";
  458. this.radioButton7.UseVisualStyleBackColor = true;
  459. //
  460. // radioButton8
  461. //
  462. this.radioButton8.AutoSize = true;
  463. this.radioButton8.Location = new System.Drawing.Point(72, 21);
  464. this.radioButton8.Name = "radioButton8";
  465. this.radioButton8.Size = new System.Drawing.Size(47, 16);
  466. this.radioButton8.TabIndex = 12;
  467. this.radioButton8.TabStop = true;
  468. this.radioButton8.Text = "矩形";
  469. this.radioButton8.UseVisualStyleBackColor = true;
  470. //
  471. // radioButton9
  472. //
  473. this.radioButton9.AutoSize = true;
  474. this.radioButton9.Checked = true;
  475. this.radioButton9.Location = new System.Drawing.Point(19, 21);
  476. this.radioButton9.Name = "radioButton9";
  477. this.radioButton9.Size = new System.Drawing.Size(47, 16);
  478. this.radioButton9.TabIndex = 11;
  479. this.radioButton9.TabStop = true;
  480. this.radioButton9.Text = "单个";
  481. this.radioButton9.UseVisualStyleBackColor = true;
  482. //
  483. // button5
  484. //
  485. this.button5.Location = new System.Drawing.Point(315, 18);
  486. this.button5.Name = "button5";
  487. this.button5.Size = new System.Drawing.Size(75, 23);
  488. this.button5.TabIndex = 0;
  489. this.button5.Text = "删除";
  490. this.button5.UseVisualStyleBackColor = true;
  491. this.button5.Click += new System.EventHandler(this.button5_Click);
  492. //
  493. // groupBox5
  494. //
  495. this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  496. | System.Windows.Forms.AnchorStyles.Right)));
  497. this.groupBox5.Controls.Add(this.radioButton11);
  498. this.groupBox5.Controls.Add(this.radioButton12);
  499. this.groupBox5.Controls.Add(this.radioButton13);
  500. this.groupBox5.Controls.Add(this.radioButton14);
  501. this.groupBox5.Controls.Add(this.button6);
  502. this.groupBox5.Location = new System.Drawing.Point(13, 249);
  503. this.groupBox5.Name = "groupBox5";
  504. this.groupBox5.Size = new System.Drawing.Size(396, 52);
  505. this.groupBox5.TabIndex = 5;
  506. this.groupBox5.TabStop = false;
  507. this.groupBox5.Text = "添加";
  508. //
  509. // radioButton11
  510. //
  511. this.radioButton11.AutoSize = true;
  512. this.radioButton11.Location = new System.Drawing.Point(125, 21);
  513. this.radioButton11.Name = "radioButton11";
  514. this.radioButton11.Size = new System.Drawing.Size(47, 16);
  515. this.radioButton11.TabIndex = 18;
  516. this.radioButton11.TabStop = true;
  517. this.radioButton11.Text = "轨迹";
  518. this.radioButton11.UseVisualStyleBackColor = true;
  519. //
  520. // radioButton12
  521. //
  522. this.radioButton12.AutoSize = true;
  523. this.radioButton12.Location = new System.Drawing.Point(178, 21);
  524. this.radioButton12.Name = "radioButton12";
  525. this.radioButton12.Size = new System.Drawing.Size(59, 16);
  526. this.radioButton12.TabIndex = 17;
  527. this.radioButton12.TabStop = true;
  528. this.radioButton12.Text = "多边形";
  529. this.radioButton12.UseVisualStyleBackColor = true;
  530. //
  531. // radioButton13
  532. //
  533. this.radioButton13.AutoSize = true;
  534. this.radioButton13.Location = new System.Drawing.Point(72, 21);
  535. this.radioButton13.Name = "radioButton13";
  536. this.radioButton13.Size = new System.Drawing.Size(47, 16);
  537. this.radioButton13.TabIndex = 16;
  538. this.radioButton13.TabStop = true;
  539. this.radioButton13.Text = "椭圆";
  540. this.radioButton13.UseVisualStyleBackColor = true;
  541. //
  542. // radioButton14
  543. //
  544. this.radioButton14.AutoSize = true;
  545. this.radioButton14.Checked = true;
  546. this.radioButton14.Location = new System.Drawing.Point(19, 21);
  547. this.radioButton14.Name = "radioButton14";
  548. this.radioButton14.Size = new System.Drawing.Size(47, 16);
  549. this.radioButton14.TabIndex = 15;
  550. this.radioButton14.TabStop = true;
  551. this.radioButton14.Text = "单个";
  552. this.radioButton14.UseVisualStyleBackColor = true;
  553. //
  554. // button6
  555. //
  556. this.button6.Location = new System.Drawing.Point(315, 18);
  557. this.button6.Name = "button6";
  558. this.button6.Size = new System.Drawing.Size(75, 23);
  559. this.button6.TabIndex = 0;
  560. this.button6.Text = "添加";
  561. this.button6.UseVisualStyleBackColor = true;
  562. this.button6.Click += new System.EventHandler(this.button6_Click);
  563. //
  564. // groupBox6
  565. //
  566. this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  567. | System.Windows.Forms.AnchorStyles.Right)));
  568. this.groupBox6.Controls.Add(this.radioButton15);
  569. this.groupBox6.Controls.Add(this.radioButton16);
  570. this.groupBox6.Controls.Add(this.radioButton17);
  571. this.groupBox6.Controls.Add(this.radioButton18);
  572. this.groupBox6.Controls.Add(this.button10);
  573. this.groupBox6.Controls.Add(this.button9);
  574. this.groupBox6.Controls.Add(this.button8);
  575. this.groupBox6.Controls.Add(this.button7);
  576. this.groupBox6.Location = new System.Drawing.Point(13, 308);
  577. this.groupBox6.Name = "groupBox6";
  578. this.groupBox6.Size = new System.Drawing.Size(396, 96);
  579. this.groupBox6.TabIndex = 6;
  580. this.groupBox6.TabStop = false;
  581. this.groupBox6.Text = "选择";
  582. //
  583. // radioButton15
  584. //
  585. this.radioButton15.AutoSize = true;
  586. this.radioButton15.Location = new System.Drawing.Point(178, 24);
  587. this.radioButton15.Name = "radioButton15";
  588. this.radioButton15.Size = new System.Drawing.Size(59, 16);
  589. this.radioButton15.TabIndex = 18;
  590. this.radioButton15.TabStop = true;
  591. this.radioButton15.Text = "多边形";
  592. this.radioButton15.UseVisualStyleBackColor = true;
  593. //
  594. // radioButton16
  595. //
  596. this.radioButton16.AutoSize = true;
  597. this.radioButton16.Location = new System.Drawing.Point(125, 24);
  598. this.radioButton16.Name = "radioButton16";
  599. this.radioButton16.Size = new System.Drawing.Size(47, 16);
  600. this.radioButton16.TabIndex = 17;
  601. this.radioButton16.TabStop = true;
  602. this.radioButton16.Text = "椭圆";
  603. this.radioButton16.UseVisualStyleBackColor = true;
  604. //
  605. // radioButton17
  606. //
  607. this.radioButton17.AutoSize = true;
  608. this.radioButton17.Location = new System.Drawing.Point(72, 24);
  609. this.radioButton17.Name = "radioButton17";
  610. this.radioButton17.Size = new System.Drawing.Size(47, 16);
  611. this.radioButton17.TabIndex = 16;
  612. this.radioButton17.TabStop = true;
  613. this.radioButton17.Text = "矩形";
  614. this.radioButton17.UseVisualStyleBackColor = true;
  615. //
  616. // radioButton18
  617. //
  618. this.radioButton18.AutoSize = true;
  619. this.radioButton18.Checked = true;
  620. this.radioButton18.Location = new System.Drawing.Point(19, 24);
  621. this.radioButton18.Name = "radioButton18";
  622. this.radioButton18.Size = new System.Drawing.Size(47, 16);
  623. this.radioButton18.TabIndex = 15;
  624. this.radioButton18.TabStop = true;
  625. this.radioButton18.Text = "单个";
  626. this.radioButton18.UseVisualStyleBackColor = true;
  627. //
  628. // button10
  629. //
  630. this.button10.Location = new System.Drawing.Point(153, 60);
  631. this.button10.Name = "button10";
  632. this.button10.Size = new System.Drawing.Size(75, 23);
  633. this.button10.TabIndex = 3;
  634. this.button10.Text = "反选";
  635. this.button10.UseVisualStyleBackColor = true;
  636. this.button10.Click += new System.EventHandler(this.button10_Click);
  637. //
  638. // button9
  639. //
  640. this.button9.Location = new System.Drawing.Point(234, 60);
  641. this.button9.Name = "button9";
  642. this.button9.Size = new System.Drawing.Size(75, 23);
  643. this.button9.TabIndex = 2;
  644. this.button9.Text = "全不选";
  645. this.button9.UseVisualStyleBackColor = true;
  646. this.button9.Click += new System.EventHandler(this.button9_Click);
  647. //
  648. // button8
  649. //
  650. this.button8.Location = new System.Drawing.Point(315, 60);
  651. this.button8.Name = "button8";
  652. this.button8.Size = new System.Drawing.Size(75, 23);
  653. this.button8.TabIndex = 1;
  654. this.button8.Text = "应用";
  655. this.button8.UseVisualStyleBackColor = true;
  656. this.button8.Click += new System.EventHandler(this.button8_Click);
  657. //
  658. // button7
  659. //
  660. this.button7.Location = new System.Drawing.Point(315, 21);
  661. this.button7.Name = "button7";
  662. this.button7.Size = new System.Drawing.Size(75, 23);
  663. this.button7.TabIndex = 0;
  664. this.button7.Text = "选择";
  665. this.button7.UseVisualStyleBackColor = true;
  666. this.button7.Click += new System.EventHandler(this.button7_Click);
  667. //
  668. // ObjectActionDialog
  669. //
  670. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  671. this.ClientSize = new System.Drawing.Size(421, 416);
  672. this.Controls.Add(this.groupBox6);
  673. this.Controls.Add(this.groupBox5);
  674. this.Controls.Add(this.groupBox4);
  675. this.Controls.Add(this.groupBox3);
  676. this.Controls.Add(this.groupBox2);
  677. this.Controls.Add(this.groupBox1);
  678. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  679. this.MaximizeBox = false;
  680. this.MinimizeBox = false;
  681. this.Name = "ObjectActionDialog";
  682. this.Text = "对象处理";
  683. //this.TopMost = true;
  684. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ObjectActionDialog_FormClosing);
  685. this.Controls.SetChildIndex(this.groupBox1, 0);
  686. this.Controls.SetChildIndex(this.groupBox2, 0);
  687. this.Controls.SetChildIndex(this.groupBox3, 0);
  688. this.Controls.SetChildIndex(this.groupBox4, 0);
  689. this.Controls.SetChildIndex(this.groupBox5, 0);
  690. this.Controls.SetChildIndex(this.groupBox6, 0);
  691. this.groupBox1.ResumeLayout(false);
  692. this.groupBox2.ResumeLayout(false);
  693. this.groupBox2.PerformLayout();
  694. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  695. this.groupBox3.ResumeLayout(false);
  696. this.groupBox3.PerformLayout();
  697. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  698. this.groupBox4.ResumeLayout(false);
  699. this.groupBox4.PerformLayout();
  700. this.groupBox5.ResumeLayout(false);
  701. this.groupBox5.PerformLayout();
  702. this.groupBox6.ResumeLayout(false);
  703. this.groupBox6.PerformLayout();
  704. this.ResumeLayout(false);
  705. }
  706. /// <summary>
  707. /// 删除
  708. /// </summary>
  709. /// <param name="sender"></param>
  710. /// <param name="e"></param>
  711. private void button5_Click(object sender, EventArgs e)
  712. {
  713. if (this.radioButton9.Checked)
  714. {
  715. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  716. {
  717. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryDelete;
  718. }
  719. }
  720. else if(this.radioButton8.Checked)
  721. {
  722. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  723. {
  724. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryDeleteRectangle;
  725. }
  726. }
  727. else if (this.radioButton7.Checked)
  728. {
  729. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  730. {
  731. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryDeleteOval;
  732. }
  733. }
  734. else if (this.radioButton10.Checked)
  735. {
  736. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  737. {
  738. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryDeletePolygon;
  739. }
  740. }
  741. }
  742. /// <summary>
  743. /// 分割
  744. /// </summary>
  745. /// <param name="sender"></param>
  746. /// <param name="e"></param>
  747. private void button3_Click(object sender, EventArgs e)
  748. {
  749. if (this.radioButton1.Checked)
  750. {
  751. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  752. {
  753. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinarySplitPolyline;
  754. }
  755. }
  756. else if (this.radioButton2.Checked)
  757. {
  758. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  759. {
  760. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinarySplitLine;
  761. }
  762. }
  763. else if (this.radioButton3.Checked)
  764. {
  765. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  766. {
  767. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinarySplitOval;
  768. }
  769. }
  770. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = true;
  771. }
  772. /// <summary>
  773. /// 连接
  774. /// </summary>
  775. /// <param name="sender"></param>
  776. /// <param name="e"></param>
  777. private void button4_Click(object sender, EventArgs e)
  778. {
  779. if (this.radioButton6.Checked)
  780. {
  781. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  782. {
  783. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryConnectionPolygonLine;
  784. }
  785. }
  786. else if (this.radioButton5.Checked)
  787. {
  788. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  789. {
  790. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryConnectionLine;
  791. }
  792. }
  793. else if (this.radioButton4.Checked)
  794. {
  795. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  796. {
  797. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryConnectionOval;
  798. }
  799. }
  800. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = true;
  801. }
  802. /// <summary>
  803. /// 添加
  804. /// </summary>
  805. /// <param name="sender"></param>
  806. /// <param name="e"></param>
  807. private void button6_Click(object sender, EventArgs e)
  808. {
  809. if (this.radioButton14.Checked)
  810. {
  811. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  812. {
  813. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryAddRectangle;
  814. }
  815. }
  816. else if (this.radioButton13.Checked)
  817. {
  818. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  819. {
  820. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryAddOval;
  821. }
  822. }
  823. else if (this.radioButton11.Checked)
  824. {
  825. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  826. {
  827. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryAddTrack;
  828. }
  829. }
  830. else if (this.radioButton12.Checked)
  831. {
  832. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  833. {
  834. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryAddPolygon;
  835. }
  836. }
  837. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = true;
  838. }
  839. /// <summary>
  840. /// 选择
  841. /// </summary>
  842. /// <param name="sender"></param>
  843. /// <param name="e"></param>
  844. private void button7_Click(object sender, EventArgs e)
  845. {
  846. if (this.radioButton18.Checked)
  847. {
  848. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  849. {
  850. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryChoise;
  851. }
  852. }
  853. else if (this.radioButton17.Checked)
  854. {
  855. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  856. {
  857. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryChoiseRectangle;
  858. }
  859. }
  860. else if (this.radioButton16.Checked)
  861. {
  862. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  863. {
  864. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryChoiseOval;
  865. }
  866. }
  867. else if (this.radioButton15.Checked)
  868. {
  869. if (this.appWorkspace.ActiveDocumentWorkspace != null)
  870. {
  871. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.BinaryChoisePolygon;
  872. }
  873. }
  874. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = true;
  875. }
  876. /// <summary>
  877. /// 取消
  878. /// </summary>
  879. /// <param name="sender"></param>
  880. /// <param name="e"></param>
  881. private void button1_Click(object sender, EventArgs e)
  882. {
  883. this.Close();
  884. }
  885. /// <summary>
  886. /// 确定
  887. /// </summary>
  888. /// <param name="sender"></param>
  889. /// <param name="e"></param>
  890. private void button2_Click(object sender, EventArgs e)
  891. {
  892. this.restore = false;
  893. this.Close();
  894. }
  895. /// <summary>
  896. /// 分割
  897. /// </summary>
  898. /// <param name="sender"></param>
  899. /// <param name="e"></param>
  900. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  901. {
  902. InvariantData.segmentation = Convert.ToInt32(this.numericUpDown1.Value);
  903. }
  904. /// <summary>
  905. /// 连接
  906. /// </summary>
  907. /// <param name="sender"></param>
  908. /// <param name="e"></param>
  909. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  910. {
  911. InvariantData.connection = Convert.ToInt32(this.numericUpDown2.Value);
  912. }
  913. /// <summary>
  914. /// 窗口关闭事件
  915. /// </summary>
  916. /// <param name="sender"></param>
  917. /// <param name="e"></param>
  918. private void ObjectActionDialog_FormClosing(object sender, FormClosingEventArgs e)
  919. {
  920. if (this.appWorkspace.ActiveDocumentWorkspace == null)
  921. return;
  922. //取消连续
  923. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = false;
  924. //设置活动的窗口工具为指针
  925. this.appWorkspace.ActiveDocumentWorkspace.ActiveTool = DrawToolType.Pointer;
  926. //清空所有交互操作的draw对象
  927. this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.Interaction);
  928. //如果为true,则还原相
  929. if (restore)
  930. {
  931. this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.PhaseModelsBackUp;
  932. }
  933. //刷新活动的窗口
  934. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  935. saveDialogParam();
  936. }
  937. /// <summary>
  938. /// 选择,反选
  939. /// </summary>
  940. /// <param name="sender"></param>
  941. /// <param name="e"></param>
  942. private void button10_Click(object sender, EventArgs e)
  943. {
  944. //判断两个备份的mat和激活的mat不相等才进行处理
  945. for (int j = 0; j < this.appWorkspace.ActiveDocumentWorkspace.phaseModels.Count; j++)
  946. {
  947. if (this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].choise)
  948. {
  949. if (!BaseTools.matEqual(this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].mat, this.PhaseModelsBackUp[j].mat))
  950. {
  951. this.appWorkspace.ActiveDocumentWorkspace.BinaryActionAntiElection(j);
  952. }
  953. }
  954. }
  955. }
  956. /// <summary>
  957. /// 选择,全不选
  958. /// </summary>
  959. /// <param name="sender"></param>
  960. /// <param name="e"></param>
  961. private void button9_Click(object sender, EventArgs e)
  962. {
  963. this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.PhaseModelsBackUpForCopy;
  964. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  965. }
  966. /// <summary>
  967. /// 选择,应用
  968. /// </summary>
  969. /// <param name="sender"></param>
  970. /// <param name="e"></param>
  971. private void button8_Click(object sender, EventArgs e)
  972. {
  973. if(this.appWorkspace.ActiveDocumentWorkspace!=null && this.appWorkspace.ActiveDocumentWorkspace.phaseModels!=null)
  974. {
  975. //判断备份的mat和激活的mat不相等才进行处理
  976. for (int j = 0; j < this.appWorkspace.ActiveDocumentWorkspace.phaseModels.Count; j++)
  977. {
  978. if (this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].choise)
  979. {
  980. if (!BaseTools.matEqual(this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].mat, this.PhaseModelsBackUp[j].mat))
  981. {
  982. this.appWorkspace.ActiveDocumentWorkspace.BinaryActionAntiConfirm(j);
  983. }
  984. }
  985. }
  986. }
  987. }
  988. #region 参数保存及提取
  989. /// <summary>
  990. /// 保存参数的key,value和type
  991. /// </summary>
  992. /// <param name="param_key"></param>
  993. /// <param name="param_value"></param>
  994. /// <param name="param_type"></param>
  995. private void saveParamValue(string param_key, string param_value, int param_type)
  996. {
  997. bool foundItem = false;
  998. foreach (var item in this.analysisModel.ListParam)
  999. {
  1000. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  1001. {
  1002. item.param_value = param_value;
  1003. item.setValue();
  1004. foundItem = true;
  1005. break;
  1006. }
  1007. }
  1008. if (!foundItem)
  1009. {
  1010. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  1011. analysisItem.menuId = this.menuId;
  1012. analysisItem.param_key = param_key;
  1013. analysisItem.param_type = param_type;
  1014. analysisItem.param_value = param_value;
  1015. analysisItem.setValue();
  1016. this.analysisModel.ListParam.Add(analysisItem);
  1017. }
  1018. }
  1019. /// <summary>
  1020. /// 获取被选中的选项放入list
  1021. /// </summary>
  1022. private void OptionList()
  1023. {
  1024. string division = string.Empty;//分割选项
  1025. string connect = string.Empty;//连接选项
  1026. string delete = string.Empty;//删除选项
  1027. string add = string.Empty;//添加选项
  1028. string choice = string.Empty;//选择选项
  1029. if (this.radioButton1.Checked)
  1030. division = this.radioButton1.Text;
  1031. if (this.radioButton2.Checked)
  1032. division = this.radioButton2.Text;
  1033. if (this.radioButton3.Checked)
  1034. division = this.radioButton3.Text;
  1035. if (this.radioButton6.Checked)
  1036. connect = this.radioButton6.Text;
  1037. if (this.radioButton5.Checked)
  1038. connect = this.radioButton5.Text;
  1039. if (this.radioButton4.Checked)
  1040. connect = this.radioButton4.Text;
  1041. if (this.radioButton9.Checked)
  1042. delete = this.radioButton9.Text;
  1043. if (this.radioButton8.Checked)
  1044. delete = this.radioButton8.Text;
  1045. if (this.radioButton7.Checked)
  1046. delete = this.radioButton7.Text;
  1047. if (this.radioButton10.Checked)
  1048. delete = this.radioButton10.Text;
  1049. if (this.radioButton14.Checked)
  1050. add = this.radioButton14.Text;
  1051. if (this.radioButton13.Checked)
  1052. add = this.radioButton13.Text;
  1053. if (this.radioButton11.Checked)
  1054. add = this.radioButton11.Text;
  1055. if (this.radioButton12.Checked)
  1056. add = this.radioButton12.Text;
  1057. if (this.radioButton18.Checked)
  1058. choice = this.radioButton18.Text;
  1059. if (this.radioButton17.Checked)
  1060. choice = this.radioButton17.Text;
  1061. if (this.radioButton16.Checked)
  1062. choice = this.radioButton16.Text;
  1063. if (this.radioButton15.Checked)
  1064. choice = this.radioButton15.Text;
  1065. optionList.Add(division);
  1066. optionList.Add(connect);
  1067. optionList.Add(delete);
  1068. optionList.Add(add);
  1069. optionList.Add(choice);
  1070. }
  1071. /// <summary>
  1072. /// 保存界面中的参数到model
  1073. /// </summary>
  1074. private void saveDialogParamValues()
  1075. {
  1076. OptionList();
  1077. saveParamValue(ParamKey_DivisionOption, optionList[0], (int)Base.Dtryt.ItemString);//分割选项
  1078. saveParamValue(ParamKey_DivisionLineWidth, this.numericUpDown1.Value.ToString(), (int)Base.Dtryt.Decimal);//分割线宽
  1079. saveParamValue(ParamKey_ConnectOption, optionList[1], (int)Base.Dtryt.ItemString);//连接选项
  1080. saveParamValue(ParamKey_ConnectLineWidth, this.numericUpDown2.Value.ToString(), (int)Base.Dtryt.Decimal);//连接线宽
  1081. saveParamValue(ParamKey_DeleteOption, optionList[2], (int)Base.Dtryt.ItemString);//删除选项
  1082. saveParamValue(ParamKey_AddOption, optionList[3], (int)Base.Dtryt.ItemString);//添加选项
  1083. saveParamValue(ParamKey_ChoiceOption, optionList[4], (int)Base.Dtryt.ItemString);//选择选项
  1084. }
  1085. /// <summary>
  1086. /// 获取保存的参数
  1087. /// </summary>
  1088. private void GetListParamModel()
  1089. {
  1090. if (this.analysisModel != null)
  1091. {
  1092. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  1093. {
  1094. switch (this.analysisModel.ListParam[i].param_key)
  1095. {
  1096. case ParamKey_DivisionOption:
  1097. if (this.radioButton1.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1098. this.radioButton1.Checked = true;
  1099. if (this.radioButton2.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1100. this.radioButton2.Checked = true;
  1101. if (this.radioButton3.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1102. this.radioButton3.Checked = true;
  1103. break;
  1104. case ParamKey_DivisionLineWidth:
  1105. this.numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  1106. break;
  1107. case ParamKey_ConnectOption:
  1108. if (this.radioButton6.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1109. this.radioButton6.Checked = true;
  1110. if (this.radioButton5.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1111. this.radioButton5.Checked = true;
  1112. if (this.radioButton4.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1113. this.radioButton4.Checked = true;
  1114. break;
  1115. case ParamKey_ConnectLineWidth:
  1116. this.numericUpDown2.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  1117. break;
  1118. case ParamKey_DeleteOption:
  1119. if (this.radioButton9.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1120. this.radioButton9.Checked = true;
  1121. if (this.radioButton8.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1122. this.radioButton8.Checked = true;
  1123. if (this.radioButton7.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1124. this.radioButton7.Checked = true;
  1125. if (this.radioButton10.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1126. this.radioButton10.Checked = true;
  1127. break;
  1128. case ParamKey_AddOption:
  1129. if (this.radioButton14.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1130. this.radioButton14.Checked = true;
  1131. if (this.radioButton13.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1132. this.radioButton13.Checked = true;
  1133. if (this.radioButton11.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1134. this.radioButton11.Checked = true;
  1135. if (this.radioButton12.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1136. this.radioButton12.Checked = true;
  1137. break;
  1138. case ParamKey_ChoiceOption:
  1139. if (this.radioButton18.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1140. this.radioButton18.Checked = true;
  1141. if (this.radioButton17.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1142. this.radioButton17.Checked = true;
  1143. if (this.radioButton16.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1144. this.radioButton16.Checked = true;
  1145. if (this.radioButton15.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1146. this.radioButton15.Checked = true;
  1147. break;
  1148. }
  1149. }
  1150. }
  1151. }
  1152. private void saveDialogParam()
  1153. {
  1154. this.saveDialogParamValues();
  1155. //xml保存路径
  1156. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
  1157. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1158. foreach (var analysisItem in this.analysisModel.ListParam)
  1159. {
  1160. bool foundItem = false;
  1161. foreach (var item in analysisModelXml.ListParam)
  1162. {
  1163. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  1164. {
  1165. item.param_value = analysisItem.param_value;
  1166. foundItem = true;
  1167. break;
  1168. }
  1169. }
  1170. if (!foundItem)
  1171. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  1172. }
  1173. //按路径和名称保存xml文件
  1174. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  1175. //保存xml
  1176. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  1177. }
  1178. #endregion
  1179. }
  1180. }