GrainBoundaryEditingDialog .cs 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249
  1. using OpenCvSharp;
  2. using PaintDotNet.Adjust;
  3. using PaintDotNet.Annotation;
  4. using PaintDotNet.Base.Functionodel;
  5. using PaintDotNet.CustomControl;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Drawing;
  9. using System.Drawing.Drawing2D;
  10. using System.Linq;
  11. using System.Windows.Forms;
  12. using Point = System.Drawing.Point;
  13. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass
  14. {
  15. internal class GrainBoundaryEditingDialog : Form
  16. {
  17. public static string ParamKey_GrainApplygrainboundaries = "GrainApplygrainboundaries";//是否应用(计算晶界)
  18. public static string ParamKey_GrainAdOutParam0 = "GrainAdOutParam0";//方法1原方法,方法2模拟软件方法 this.radioButton1.Checked? 2 : 1;
  19. public static string ParamKey_GrainAdOutParam1 = "GrainAdOutParam1";//默认为暗晶界,为2时为亮晶界 this.radioButton3.Checked? 2 : 0;
  20. public static string ParamKey_GrainSigma = "GrainSigma";//西格玛 如果是高斯平滑,则指定高斯sigma,如果是方向平滑 则忽略此参数 double.TryParse(textBox6.Text, out sigma)
  21. public static string ParamKey_GrainDark = "GrainDark";//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度 dark = this.comboBox2.SelectedIndex;
  22. public static string ParamKey_GrainSmooth_type = "GrainSmooth_type";//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1 smooth_type = this.comboBox3.SelectedIndex;
  23. public static string ParamKey_GrainEnhance = "GrainDisplaysections";//是否增强晶界?不增强:enhance=0; 增强: enhance=1 enhance = this.checkBox2.Checked? 1 : 0
  24. public static string ParamKey_GrainCell_size1 = "GrainCell_size1";//晶界大小
  25. public static string ParamKey_GrainCell_size2 = "GrainCell_size2";//晶界大小 cell_size = new double[2] { (double) numericUpDown1.Value, (double) numericUpDown2.Value }
  26. /// <summary>
  27. /// 调色板
  28. /// </summary>
  29. private ColorsForm colorsFormGrid;
  30. private Panel panelC;
  31. /// <summary>
  32. /// 公共按钮
  33. /// </summary>
  34. private CommonControlButtons commonControlButtons;
  35. /// <summary>
  36. /// 主控件
  37. /// </summary>
  38. private AppWorkspace appWorkspace;
  39. private DocumentWorkspaceWindow documentWorkspace;
  40. /// <summary>
  41. /// 存在视场标记
  42. /// </summary>
  43. private bool existViewFlag = false;
  44. /// <summary>
  45. /// 选中图片的mat
  46. /// </summary>
  47. private Mat imageMat;
  48. /// <summary>
  49. /// 用于get处理后的图像
  50. /// </summary>
  51. private Mat phaseMat;
  52. /// <summary>
  53. /// 用于get处理后的图像的颜色
  54. /// </summary>
  55. private Color phaseColor;
  56. private int menuId;
  57. /// <summary>
  58. /// 是否显示视场
  59. /// </summary>
  60. Boolean ShowDrawClassView = false;
  61. /// <summary>
  62. /// 起始点
  63. /// </summary>
  64. private Point startPoint = new Point(-1, -1);
  65. /// <summary>
  66. /// 是否绘制了起始点
  67. /// </summary>
  68. private bool drawedStartPoint = false;
  69. /// <summary>
  70. /// 结束点
  71. /// </summary>
  72. private Point endPoint = new Point(-1, -1);
  73. //1013###19326 晶粒度的晶界编辑页面,需要把辅助线带过去(客户编辑只处理辅助线位置的晶界)
  74. /// <summary>
  75. /// 辅助线集成 20720 【专用分析-晶粒度】4290-仲裁法,晶界重现后,在晶界编辑页面没有把网格带过去
  76. /// </summary>
  77. private GrainSize.GuideSizeArLawClass guide2Class;
  78. /// <summary>
  79. /// 辅助线集成
  80. /// </summary>
  81. private GrainSizeGuideClass guideClass;
  82. public object SelectedItem;
  83. /// <summary>
  84. /// 操作类型
  85. /// 0,没有操作 1,折线添加 2,直线添加
  86. /// 11,多边形删除 12,圆形删除 13,矩形删除 14,椭圆删除
  87. /// </summary>
  88. private int pointKtype = 0;
  89. /// <summary>
  90. /// 折线点的集合
  91. /// </summary>
  92. public List<PointF> pointFloatArray = new List<PointF>();
  93. /// <summary>
  94. /// 外接矩形,或者是计算的矩形
  95. /// </summary>
  96. protected RectangleF rectangle = new RectangleF(/*pointFloatArray 0, 1,,,, 2, 3*/);
  97. #region 实现撤销、恢复、重置的功能
  98. /// <summary>
  99. /// 当前操作在OperationsList的位置,用于判断是否可以撤销、恢复、重置
  100. /// </summary>
  101. private int OperationIndex = -1;
  102. /// <summary>
  103. /// 将 操作类型的集合放入一个List,通过OperationIndex读取当前操作位置
  104. /// </summary>
  105. private List<int> OperationKtypeList = new List<int>();
  106. /// <summary>
  107. /// 将 折线(/直线)点的集合(/外接矩形的xywh)放入一个List,通过OperationIndex读取当前操作位置
  108. /// </summary>
  109. private List<PointF[]> OperationsList = new List<PointF[]>();
  110. /// <summary>
  111. /// 保存晶界重现运算的结果
  112. /// </summary>
  113. private Mat PhaseModel0MatCopy;
  114. #endregion
  115. private GroupBox groupBox1;
  116. private GroupBox groupBox2;
  117. private GroupBox groupBox3;
  118. private Button button2;
  119. private Button button1;
  120. private Button button3;
  121. private Button button4;
  122. private Button button8;
  123. private Button button7;
  124. private Button button6;
  125. private Button button5;
  126. private Button button9;
  127. private GroupBox groupBox4;
  128. private Panel panel1;
  129. private Label label17;
  130. private GroupBox groupBox7;
  131. private GroupBox itemsGroupBox;
  132. private Button undoButton;
  133. private Button redoButton;
  134. private Button resetButton;
  135. private Panel panel2;
  136. private RadioButton applyRadioButton2;
  137. private RadioButton applyRadioButton1;
  138. private Label applyLabel;
  139. private Panel panel3;
  140. private RadioButton radioButton1;
  141. private RadioButton radioButton2;
  142. private Label label2;
  143. private Panel panel4;
  144. private RadioButton radioButton3;
  145. private RadioButton radioButton4;
  146. private Label label3;
  147. private Panel panel5;
  148. private Label label1;
  149. private Panel panel6;
  150. private TrackBar trackBar2;
  151. private Label label4;
  152. private TrackBar trackBar1;
  153. private Panel panel7;
  154. private RadioButton radioButton5;
  155. private RadioButton radioButton6;
  156. private Label label5;
  157. private Panel panel8;
  158. private TrackBar trackBar3;
  159. private Label label6;
  160. private RadioButton radioButton10;
  161. private RadioButton radioButton7;
  162. private RadioButton radioButton8;
  163. private Panel panel9;
  164. private RadioButton radioButton9;
  165. private RadioButton radioButton11;
  166. private Label label7;
  167. private int focusedItemIndex;
  168. /// <summary>
  169. /// 返回当前选择的图片内容
  170. /// </summary>
  171. /// <returns></returns>
  172. private DocumentWorkspace getCurrentWorkspace()
  173. {
  174. return this.appWorkspace.DocumentWorkspaces[focusedItemIndex];
  175. }
  176. public GrainSize.GuideSizeArLawClass Guide2Class
  177. {
  178. set
  179. {
  180. this.guide2Class = value;
  181. }
  182. }
  183. public GrainSizeGuideClass GuideClass
  184. {
  185. set
  186. {
  187. this.guideClass = value;
  188. }
  189. }
  190. /// <summary>
  191. /// PanelC的调色板颜色改变
  192. /// </summary>
  193. /// <param name="sender"></param>
  194. /// <param name="e"></param>
  195. private void gridColorChanged(object sender, EventArgs e)
  196. {
  197. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  198. ////更改背景色,触发事件
  199. //if (this.panelC != null)
  200. //{
  201. // this.panelC.BackColor = color;
  202. // //this.ColorPanelChanged(this.panelC);
  203. // this.panelC = null;
  204. // //关闭色板
  205. // this.colorsFormGrid.Close();
  206. // this.PhaseColor = this.panel1.BackColor;
  207. // return;
  208. //}
  209. //更改背景色,触发事件
  210. this.panel1.BackColor = color;
  211. this.documentWorkspace.PhaseModels[0].color = this.panel1.BackColor.ToArgb();
  212. this.PhaseColor = this.panel1.BackColor;
  213. this.runDectForColor();
  214. this.documentWorkspace.Refresh();
  215. //关闭色板
  216. this.colorsFormGrid.Close();
  217. }
  218. private Mat dstBinary = null;
  219. private Vec4b dstVec4b;
  220. private Vec4b dstVecBack4b;
  221. /// <summary>
  222. /// 颜色改变时改变相的颜色
  223. /// </summary>
  224. private unsafe void runDectForColor()
  225. {
  226. if (dstBinary != null)
  227. {
  228. dstBinary.Dispose();
  229. dstBinary = null;
  230. }
  231. if (this.documentWorkspace.PhaseModels[0].mat == null)
  232. return;
  233. dstVec4b = new Vec4b(this.PhaseColor.B, this.PhaseColor.G, this.PhaseColor.R, this.PhaseColor.A);
  234. dstVecBack4b = new Vec4b(this.PhaseColor.B, this.PhaseColor.G, this.PhaseColor.R, 0);
  235. dstBinary = this.documentWorkspace.PhaseModels[0].mat.Clone();// new Mat(this.documentWorkspace.PhaseModels[0].mat.Rows, this.documentWorkspace.PhaseModels[0].mat.Cols, MatType.CV_8UC1, new Scalar(0));
  236. //如果是rgba
  237. this.documentWorkspace.PhaseModels[0].mat.ForEachAsVec4b(ForeachFunctionByteForWhole4B);
  238. this.documentWorkspace.PhaseModels[0].mat = dstBinary.Clone();
  239. //Cv2.ImShow("dstBinary", dstBinary);
  240. //Cv2.WaitKey();
  241. this.documentWorkspace.Refresh();
  242. }
  243. /// <summary>
  244. /// 提取二值化的透明通道并赋值
  245. /// </summary>
  246. /// <param name="t"></param>
  247. /// <param name="position"></param>
  248. private unsafe void ForeachFunctionByteForWhole4B(Vec4b* t, int* position)
  249. {
  250. if (t->Item3 > 0)
  251. dstBinary.Set(position[0], position[1], dstVec4b);
  252. else
  253. dstBinary.Set(position[0], position[1], dstVecBack4b);
  254. }
  255. public GrainBoundaryEditingDialog(AppWorkspace appWorkspace, int menuId, int focusedItemIndex, Color phaseColor, Mat phaseMat, Boolean ShowDrawClassView = false)
  256. {
  257. this.menuId = menuId;
  258. this.ShowDrawClassView = ShowDrawClassView;
  259. this.focusedItemIndex = focusedItemIndex;
  260. this.appWorkspace = appWorkspace;
  261. this.colorsFormGrid = new ColorsForm();
  262. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  263. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
  264. InitializeComponent();
  265. InitializeLanguageText();
  266. //
  267. //初始化图像控件
  268. //
  269. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  270. this.documentWorkspace.Cursor = Cursors.Default;
  271. this.documentWorkspace.Dock = DockStyle.Fill;
  272. this.documentWorkspace.HookMouseEvents();
  273. this.documentWorkspace.AuxiliaryLineEnabled = false;
  274. this.documentWorkspace.Visible = false;
  275. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  276. this.documentWorkspace.panel.Paint += Panel_Paint;
  277. this.documentWorkspace.panel.MouseMove += onMouseMove;
  278. this.documentWorkspace.panel.MouseUp += onMouseUp;
  279. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;//禁止视场移动
  280. this.groupBox7.Controls.Add(documentWorkspace);
  281. //
  282. //初始化操作按钮
  283. //
  284. this.commonControlButtons = new CommonControlButtons();
  285. this.commonControlButtons.Dock = DockStyle.Top;
  286. this.commonControlButtons.Height = 30;
  287. this.commonControlButtons.HideZoomToWindowAndActualSize();
  288. this.groupBox7.Controls.Add(commonControlButtons);
  289. {
  290. //
  291. //初始化相
  292. //
  293. PhaseModel model = new PhaseModel();
  294. model.choise = true;
  295. model.mat = null;
  296. model.color = phaseColor.ToArgb();// Color.Green/*panel2.BackColor*/.ToArgb();
  297. model.position = this.documentWorkspace.PhaseModels.Count + 1;
  298. model.name = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  299. this.documentWorkspace.PhaseModels.Add(model);
  300. }
  301. if (phaseMat != null)
  302. {
  303. this.documentWorkspace.PhaseModels[0].mat = phaseMat;
  304. PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
  305. this.PhaseColor = phaseColor;
  306. }
  307. else
  308. this.PhaseColor = Color.Red;
  309. this.documentWorkspace.Refresh();
  310. existViewFlag = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].GraphicsList.IsExsitView() && ShowDrawClassView;
  311. this.imageMat = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].CompositionSurface.CreatedAliasedMat();
  312. Document document = Document.FromImageMat(imageMat.Clone());
  313. this.documentWorkspace.Document = document;
  314. this.documentWorkspace.Visible = true;
  315. if (ShowDrawClassView)
  316. {
  317. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].GraphicsList;
  318. }
  319. else
  320. {
  321. GraphicsList itemGraphicsList = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].GraphicsList;
  322. GraphicsList graphicsList = new GraphicsList();
  323. for (int j = 0; j < itemGraphicsList.Count; j++)
  324. {
  325. if (itemGraphicsList[j].objectType != Annotation.Enum.DrawClass.View)
  326. graphicsList.Add(itemGraphicsList[j]);
  327. }
  328. this.documentWorkspace.GraphicsList = graphicsList;
  329. }
  330. InitCommonButtonEvent();
  331. }
  332. /// <summary>
  333. /// 添加操作数据到List集合中,并刷新操作按钮的状态
  334. /// </summary>
  335. /// <param name="addKtype"></param>
  336. /// <param name="pointFs"></param>
  337. private void AddOperationToList(int addKtype, PointF[] pointFs)
  338. {
  339. this.RefreshOperationsToIndex();
  340. this.OperationKtypeList.Add(addKtype);
  341. this.OperationsList.Add(pointFs);
  342. this.OperationIndex = this.OperationsList.Count - 1;
  343. this.RefreshOperationsButtons();
  344. }
  345. /// <summary>
  346. /// 根据OperationIndex去掉已经撤销的操作记录
  347. /// </summary>
  348. private void RefreshOperationsToIndex()
  349. {
  350. if (this.OperationIndex < this.OperationsList.Count - 1)
  351. {
  352. int operationSum = this.OperationsList.Count;
  353. for (int i = operationSum - 1; i > this.OperationIndex; i--)
  354. {
  355. this.OperationKtypeList.RemoveAt(i);
  356. this.OperationsList.RemoveAt(i);
  357. }
  358. }
  359. }
  360. /// <summary>
  361. /// 刷新操作按钮的状态
  362. /// </summary>
  363. private void RefreshOperationsButtons()
  364. {
  365. if (/*this.OperationIndex >= 0 && */this.OperationKtypeList.Count == this.OperationsList.Count && this.OperationKtypeList.Count > 0)
  366. this.resetButton.Enabled = true;
  367. else
  368. this.resetButton.Enabled = false;
  369. if (this.OperationIndex >= 0)
  370. this.undoButton.Enabled = true;
  371. else
  372. this.undoButton.Enabled = false;
  373. if (this.OperationIndex < this.OperationKtypeList.Count - 1)
  374. this.redoButton.Enabled = true;
  375. else
  376. this.redoButton.Enabled = false;
  377. }
  378. #region 矩形拖动
  379. /// <summary>
  380. /// 鼠标按下
  381. /// </summary>
  382. /// <param name="drawArea"></param>
  383. /// <param name="e"></param>
  384. private void OnMouseDown(object sender, MouseEventArgs e)
  385. {
  386. // 换算后的点
  387. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  388. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  389. && point1.X >= 0
  390. && point1.Y >= 0
  391. && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  392. {
  393. if (e.Button == MouseButtons.Left && this.pointKtype >= 1
  394. && !drawedStartPoint)
  395. drawedStartPoint = true;
  396. startPoint = new Point((int)point1.X, (int)point1.Y);
  397. }
  398. else if (this.pointKtype == 14 || this.pointKtype == 13 || this.pointKtype == 12)
  399. {
  400. if (!drawedStartPoint)//#21757
  401. {
  402. drawedStartPoint = true;
  403. startPoint = new Point((int)point1.X, (int)point1.Y);
  404. }
  405. }
  406. }
  407. /// <summary>
  408. /// 移动
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. private void onMouseMove(object sender, MouseEventArgs e)
  413. {
  414. // 换算后的点
  415. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  416. if (e.Button == MouseButtons.Left)
  417. {
  418. // 椭圆删除/圆形删除
  419. if ((this.pointKtype == 14 || this.pointKtype == 12) && drawedStartPoint)
  420. {
  421. endPoint = new Point((int)point1.X, (int)point1.Y);
  422. if (this.startPoint.X < this.endPoint.X)
  423. {
  424. //this.pointFloatArray.Clear();
  425. this.rectangle.X = this.startPoint.X;
  426. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  427. }
  428. else
  429. {
  430. this.rectangle.X = this.endPoint.X;
  431. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  432. }
  433. if (this.startPoint.Y < this.endPoint.Y)
  434. {
  435. this.rectangle.Y = this.startPoint.Y;
  436. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  437. }
  438. else
  439. {
  440. this.rectangle.Y = this.endPoint.Y;
  441. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  442. }
  443. this.documentWorkspace.Refresh();
  444. }
  445. // 矩形删除
  446. if (this.pointKtype == 13 && drawedStartPoint)
  447. {
  448. endPoint = new Point((int)point1.X, (int)point1.Y);
  449. if (this.startPoint.X < this.endPoint.X)
  450. {
  451. this.rectangle.X = this.startPoint.X;
  452. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  453. }
  454. else
  455. {
  456. this.rectangle.X = this.endPoint.X;
  457. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  458. }
  459. if (this.startPoint.Y < this.endPoint.Y)
  460. {
  461. this.rectangle.Y = this.startPoint.Y;
  462. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  463. }
  464. else
  465. {
  466. this.rectangle.Y = this.endPoint.Y;
  467. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  468. }
  469. this.documentWorkspace.Refresh();
  470. }
  471. // 直线添加
  472. if (this.pointKtype == 2 && drawedStartPoint)
  473. {
  474. endPoint = new Point((int)point1.X, (int)point1.Y);
  475. this.documentWorkspace.Refresh();
  476. }
  477. }
  478. }
  479. /// <summary>
  480. /// 鼠标抬起
  481. /// </summary>
  482. /// <param name="sender"></param>
  483. /// <param name="e"></param>
  484. private void onMouseUp(object sender, MouseEventArgs e)
  485. {
  486. // 换算后的点
  487. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  488. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  489. && point1.X >= 0
  490. && point1.Y >= 0
  491. && point1.Y <= this.documentWorkspace.CompositionSurface.Height) { }
  492. else
  493. {
  494. if (this.pointKtype == 14 || this.pointKtype == 13 || this.pointKtype == 12)//#21757
  495. {
  496. //if (point1.X >= this.documentWorkspace.CompositionSurface.Width)
  497. // point1.X = this.documentWorkspace.CompositionSurface.Width - 1;
  498. //if (point1.X < 0)
  499. // point1.X = 0;
  500. //if (point1.Y >= this.documentWorkspace.CompositionSurface.Height)
  501. // point1.Y = this.documentWorkspace.CompositionSurface.Height - 1;
  502. //if (point1.Y < 0)
  503. // point1.Y = 0;
  504. }
  505. else
  506. return;
  507. }
  508. if (e.Button == MouseButtons.Right)
  509. {
  510. // 折线删除
  511. if (this.pointKtype == 11 && pointFloatArray.Count > 1)
  512. {
  513. pointFloatArray.Add(new PointF(point1.X, point1.Y));
  514. endPoint = new Point((int)point1.X, (int)point1.Y);
  515. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.PolygonDelete(this.documentWorkspace.PhaseModels[0].mat, pointFloatArray);
  516. this.AddOperationToList(this.pointKtype, pointFloatArray.ToArray());
  517. this.rectangle.X = -1;
  518. this.rectangle.Y = -1;
  519. this.rectangle.Width = 0;
  520. this.rectangle.Height = 0;
  521. pointFloatArray.Clear();
  522. startPoint = new Point(-1, -1);
  523. drawedStartPoint = false;
  524. endPoint = new Point(-1, -1);
  525. this.pointKtype = 0;
  526. this.documentWorkspace.Refresh();
  527. }
  528. // 折线添加
  529. if (this.pointKtype == 1 && pointFloatArray.Count > 1)
  530. {
  531. pointFloatArray.Add(new PointF(point1.X, point1.Y));
  532. endPoint = new Point((int)point1.X, (int)point1.Y);
  533. //保存处理后的图片
  534. Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  535. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  536. Graphics graphics = Graphics.FromImage(newBit);
  537. Draw(graphics, false);
  538. this.documentWorkspace.PhaseModels[0].mat = PaintDotNet.Camera.Tools.ToMat(newBit);
  539. this.AddOperationToList(this.pointKtype, pointFloatArray.ToArray());
  540. pointFloatArray.Clear();
  541. startPoint = new Point(-1, -1);
  542. drawedStartPoint = false;
  543. endPoint = new Point(-1, -1);
  544. this.pointKtype = 0;
  545. this.documentWorkspace.Refresh();
  546. }
  547. }
  548. if (e.Button == MouseButtons.Left)
  549. {
  550. // 圆形删除/椭圆删除
  551. if ((this.pointKtype == 14 || this.pointKtype == 12) && drawedStartPoint)
  552. {
  553. endPoint = new Point((int)point1.X, (int)point1.Y);
  554. if (this.startPoint.X < this.endPoint.X)
  555. {
  556. this.rectangle.X = this.startPoint.X;
  557. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  558. }
  559. else
  560. {
  561. this.rectangle.X = this.endPoint.X;
  562. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  563. }
  564. if (this.startPoint.Y < this.endPoint.Y)
  565. {
  566. this.rectangle.Y = this.startPoint.Y;
  567. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  568. }
  569. else
  570. {
  571. this.rectangle.Y = this.endPoint.Y;
  572. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  573. }
  574. if (this.pointKtype == 14)
  575. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.OvalDelete(this.documentWorkspace.PhaseModels[0].mat, this.rectangle);
  576. else
  577. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.OvalDelete(this.documentWorkspace.PhaseModels[0].mat
  578. , new RectangleF(this.rectangle.X, this.rectangle.Y, Math.Min(this.rectangle.Width, this.rectangle.Height), Math.Min(this.rectangle.Width, this.rectangle.Height)));
  579. List<PointF> pointOperationArray = new List<PointF>();
  580. pointOperationArray.Add(new PointF(this.rectangle.X, this.rectangle.Y));
  581. pointOperationArray.Add(new PointF(this.rectangle.Width, this.rectangle.Height));
  582. this.AddOperationToList(this.pointKtype, pointOperationArray/*pointFloatArray*/.ToArray());
  583. this.rectangle.X = -1;
  584. this.rectangle.Y = -1;
  585. this.rectangle.Width = 0;
  586. this.rectangle.Height = 0;
  587. startPoint = new Point(-1, -1);
  588. drawedStartPoint = false;
  589. endPoint = new Point(-1, -1);
  590. this.pointKtype = 0;
  591. this.documentWorkspace.Refresh();
  592. }
  593. // 矩形删除
  594. if (this.pointKtype == 13 && drawedStartPoint)
  595. {
  596. endPoint = new Point((int)point1.X, (int)point1.Y);
  597. if (this.startPoint.X < this.endPoint.X)
  598. {
  599. this.rectangle.X = this.startPoint.X;
  600. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  601. }
  602. else
  603. {
  604. this.rectangle.X = this.endPoint.X;
  605. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  606. }
  607. if (this.startPoint.Y < this.endPoint.Y)
  608. {
  609. this.rectangle.Y = this.startPoint.Y;
  610. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  611. }
  612. else
  613. {
  614. this.rectangle.Y = this.endPoint.Y;
  615. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  616. }
  617. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.RectangleDelete(this.documentWorkspace.PhaseModels[0].mat, this.rectangle);
  618. List<PointF> pointOperationArray = new List<PointF>();
  619. pointOperationArray.Add(new PointF(this.rectangle.X, this.rectangle.Y));
  620. pointOperationArray.Add(new PointF(this.rectangle.Width, this.rectangle.Height));
  621. this.AddOperationToList(this.pointKtype, pointOperationArray/*pointFloatArray*/.ToArray());
  622. this.rectangle.X = -1;
  623. this.rectangle.Y = -1;
  624. this.rectangle.Width = 0;
  625. this.rectangle.Height = 0;
  626. startPoint = new Point(-1, -1);
  627. drawedStartPoint = false;
  628. endPoint = new Point(-1, -1);
  629. this.pointKtype = 0;
  630. this.documentWorkspace.Refresh();
  631. }
  632. // 折线添加/折线删除
  633. if (this.pointKtype == 1 || this.pointKtype == 11)
  634. {
  635. pointFloatArray.Add(new PointF(point1.X, point1.Y));
  636. if (drawedStartPoint)
  637. {
  638. }
  639. else
  640. startPoint = new Point((int)point1.X, (int)point1.Y);
  641. this.documentWorkspace.Refresh();
  642. }
  643. // 直线添加
  644. if (this.pointKtype == 2 && drawedStartPoint)
  645. {
  646. endPoint = new Point((int)point1.X, (int)point1.Y);
  647. //保存处理后的图片
  648. Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  649. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  650. Graphics graphics = Graphics.FromImage(newBit);
  651. Draw(graphics, false);
  652. this.documentWorkspace.PhaseModels[0].mat = PaintDotNet.Camera.Tools.ToMat(newBit);
  653. List<PointF> pointOperationArray = new List<PointF>();
  654. pointOperationArray.Add(new PointF(startPoint.X, startPoint.Y));
  655. pointOperationArray.Add(new PointF(endPoint.X, endPoint.Y));
  656. this.AddOperationToList(this.pointKtype, pointOperationArray/*pointFloatArray*/.ToArray());
  657. startPoint = new Point(-1, -1);
  658. drawedStartPoint = false;
  659. endPoint = new Point(-1, -1);
  660. this.pointKtype = 0;
  661. this.documentWorkspace.Refresh();
  662. }
  663. }
  664. }
  665. #endregion
  666. /// <summary>
  667. /// 画布绘制
  668. /// </summary>
  669. /// <param name="sender"></param>
  670. /// <param name="e"></param>
  671. private void Panel_Paint(object sender, PaintEventArgs e)
  672. {
  673. if (this.documentWorkspace.CompositionSurface != null)
  674. {
  675. //
  676. // 以下是计算绘制图片的位置和大小并绘制图片
  677. //
  678. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  679. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  680. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  681. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  682. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  683. //
  684. // 以下是绘制网格、标注、测量、视场等开始
  685. //
  686. e.Graphics.TranslateTransform(x, y);
  687. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  688. //if (this.checkBox4_0.Checked)//显示网格
  689. Draw(e.Graphics, true);
  690. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  691. e.Graphics.TranslateTransform(-x, -y);
  692. }
  693. }
  694. /// <summary>
  695. /// 绘制
  696. /// </summary>
  697. private void Draw(Graphics g, bool DrawGuideLines)
  698. {
  699. // 抗锯齿
  700. g.SmoothingMode = SmoothingMode.AntiAlias;
  701. if (DrawGuideLines)
  702. {
  703. if (guideClass != null && guideClass.GrainSizeGuideAreaMethodModel != null)
  704. guideClass.DrawAreaGuide(g, SelectedItem, guideClass.guideModel);
  705. else if (guideClass != null && guideClass.GrainSizeGuideStyleModel != null)
  706. guideClass.DrawGuideLines(g, SelectedItem, guideClass.guideModel);
  707. }
  708. if (guide2Class != null && this.documentWorkspace.CompositionSurface != null)
  709. guide2Class.DrawGridViews(g, this.documentWorkspace.CompositionSurface.Height, this.documentWorkspace.CompositionSurface.Width);
  710. //圆形删除/椭圆删除
  711. if ((this.pointKtype == 14 || this.pointKtype == 12) && (this.rectangle.Width > 0 || this.rectangle.Height > 0))
  712. {
  713. Pen pen = new Pen(this.phaseColor, 1);
  714. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  715. if (this.pointKtype == 14)
  716. g.DrawEllipse(pen, this.rectangle);
  717. else
  718. g.DrawEllipse(pen, new RectangleF(this.rectangle.X, this.rectangle.Y, Math.Min(this.rectangle.Width, this.rectangle.Height), Math.Min(this.rectangle.Width, this.rectangle.Height)));
  719. pen.Dispose();
  720. }
  721. //矩形删除
  722. if (this.pointKtype == 13 && (this.rectangle.Width > 0 || this.rectangle.Height > 0))
  723. {
  724. Pen pen = new Pen(this.phaseColor, 1);
  725. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  726. g.DrawRectangle(pen, new Rectangle((int)this.rectangle.X, (int)this.rectangle.Y, (int)this.rectangle.Width, (int)this.rectangle.Height));
  727. pen.Dispose();
  728. }
  729. // 折线删除
  730. if (this.pointKtype == 11 && pointFloatArray.Count >= 2)
  731. {
  732. Pen pen = new Pen(this.phaseColor, 1);
  733. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  734. g.DrawPolygon(pen, pointFloatArray.ToArray());
  735. pen.Dispose();
  736. }
  737. // 直线添加
  738. if (this.pointKtype == 2 && /*pointFloatArray.Count == 2*/drawedStartPoint && this.endPoint.X > -1 && this.endPoint.Y > -1)
  739. {
  740. Pen pen = new Pen(this.phaseColor, 1);
  741. //g.DrawLine(pen, pointFloatArray[0].X, pointFloatArray[0].Y, pointFloatArray[1].X, pointFloatArray[1].Y);
  742. ////pen.DashStyle = DashStyle.Dash;
  743. g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
  744. pen.Dispose();
  745. }
  746. // 折线添加
  747. if (this.pointKtype == 1 && pointFloatArray.Count >= 2)
  748. {
  749. Pen pen = new Pen(this.phaseColor, 1);
  750. g.DrawLines(pen, pointFloatArray.ToArray());
  751. pen.Dispose();
  752. }
  753. }
  754. private void InitializeLanguageText()
  755. {
  756. this.applyLabel.Text = PdnResources.GetString("Menu.IsItApplied.text") + ":";
  757. this.label2.Text = PdnResources.GetString("Menu.Method.text") + ":";
  758. this.label3.Text = PdnResources.GetString("Menu.Grainboundarytype.text") + ":";
  759. this.label17.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
  760. this.label1.Text = PdnResources.GetString("Menu.GrainScale.text") + ":";
  761. this.label4.Text = PdnResources.GetString("Menu.GrainWidth.text") + ":";
  762. this.label5.Text = PdnResources.GetString("Menu.adjustment.text") + ":";
  763. this.label6.Text = PdnResources.GetString("Menu.intensity.text") + ":";
  764. this.label7.Text = PdnResources.GetString("Menu.linear.text") + ":";
  765. this.button3.Text = PdnResources.GetString("Menu.Grainboundaryedit.text");
  766. this.groupBox4.Text = PdnResources.GetString("Menu.params.text");// PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  767. //this.comboBox3.Items.AddRange(new object[] {
  768. //PdnResources.GetString("Menu.Gaussiansmoothing.text"),
  769. //PdnResources.GetString("Menu.directionalsmoothing.text")});
  770. //this.comboBox2.Items.AddRange(new object[] {
  771. //PdnResources.GetString("Menu.Brightgrainboundary.text"),
  772. //PdnResources.GetString("Menu.Darkgrainboundary.text"),
  773. //PdnResources.GetString("Menu.gradient.text")});
  774. this.resetButton.Text = PdnResources.GetString("Menu.reinformation.text");
  775. this.resetButton.Enabled = false;
  776. this.redoButton.Text = PdnResources.GetString("Menu.Edit.Redo.Text");
  777. this.redoButton.Enabled = false;
  778. this.undoButton.Text = PdnResources.GetString("CommonAction.Undo");
  779. this.undoButton.Enabled = false;
  780. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  781. this.button9.Text = PdnResources.GetString("CommonAction.Undo");
  782. this.button2.Text = PdnResources.GetString("Menu.application.text");// PdnResources.GetString("Menu.File.Close.Text");
  783. this.button1.Text = PdnResources.GetString("Form.OkButton.Text");
  784. this.groupBox2.Text = PdnResources.GetString("Menu.Addgrainboundaries.text");
  785. this.button4.Text = PdnResources.GetString("Menu.Lineadd.text");
  786. this.button3.Text = PdnResources.GetString("Menu.Polylineadd.text");
  787. this.groupBox3.Text = PdnResources.GetString("Menu.Deletegrainboundary.text");
  788. this.button8.Text = PdnResources.GetString("Menu.Ellipsedelete.text");
  789. this.button7.Text = PdnResources.GetString("Menu.BinaryAction.RectangleDelete.Text");
  790. this.button6.Text = PdnResources.GetString("Menu.rounddelete.text");
  791. this.button5.Text = PdnResources.GetString("Menu.BinaryAction.PolygonleDelete.Text");
  792. this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
  793. this.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");// PdnResources.GetString("Menu.Grainboundaryedit.text");
  794. this.radioButton9.Text = PdnResources.GetString("Menu.Intercept.text");
  795. this.radioButton11.Text = PdnResources.GetString("Menu.Slope.text");
  796. this.radioButton10.Text = PdnResources.GetString("Menu.LinearTrim.text");
  797. this.radioButton7.Text = PdnResources.GetString("Menu.Bright.text");
  798. this.radioButton8.Text = PdnResources.GetString("Menu.Dimming.text");
  799. this.radioButton5.Text = PdnResources.GetString("Menu.auto-adjust.text");
  800. this.radioButton6.Text = PdnResources.GetString("Menu.NoAdjust.text");
  801. this.radioButton3.Text = PdnResources.GetString("Menu.Brightgrainboundary.text");
  802. this.radioButton4.Text = PdnResources.GetString("Menu.Darkgrainboundary.text");
  803. this.applyRadioButton2.Text = PdnResources.GetString("Menu.no.text");
  804. this.applyRadioButton1.Text = PdnResources.GetString("Menu.Yes.text");
  805. this.itemsGroupBox.Text = PdnResources.GetString("Menu.operation.text");
  806. //
  807. }
  808. private void InitializeComponent()
  809. {
  810. this.groupBox1 = new System.Windows.Forms.GroupBox();
  811. this.button9 = new System.Windows.Forms.Button();
  812. this.button2 = new System.Windows.Forms.Button();
  813. this.button1 = new System.Windows.Forms.Button();
  814. this.groupBox2 = new System.Windows.Forms.GroupBox();
  815. this.button4 = new System.Windows.Forms.Button();
  816. this.button3 = new System.Windows.Forms.Button();
  817. this.groupBox3 = new System.Windows.Forms.GroupBox();
  818. this.button8 = new System.Windows.Forms.Button();
  819. this.button7 = new System.Windows.Forms.Button();
  820. this.button6 = new System.Windows.Forms.Button();
  821. this.button5 = new System.Windows.Forms.Button();
  822. this.groupBox7 = new System.Windows.Forms.GroupBox();
  823. this.groupBox4 = new System.Windows.Forms.GroupBox();
  824. this.panel9 = new System.Windows.Forms.Panel();
  825. this.radioButton9 = new System.Windows.Forms.RadioButton();
  826. this.radioButton11 = new System.Windows.Forms.RadioButton();
  827. this.label7 = new System.Windows.Forms.Label();
  828. this.panel8 = new System.Windows.Forms.Panel();
  829. this.trackBar3 = new System.Windows.Forms.TrackBar();
  830. this.label6 = new System.Windows.Forms.Label();
  831. this.panel7 = new System.Windows.Forms.Panel();
  832. this.radioButton10 = new System.Windows.Forms.RadioButton();
  833. this.radioButton7 = new System.Windows.Forms.RadioButton();
  834. this.radioButton8 = new System.Windows.Forms.RadioButton();
  835. this.radioButton5 = new System.Windows.Forms.RadioButton();
  836. this.radioButton6 = new System.Windows.Forms.RadioButton();
  837. this.label5 = new System.Windows.Forms.Label();
  838. this.panel1 = new System.Windows.Forms.Panel();
  839. this.panel6 = new System.Windows.Forms.Panel();
  840. this.trackBar2 = new System.Windows.Forms.TrackBar();
  841. this.label4 = new System.Windows.Forms.Label();
  842. this.panel5 = new System.Windows.Forms.Panel();
  843. this.trackBar1 = new System.Windows.Forms.TrackBar();
  844. this.label1 = new System.Windows.Forms.Label();
  845. this.panel4 = new System.Windows.Forms.Panel();
  846. this.radioButton3 = new System.Windows.Forms.RadioButton();
  847. this.radioButton4 = new System.Windows.Forms.RadioButton();
  848. this.label3 = new System.Windows.Forms.Label();
  849. this.panel3 = new System.Windows.Forms.Panel();
  850. this.radioButton1 = new System.Windows.Forms.RadioButton();
  851. this.radioButton2 = new System.Windows.Forms.RadioButton();
  852. this.label2 = new System.Windows.Forms.Label();
  853. this.panel2 = new System.Windows.Forms.Panel();
  854. this.applyRadioButton2 = new System.Windows.Forms.RadioButton();
  855. this.applyRadioButton1 = new System.Windows.Forms.RadioButton();
  856. this.applyLabel = new System.Windows.Forms.Label();
  857. this.label17 = new System.Windows.Forms.Label();
  858. this.itemsGroupBox = new System.Windows.Forms.GroupBox();
  859. this.undoButton = new System.Windows.Forms.Button();
  860. this.redoButton = new System.Windows.Forms.Button();
  861. this.resetButton = new System.Windows.Forms.Button();
  862. this.groupBox1.SuspendLayout();
  863. this.groupBox2.SuspendLayout();
  864. this.groupBox3.SuspendLayout();
  865. this.groupBox4.SuspendLayout();
  866. this.panel9.SuspendLayout();
  867. this.panel8.SuspendLayout();
  868. ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
  869. this.panel7.SuspendLayout();
  870. this.panel6.SuspendLayout();
  871. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
  872. this.panel5.SuspendLayout();
  873. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  874. this.panel4.SuspendLayout();
  875. this.panel3.SuspendLayout();
  876. this.panel2.SuspendLayout();
  877. this.itemsGroupBox.SuspendLayout();
  878. this.SuspendLayout();
  879. //
  880. // groupBox1
  881. //
  882. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  883. | System.Windows.Forms.AnchorStyles.Right)));
  884. this.groupBox1.Controls.Add(this.button9);
  885. this.groupBox1.Controls.Add(this.button2);
  886. this.groupBox1.Controls.Add(this.button1);
  887. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  888. this.groupBox1.Name = "groupBox1";
  889. this.groupBox1.Size = new System.Drawing.Size(808, 45);
  890. this.groupBox1.TabIndex = 0;
  891. this.groupBox1.TabStop = false;
  892. //
  893. // button9
  894. //
  895. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  896. this.button9.Location = new System.Drawing.Point(468, 13);
  897. this.button9.Name = "button9";
  898. this.button9.Size = new System.Drawing.Size(91, 26);
  899. this.button9.TabIndex = 2;
  900. this.button9.UseVisualStyleBackColor = true;
  901. this.button9.Visible = false;
  902. this.button9.Click += new System.EventHandler(this.button9_Click);
  903. //
  904. // button2
  905. //
  906. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  907. this.button2.Location = new System.Drawing.Point(592, 14);
  908. this.button2.Name = "button2";
  909. this.button2.Size = new System.Drawing.Size(91, 24);
  910. this.button2.TabIndex = 1;
  911. this.button2.UseVisualStyleBackColor = true;
  912. this.button2.Click += new System.EventHandler(this.button2_Click);
  913. //
  914. // button1
  915. //
  916. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  917. this.button1.Location = new System.Drawing.Point(694, 14);
  918. this.button1.Name = "button1";
  919. this.button1.Size = new System.Drawing.Size(91, 24);
  920. this.button1.TabIndex = 0;
  921. this.button1.UseVisualStyleBackColor = true;
  922. this.button1.Click += new System.EventHandler(this.button1_Click);
  923. //
  924. // groupBox2
  925. //
  926. this.groupBox2.Controls.Add(this.button4);
  927. this.groupBox2.Controls.Add(this.button3);
  928. this.groupBox2.Location = new System.Drawing.Point(12, 359);
  929. this.groupBox2.Name = "groupBox2";
  930. this.groupBox2.Size = new System.Drawing.Size(233, 57);
  931. this.groupBox2.TabIndex = 1;
  932. this.groupBox2.TabStop = false;
  933. //
  934. // button4
  935. //
  936. this.button4.Location = new System.Drawing.Point(135, 24);
  937. this.button4.Name = "button4";
  938. this.button4.Size = new System.Drawing.Size(73, 26);
  939. this.button4.TabIndex = 3;
  940. this.button4.UseVisualStyleBackColor = true;
  941. this.button4.Click += new System.EventHandler(this.button4_Click);
  942. //
  943. // button3
  944. //
  945. this.button3.Location = new System.Drawing.Point(28, 24);
  946. this.button3.Name = "button3";
  947. this.button3.Size = new System.Drawing.Size(73, 26);
  948. this.button3.TabIndex = 2;
  949. this.button3.UseVisualStyleBackColor = true;
  950. this.button3.Click += new System.EventHandler(this.button3_Click);
  951. //
  952. // groupBox3
  953. //
  954. this.groupBox3.Controls.Add(this.button8);
  955. this.groupBox3.Controls.Add(this.button7);
  956. this.groupBox3.Controls.Add(this.button6);
  957. this.groupBox3.Controls.Add(this.button5);
  958. this.groupBox3.Location = new System.Drawing.Point(12, 420);
  959. this.groupBox3.Name = "groupBox3";
  960. this.groupBox3.Size = new System.Drawing.Size(233, 80);
  961. this.groupBox3.TabIndex = 1;
  962. this.groupBox3.TabStop = false;
  963. //
  964. // button8
  965. //
  966. this.button8.Location = new System.Drawing.Point(135, 49);
  967. this.button8.Name = "button8";
  968. this.button8.Size = new System.Drawing.Size(73, 26);
  969. this.button8.TabIndex = 7;
  970. this.button8.UseVisualStyleBackColor = true;
  971. this.button8.Click += new System.EventHandler(this.button8_Click);
  972. //
  973. // button7
  974. //
  975. this.button7.Location = new System.Drawing.Point(28, 49);
  976. this.button7.Name = "button7";
  977. this.button7.Size = new System.Drawing.Size(73, 26);
  978. this.button7.TabIndex = 6;
  979. this.button7.UseVisualStyleBackColor = true;
  980. this.button7.Click += new System.EventHandler(this.button7_Click);
  981. //
  982. // button6
  983. //
  984. this.button6.Location = new System.Drawing.Point(135, 20);
  985. this.button6.Name = "button6";
  986. this.button6.Size = new System.Drawing.Size(73, 26);
  987. this.button6.TabIndex = 5;
  988. this.button6.UseVisualStyleBackColor = true;
  989. this.button6.Click += new System.EventHandler(this.button6_Click);
  990. //
  991. // button5
  992. //
  993. this.button5.Location = new System.Drawing.Point(28, 20);
  994. this.button5.Name = "button5";
  995. this.button5.Size = new System.Drawing.Size(73, 26);
  996. this.button5.TabIndex = 4;
  997. this.button5.UseVisualStyleBackColor = true;
  998. this.button5.Click += new System.EventHandler(this.button5_Click);
  999. //
  1000. // groupBox7
  1001. //
  1002. this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  1003. | System.Windows.Forms.AnchorStyles.Left)
  1004. | System.Windows.Forms.AnchorStyles.Right)));
  1005. this.groupBox7.Location = new System.Drawing.Point(251, 63);
  1006. this.groupBox7.Name = "groupBox7";
  1007. this.groupBox7.Size = new System.Drawing.Size(569, 502);
  1008. this.groupBox7.TabIndex = 1;
  1009. this.groupBox7.TabStop = false;
  1010. //
  1011. // groupBox4
  1012. //
  1013. this.groupBox4.Controls.Add(this.panel9);
  1014. this.groupBox4.Controls.Add(this.label7);
  1015. this.groupBox4.Controls.Add(this.panel8);
  1016. this.groupBox4.Controls.Add(this.label6);
  1017. this.groupBox4.Controls.Add(this.panel7);
  1018. this.groupBox4.Controls.Add(this.label5);
  1019. this.groupBox4.Controls.Add(this.panel1);
  1020. this.groupBox4.Controls.Add(this.panel6);
  1021. this.groupBox4.Controls.Add(this.label4);
  1022. this.groupBox4.Controls.Add(this.panel5);
  1023. this.groupBox4.Controls.Add(this.label1);
  1024. this.groupBox4.Controls.Add(this.panel4);
  1025. this.groupBox4.Controls.Add(this.label3);
  1026. this.groupBox4.Controls.Add(this.panel3);
  1027. this.groupBox4.Controls.Add(this.label2);
  1028. this.groupBox4.Controls.Add(this.panel2);
  1029. this.groupBox4.Controls.Add(this.applyLabel);
  1030. this.groupBox4.Controls.Add(this.label17);
  1031. this.groupBox4.Location = new System.Drawing.Point(12, 63);
  1032. this.groupBox4.Name = "groupBox4";
  1033. this.groupBox4.Size = new System.Drawing.Size(233, 290);
  1034. this.groupBox4.TabIndex = 38;
  1035. this.groupBox4.TabStop = false;
  1036. //
  1037. // panel9
  1038. //
  1039. this.panel9.Controls.Add(this.radioButton9);
  1040. this.panel9.Controls.Add(this.radioButton11);
  1041. this.panel9.Location = new System.Drawing.Point(69, 251);
  1042. this.panel9.Name = "panel9";
  1043. this.panel9.Size = new System.Drawing.Size(134, 33);
  1044. this.panel9.TabIndex = 132;
  1045. //
  1046. // radioButton9
  1047. //
  1048. this.radioButton9.AutoSize = true;
  1049. this.radioButton9.Location = new System.Drawing.Point(66, 8);
  1050. this.radioButton9.Name = "radioButton9";
  1051. this.radioButton9.Size = new System.Drawing.Size(47, 16);
  1052. this.radioButton9.TabIndex = 129;
  1053. this.radioButton9.Text = "截距";
  1054. this.radioButton9.UseVisualStyleBackColor = true;
  1055. //
  1056. // radioButton11
  1057. //
  1058. this.radioButton11.AutoSize = true;
  1059. this.radioButton11.Checked = true;
  1060. this.radioButton11.Location = new System.Drawing.Point(16, 8);
  1061. this.radioButton11.Name = "radioButton11";
  1062. this.radioButton11.Size = new System.Drawing.Size(47, 16);
  1063. this.radioButton11.TabIndex = 128;
  1064. this.radioButton11.TabStop = true;
  1065. this.radioButton11.Text = "斜率";
  1066. this.radioButton11.UseVisualStyleBackColor = true;
  1067. //
  1068. // label7
  1069. //
  1070. this.label7.AutoSize = true;
  1071. this.label7.Location = new System.Drawing.Point(6, 261);
  1072. this.label7.Name = "label7";
  1073. this.label7.Size = new System.Drawing.Size(0, 12);
  1074. this.label7.TabIndex = 131;
  1075. //
  1076. // panel8
  1077. //
  1078. this.panel8.Controls.Add(this.trackBar3);
  1079. this.panel8.Location = new System.Drawing.Point(69, 222);
  1080. this.panel8.Name = "panel8";
  1081. this.panel8.Size = new System.Drawing.Size(156, 33);
  1082. this.panel8.TabIndex = 138;
  1083. //
  1084. // trackBar3
  1085. //
  1086. this.trackBar3.AutoSize = false;
  1087. this.trackBar3.Location = new System.Drawing.Point(8, 5);
  1088. this.trackBar3.Maximum = 20;
  1089. this.trackBar3.Minimum = 10;
  1090. this.trackBar3.Name = "trackBar3";
  1091. this.trackBar3.Size = new System.Drawing.Size(134, 22);
  1092. this.trackBar3.TabIndex = 0;
  1093. this.trackBar3.TickStyle = System.Windows.Forms.TickStyle.None;
  1094. this.trackBar3.Value = 10;
  1095. //
  1096. // label6
  1097. //
  1098. this.label6.AutoSize = true;
  1099. this.label6.Location = new System.Drawing.Point(6, 231);
  1100. this.label6.Name = "label6";
  1101. this.label6.Size = new System.Drawing.Size(0, 12);
  1102. this.label6.TabIndex = 137;
  1103. //
  1104. // panel7
  1105. //
  1106. this.panel7.Controls.Add(this.radioButton10);
  1107. this.panel7.Controls.Add(this.radioButton7);
  1108. this.panel7.Controls.Add(this.radioButton8);
  1109. this.panel7.Controls.Add(this.radioButton5);
  1110. this.panel7.Controls.Add(this.radioButton6);
  1111. this.panel7.Location = new System.Drawing.Point(69, 163);
  1112. this.panel7.Name = "panel7";
  1113. this.panel7.Size = new System.Drawing.Size(158, 63);
  1114. this.panel7.TabIndex = 132;
  1115. //
  1116. // radioButton10
  1117. //
  1118. this.radioButton10.AutoSize = true;
  1119. this.radioButton10.Location = new System.Drawing.Point(7, 42);
  1120. this.radioButton10.Name = "radioButton10";
  1121. this.radioButton10.Size = new System.Drawing.Size(71, 16);
  1122. this.radioButton10.TabIndex = 132;
  1123. this.radioButton10.Text = "线性调整";
  1124. this.radioButton10.UseVisualStyleBackColor = true;
  1125. this.radioButton10.CheckedChanged += new System.EventHandler(this.radioButton10_CheckedChanged);
  1126. //
  1127. // radioButton7
  1128. //
  1129. this.radioButton7.AutoSize = true;
  1130. this.radioButton7.Location = new System.Drawing.Point(80, 22);
  1131. this.radioButton7.Name = "radioButton7";
  1132. this.radioButton7.Size = new System.Drawing.Size(71, 16);
  1133. this.radioButton7.TabIndex = 131;
  1134. this.radioButton7.Text = "整体调亮";
  1135. this.radioButton7.UseVisualStyleBackColor = true;
  1136. this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
  1137. //
  1138. // radioButton8
  1139. //
  1140. this.radioButton8.AutoSize = true;
  1141. this.radioButton8.Location = new System.Drawing.Point(7, 22);
  1142. this.radioButton8.Name = "radioButton8";
  1143. this.radioButton8.Size = new System.Drawing.Size(71, 16);
  1144. this.radioButton8.TabIndex = 130;
  1145. this.radioButton8.Text = "整体调暗";
  1146. this.radioButton8.UseVisualStyleBackColor = true;
  1147. this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  1148. //
  1149. // radioButton5
  1150. //
  1151. this.radioButton5.AutoSize = true;
  1152. this.radioButton5.Location = new System.Drawing.Point(81, 3);
  1153. this.radioButton5.Name = "radioButton5";
  1154. this.radioButton5.Size = new System.Drawing.Size(71, 16);
  1155. this.radioButton5.TabIndex = 129;
  1156. this.radioButton5.Text = "自动调整";
  1157. this.radioButton5.UseVisualStyleBackColor = true;
  1158. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  1159. //
  1160. // radioButton6
  1161. //
  1162. this.radioButton6.AutoSize = true;
  1163. this.radioButton6.Checked = true;
  1164. this.radioButton6.Location = new System.Drawing.Point(8, 3);
  1165. this.radioButton6.Name = "radioButton6";
  1166. this.radioButton6.Size = new System.Drawing.Size(59, 16);
  1167. this.radioButton6.TabIndex = 128;
  1168. this.radioButton6.TabStop = true;
  1169. this.radioButton6.Text = "不调整";
  1170. this.radioButton6.UseVisualStyleBackColor = true;
  1171. this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
  1172. //
  1173. // label5
  1174. //
  1175. this.label5.AutoSize = true;
  1176. this.label5.Location = new System.Drawing.Point(6, 173);
  1177. this.label5.Name = "label5";
  1178. this.label5.Size = new System.Drawing.Size(0, 12);
  1179. this.label5.TabIndex = 131;
  1180. //
  1181. // panel1
  1182. //
  1183. this.panel1.BackColor = System.Drawing.Color.Red;
  1184. this.panel1.Location = new System.Drawing.Point(85, 39);
  1185. this.panel1.Name = "panel1";
  1186. this.panel1.Size = new System.Drawing.Size(72, 21);
  1187. this.panel1.TabIndex = 20;
  1188. this.panel1.Click += new System.EventHandler(this.panel1_click);
  1189. //
  1190. // panel6
  1191. //
  1192. this.panel6.Controls.Add(this.trackBar2);
  1193. this.panel6.Location = new System.Drawing.Point(69, 136);
  1194. this.panel6.Name = "panel6";
  1195. this.panel6.Size = new System.Drawing.Size(156, 33);
  1196. this.panel6.TabIndex = 136;
  1197. //
  1198. // trackBar2
  1199. //
  1200. this.trackBar2.AutoSize = false;
  1201. this.trackBar2.Location = new System.Drawing.Point(8, 5);
  1202. this.trackBar2.Maximum = 50;
  1203. this.trackBar2.Minimum = 10;
  1204. this.trackBar2.Name = "trackBar2";
  1205. this.trackBar2.Size = new System.Drawing.Size(134, 22);
  1206. this.trackBar2.TabIndex = 0;
  1207. this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None;
  1208. this.trackBar2.Value = 10;
  1209. //
  1210. // label4
  1211. //
  1212. this.label4.AutoSize = true;
  1213. this.label4.Location = new System.Drawing.Point(6, 145);
  1214. this.label4.Name = "label4";
  1215. this.label4.Size = new System.Drawing.Size(0, 12);
  1216. this.label4.TabIndex = 135;
  1217. //
  1218. // panel5
  1219. //
  1220. this.panel5.Controls.Add(this.trackBar1);
  1221. this.panel5.Location = new System.Drawing.Point(69, 109);
  1222. this.panel5.Name = "panel5";
  1223. this.panel5.Size = new System.Drawing.Size(156, 33);
  1224. this.panel5.TabIndex = 134;
  1225. //
  1226. // trackBar1
  1227. //
  1228. this.trackBar1.AutoSize = false;
  1229. this.trackBar1.Location = new System.Drawing.Point(8, 5);
  1230. this.trackBar1.Maximum = 40;
  1231. this.trackBar1.Minimum = 10;
  1232. this.trackBar1.Name = "trackBar1";
  1233. this.trackBar1.Size = new System.Drawing.Size(134, 22);
  1234. this.trackBar1.TabIndex = 0;
  1235. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  1236. this.trackBar1.Value = 30;
  1237. //
  1238. // label1
  1239. //
  1240. this.label1.AutoSize = true;
  1241. this.label1.Location = new System.Drawing.Point(6, 118);
  1242. this.label1.Name = "label1";
  1243. this.label1.Size = new System.Drawing.Size(0, 12);
  1244. this.label1.TabIndex = 133;
  1245. //
  1246. // panel4
  1247. //
  1248. this.panel4.Controls.Add(this.radioButton3);
  1249. this.panel4.Controls.Add(this.radioButton4);
  1250. this.panel4.Location = new System.Drawing.Point(69, 82);
  1251. this.panel4.Name = "panel4";
  1252. this.panel4.Size = new System.Drawing.Size(156, 33);
  1253. this.panel4.TabIndex = 132;
  1254. //
  1255. // radioButton3
  1256. //
  1257. this.radioButton3.AutoSize = true;
  1258. this.radioButton3.Location = new System.Drawing.Point(83, 8);
  1259. this.radioButton3.Name = "radioButton3";
  1260. this.radioButton3.Size = new System.Drawing.Size(59, 16);
  1261. this.radioButton3.TabIndex = 129;
  1262. this.radioButton3.Text = "亮晶界";
  1263. this.radioButton3.UseVisualStyleBackColor = true;
  1264. //
  1265. // radioButton4
  1266. //
  1267. this.radioButton4.AutoSize = true;
  1268. this.radioButton4.Checked = true;
  1269. this.radioButton4.Location = new System.Drawing.Point(7, 8);
  1270. this.radioButton4.Name = "radioButton4";
  1271. this.radioButton4.Size = new System.Drawing.Size(59, 16);
  1272. this.radioButton4.TabIndex = 128;
  1273. this.radioButton4.TabStop = true;
  1274. this.radioButton4.Text = "暗晶界";
  1275. this.radioButton4.UseVisualStyleBackColor = true;
  1276. //
  1277. // label3
  1278. //
  1279. this.label3.AutoSize = true;
  1280. this.label3.Location = new System.Drawing.Point(6, 92);
  1281. this.label3.Name = "label3";
  1282. this.label3.Size = new System.Drawing.Size(0, 12);
  1283. this.label3.TabIndex = 131;
  1284. //
  1285. // panel3
  1286. //
  1287. this.panel3.Controls.Add(this.radioButton1);
  1288. this.panel3.Controls.Add(this.radioButton2);
  1289. this.panel3.Location = new System.Drawing.Point(69, 55);
  1290. this.panel3.Name = "panel3";
  1291. this.panel3.Size = new System.Drawing.Size(134, 33);
  1292. this.panel3.TabIndex = 132;
  1293. //
  1294. // radioButton1
  1295. //
  1296. this.radioButton1.AutoSize = true;
  1297. this.radioButton1.Location = new System.Drawing.Point(68, 8);
  1298. this.radioButton1.Name = "radioButton1";
  1299. this.radioButton1.Size = new System.Drawing.Size(29, 16);
  1300. this.radioButton1.TabIndex = 129;
  1301. this.radioButton1.Text = "2";
  1302. this.radioButton1.UseVisualStyleBackColor = true;
  1303. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  1304. //
  1305. // radioButton2
  1306. //
  1307. this.radioButton2.AutoSize = true;
  1308. this.radioButton2.Checked = true;
  1309. this.radioButton2.Location = new System.Drawing.Point(7, 8);
  1310. this.radioButton2.Name = "radioButton2";
  1311. this.radioButton2.Size = new System.Drawing.Size(29, 16);
  1312. this.radioButton2.TabIndex = 128;
  1313. this.radioButton2.TabStop = true;
  1314. this.radioButton2.Text = "1";
  1315. this.radioButton2.UseVisualStyleBackColor = true;
  1316. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  1317. //
  1318. // label2
  1319. //
  1320. this.label2.AutoSize = true;
  1321. this.label2.Location = new System.Drawing.Point(6, 65);
  1322. this.label2.Name = "label2";
  1323. this.label2.Size = new System.Drawing.Size(0, 12);
  1324. this.label2.TabIndex = 131;
  1325. //
  1326. // panel2
  1327. //
  1328. this.panel2.Controls.Add(this.applyRadioButton2);
  1329. this.panel2.Controls.Add(this.applyRadioButton1);
  1330. this.panel2.Location = new System.Drawing.Point(69, 12);
  1331. this.panel2.Name = "panel2";
  1332. this.panel2.Size = new System.Drawing.Size(134, 33);
  1333. this.panel2.TabIndex = 130;
  1334. //
  1335. // applyRadioButton2
  1336. //
  1337. this.applyRadioButton2.AutoSize = true;
  1338. this.applyRadioButton2.Location = new System.Drawing.Point(68, 8);
  1339. this.applyRadioButton2.Name = "applyRadioButton2";
  1340. this.applyRadioButton2.Size = new System.Drawing.Size(35, 16);
  1341. this.applyRadioButton2.TabIndex = 129;
  1342. this.applyRadioButton2.Text = "否";
  1343. this.applyRadioButton2.UseVisualStyleBackColor = true;
  1344. //
  1345. // applyRadioButton1
  1346. //
  1347. this.applyRadioButton1.AutoSize = true;
  1348. this.applyRadioButton1.Checked = true;
  1349. this.applyRadioButton1.Location = new System.Drawing.Point(7, 8);
  1350. this.applyRadioButton1.Name = "applyRadioButton1";
  1351. this.applyRadioButton1.Size = new System.Drawing.Size(35, 16);
  1352. this.applyRadioButton1.TabIndex = 128;
  1353. this.applyRadioButton1.TabStop = true;
  1354. this.applyRadioButton1.Text = "是";
  1355. this.applyRadioButton1.UseVisualStyleBackColor = true;
  1356. //
  1357. // applyLabel
  1358. //
  1359. this.applyLabel.AutoSize = true;
  1360. this.applyLabel.Location = new System.Drawing.Point(6, 22);
  1361. this.applyLabel.Name = "applyLabel";
  1362. this.applyLabel.Size = new System.Drawing.Size(0, 12);
  1363. this.applyLabel.TabIndex = 127;
  1364. //
  1365. // label17
  1366. //
  1367. this.label17.AutoSize = true;
  1368. this.label17.Location = new System.Drawing.Point(6, 43);
  1369. this.label17.Name = "label17";
  1370. this.label17.Size = new System.Drawing.Size(0, 12);
  1371. this.label17.TabIndex = 124;
  1372. //
  1373. // itemsGroupBox
  1374. //
  1375. this.itemsGroupBox.Controls.Add(this.undoButton);
  1376. this.itemsGroupBox.Controls.Add(this.redoButton);
  1377. this.itemsGroupBox.Controls.Add(this.resetButton);
  1378. this.itemsGroupBox.Location = new System.Drawing.Point(12, 506);
  1379. this.itemsGroupBox.Name = "itemsGroupBox";
  1380. this.itemsGroupBox.Size = new System.Drawing.Size(233, 59);
  1381. this.itemsGroupBox.TabIndex = 39;
  1382. this.itemsGroupBox.TabStop = false;
  1383. this.itemsGroupBox.Text = "操作";
  1384. //
  1385. // undoButton
  1386. //
  1387. this.undoButton.Location = new System.Drawing.Point(156, 23);
  1388. this.undoButton.Name = "undoButton";
  1389. this.undoButton.Size = new System.Drawing.Size(64, 26);
  1390. this.undoButton.TabIndex = 10;
  1391. this.undoButton.UseVisualStyleBackColor = true;
  1392. this.undoButton.Click += new System.EventHandler(this.undoButton_Click);
  1393. //
  1394. // redoButton
  1395. //
  1396. this.redoButton.Location = new System.Drawing.Point(86, 23);
  1397. this.redoButton.Name = "redoButton";
  1398. this.redoButton.Size = new System.Drawing.Size(64, 26);
  1399. this.redoButton.TabIndex = 9;
  1400. this.redoButton.UseVisualStyleBackColor = true;
  1401. this.redoButton.Click += new System.EventHandler(this.redoButton_Click);
  1402. //
  1403. // resetButton
  1404. //
  1405. this.resetButton.Location = new System.Drawing.Point(16, 23);
  1406. this.resetButton.Name = "resetButton";
  1407. this.resetButton.Size = new System.Drawing.Size(64, 26);
  1408. this.resetButton.TabIndex = 8;
  1409. this.resetButton.UseVisualStyleBackColor = true;
  1410. this.resetButton.Click += new System.EventHandler(this.resetButton_Click);
  1411. //
  1412. // GrainBoundaryEditingDialog
  1413. //
  1414. this.ClientSize = new System.Drawing.Size(832, 577);
  1415. this.Controls.Add(this.itemsGroupBox);
  1416. this.Controls.Add(this.groupBox4);
  1417. this.Controls.Add(this.groupBox2);
  1418. this.Controls.Add(this.groupBox3);
  1419. this.Controls.Add(this.groupBox7);
  1420. this.Controls.Add(this.groupBox1);
  1421. this.MaximizeBox = false;
  1422. this.MinimizeBox = false;
  1423. this.MinimumSize = new System.Drawing.Size(848, 616);
  1424. this.Name = "GrainBoundaryEditingDialog";
  1425. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainBoundryEditingDialog_FormClosing);
  1426. this.Load += new System.EventHandler(this.GrainBoundryEditingDialog_Load);
  1427. this.groupBox1.ResumeLayout(false);
  1428. this.groupBox2.ResumeLayout(false);
  1429. this.groupBox3.ResumeLayout(false);
  1430. this.groupBox4.ResumeLayout(false);
  1431. this.groupBox4.PerformLayout();
  1432. this.panel9.ResumeLayout(false);
  1433. this.panel9.PerformLayout();
  1434. this.panel8.ResumeLayout(false);
  1435. ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();
  1436. this.panel7.ResumeLayout(false);
  1437. this.panel7.PerformLayout();
  1438. this.panel6.ResumeLayout(false);
  1439. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
  1440. this.panel5.ResumeLayout(false);
  1441. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  1442. this.panel4.ResumeLayout(false);
  1443. this.panel4.PerformLayout();
  1444. this.panel3.ResumeLayout(false);
  1445. this.panel3.PerformLayout();
  1446. this.panel2.ResumeLayout(false);
  1447. this.panel2.PerformLayout();
  1448. this.itemsGroupBox.ResumeLayout(false);
  1449. this.ResumeLayout(false);
  1450. }
  1451. /// <summary>
  1452. /// 折线添加
  1453. /// </summary>
  1454. /// <param name="sender"></param>
  1455. /// <param name="e"></param>
  1456. private void button3_Click(object sender, EventArgs e)
  1457. {
  1458. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1459. {
  1460. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1461. return;
  1462. }
  1463. pointFloatArray.Clear();
  1464. startPoint = new Point(-1, -1);
  1465. drawedStartPoint = false;
  1466. endPoint = new Point(-1, -1);
  1467. pointKtype = 1;
  1468. this.documentWorkspace.Refresh();
  1469. }
  1470. /// <summary>
  1471. /// 直线添加
  1472. /// </summary>
  1473. /// <param name="sender"></param>
  1474. /// <param name="e"></param>
  1475. private void button4_Click(object sender, EventArgs e)
  1476. {
  1477. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1478. {
  1479. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1480. return;
  1481. }
  1482. startPoint = new Point(-1, -1);
  1483. drawedStartPoint = false;
  1484. endPoint = new Point(-1, -1);
  1485. pointKtype = 2;
  1486. this.documentWorkspace.Refresh();
  1487. }
  1488. private void InitCommonButtonEvent()
  1489. {
  1490. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1491. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1492. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1493. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1494. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1495. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1496. }
  1497. private void zoomInButton_Click(object sender, EventArgs e)
  1498. {
  1499. this.documentWorkspace.ZoomIn();
  1500. }
  1501. private void zoomOutButton_Click(object sender, EventArgs e)
  1502. {
  1503. this.documentWorkspace.ZoomOut();
  1504. }
  1505. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1506. {
  1507. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1508. }
  1509. private void actualSizeButton_Click(object sender, EventArgs e)
  1510. {
  1511. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1512. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1513. }
  1514. private void pointerButton_Click(object sender, EventArgs e)
  1515. {
  1516. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  1517. this.documentWorkspace.Cursor = Cursors.Default;
  1518. }
  1519. private void mobileModeButton_Click(object sender, EventArgs e)
  1520. {
  1521. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1522. }
  1523. //确定按钮点击事件
  1524. private void button1_Click(object sender, EventArgs e)
  1525. {
  1526. this.PhaseMat = this.documentWorkspace.PhaseModels[0].mat;
  1527. this.DialogResult = DialogResult.OK;
  1528. this.Close();
  1529. }
  1530. /// <summary>
  1531. /// 用于get处理后的图像
  1532. /// </summary>
  1533. public Mat PhaseMat
  1534. {
  1535. get
  1536. {
  1537. return this.phaseMat;
  1538. }
  1539. set
  1540. {
  1541. this.phaseMat = value;
  1542. }
  1543. }
  1544. /// <summary>
  1545. /// 用于get处理后的图像相的颜色
  1546. /// </summary>
  1547. public Color PhaseColor
  1548. {
  1549. get
  1550. {
  1551. return this.phaseColor;
  1552. }
  1553. set
  1554. {
  1555. this.phaseColor = value;
  1556. }
  1557. }
  1558. /// <summary>
  1559. /// 矩形删除
  1560. /// </summary>
  1561. /// <param name="sender"></param>
  1562. /// <param name="e"></param>
  1563. private void button7_Click(object sender, EventArgs e)
  1564. {
  1565. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1566. {
  1567. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1568. return;
  1569. }
  1570. startPoint = new Point(-1, -1);
  1571. drawedStartPoint = false;
  1572. endPoint = new Point(-1, -1);
  1573. this.rectangle.X = -1;
  1574. this.rectangle.Y = -1;
  1575. this.rectangle.Width = 0;
  1576. this.rectangle.Height = 0;
  1577. this.pointKtype = 13;
  1578. this.documentWorkspace.Refresh();
  1579. }
  1580. /// <summary>
  1581. /// 椭圆删除
  1582. /// </summary>
  1583. /// <param name="sender"></param>
  1584. /// <param name="e"></param>
  1585. private void button8_Click(object sender, EventArgs e)
  1586. {
  1587. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1588. {
  1589. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1590. return;
  1591. }
  1592. startPoint = new Point(-1, -1);
  1593. drawedStartPoint = false;
  1594. endPoint = new Point(-1, -1);
  1595. this.rectangle.X = -1;
  1596. this.rectangle.Y = -1;
  1597. this.rectangle.Width = 0;
  1598. this.rectangle.Height = 0;
  1599. this.pointKtype = 14;
  1600. this.documentWorkspace.Refresh();
  1601. }
  1602. /// <summary>
  1603. /// 圆形删除
  1604. /// </summary>
  1605. /// <param name="sender"></param>
  1606. /// <param name="e"></param>
  1607. private void button6_Click(object sender, EventArgs e)
  1608. {
  1609. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1610. {
  1611. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1612. return;
  1613. }
  1614. startPoint = new Point(-1, -1);
  1615. drawedStartPoint = false;
  1616. endPoint = new Point(-1, -1);
  1617. this.rectangle.X = -1;
  1618. this.rectangle.Y = -1;
  1619. this.rectangle.Width = 0;
  1620. this.rectangle.Height = 0;
  1621. this.pointKtype = 12;
  1622. this.documentWorkspace.Refresh();
  1623. }
  1624. /// <summary>
  1625. /// 多边形删除
  1626. /// </summary>
  1627. /// <param name="sender"></param>
  1628. /// <param name="e"></param>
  1629. private void button5_Click(object sender, EventArgs e)
  1630. {
  1631. if (this.documentWorkspace.PhaseModels[0].mat == null)
  1632. {
  1633. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  1634. return;
  1635. }
  1636. pointFloatArray.Clear();
  1637. startPoint = new Point(-1, -1);
  1638. drawedStartPoint = false;
  1639. endPoint = new Point(-1, -1);
  1640. this.rectangle.X = -1;
  1641. this.rectangle.Y = -1;
  1642. this.rectangle.Width = 0;
  1643. this.rectangle.Height = 0;
  1644. this.pointKtype = 11;
  1645. this.documentWorkspace.Refresh();
  1646. }
  1647. private void button2_Click(object sender, EventArgs e)
  1648. {
  1649. this.applyDect();
  1650. //this.Close();//##################################
  1651. }
  1652. /// <summary>
  1653. /// 撤销按钮点击事件
  1654. /// </summary>
  1655. /// <param name="sender"></param>
  1656. /// <param name="e"></param>
  1657. private void button9_Click(object sender, EventArgs e)
  1658. {
  1659. }
  1660. #region 晶界重现方法
  1661. ProgressThreadProcClass procClass;
  1662. int grainApplygrainboundaries;
  1663. int adOutParam0;
  1664. int adOutParam1;
  1665. double adOutParam2;// = 3;
  1666. double adOutParam3;
  1667. int adOutParam4;
  1668. double adOutParam5;
  1669. int adOutParam6;
  1670. Mat OrgImg0;
  1671. private int getAdOutParam4Value()
  1672. {
  1673. int adOutParam = 0;
  1674. if (this.radioButton6.Checked) adOutParam = 0;
  1675. else if (this.radioButton5.Checked) adOutParam = 1;
  1676. else if (this.radioButton8.Checked) adOutParam = 2;
  1677. else if (this.radioButton7.Checked) adOutParam = 3;
  1678. else if (this.radioButton10.Checked) adOutParam = 4;
  1679. return adOutParam;
  1680. }
  1681. private void applyDect()
  1682. {
  1683. if (this.imageMat == null)
  1684. {
  1685. return;
  1686. }
  1687. //string inputImageFile = "原始图片1.jpg";// "j1.JPG";
  1688. ////char[] inputImageFile2 = inputImageFile.ToCharArray();
  1689. grainApplygrainboundaries = this.applyRadioButton1.Checked ? 1 : 0;
  1690. adOutParam0 = this.radioButton1/*checkBox3*/.Checked ? 2 : 1;
  1691. adOutParam1 = this.radioButton3.Checked ? 2 : 0;
  1692. adOutParam2 = this.trackBar1.Value / 10.0;
  1693. adOutParam3 = this.trackBar2.Value / 10.0;
  1694. adOutParam4 = this.getAdOutParam4Value();
  1695. adOutParam5 = this.trackBar3.Value / 10.0;
  1696. adOutParam6 = this.radioButton11.Checked ? 0 : 1;
  1697. /*int */
  1698. //dark = this.comboBox2.SelectedIndex;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
  1699. /*int */
  1700. //smooth_type = this.comboBox3.SelectedIndex;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
  1701. /*double[] */
  1702. //cell_size = new double[2] { (double)numericUpDown1.Value, (double)numericUpDown2.Value }; ;// new double[2] { 0.01, 500 };//晶界大小
  1703. procClass = new ProgressThreadProcClass();
  1704. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
  1705. //if (isOtherGrainSizeStandardDialog)
  1706. //{
  1707. // if (OrgImg0 != null)
  1708. // {
  1709. // this.documentWorkspace.PhaseModels[1].mat = OrgImg0.Clone();
  1710. // this.documentWorkspace.Refresh();
  1711. // OrgImg0 = null;
  1712. // }
  1713. // if (OrgImg != null)
  1714. // {
  1715. // OrgImg.Dispose();
  1716. // OrgImg = null;
  1717. // }
  1718. // return;//##
  1719. //}
  1720. if (OrgImg0 != null)
  1721. {
  1722. if (getCurrentWorkspace().GraphicsList.IsExsitView() && ShowDrawClassView)
  1723. {
  1724. Vec4b vec4 = new Vec4b(0, 0, 0, 0);
  1725. //视场图像
  1726. Mat exsitViewMatOrg = PaintDotNet.Camera.Tools.ToMat(getCurrentWorkspace().GetFullSizeWithRegion());
  1727. for (int y = 0; y < exsitViewMatOrg/*temp*/.Rows; y++)
  1728. {
  1729. for (int x = 0; x < exsitViewMatOrg/*temp*/.Cols; x++)
  1730. {
  1731. if (exsitViewMatOrg.At<Vec4b>(y, x).Item3 == 0)
  1732. OrgImg0.Set(y, x, vec4);//不在视场图像范围内
  1733. }
  1734. }
  1735. }
  1736. this.documentWorkspace.PhaseModels[0].mat = OrgImg0.Clone();
  1737. this.documentWorkspace.Refresh();
  1738. if (PhaseModel0MatCopy != null)
  1739. {
  1740. PhaseModel0MatCopy.Dispose();
  1741. PhaseModel0MatCopy = null;
  1742. }
  1743. PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
  1744. this.resetOperationsAction();
  1745. OrgImg0.Dispose();//待测试
  1746. OrgImg0 = null;
  1747. }
  1748. ////this.runDect(OrgImg, dark, smooth_type, sigma, enhance, cell_size);//###########################2
  1749. //if (!isAreaType)
  1750. // AddRectangleToRectangleFCaps();//0916###18747
  1751. //else
  1752. //{
  1753. // GetClassNumberOfGrains();
  1754. //}
  1755. }
  1756. private void applyDectAction()
  1757. {
  1758. OrgImg0 = /*GrainBoundaryEditingDialog.*/runDect(this.panel1.BackColor, imageMat.Clone(), adOutParam0, adOutParam1, (int)adOutParam2, (int)adOutParam3, adOutParam4, adOutParam5, adOutParam6);
  1759. if (procClass != null) procClass.DismissProgressAction(this);
  1760. }
  1761. public static Mat runDect(Color phaseColor, Mat OrgImg0, int adOutParam0, int adOutParam1, int adOutParam2, int adOutParam3, int adOutParam4, double adOutParam5, int adOutParam6)
  1762. {
  1763. Mat GryImg = new Mat();
  1764. Mat OrgImg = new Mat();
  1765. if (4 == OrgImg0.Channels())
  1766. Cv2.CvtColor(OrgImg0, OrgImg, ColorConversionCodes.BGRA2BGR);
  1767. else
  1768. OrgImg = OrgImg0.Clone();
  1769. //转为为灰度
  1770. if (3 == OrgImg.Channels() || 4 == OrgImg.Channels())
  1771. Cv2.CvtColor(OrgImg, GryImg, ColorConversionCodes.BGR2GRAY/*RGB2GRAY*/);
  1772. else
  1773. if (1 == OrgImg.Channels())
  1774. GryImg = OrgImg.Clone();
  1775. else
  1776. return null;
  1777. //if (0 == m_iStandardImage)
  1778. {
  1779. //调用算法
  1780. OUTsegmsurf RSTss = new OLDcellsegm().mf_segmsurf_progress_auto(GryImg, phaseColor, adOutParam0, adOutParam1, adOutParam2, adOutParam3, adOutParam4, adOutParam5, adOutParam6);
  1781. Cv2.CvtColor(RSTss.wat, OrgImg0, ColorConversionCodes.BGR2BGRA);
  1782. }
  1783. //else OrgImg0/*Mat WAT*/ = new OLDcellsegm().ProFroStandardImage(GryImg, iConnect, phaseColor);
  1784. return OrgImg0;
  1785. }
  1786. private void panel1_click(object sender, EventArgs e)
  1787. {
  1788. this.panelC = (Panel)sender;
  1789. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
  1790. this.colorsFormGrid.ShowDialog();
  1791. }
  1792. #endregion
  1793. private void GrainBoundryEditingDialog_FormClosing(object sender, FormClosingEventArgs e)
  1794. {
  1795. string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  1796. bool createNewFile = !System.IO.File.Exists(xmlFilePath);
  1797. if (createNewFile)
  1798. xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel.xml";
  1799. Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
  1800. //# 保存参数
  1801. adOutParam0 = this.radioButton1.Checked ? 2 : 1;
  1802. grainBoundryDectModel.m_AdOutParam_0 = adOutParam0;
  1803. adOutParam1 = this.radioButton3.Checked ? 2 : 0;
  1804. grainBoundryDectModel.m_AdOutParam_1 = adOutParam1;
  1805. adOutParam2 = this.trackBar1.Value / 10.0;
  1806. grainBoundryDectModel.m_AdOutParam_2 = adOutParam2;
  1807. adOutParam3 = this.trackBar2.Value / 10.0;
  1808. grainBoundryDectModel.m_AdOutParam_3 = adOutParam3;
  1809. adOutParam4 = this.getAdOutParam4Value();
  1810. grainBoundryDectModel.m_AdOutParam_4 = adOutParam4;
  1811. adOutParam5 = this.trackBar3.Value / 10.0;
  1812. grainBoundryDectModel.m_AdOutParam_5 = adOutParam5;
  1813. adOutParam6 = this.radioButton11.Checked ? 0 : 1;
  1814. grainBoundryDectModel.m_AdOutParam_6 = adOutParam6;
  1815. grainBoundryDectModel.grainColor = this.phaseColor.ToArgb();
  1816. grainApplygrainboundaries = this.applyRadioButton1.Checked ? 1 : 0;
  1817. grainBoundryDectModel.grainApplygrainboundaries = grainApplygrainboundaries;
  1818. xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  1819. string userInfoXml = Base.CommTool.XmlSerializeHelper.XmlSerialize<Base.SettingModel.GrainBoundryDectModel>(grainBoundryDectModel);
  1820. Base.CommTool.FileOperationHelper.WriteStringToFile(userInfoXml, xmlFilePath, System.IO.FileMode.Create);
  1821. }
  1822. private void GrainBoundryEditingDialog_Load(object sender, EventArgs e)
  1823. {
  1824. string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
  1825. bool createNewFile = !System.IO.File.Exists(xmlFilePath);
  1826. if (createNewFile)
  1827. return;
  1828. Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer<Base.SettingModel.GrainBoundryDectModel>(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
  1829. this.phaseColor = Color.FromArgb(grainBoundryDectModel.grainColor == 0 ? Color.Red.ToArgb() : grainBoundryDectModel.grainColor);
  1830. this.panel1.BackColor = this.phaseColor;
  1831. //# 读取参数
  1832. adOutParam0 = grainBoundryDectModel.m_AdOutParam_0;
  1833. this.radioButton1.Checked = (adOutParam0 == 2);
  1834. adOutParam1 = grainBoundryDectModel.m_AdOutParam_1;
  1835. this.radioButton3.Checked = (adOutParam1 == 2);
  1836. adOutParam2 = grainBoundryDectModel.m_AdOutParam_2;
  1837. this.trackBar1.Value = (int)(adOutParam2 * 10.0);
  1838. adOutParam3 = grainBoundryDectModel.m_AdOutParam_3;
  1839. this.trackBar2.Value = (int)(adOutParam3 * 10.0);
  1840. adOutParam4 = grainBoundryDectModel.m_AdOutParam_4;
  1841. int adOutParam = adOutParam4;
  1842. switch (adOutParam)
  1843. {
  1844. case 0:
  1845. this.radioButton6.Checked = true;
  1846. break;
  1847. case 1:
  1848. this.radioButton5.Checked = true;
  1849. break;
  1850. case 2:
  1851. this.radioButton8.Checked = true;
  1852. break;
  1853. case 3:
  1854. this.radioButton7.Checked = true;
  1855. break;
  1856. case 4:
  1857. this.radioButton10.Checked = true;
  1858. break;
  1859. default:
  1860. break;
  1861. }
  1862. adOutParam5 = grainBoundryDectModel.m_AdOutParam_5;
  1863. this.trackBar3.Value = (int)(adOutParam5 * 10.0);
  1864. adOutParam6 = grainBoundryDectModel.m_AdOutParam_6;
  1865. this.radioButton11.Checked = (adOutParam6 == 0);
  1866. this.radioButton9.Checked = (adOutParam6 == 1);
  1867. this.refreshRadioStatus();
  1868. grainApplygrainboundaries = grainBoundryDectModel.grainApplygrainboundaries;
  1869. this.applyRadioButton1.Checked = (grainApplygrainboundaries == 1);
  1870. this.applyRadioButton2.Checked = (grainApplygrainboundaries != 1);
  1871. }
  1872. /// <summary>
  1873. /// 根据当前操作位置处理图片,并刷新操作按钮状态
  1874. /// </summary>
  1875. /// <param name="OperationTag"></param>
  1876. private void RefreshMatsToIndex(int OperationTag)
  1877. {
  1878. //...处理图片(this.OperationIndex)
  1879. this.OperationIndex = OperationTag;
  1880. ///// 操作类型
  1881. //private int pointKtype = 0;
  1882. if (PhaseModel0MatCopy != null && this.OperationIndex >= 0)
  1883. {
  1884. Mat newModel0Mat = PhaseModel0MatCopy.Clone();
  1885. for (int i = 0; i <= this.OperationIndex; i++)
  1886. {
  1887. //操作类型 0,没有操作 1,折线添加 2,直线添加 11,多边形删除 12,圆形删除 13,矩形删除 14,椭圆删除
  1888. int opeType = this.OperationKtypeList[i];
  1889. PointF[] opePoints = this.OperationsList[i];
  1890. // 折线删除
  1891. if (opeType == 11 && opePoints.Length > 1)
  1892. {
  1893. newModel0Mat/*this.documentWorkspace.PhaseModels[0].mat*/ = PreActionIntent.PolygonDelete(newModel0Mat/*this.documentWorkspace.PhaseModels[0].mat*/, opePoints.ToList()/*pointFloatArray*/);
  1894. //this.pointKtype = 0;
  1895. //this.documentWorkspace.Refresh();
  1896. }
  1897. // 折线添加
  1898. if (opeType == 1 && opePoints.Length > 1)
  1899. {
  1900. //保存处理后的图片
  1901. Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(newModel0Mat);
  1902. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1903. Graphics graphics = Graphics.FromImage(newBit);
  1904. //Draw(graphics, false);
  1905. // 抗锯齿
  1906. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  1907. // 折线添加
  1908. if (opeType == 1 && opePoints.Length >= 2)
  1909. {
  1910. Pen pen = new Pen(this.phaseColor, 1);
  1911. graphics.DrawLines(pen, opePoints);
  1912. pen.Dispose();
  1913. }
  1914. newModel0Mat = PaintDotNet.Camera.Tools.ToMat(newBit);
  1915. }
  1916. // 圆形删除/椭圆删除
  1917. if ((opeType == 14 || opeType == 12) && opePoints.Length == 2)
  1918. {
  1919. RectangleF rectangleFOpe = new RectangleF(opePoints[0].X, opePoints[0].Y, opePoints[1].X, opePoints[1].Y);
  1920. if (this.pointKtype == 14)
  1921. newModel0Mat = PreActionIntent.OvalDelete(newModel0Mat, rectangleFOpe);
  1922. else
  1923. newModel0Mat = PreActionIntent.OvalDelete(newModel0Mat, rectangleFOpe);
  1924. }
  1925. // 矩形删除
  1926. if (opeType == 13 && opePoints.Length == 2)
  1927. {
  1928. RectangleF rectangleFOpe = new RectangleF(opePoints[0].X, opePoints[0].Y, opePoints[1].X, opePoints[1].Y);
  1929. newModel0Mat = PreActionIntent.RectangleDelete(newModel0Mat, rectangleFOpe);
  1930. }
  1931. // 直线添加
  1932. if (opeType == 2 && opePoints.Length == 2/*this.startPoint.X > -1 && this.startPoint.Y > -1*/)
  1933. {
  1934. //保存处理后的图片
  1935. Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(newModel0Mat);
  1936. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1937. Graphics graphics = Graphics.FromImage(newBit);
  1938. //Draw(graphics, false);
  1939. // 抗锯齿
  1940. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  1941. // 直线添加
  1942. if (opeType == 2 && opePoints.Length == 2/*this.startPoint.X > -1 && this.startPoint.Y > -1 && this.endPoint.X > -1 && this.endPoint.Y > -1*/)
  1943. {
  1944. Pen pen = new Pen(this.phaseColor, 1);
  1945. graphics.DrawLine(pen, opePoints[0].X, opePoints[0].Y, opePoints[1].X, opePoints[1].Y);
  1946. //////pen.DashStyle = DashStyle.Dash;
  1947. //g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
  1948. pen.Dispose();
  1949. }
  1950. newModel0Mat = PaintDotNet.Camera.Tools.ToMat(newBit);
  1951. }
  1952. }
  1953. this.documentWorkspace.PhaseModels[0].mat = newModel0Mat;
  1954. this.documentWorkspace.Refresh();
  1955. }
  1956. else if (PhaseModel0MatCopy != null)
  1957. {
  1958. this.documentWorkspace.PhaseModels[0].mat = PhaseModel0MatCopy.Clone();
  1959. this.documentWorkspace.Refresh();
  1960. }
  1961. //刷新操作按钮的状态
  1962. this.RefreshOperationsButtons();
  1963. }
  1964. /// <summary>
  1965. /// 操作-重置
  1966. /// </summary>
  1967. private void resetOperationsAction()
  1968. {
  1969. this.OperationIndex = -1;
  1970. this.RefreshOperationsToIndex();
  1971. this.RefreshOperationsButtons();
  1972. }
  1973. /// <summary>
  1974. /// 操作-重置
  1975. /// </summary>
  1976. /// <param name="sender"></param>
  1977. /// <param name="e"></param>
  1978. private void resetButton_Click(object sender, EventArgs e)
  1979. {
  1980. if (PhaseModel0MatCopy != null)
  1981. {
  1982. this.documentWorkspace.PhaseModels[0].mat = PhaseModel0MatCopy.Clone();
  1983. this.documentWorkspace.Refresh();
  1984. }
  1985. this.resetOperationsAction();
  1986. }
  1987. /// <summary>
  1988. /// 操作-撤销
  1989. /// </summary>
  1990. /// <param name="sender"></param>
  1991. /// <param name="e"></param>
  1992. private void undoButton_Click(object sender, EventArgs e)
  1993. {
  1994. if (this.OperationIndex >= 0)
  1995. {
  1996. this.RefreshMatsToIndex(this.OperationIndex - 1);
  1997. }
  1998. else
  1999. this.undoButton.Enabled = false;
  2000. }
  2001. /// <summary>
  2002. /// 操作-恢复
  2003. /// </summary>
  2004. /// <param name="sender"></param>
  2005. /// <param name="e"></param>
  2006. private void redoButton_Click(object sender, EventArgs e)
  2007. {
  2008. if (this.OperationIndex < this.OperationKtypeList.Count - 1)
  2009. {
  2010. this.RefreshMatsToIndex(this.OperationIndex + 1);
  2011. }
  2012. else
  2013. this.redoButton.Enabled = false;
  2014. }
  2015. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  2016. {
  2017. if (radioButton1.Checked)
  2018. {
  2019. this.label3.Enabled = false;
  2020. this.radioButton3.Enabled = false;
  2021. this.radioButton4.Enabled = false;
  2022. this.label1.Enabled = false;
  2023. this.trackBar1.Enabled = false;
  2024. this.label4.Enabled = false;
  2025. this.trackBar2.Enabled = false;
  2026. this.label5.Enabled = false;
  2027. this.radioButton6.Enabled = false;
  2028. this.radioButton5.Enabled = false;
  2029. this.radioButton8.Enabled = false;
  2030. this.radioButton7.Enabled = false;
  2031. this.radioButton10.Enabled = false;
  2032. this.label6.Enabled = false;
  2033. this.trackBar3.Enabled = false;
  2034. this.label7.Enabled = false;
  2035. this.radioButton11.Enabled = false;
  2036. this.radioButton9.Enabled = false;
  2037. }
  2038. }
  2039. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  2040. {
  2041. if (radioButton2.Checked)
  2042. {
  2043. this.label3.Enabled = true;
  2044. this.radioButton3.Enabled = true;
  2045. this.radioButton4.Enabled = true;
  2046. this.label1.Enabled = true;
  2047. this.trackBar1.Enabled = true;
  2048. this.label4.Enabled = true;
  2049. this.trackBar2.Enabled = true;
  2050. this.label5.Enabled = true;
  2051. this.radioButton6.Enabled = true;
  2052. this.radioButton5.Enabled = true;
  2053. this.radioButton8.Enabled = true;
  2054. this.radioButton7.Enabled = true;
  2055. this.radioButton10.Enabled = true;
  2056. this.refreshRadioStatus();
  2057. }
  2058. }
  2059. private void refreshRadioStatus()
  2060. {
  2061. if (radioButton6.Checked)
  2062. {
  2063. this.label6.Enabled = false;
  2064. this.trackBar3.Enabled = false;
  2065. this.label7.Enabled = false;
  2066. this.radioButton11.Enabled = false;
  2067. this.radioButton9.Enabled = false;
  2068. }
  2069. else if (radioButton5.Checked)
  2070. {
  2071. this.label6.Enabled = false;
  2072. this.trackBar3.Enabled = false;
  2073. this.label7.Enabled = false;
  2074. this.radioButton11.Enabled = false;
  2075. this.radioButton9.Enabled = false;
  2076. }
  2077. else if (radioButton8.Checked)
  2078. {
  2079. this.label6.Enabled = true;
  2080. this.trackBar3.Enabled = true;
  2081. this.label7.Enabled = false;
  2082. this.radioButton11.Enabled = false;
  2083. this.radioButton9.Enabled = false;
  2084. }
  2085. else if (radioButton7.Checked)
  2086. {
  2087. this.label6.Enabled = true;
  2088. this.trackBar3.Enabled = true;
  2089. this.label7.Enabled = false;
  2090. this.radioButton11.Enabled = false;
  2091. this.radioButton9.Enabled = false;
  2092. }
  2093. else if (radioButton10.Checked)
  2094. {
  2095. this.label6.Enabled = false;
  2096. this.trackBar3.Enabled = false;
  2097. this.label7.Enabled = true;
  2098. this.radioButton11.Enabled = true;
  2099. this.radioButton9.Enabled = true;
  2100. }
  2101. }
  2102. private void radioButton6_CheckedChanged(object sender, EventArgs e)
  2103. {
  2104. this.refreshRadioStatus();
  2105. }
  2106. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  2107. {
  2108. this.refreshRadioStatus();
  2109. }
  2110. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  2111. {
  2112. this.refreshRadioStatus();
  2113. }
  2114. private void radioButton7_CheckedChanged(object sender, EventArgs e)
  2115. {
  2116. this.refreshRadioStatus();
  2117. }
  2118. private void radioButton10_CheckedChanged(object sender, EventArgs e)
  2119. {
  2120. this.refreshRadioStatus();
  2121. }
  2122. }
  2123. }