ObjectActionDialog.cs 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  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. //取消连续
  921. this.appWorkspace.ActiveDocumentWorkspace.ContinuousBinaryAction = false;
  922. //设置活动的窗口工具为指针
  923. this.appWorkspace.ActiveDocumentWorkspace.activeTool = DrawToolType.Pointer;
  924. //清空所有交互操作的draw对象
  925. this.appWorkspace.ActiveDocumentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.Interaction);
  926. //如果为true,则还原相
  927. if (restore)
  928. {
  929. this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.PhaseModelsBackUp;
  930. }
  931. //刷新活动的窗口
  932. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  933. saveDialogParam();
  934. }
  935. /// <summary>
  936. /// 选择,反选
  937. /// </summary>
  938. /// <param name="sender"></param>
  939. /// <param name="e"></param>
  940. private void button10_Click(object sender, EventArgs e)
  941. {
  942. //判断两个备份的mat和激活的mat不相等才进行处理
  943. for (int j = 0; j < this.appWorkspace.ActiveDocumentWorkspace.phaseModels.Count; j++)
  944. {
  945. if (this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].choise)
  946. {
  947. if (!BaseTools.matEqual(this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].mat, this.PhaseModelsBackUp[j].mat))
  948. {
  949. this.appWorkspace.ActiveDocumentWorkspace.BinaryActionAntiElection(j);
  950. }
  951. }
  952. }
  953. }
  954. /// <summary>
  955. /// 选择,全不选
  956. /// </summary>
  957. /// <param name="sender"></param>
  958. /// <param name="e"></param>
  959. private void button9_Click(object sender, EventArgs e)
  960. {
  961. this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.PhaseModelsBackUpForCopy;
  962. this.appWorkspace.ActiveDocumentWorkspace.Refresh();
  963. }
  964. /// <summary>
  965. /// 选择,应用
  966. /// </summary>
  967. /// <param name="sender"></param>
  968. /// <param name="e"></param>
  969. private void button8_Click(object sender, EventArgs e)
  970. {
  971. if(this.appWorkspace.ActiveDocumentWorkspace!=null && this.appWorkspace.ActiveDocumentWorkspace.phaseModels!=null)
  972. {
  973. //判断备份的mat和激活的mat不相等才进行处理
  974. for (int j = 0; j < this.appWorkspace.ActiveDocumentWorkspace.phaseModels.Count; j++)
  975. {
  976. if (this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].choise)
  977. {
  978. if (!BaseTools.matEqual(this.appWorkspace.ActiveDocumentWorkspace.phaseModels[j].mat, this.PhaseModelsBackUp[j].mat))
  979. {
  980. this.appWorkspace.ActiveDocumentWorkspace.BinaryActionAntiConfirm(j);
  981. }
  982. }
  983. }
  984. }
  985. }
  986. #region 参数保存及提取
  987. /// <summary>
  988. /// 保存参数的key,value和type
  989. /// </summary>
  990. /// <param name="param_key"></param>
  991. /// <param name="param_value"></param>
  992. /// <param name="param_type"></param>
  993. private void saveParamValue(string param_key, string param_value, int param_type)
  994. {
  995. bool foundItem = false;
  996. foreach (var item in this.analysisModel.ListParam)
  997. {
  998. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  999. {
  1000. item.param_value = param_value;
  1001. item.setValue();
  1002. foundItem = true;
  1003. break;
  1004. }
  1005. }
  1006. if (!foundItem)
  1007. {
  1008. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  1009. analysisItem.menuId = this.menuId;
  1010. analysisItem.param_key = param_key;
  1011. analysisItem.param_type = param_type;
  1012. analysisItem.param_value = param_value;
  1013. analysisItem.setValue();
  1014. this.analysisModel.ListParam.Add(analysisItem);
  1015. }
  1016. }
  1017. /// <summary>
  1018. /// 获取被选中的选项放入list
  1019. /// </summary>
  1020. private void OptionList()
  1021. {
  1022. string division = string.Empty;//分割选项
  1023. string connect = string.Empty;//连接选项
  1024. string delete = string.Empty;//删除选项
  1025. string add = string.Empty;//添加选项
  1026. string choice = string.Empty;//选择选项
  1027. if (this.radioButton1.Checked)
  1028. division = this.radioButton1.Text;
  1029. if (this.radioButton2.Checked)
  1030. division = this.radioButton2.Text;
  1031. if (this.radioButton3.Checked)
  1032. division = this.radioButton3.Text;
  1033. if (this.radioButton6.Checked)
  1034. connect = this.radioButton6.Text;
  1035. if (this.radioButton5.Checked)
  1036. connect = this.radioButton5.Text;
  1037. if (this.radioButton4.Checked)
  1038. connect = this.radioButton4.Text;
  1039. if (this.radioButton9.Checked)
  1040. delete = this.radioButton9.Text;
  1041. if (this.radioButton8.Checked)
  1042. delete = this.radioButton8.Text;
  1043. if (this.radioButton7.Checked)
  1044. delete = this.radioButton7.Text;
  1045. if (this.radioButton10.Checked)
  1046. delete = this.radioButton10.Text;
  1047. if (this.radioButton14.Checked)
  1048. add = this.radioButton14.Text;
  1049. if (this.radioButton13.Checked)
  1050. add = this.radioButton13.Text;
  1051. if (this.radioButton11.Checked)
  1052. add = this.radioButton11.Text;
  1053. if (this.radioButton12.Checked)
  1054. add = this.radioButton12.Text;
  1055. if (this.radioButton18.Checked)
  1056. choice = this.radioButton18.Text;
  1057. if (this.radioButton17.Checked)
  1058. choice = this.radioButton17.Text;
  1059. if (this.radioButton16.Checked)
  1060. choice = this.radioButton16.Text;
  1061. if (this.radioButton15.Checked)
  1062. choice = this.radioButton15.Text;
  1063. optionList.Add(division);
  1064. optionList.Add(connect);
  1065. optionList.Add(delete);
  1066. optionList.Add(add);
  1067. optionList.Add(choice);
  1068. }
  1069. /// <summary>
  1070. /// 保存界面中的参数到model
  1071. /// </summary>
  1072. private void saveDialogParamValues()
  1073. {
  1074. OptionList();
  1075. saveParamValue(ParamKey_DivisionOption, optionList[0], (int)Base.Dtryt.ItemString);//分割选项
  1076. saveParamValue(ParamKey_DivisionLineWidth, this.numericUpDown1.Value.ToString(), (int)Base.Dtryt.Decimal);//分割线宽
  1077. saveParamValue(ParamKey_ConnectOption, optionList[1], (int)Base.Dtryt.ItemString);//连接选项
  1078. saveParamValue(ParamKey_ConnectLineWidth, this.numericUpDown2.Value.ToString(), (int)Base.Dtryt.Decimal);//连接线宽
  1079. saveParamValue(ParamKey_DeleteOption, optionList[2], (int)Base.Dtryt.ItemString);//删除选项
  1080. saveParamValue(ParamKey_AddOption, optionList[3], (int)Base.Dtryt.ItemString);//添加选项
  1081. saveParamValue(ParamKey_ChoiceOption, optionList[4], (int)Base.Dtryt.ItemString);//选择选项
  1082. }
  1083. /// <summary>
  1084. /// 获取保存的参数
  1085. /// </summary>
  1086. private void GetListParamModel()
  1087. {
  1088. if (this.analysisModel != null)
  1089. {
  1090. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  1091. {
  1092. switch (this.analysisModel.ListParam[i].param_key)
  1093. {
  1094. case ParamKey_DivisionOption:
  1095. if (this.radioButton1.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1096. this.radioButton1.Checked = true;
  1097. if (this.radioButton2.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1098. this.radioButton2.Checked = true;
  1099. if (this.radioButton3.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1100. this.radioButton3.Checked = true;
  1101. break;
  1102. case ParamKey_DivisionLineWidth:
  1103. this.numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  1104. break;
  1105. case ParamKey_ConnectOption:
  1106. if (this.radioButton6.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1107. this.radioButton6.Checked = true;
  1108. if (this.radioButton5.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1109. this.radioButton5.Checked = true;
  1110. if (this.radioButton4.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1111. this.radioButton4.Checked = true;
  1112. break;
  1113. case ParamKey_ConnectLineWidth:
  1114. this.numericUpDown2.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
  1115. break;
  1116. case ParamKey_DeleteOption:
  1117. if (this.radioButton9.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1118. this.radioButton9.Checked = true;
  1119. if (this.radioButton8.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1120. this.radioButton8.Checked = true;
  1121. if (this.radioButton7.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1122. this.radioButton7.Checked = true;
  1123. if (this.radioButton10.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1124. this.radioButton10.Checked = true;
  1125. break;
  1126. case ParamKey_AddOption:
  1127. if (this.radioButton14.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1128. this.radioButton14.Checked = true;
  1129. if (this.radioButton13.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1130. this.radioButton13.Checked = true;
  1131. if (this.radioButton11.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1132. this.radioButton11.Checked = true;
  1133. if (this.radioButton12.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1134. this.radioButton12.Checked = true;
  1135. break;
  1136. case ParamKey_ChoiceOption:
  1137. if (this.radioButton18.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1138. this.radioButton18.Checked = true;
  1139. if (this.radioButton17.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1140. this.radioButton17.Checked = true;
  1141. if (this.radioButton16.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1142. this.radioButton16.Checked = true;
  1143. if (this.radioButton15.Text.Equals(this.analysisModel.ListParam[i].param_value))
  1144. this.radioButton15.Checked = true;
  1145. break;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. private void saveDialogParam()
  1151. {
  1152. this.saveDialogParamValues();
  1153. //xml保存路径
  1154. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
  1155. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1156. foreach (var analysisItem in this.analysisModel.ListParam)
  1157. {
  1158. bool foundItem = false;
  1159. foreach (var item in analysisModelXml.ListParam)
  1160. {
  1161. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  1162. {
  1163. item.param_value = analysisItem.param_value;
  1164. foundItem = true;
  1165. break;
  1166. }
  1167. }
  1168. if (!foundItem)
  1169. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  1170. }
  1171. //按路径和名称保存xml文件
  1172. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  1173. //保存xml
  1174. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  1175. }
  1176. #endregion
  1177. }
  1178. }