GrainSizeCutOffPointMethodDialog.cs 125 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868
  1. using OpenCvSharp;
  2. using PaintDotNet.Base.CommTool;
  3. using PaintDotNet.Base.SettingModel;
  4. using PaintDotNet.DedicatedAnalysis.GrainSize.GBT6394_2017;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Drawing;
  10. using System.Drawing.Drawing2D;
  11. using System.IO;
  12. using System.Windows.Forms;
  13. using Point = System.Drawing.Point;
  14. using PaintDotNet.Base.Functionodel;
  15. using PaintDotNet.Base.Enum;
  16. using PaintDotNet.Annotation.Enum;
  17. using PaintDotNet.CustomControl;
  18. using Application = System.Windows.Forms.Application;
  19. using GroupBox = System.Windows.Forms.GroupBox;
  20. using CheckBox = System.Windows.Forms.CheckBox;
  21. using Button = System.Windows.Forms.Button;
  22. using Label = System.Windows.Forms.Label;
  23. using TextBox = System.Windows.Forms.TextBox;
  24. using System.Data;
  25. using PaintDotNet.DbOpreate.DbModel;
  26. using PaintDotNet.Annotation;
  27. namespace PaintDotNet.DedicatedAnalysis.GrainSize
  28. {
  29. internal class GrainSizeCutOffPointMethodDialog : PdnBaseForm
  30. {
  31. /// <summary>
  32. /// 晶粒度(截点法)
  33. /// </summary>
  34. #region 控件
  35. private GroupBox groupBox1;
  36. private Button button2;
  37. private CheckBox checkBox2_0;
  38. private GroupBox groupBox2;
  39. private ListView listView1;
  40. private Button button10;
  41. private Button button9;
  42. private GroupBox groupBox8;
  43. private NumericUpDown numericUpDown1_0;
  44. private Button button16;
  45. private Label label5;
  46. private Button button14;
  47. private Button button13;
  48. private DataGridView dataGridView2;
  49. private Button button12;
  50. private Button button11;
  51. private Label label4;
  52. private Label label3;
  53. private GroupBox groupBox7;
  54. private GroupBox groupBox3;
  55. private GroupBox groupBox10;
  56. private GroupBox groupBox11;
  57. private ComboBox comboBox1;
  58. private Button button6_0;
  59. private Button button8;
  60. private Button button7_0;
  61. private CheckBox checkBox5_0;
  62. private CheckBox checkBox4_0;
  63. private CheckBox checkBox3_0;
  64. private ImageList imageList1;
  65. private IContainer components;
  66. private Button button1;
  67. #endregion
  68. /// <summary>
  69. /// 主控件
  70. /// </summary>
  71. private AppWorkspace appWorkspace;
  72. /// <summary>
  73. /// 0,GBT6394; 1,GBT4335; 2,GBT24177; 3,E112; 4,ISO643
  74. /// </summary>
  75. int gbtType;
  76. #region 生成报告相关
  77. //1013###19377 刘虎--晶粒度--结果位置增加平均截距的显示,修改网格长度为实际长度
  78. //分析结果列表的头标题
  79. /// <summary>
  80. /// PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text")
  81. /// </summary>
  82. List<string> contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text") };
  83. /// <summary>
  84. /// 保存用于生成报告的图片
  85. /// </summary>
  86. private List<Bitmap> bitList;
  87. /// <summary>
  88. /// 储存点击保存结果后的所有原图与分析图
  89. /// </summary>
  90. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  91. /// <summary>
  92. /// 中间数据
  93. /// </summary>
  94. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  95. #endregion
  96. //截点样式集成
  97. GrainPointStyleClass styleClass = new GrainPointStyleClass();
  98. //辅助线集成
  99. GrainSizeGuideClass guideClass = new GrainSizeGuideClass();
  100. /// <summary>
  101. /// 图形位置
  102. /// </summary>
  103. private PointF loctation;
  104. //二值化集成1
  105. BinaryClass binaryClass;
  106. /// <summary>
  107. /// 调色板
  108. /// </summary>
  109. private ColorsForm colorsFormGrid;
  110. /// <summary>
  111. /// 选中图片的bitmap
  112. /// </summary>
  113. private Bitmap bitmap;
  114. private DocumentWorkspaceWindow documentWorkspace;
  115. /// <summary>
  116. /// 公共按钮
  117. /// </summary>
  118. private CommonControlButtons commonControlButtons;
  119. /// <summary>
  120. /// 图形上所有的点
  121. /// </summary>
  122. private List<PointF> linePointList = new List<PointF>();
  123. /// <summary>
  124. /// 是否选择了图片
  125. /// </summary>
  126. private bool selectPicture = false;
  127. /// <summary>
  128. /// 存在视场标记
  129. /// </summary>
  130. private bool existViewFlag = false;
  131. /// <summary>
  132. /// 当前选择的图片
  133. /// </summary>
  134. private Mat matOrg;
  135. /// <summary>
  136. /// 分析结果暂存
  137. /// </summary>
  138. private List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
  139. /// <summary>
  140. /// 全部显示
  141. /// </summary>
  142. private bool allShow = false;
  143. private PointF m_StartPoint = Point.Empty;
  144. private bool m_canMove;
  145. private DataGridViewTextBoxColumn Column1;
  146. private DataGridViewTextBoxColumn Column2;
  147. private DataGridViewTextBoxColumn Column3;
  148. private DataGridViewTextBoxColumn Column4;
  149. private DataGridViewTextBoxColumn Column5;
  150. private DataGridViewTextBoxColumn Column6;
  151. private ListView listView2;
  152. private GroupBox groupBox4;
  153. private CheckBox grainBoundryCheckBox;
  154. private ComboBox comboBox2;
  155. private Label label1;
  156. private ComboBox comboBox3;
  157. private Label label6;
  158. private Label label7;
  159. private TextBox textBox6;
  160. private CheckBox checkBox2;
  161. private Label label8;
  162. private NumericUpDown numericUpDown2;
  163. private NumericUpDown numericUpDown1;
  164. private Button button3;
  165. private Panel panel1;
  166. private Button button5;
  167. private BinaryControl bc;
  168. public bool comboboxChange = true;
  169. /// <summary>
  170. ///
  171. /// </summary>
  172. /// <param name="appWorkspace"></param>
  173. /// <param name="gbtType">0,GBT6394; 1,GBT4335; 2,GBT24177; 3,E112; 4,ISO643;5,YST347(XX)</param>
  174. public GrainSizeCutOffPointMethodDialog(AppWorkspace appWorkspace, int gbtType)
  175. {
  176. this.gbtType = gbtType;
  177. if (gbtType == 3 || this.gbtType == 4)
  178. contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text") };
  179. InitializeComponent();
  180. this.binaryClass = new BinaryClass();
  181. InitializeLanguageText();
  182. string dialogName = "GBT6394_2017";
  183. switch (this.gbtType)
  184. {
  185. case 1:
  186. dialogName = "GBT4335_2013";
  187. break;
  188. case 2:
  189. dialogName = "GBT24177_2009";
  190. break;
  191. case 3:
  192. dialogName = "ASTM_E112_2013";
  193. break;
  194. case 4:
  195. dialogName = "ISO643";
  196. break;
  197. default:
  198. break;
  199. }
  200. this.Text = dialogName + "("+ PdnResources.GetString("Menu.Areamethod.text")+ ")";
  201. if (this.gbtType == 3 || this.gbtType == 4)
  202. {
  203. this.Text = dialogName + "("+ PdnResources.GetString("Menu.Interceptmethod.text")+ ")";
  204. }
  205. else
  206. {
  207. if (this.gbtType == 1)
  208. this.Text = dialogName + "("+ PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Three-circleinterceptmethod.text")+ ")";
  209. else
  210. this.Text = dialogName + "("+ PdnResources.GetString("Menu.sectionmethod.text")+ ")";
  211. }
  212. this.appWorkspace = appWorkspace;
  213. this.button11.Visible = true;
  214. this.button16.Visible = false;
  215. //
  216. //初始化色板
  217. //
  218. this.colorsFormGrid = new ColorsForm();
  219. this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
  220. this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));//##############
  221. //
  222. //初始化图像控件
  223. //
  224. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  225. this.documentWorkspace.Dock = DockStyle.Fill;
  226. this.documentWorkspace.HookMouseEvents();
  227. this.documentWorkspace.AuxiliaryLineEnabled = false;
  228. this.documentWorkspace.Visible = false;
  229. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  230. this.documentWorkspace.panel.Paint += Panel_Paint;
  231. this.documentWorkspace.panel.MouseMove += onMouseMove;
  232. this.documentWorkspace.panel.MouseUp += onMouseUp;
  233. this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
  234. this.groupBox7.Controls.Add(documentWorkspace);
  235. //
  236. //初始化操作按钮
  237. //
  238. this.commonControlButtons = new CommonControlButtons();
  239. this.commonControlButtons.Dock = DockStyle.Top;
  240. this.commonControlButtons.Height = 30;
  241. this.commonControlButtons.HideZoomToWindowAndActualSize();
  242. this.groupBox7.Controls.Add(commonControlButtons);
  243. //二值化集成2
  244. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  245. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }
  246. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  247. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  248. //初始化头
  249. this.listView2.View = View.Details;
  250. ColumnHeader header0 = new ColumnHeader();
  251. header0.Text = "";
  252. header0.Width = 180;
  253. this.listView2.Columns.Add(header0);
  254. InitPicList();
  255. InitComboboxValue(null);
  256. styleClass.UpdateCupOffPointStyle();
  257. AddRectangleToRectangleFCaps();
  258. InitCommonButtonEvent();
  259. string templateName = "Template.Manager.item3.GrainSizeCutOff6394Method";
  260. switch (this.gbtType)
  261. {
  262. case 1:
  263. templateName = "Template.Manager.item3.GrainSizeCutOff4335Method";
  264. break;
  265. case 2:
  266. templateName = "Template.Manager.item3.GrainSizeCutOff24177Method";
  267. break;
  268. case 3:
  269. templateName = "Template.Manager.item3.GrainSizeCutOff112Method";
  270. break;
  271. case 4:
  272. templateName = "Template.Manager.item3.GrainSizeCutOff643Method";
  273. break;
  274. default:
  275. break;
  276. }
  277. SetAnalyzeModelFromXml(templateName);
  278. }
  279. //二值化集成3
  280. #region 二值化相关方法
  281. /// <summary>
  282. /// 添加参数改变的监听
  283. /// </summary>
  284. /// <param name="sender"></param>
  285. /// <param name="e"></param>
  286. private void GrainSizeDialog_Load(object sender, EventArgs e)
  287. {
  288. this.comboBox3.Text = PdnResources.GetString("Menu.pdenoisingtype.Text");
  289. this.comboBox3.SelectedIndex = 1;
  290. this.comboBox2.Text = PdnResources.GetString("Menu.electthegrainboundarytype.Text");
  291. this.comboBox2.SelectedIndex = 1;
  292. this.binaryClass.loadParams();
  293. this.binaryClass.guideClass = this.guideClass;
  294. this.binaryClass.comboBox1 = this.comboBox1;
  295. }
  296. private bool bcBinaryChecked()
  297. {
  298. return bc != null && bc.BinaryChecked;
  299. }
  300. private bool bcOriginChecked()
  301. {
  302. return bc != null && bc.OriginChecked;
  303. }
  304. /// <summary>
  305. /// 参数改变时,重新处理图像
  306. /// </summary>
  307. /// <param name="sender"></param>
  308. /// <param name="e"></param>
  309. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  310. {
  311. AddRectangleToRectangleFCaps();
  312. }
  313. /// <summary>
  314. /// 显示原图/原图+二值图
  315. /// </summary>
  316. /// <param name="sender"></param>
  317. /// <param name="e"></param>
  318. private void bcOriginCheckedChanged(object sender, EventArgs e)
  319. {
  320. if (!bcOriginChecked())
  321. {
  322. if (bcBinaryChecked())
  323. this.documentWorkspace.PhaseModels[0].choise = true;
  324. if (grainBoundryCheckBox.Checked && checkBox3_0.Checked)
  325. this.documentWorkspace.PhaseModels[1].choise = true;
  326. }
  327. else
  328. {
  329. this.documentWorkspace.PhaseModels[0].choise = false;
  330. this.documentWorkspace.PhaseModels[1].choise = false;
  331. }
  332. this.documentWorkspace.Refresh();
  333. }
  334. #endregion
  335. private void InitCommonButtonEvent()
  336. {
  337. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  338. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  339. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  340. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  341. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  342. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  343. }
  344. private void zoomInButton_Click(object sender, EventArgs e)
  345. {
  346. this.documentWorkspace.ZoomIn();
  347. }
  348. private void zoomOutButton_Click(object sender, EventArgs e)
  349. {
  350. this.documentWorkspace.ZoomOut();
  351. }
  352. private void zoomToWindowButton_Click(object sender, EventArgs e)
  353. {
  354. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  355. }
  356. private void actualSizeButton_Click(object sender, EventArgs e)
  357. {
  358. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  359. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  360. }
  361. private void pointerButton_Click(object sender, EventArgs e)
  362. {
  363. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  364. }
  365. private void mobileModeButton_Click(object sender, EventArgs e)
  366. {
  367. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  368. }
  369. /// <summary>
  370. /// 初始化图片列表数据
  371. /// </summary>
  372. public void InitPicList()
  373. {
  374. //初始化图片列表
  375. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  376. {
  377. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  378. this.listView1.Items.Add("", i);
  379. this.listView1.Items[i].ImageIndex = i;
  380. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  381. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  382. }
  383. }
  384. #region 初始化
  385. private void InitializeLanguageText()
  386. {
  387. this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  388. this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  389. this.button14.Text = PdnResources.GetString("Menu.Exportresults.text");
  390. this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  391. this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  392. this.button5.Text = PdnResources.GetString("Menu.Exportproject.text");
  393. this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
  394. this.button9.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
  395. this.button10.Text = PdnResources.GetString("Menu.Setting.Text");
  396. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  397. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  398. this.checkBox2_0.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  399. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  400. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  401. this.label7.Text = PdnResources.GetString("Menu.Image.Sigma.Text");
  402. this.checkBox2.Text = PdnResources.GetString("Menu.Grainboundaryenhancement.text");
  403. this.label8.Text = PdnResources.GetString("Menu.Grainboundarysize.text") + ":";
  404. this.button3.Text = PdnResources.GetString("Menu.Grainboundaryedit.text");
  405. this.groupBox4.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  406. this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  407. this.checkBox4_0.Text = PdnResources.GetString("Menu.displaygrid.text");
  408. this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
  409. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  410. this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
  411. this.button7_0.Text = PdnResources.GetString("Menu.1section.text");
  412. this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
  413. this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
  414. this.groupBox3.Text = PdnResources.GetString("Menu.Tools.GridLine.Text");
  415. this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
  416. this.button11.Text = PdnResources.GetString("Menu.Showall.text");
  417. this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  418. this.Column6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  419. this.Column5.HeaderText = PdnResources.GetString("Menu.averageintercept.text");
  420. this.Column4.HeaderText = PdnResources.GetString("Menu.Thenumberofsections.text");
  421. this.Column3.HeaderText = PdnResources.GetString("Menu.hectuallength.Text");
  422. this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
  423. this.grainBoundryCheckBox.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  424. this.label1.Text = PdnResources.GetString("Menu.Grainboundarytype.text") + ":";
  425. this.label6.Text = PdnResources.GetString("Menu.Denoisingtype.text") + ":";
  426. this.comboBox3.Items.AddRange(new object[] {
  427. PdnResources.GetString("Menu.Gaussiansmoothing.text"),
  428. PdnResources.GetString("Menu.directionalsmoothing.text")});
  429. this.comboBox2.Items.AddRange(new object[] {
  430. PdnResources.GetString("Menu.Brightgrainboundary.text"),
  431. PdnResources.GetString("Menu.Darkgrainboundary.text"),
  432. PdnResources.GetString("Menu.gradient.text")});
  433. //
  434. // bc
  435. //
  436. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  437. this.bc.BinaryChecked = false;
  438. this.bc.Location = new System.Drawing.Point(151, 59);
  439. this.bc.Name = "bc";
  440. this.bc.OriginChecked = false;
  441. this.bc.scope1End = 0D;
  442. this.bc.scope1Start = 0D;
  443. this.bc.scope2End = 0D;
  444. this.bc.scope2Start = 0D;
  445. this.bc.scope3End = 0D;
  446. this.bc.scope3Start = 0D;
  447. this.bc.Size = new System.Drawing.Size(360, 292);
  448. this.bc.TabIndex = 18;
  449. this.Controls.Add(this.bc);
  450. this.Controls.SetChildIndex(this.bc, 0);
  451. }
  452. private void InitializeComponent()
  453. {
  454. this.components = new System.ComponentModel.Container();
  455. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  456. this.groupBox1 = new System.Windows.Forms.GroupBox();
  457. this.button2 = new System.Windows.Forms.Button();
  458. this.checkBox2_0 = new System.Windows.Forms.CheckBox();
  459. this.button1 = new System.Windows.Forms.Button();
  460. this.groupBox2 = new System.Windows.Forms.GroupBox();
  461. this.listView1 = new System.Windows.Forms.ListView();
  462. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  463. this.button10 = new System.Windows.Forms.Button();
  464. this.button9 = new System.Windows.Forms.Button();
  465. this.groupBox8 = new System.Windows.Forms.GroupBox();
  466. this.button5 = new System.Windows.Forms.Button();
  467. this.listView2 = new System.Windows.Forms.ListView();
  468. this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
  469. this.button16 = new System.Windows.Forms.Button();
  470. this.label5 = new System.Windows.Forms.Label();
  471. this.button14 = new System.Windows.Forms.Button();
  472. this.button13 = new System.Windows.Forms.Button();
  473. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  474. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  475. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  476. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  477. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  478. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  479. this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  480. this.button12 = new System.Windows.Forms.Button();
  481. this.button11 = new System.Windows.Forms.Button();
  482. this.label4 = new System.Windows.Forms.Label();
  483. this.label3 = new System.Windows.Forms.Label();
  484. this.groupBox7 = new System.Windows.Forms.GroupBox();
  485. this.groupBox3 = new System.Windows.Forms.GroupBox();
  486. this.comboBox1 = new System.Windows.Forms.ComboBox();
  487. this.groupBox10 = new System.Windows.Forms.GroupBox();
  488. this.button8 = new System.Windows.Forms.Button();
  489. this.button7_0 = new System.Windows.Forms.Button();
  490. this.button6_0 = new System.Windows.Forms.Button();
  491. this.groupBox11 = new System.Windows.Forms.GroupBox();
  492. this.checkBox5_0 = new System.Windows.Forms.CheckBox();
  493. this.checkBox4_0 = new System.Windows.Forms.CheckBox();
  494. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  495. this.groupBox4 = new System.Windows.Forms.GroupBox();
  496. this.panel1 = new System.Windows.Forms.Panel();
  497. this.button3 = new System.Windows.Forms.Button();
  498. this.label8 = new System.Windows.Forms.Label();
  499. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  500. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  501. this.checkBox2 = new System.Windows.Forms.CheckBox();
  502. this.textBox6 = new System.Windows.Forms.TextBox();
  503. this.label7 = new System.Windows.Forms.Label();
  504. this.comboBox3 = new System.Windows.Forms.ComboBox();
  505. this.label6 = new System.Windows.Forms.Label();
  506. this.comboBox2 = new System.Windows.Forms.ComboBox();
  507. this.label1 = new System.Windows.Forms.Label();
  508. this.grainBoundryCheckBox = new System.Windows.Forms.CheckBox();
  509. this.groupBox1.SuspendLayout();
  510. this.groupBox2.SuspendLayout();
  511. this.groupBox8.SuspendLayout();
  512. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
  513. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  514. this.groupBox3.SuspendLayout();
  515. this.groupBox10.SuspendLayout();
  516. this.groupBox11.SuspendLayout();
  517. this.groupBox4.SuspendLayout();
  518. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  519. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  520. this.SuspendLayout();
  521. //
  522. // groupBox1
  523. //
  524. this.groupBox1.Controls.Add(this.button2);
  525. this.groupBox1.Controls.Add(this.checkBox2_0);
  526. this.groupBox1.Controls.Add(this.button1);
  527. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  528. this.groupBox1.Name = "groupBox1";
  529. this.groupBox1.Size = new System.Drawing.Size(1081, 50);
  530. this.groupBox1.TabIndex = 2;
  531. this.groupBox1.TabStop = false;
  532. //
  533. // button2
  534. //
  535. this.button2.BackColor = System.Drawing.SystemColors.Control;
  536. this.button2.Location = new System.Drawing.Point(985, 14);
  537. this.button2.Name = "button2";
  538. this.button2.Size = new System.Drawing.Size(84, 30);
  539. this.button2.TabIndex = 3;
  540. this.button2.UseVisualStyleBackColor = false;
  541. this.button2.Click += new System.EventHandler(this.button2_Click);
  542. //
  543. // checkBox2_0
  544. //
  545. this.checkBox2_0.AutoSize = true;
  546. this.checkBox2_0.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
  547. this.checkBox2_0.Location = new System.Drawing.Point(139, 22);
  548. this.checkBox2_0.Name = "checkBox2_0";
  549. this.checkBox2_0.Size = new System.Drawing.Size(132, 16);
  550. this.checkBox2_0.TabIndex = 2;
  551. this.checkBox2_0.UseVisualStyleBackColor = true;
  552. //
  553. // button1
  554. //
  555. this.button1.BackColor = System.Drawing.SystemColors.Control;
  556. this.button1.Location = new System.Drawing.Point(15, 14);
  557. this.button1.Name = "button1";
  558. this.button1.Size = new System.Drawing.Size(84, 30);
  559. this.button1.TabIndex = 0;
  560. this.button1.UseVisualStyleBackColor = false;
  561. this.button1.Click += new System.EventHandler(this.button1_Click);
  562. //
  563. // groupBox2
  564. //
  565. this.groupBox2.Controls.Add(this.listView1);
  566. this.groupBox2.Location = new System.Drawing.Point(14, 59);
  567. this.groupBox2.Name = "groupBox2";
  568. this.groupBox2.Size = new System.Drawing.Size(135, 592);
  569. this.groupBox2.TabIndex = 3;
  570. this.groupBox2.TabStop = false;
  571. //
  572. // listView1
  573. //
  574. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  575. | System.Windows.Forms.AnchorStyles.Left)
  576. | System.Windows.Forms.AnchorStyles.Right)));
  577. this.listView1.HideSelection = false;
  578. this.listView1.LargeImageList = this.imageList1;
  579. this.listView1.Location = new System.Drawing.Point(5, 17);
  580. this.listView1.MultiSelect = false;
  581. this.listView1.Name = "listView1";
  582. this.listView1.Size = new System.Drawing.Size(124, 569);
  583. this.listView1.TabIndex = 0;
  584. this.listView1.UseCompatibleStateImageBehavior = false;
  585. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  586. //
  587. // imageList1
  588. //
  589. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  590. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  591. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  592. //
  593. // button10
  594. //
  595. this.button10.BackColor = System.Drawing.SystemColors.Control;
  596. this.button10.Location = new System.Drawing.Point(106, 57);
  597. this.button10.Name = "button10";
  598. this.button10.Size = new System.Drawing.Size(95, 26);
  599. this.button10.TabIndex = 11;
  600. this.button10.UseVisualStyleBackColor = false;
  601. this.button10.Click += new System.EventHandler(this.button10_Click);
  602. //
  603. // button9
  604. //
  605. this.button9.BackColor = System.Drawing.SystemColors.Control;
  606. this.button9.Location = new System.Drawing.Point(242, 18);
  607. this.button9.Name = "button9";
  608. this.button9.Size = new System.Drawing.Size(92, 26);
  609. this.button9.TabIndex = 10;
  610. this.button9.UseVisualStyleBackColor = false;
  611. this.button9.Click += new System.EventHandler(this.button9_Click);
  612. //
  613. // groupBox8
  614. //
  615. this.groupBox8.Controls.Add(this.button5);
  616. this.groupBox8.Controls.Add(this.listView2);
  617. this.groupBox8.Controls.Add(this.numericUpDown1_0);
  618. this.groupBox8.Controls.Add(this.button16);
  619. this.groupBox8.Controls.Add(this.label5);
  620. this.groupBox8.Controls.Add(this.button14);
  621. this.groupBox8.Controls.Add(this.button13);
  622. this.groupBox8.Controls.Add(this.dataGridView2);
  623. this.groupBox8.Controls.Add(this.button12);
  624. this.groupBox8.Controls.Add(this.button11);
  625. this.groupBox8.Controls.Add(this.label4);
  626. this.groupBox8.Controls.Add(this.label3);
  627. this.groupBox8.Location = new System.Drawing.Point(14, 657);
  628. this.groupBox8.Name = "groupBox8";
  629. this.groupBox8.Size = new System.Drawing.Size(1081, 204);
  630. this.groupBox8.TabIndex = 10;
  631. this.groupBox8.TabStop = false;
  632. //
  633. // button5
  634. //
  635. this.button5.BackColor = System.Drawing.SystemColors.Control;
  636. this.button5.Location = new System.Drawing.Point(941, 109);
  637. this.button5.Name = "button5";
  638. this.button5.Size = new System.Drawing.Size(128, 26);
  639. this.button5.TabIndex = 24;
  640. this.button5.UseVisualStyleBackColor = false;
  641. this.button5.Click += new System.EventHandler(this.button5_Click);
  642. //
  643. // listView2
  644. //
  645. this.listView2.FullRowSelect = true;
  646. this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
  647. this.listView2.HideSelection = false;
  648. this.listView2.Location = new System.Drawing.Point(15, 56);
  649. this.listView2.Name = "listView2";
  650. this.listView2.Size = new System.Drawing.Size(181, 140);
  651. this.listView2.TabIndex = 23;
  652. this.listView2.UseCompatibleStateImageBehavior = false;
  653. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
  654. //
  655. // numericUpDown1_0
  656. //
  657. this.numericUpDown1_0.Location = new System.Drawing.Point(997, 163);
  658. this.numericUpDown1_0.Maximum = new decimal(new int[] {
  659. 10,
  660. 0,
  661. 0,
  662. 0});
  663. this.numericUpDown1_0.Name = "numericUpDown1_0";
  664. this.numericUpDown1_0.Size = new System.Drawing.Size(56, 21);
  665. this.numericUpDown1_0.TabIndex = 21;
  666. this.numericUpDown1_0.Value = new decimal(new int[] {
  667. 2,
  668. 0,
  669. 0,
  670. 0});
  671. this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
  672. //
  673. // button16
  674. //
  675. this.button16.BackColor = System.Drawing.SystemColors.Control;
  676. this.button16.Location = new System.Drawing.Point(15, 20);
  677. this.button16.Name = "button16";
  678. this.button16.Size = new System.Drawing.Size(93, 26);
  679. this.button16.TabIndex = 20;
  680. this.button16.UseVisualStyleBackColor = false;
  681. this.button16.Click += new System.EventHandler(this.button16_Click);
  682. //
  683. // label5
  684. //
  685. this.label5.AutoSize = true;
  686. this.label5.Location = new System.Drawing.Point(958, 169);
  687. this.label5.Name = "label5";
  688. this.label5.Size = new System.Drawing.Size(41, 12);
  689. this.label5.TabIndex = 18;
  690. //
  691. // button14
  692. //
  693. this.button14.BackColor = System.Drawing.SystemColors.Control;
  694. this.button14.Location = new System.Drawing.Point(941, 71);
  695. this.button14.Name = "button14";
  696. this.button14.Size = new System.Drawing.Size(128, 26);
  697. this.button14.TabIndex = 16;
  698. this.button14.UseVisualStyleBackColor = false;
  699. this.button14.Click += new System.EventHandler(this.button14_Click);
  700. //
  701. // button13
  702. //
  703. this.button13.BackColor = System.Drawing.SystemColors.Control;
  704. this.button13.Location = new System.Drawing.Point(941, 34);
  705. this.button13.Name = "button13";
  706. this.button13.Size = new System.Drawing.Size(128, 26);
  707. this.button13.TabIndex = 12;
  708. this.button13.UseVisualStyleBackColor = false;
  709. this.button13.Click += new System.EventHandler(this.button13_Click);
  710. //
  711. // dataGridView2
  712. //
  713. this.dataGridView2.AllowUserToAddRows = false;
  714. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  715. this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  716. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  717. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  718. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
  719. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  720. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  721. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  722. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  723. this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  724. this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  725. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  726. this.Column1,
  727. this.Column2,
  728. this.Column3,
  729. this.Column4,
  730. this.Column5,
  731. this.Column6});
  732. this.dataGridView2.Location = new System.Drawing.Point(228, 20);
  733. this.dataGridView2.Name = "dataGridView2";
  734. this.dataGridView2.ReadOnly = true;
  735. this.dataGridView2.RowHeadersVisible = false;
  736. this.dataGridView2.RowTemplate.Height = 23;
  737. this.dataGridView2.Size = new System.Drawing.Size(693, 176);
  738. this.dataGridView2.TabIndex = 15;
  739. //
  740. // Column1
  741. //
  742. this.Column1.Name = "Column1";
  743. this.Column1.ReadOnly = true;
  744. //
  745. // Column2
  746. //
  747. this.Column2.Name = "Column2";
  748. this.Column2.ReadOnly = true;
  749. //
  750. // Column3
  751. //
  752. this.Column3.Name = "Column3";
  753. this.Column3.ReadOnly = true;
  754. //
  755. // Column4
  756. //
  757. this.Column4.Name = "Column4";
  758. this.Column4.ReadOnly = true;
  759. //
  760. // Column5
  761. //
  762. this.Column5.Name = "Column5";
  763. this.Column5.ReadOnly = true;
  764. //
  765. // Column6
  766. //
  767. this.Column6.Name = "Column6";
  768. this.Column6.ReadOnly = true;
  769. //
  770. // button12
  771. //
  772. this.button12.BackColor = System.Drawing.SystemColors.Control;
  773. this.button12.Location = new System.Drawing.Point(145, 20);
  774. this.button12.Name = "button12";
  775. this.button12.Size = new System.Drawing.Size(52, 26);
  776. this.button12.TabIndex = 13;
  777. this.button12.UseVisualStyleBackColor = false;
  778. this.button12.Click += new System.EventHandler(this.button12_Click);
  779. //
  780. // button11
  781. //
  782. this.button11.BackColor = System.Drawing.SystemColors.Control;
  783. this.button11.Location = new System.Drawing.Point(15, 20);
  784. this.button11.Name = "button11";
  785. this.button11.Size = new System.Drawing.Size(63, 26);
  786. this.button11.TabIndex = 12;
  787. this.button11.UseVisualStyleBackColor = false;
  788. this.button11.Click += new System.EventHandler(this.button11_Click);
  789. //
  790. // label4
  791. //
  792. this.label4.AutoSize = true;
  793. this.label4.ForeColor = System.Drawing.SystemColors.ScrollBar;
  794. this.label4.Location = new System.Drawing.Point(924, 9);
  795. this.label4.Name = "label4";
  796. this.label4.Size = new System.Drawing.Size(11, 192);
  797. this.label4.TabIndex = 1;
  798. this.label4.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  799. //
  800. // label3
  801. //
  802. this.label3.AutoSize = true;
  803. this.label3.ForeColor = System.Drawing.SystemColors.ScrollBar;
  804. this.label3.Location = new System.Drawing.Point(214, 9);
  805. this.label3.Name = "label3";
  806. this.label3.Size = new System.Drawing.Size(11, 192);
  807. this.label3.TabIndex = 0;
  808. this.label3.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
  809. //
  810. // groupBox7
  811. //
  812. this.groupBox7.Location = new System.Drawing.Point(515, 59);
  813. this.groupBox7.Name = "groupBox7";
  814. this.groupBox7.Size = new System.Drawing.Size(580, 592);
  815. this.groupBox7.TabIndex = 11;
  816. this.groupBox7.TabStop = false;
  817. //
  818. // groupBox3
  819. //
  820. this.groupBox3.Controls.Add(this.comboBox1);
  821. this.groupBox3.Controls.Add(this.button9);
  822. this.groupBox3.Location = new System.Drawing.Point(153, 497);
  823. this.groupBox3.Name = "groupBox3";
  824. this.groupBox3.Size = new System.Drawing.Size(356, 57);
  825. this.groupBox3.TabIndex = 12;
  826. this.groupBox3.TabStop = false;
  827. //
  828. // comboBox1
  829. //
  830. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  831. this.comboBox1.FormattingEnabled = true;
  832. this.comboBox1.Location = new System.Drawing.Point(15, 22);
  833. this.comboBox1.Name = "comboBox1";
  834. this.comboBox1.Size = new System.Drawing.Size(214, 20);
  835. this.comboBox1.TabIndex = 0;
  836. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  837. //
  838. // groupBox10
  839. //
  840. this.groupBox10.Controls.Add(this.button10);
  841. this.groupBox10.Controls.Add(this.button8);
  842. this.groupBox10.Controls.Add(this.button7_0);
  843. this.groupBox10.Controls.Add(this.button6_0);
  844. this.groupBox10.Location = new System.Drawing.Point(153, 560);
  845. this.groupBox10.Name = "groupBox10";
  846. this.groupBox10.Size = new System.Drawing.Size(208, 91);
  847. this.groupBox10.TabIndex = 16;
  848. this.groupBox10.TabStop = false;
  849. //
  850. // button8
  851. //
  852. this.button8.BackColor = System.Drawing.SystemColors.Control;
  853. this.button8.Location = new System.Drawing.Point(106, 16);
  854. this.button8.Name = "button8";
  855. this.button8.Size = new System.Drawing.Size(95, 26);
  856. this.button8.TabIndex = 9;
  857. this.button8.UseVisualStyleBackColor = false;
  858. this.button8.Click += new System.EventHandler(this.button8_Click);
  859. //
  860. // button7_0
  861. //
  862. this.button7_0.BackColor = System.Drawing.SystemColors.Control;
  863. this.button7_0.Location = new System.Drawing.Point(5, 57);
  864. this.button7_0.Name = "button7_0";
  865. this.button7_0.Size = new System.Drawing.Size(95, 26);
  866. this.button7_0.TabIndex = 8;
  867. this.button7_0.UseVisualStyleBackColor = false;
  868. this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
  869. //
  870. // button6_0
  871. //
  872. this.button6_0.BackColor = System.Drawing.SystemColors.Control;
  873. this.button6_0.Location = new System.Drawing.Point(5, 17);
  874. this.button6_0.Name = "button6_0";
  875. this.button6_0.Size = new System.Drawing.Size(95, 26);
  876. this.button6_0.TabIndex = 7;
  877. this.button6_0.UseVisualStyleBackColor = false;
  878. this.button6_0.Click += new System.EventHandler(this.button6_0_Click);
  879. //
  880. // groupBox11
  881. //
  882. this.groupBox11.Controls.Add(this.checkBox5_0);
  883. this.groupBox11.Controls.Add(this.checkBox4_0);
  884. this.groupBox11.Controls.Add(this.checkBox3_0);
  885. this.groupBox11.Location = new System.Drawing.Point(367, 560);
  886. this.groupBox11.Name = "groupBox11";
  887. this.groupBox11.Size = new System.Drawing.Size(142, 91);
  888. this.groupBox11.TabIndex = 17;
  889. this.groupBox11.TabStop = false;
  890. //
  891. // checkBox5_0
  892. //
  893. this.checkBox5_0.AutoSize = true;
  894. this.checkBox5_0.Checked = true;
  895. this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
  896. this.checkBox5_0.Location = new System.Drawing.Point(15, 64);
  897. this.checkBox5_0.Name = "checkBox5_0";
  898. this.checkBox5_0.Size = new System.Drawing.Size(72, 16);
  899. this.checkBox5_0.TabIndex = 2;
  900. this.checkBox5_0.UseVisualStyleBackColor = true;
  901. this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
  902. //
  903. // checkBox4_0
  904. //
  905. this.checkBox4_0.AutoSize = true;
  906. this.checkBox4_0.Checked = true;
  907. this.checkBox4_0.CheckState = System.Windows.Forms.CheckState.Checked;
  908. this.checkBox4_0.Location = new System.Drawing.Point(15, 45);
  909. this.checkBox4_0.Name = "checkBox4_0";
  910. this.checkBox4_0.Size = new System.Drawing.Size(72, 16);
  911. this.checkBox4_0.TabIndex = 1;
  912. this.checkBox4_0.UseVisualStyleBackColor = true;
  913. this.checkBox4_0.CheckedChanged += new System.EventHandler(this.checkBox4_0_CheckedChanged);
  914. //
  915. // checkBox3_0
  916. //
  917. this.checkBox3_0.AutoSize = true;
  918. this.checkBox3_0.Checked = true;
  919. this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
  920. this.checkBox3_0.Location = new System.Drawing.Point(15, 23);
  921. this.checkBox3_0.Name = "checkBox3_0";
  922. this.checkBox3_0.Size = new System.Drawing.Size(72, 16);
  923. this.checkBox3_0.TabIndex = 0;
  924. this.checkBox3_0.UseVisualStyleBackColor = true;
  925. this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
  926. //
  927. // groupBox4
  928. //
  929. this.groupBox4.Controls.Add(this.panel1);
  930. this.groupBox4.Controls.Add(this.button3);
  931. this.groupBox4.Controls.Add(this.label8);
  932. this.groupBox4.Controls.Add(this.numericUpDown2);
  933. this.groupBox4.Controls.Add(this.numericUpDown1);
  934. this.groupBox4.Controls.Add(this.checkBox2);
  935. this.groupBox4.Controls.Add(this.textBox6);
  936. this.groupBox4.Controls.Add(this.label7);
  937. this.groupBox4.Controls.Add(this.comboBox3);
  938. this.groupBox4.Controls.Add(this.label6);
  939. this.groupBox4.Controls.Add(this.comboBox2);
  940. this.groupBox4.Controls.Add(this.label1);
  941. this.groupBox4.Controls.Add(this.grainBoundryCheckBox);
  942. this.groupBox4.Location = new System.Drawing.Point(153, 353);
  943. this.groupBox4.Name = "groupBox4";
  944. this.groupBox4.Size = new System.Drawing.Size(356, 138);
  945. this.groupBox4.TabIndex = 21;
  946. this.groupBox4.TabStop = false;
  947. //
  948. // panel1
  949. //
  950. this.panel1.BackColor = System.Drawing.Color.Red;
  951. this.panel1.Location = new System.Drawing.Point(89, 16);
  952. this.panel1.Name = "panel1";
  953. this.panel1.Size = new System.Drawing.Size(72, 21);
  954. this.panel1.TabIndex = 31;
  955. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  956. //
  957. // button3
  958. //
  959. this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
  960. this.button3.Location = new System.Drawing.Point(260, 16);
  961. this.button3.Name = "button3";
  962. this.button3.Size = new System.Drawing.Size(75, 23);
  963. this.button3.TabIndex = 18;
  964. this.button3.UseVisualStyleBackColor = true;
  965. this.button3.Click += new System.EventHandler(this.button3_Click);
  966. //
  967. // label8
  968. //
  969. this.label8.AutoSize = true;
  970. this.label8.Location = new System.Drawing.Point(6, 108);
  971. this.label8.Name = "label8";
  972. this.label8.Size = new System.Drawing.Size(65, 12);
  973. this.label8.TabIndex = 30;
  974. //
  975. // numericUpDown2
  976. //
  977. this.numericUpDown2.DecimalPlaces = 2;
  978. this.numericUpDown2.Location = new System.Drawing.Point(164, 104);
  979. this.numericUpDown2.Maximum = new decimal(new int[] {
  980. 1000,
  981. 0,
  982. 0,
  983. 0});
  984. this.numericUpDown2.Name = "numericUpDown2";
  985. this.numericUpDown2.Size = new System.Drawing.Size(61, 21);
  986. this.numericUpDown2.TabIndex = 29;
  987. this.numericUpDown2.Tag = "max";
  988. this.numericUpDown2.Value = new decimal(new int[] {
  989. 500,
  990. 0,
  991. 0,
  992. 0});
  993. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged_1);
  994. //
  995. // numericUpDown1
  996. //
  997. this.numericUpDown1.DecimalPlaces = 2;
  998. this.numericUpDown1.Location = new System.Drawing.Point(85, 104);
  999. this.numericUpDown1.Maximum = new decimal(new int[] {
  1000. 1000,
  1001. 0,
  1002. 0,
  1003. 0});
  1004. this.numericUpDown1.Name = "numericUpDown1";
  1005. this.numericUpDown1.Size = new System.Drawing.Size(61, 21);
  1006. this.numericUpDown1.TabIndex = 28;
  1007. this.numericUpDown1.Tag = "min";
  1008. this.numericUpDown1.Value = new decimal(new int[] {
  1009. 1,
  1010. 0,
  1011. 0,
  1012. 131072});
  1013. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged_1);
  1014. //
  1015. // checkBox2
  1016. //
  1017. this.checkBox2.AutoSize = true;
  1018. this.checkBox2.Checked = true;
  1019. this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
  1020. this.checkBox2.Location = new System.Drawing.Point(8, 50);
  1021. this.checkBox2.Name = "checkBox2";
  1022. this.checkBox2.Size = new System.Drawing.Size(72, 16);
  1023. this.checkBox2.TabIndex = 26;
  1024. this.checkBox2.UseVisualStyleBackColor = true;
  1025. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  1026. //
  1027. // textBox6
  1028. //
  1029. this.textBox6.Location = new System.Drawing.Point(65, 75);
  1030. this.textBox6.Name = "textBox6";
  1031. this.textBox6.Size = new System.Drawing.Size(45, 21);
  1032. this.textBox6.TabIndex = 25;
  1033. this.textBox6.Text = "0.5";
  1034. this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged);
  1035. //
  1036. // label7
  1037. //
  1038. this.label7.AutoSize = true;
  1039. this.label7.Location = new System.Drawing.Point(6, 79);
  1040. this.label7.Name = "label7";
  1041. this.label7.Size = new System.Drawing.Size(53, 12);
  1042. this.label7.TabIndex = 24;
  1043. //
  1044. // comboBox3
  1045. //
  1046. this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  1047. this.comboBox3.FormattingEnabled = true;
  1048. this.comboBox3.Location = new System.Drawing.Point(201, 76);
  1049. this.comboBox3.Name = "comboBox3";
  1050. this.comboBox3.Size = new System.Drawing.Size(133, 20);
  1051. this.comboBox3.TabIndex = 23;
  1052. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  1053. //
  1054. // label6
  1055. //
  1056. this.label6.AutoSize = true;
  1057. this.label6.Location = new System.Drawing.Point(136, 79);
  1058. this.label6.Name = "label6";
  1059. this.label6.Size = new System.Drawing.Size(65, 12);
  1060. this.label6.TabIndex = 22;
  1061. //
  1062. // comboBox2
  1063. //
  1064. this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  1065. this.comboBox2.FormattingEnabled = true;
  1066. this.comboBox2.Location = new System.Drawing.Point(201, 48);
  1067. this.comboBox2.Name = "comboBox2";
  1068. this.comboBox2.Size = new System.Drawing.Size(133, 20);
  1069. this.comboBox2.TabIndex = 11;
  1070. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  1071. //
  1072. // label1
  1073. //
  1074. this.label1.AutoSize = true;
  1075. this.label1.Location = new System.Drawing.Point(136, 51);
  1076. this.label1.Name = "label1";
  1077. this.label1.Size = new System.Drawing.Size(65, 12);
  1078. this.label1.TabIndex = 21;
  1079. //
  1080. // grainBoundryCheckBox
  1081. //
  1082. this.grainBoundryCheckBox.AutoSize = true;
  1083. this.grainBoundryCheckBox.Location = new System.Drawing.Point(8, 20);
  1084. this.grainBoundryCheckBox.Name = "grainBoundryCheckBox";
  1085. this.grainBoundryCheckBox.Size = new System.Drawing.Size(72, 16);
  1086. this.grainBoundryCheckBox.TabIndex = 7;
  1087. this.grainBoundryCheckBox.UseVisualStyleBackColor = true;
  1088. this.grainBoundryCheckBox.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  1089. //
  1090. // GrainSizeCutOffPointMethodDialog
  1091. //
  1092. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  1093. this.ClientSize = new System.Drawing.Size(1100, 870);
  1094. this.Controls.Add(this.groupBox4);
  1095. this.Controls.Add(this.groupBox3);
  1096. this.Controls.Add(this.groupBox10);
  1097. this.Controls.Add(this.groupBox11);
  1098. this.Controls.Add(this.groupBox7);
  1099. this.Controls.Add(this.groupBox8);
  1100. this.Controls.Add(this.groupBox2);
  1101. this.Controls.Add(this.groupBox1);
  1102. this.MaximumSize = new System.Drawing.Size(1116, 909);
  1103. this.MinimumSize = new System.Drawing.Size(1116, 909);
  1104. this.Name = "GrainSizeCutOffPointMethodDialog";
  1105. this.Text = "";
  1106. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeDialog_FormClosing);
  1107. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  1108. this.Controls.SetChildIndex(this.groupBox1, 0);
  1109. this.Controls.SetChildIndex(this.groupBox2, 0);
  1110. this.Controls.SetChildIndex(this.groupBox8, 0);
  1111. this.Controls.SetChildIndex(this.groupBox7, 0);
  1112. this.Controls.SetChildIndex(this.groupBox11, 0);
  1113. this.Controls.SetChildIndex(this.groupBox10, 0);
  1114. this.Controls.SetChildIndex(this.groupBox3, 0);
  1115. this.Controls.SetChildIndex(this.groupBox4, 0);
  1116. this.groupBox1.ResumeLayout(false);
  1117. this.groupBox1.PerformLayout();
  1118. this.groupBox2.ResumeLayout(false);
  1119. this.groupBox8.ResumeLayout(false);
  1120. this.groupBox8.PerformLayout();
  1121. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
  1122. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  1123. this.groupBox3.ResumeLayout(false);
  1124. this.groupBox10.ResumeLayout(false);
  1125. this.groupBox11.ResumeLayout(false);
  1126. this.groupBox11.PerformLayout();
  1127. this.groupBox4.ResumeLayout(false);
  1128. this.groupBox4.PerformLayout();
  1129. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  1130. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  1131. this.ResumeLayout(false);
  1132. }
  1133. #endregion
  1134. /// <summary>
  1135. /// 初始化矩形
  1136. /// </summary>
  1137. private void InitRectangleF(PointF pointF)
  1138. {
  1139. if (this.selectPicture)
  1140. {
  1141. bool foundItem;
  1142. guideClass.RectangleFLine = guideClass.guideRectLine(pointF, this.comboBox1.SelectedItem, out foundItem);
  1143. if (foundItem)
  1144. this.AddRectangleToRectangleFCaps();
  1145. }
  1146. }
  1147. //rundect
  1148. /// <summary>
  1149. /// 刷新截点集合
  1150. /// </summary>
  1151. private void AddRectangleToRectangleFCaps()
  1152. {
  1153. GrainSizeGuideStyleModel grainSizeGuideStyleModel = guideClass.GrainSizeGuideStyleModel;
  1154. if (grainSizeGuideStyleModel == null)
  1155. return;
  1156. Mat mat;
  1157. if (!grainBoundryCheckBox.Checked && !bcBinaryChecked())
  1158. {
  1159. mat = matOrg;
  1160. }
  1161. else
  1162. {
  1163. if (grainBoundryCheckBox.Checked)
  1164. {
  1165. if (this.documentWorkspace.PhaseModels[1].mat != null)
  1166. mat = this.documentWorkspace.PhaseModels[1].mat;
  1167. else
  1168. return;
  1169. }
  1170. else if (this.documentWorkspace.PhaseModels[0].mat != null)
  1171. {
  1172. mat = this.documentWorkspace.PhaseModels[0].mat;
  1173. }
  1174. else
  1175. return;
  1176. }
  1177. if (mat == null)
  1178. return;
  1179. this.linePointList.Clear();
  1180. //获取图形上所有的点
  1181. this.linePointList.AddRange(guideClass.getGuidePointList(mat, this.comboBox1.SelectedItem));
  1182. //垂直辅助线 / 水平辅助线
  1183. bool vGuideStylesOrHGuideStyles = guideClass.IsVGuideStylesOrHGuideStyles(this.comboBox1.SelectedItem);
  1184. int matLevel = 0;
  1185. if (grainBoundryCheckBox.Checked)
  1186. matLevel = 2;
  1187. else if (bcBinaryChecked())
  1188. matLevel = 1;
  1189. else if(!grainBoundryCheckBox.Checked && !bcBinaryChecked())
  1190. matLevel = 0;
  1191. //自动添加截点
  1192. styleClass.AddRectangleToRectangleFCaps(mat, matLevel, this.linePointList, vGuideStylesOrHGuideStyles, this.documentWorkspace.CompositionSurface.Width
  1193. , this.documentWorkspace.CompositionSurface.Height);
  1194. this.documentWorkspace.Refresh();
  1195. }
  1196. /// <summary>
  1197. /// 辅助线维护
  1198. /// </summary>
  1199. public void InitComboboxValue(ArrayList arrayList)
  1200. {
  1201. guideClass.createGuideClassModels(this.gbtType);
  1202. this.comboBox1.DataSource = null;
  1203. if (arrayList != null && arrayList.Count > 0)
  1204. {
  1205. this.comboboxChange = false;
  1206. arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
  1207. this.comboBox1.DataSource = arrayList;
  1208. this.comboboxChange = false;
  1209. int oldSelectIndex = -1;
  1210. for (int i = 0; i < this.comboBox1.Items.Count; i++)
  1211. {
  1212. if (this.oldSelectItem.Equals(this.comboBox1.Items[i]))
  1213. {
  1214. oldSelectIndex = i;
  1215. }
  1216. }
  1217. if (oldSelectIndex > -1)
  1218. this.comboBox1.SelectedIndex = oldSelectIndex;
  1219. else if (this.comboBox1.Items.Count > 0)
  1220. this.comboBox1.SelectedIndex = 0;
  1221. }
  1222. else
  1223. {
  1224. ArrayList arrayList1 = guideClass.GetComboList();
  1225. if (arrayList1.Count > 0)
  1226. {
  1227. this.comboBox1.DataSource = arrayList1;
  1228. this.comboBox1.SelectedIndex = 0;
  1229. }
  1230. }
  1231. // 更新辅助线及其样式
  1232. guideClass.UpdateGuideStyle(matOrg, this.comboBox1.SelectedItem);
  1233. this.documentWorkspace.Refresh();
  1234. }
  1235. /// <summary>
  1236. /// ListView图片选择改变事件
  1237. /// </summary>
  1238. /// <param name="sender"></param>
  1239. /// <param name="e"></param>
  1240. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1241. {
  1242. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1243. {
  1244. existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
  1245. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1246. if (!existViewFlag)
  1247. {
  1248. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  1249. }
  1250. else
  1251. {
  1252. matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFullSizeWithRegion());
  1253. }
  1254. //二值化集成4
  1255. binaryClass.listView1_SelectedIndexChanged(this.bitmap);
  1256. if (this.grainBoundryCheckBox.Checked)
  1257. {
  1258. this.documentWorkspace.PhaseModels[1].choise = true;
  1259. this.applyDect();
  1260. }
  1261. this.selectPicture = true;
  1262. this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  1263. InitRectangleF(new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2));
  1264. AddRectangleToRectangleFCaps();
  1265. }
  1266. }
  1267. /// <summary>
  1268. /// 辅助线样式
  1269. /// </summary>
  1270. /// <param name="sender"></param>
  1271. /// <param name="e"></param>
  1272. private void button9_Click(object sender, EventArgs e)
  1273. {
  1274. if (this.bitmap == null)
  1275. {
  1276. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1277. return;
  1278. }
  1279. this.oldSelectItem = (string)this.comboBox1.SelectedItem;
  1280. GrainGuideStyleSettingsDialog grainGuideStyleSettingsDialog = new GrainGuideStyleSettingsDialog(0, this.gbtType, this.bitmap);
  1281. grainGuideStyleSettingsDialog.StartPosition = FormStartPosition.CenterScreen;
  1282. grainGuideStyleSettingsDialog.ShowDialog(this);
  1283. }
  1284. /// <summary>
  1285. /// 截点样式
  1286. /// </summary>
  1287. /// <param name="sender"></param>
  1288. /// <param name="e"></param>
  1289. private void button10_Click(object sender, EventArgs e)
  1290. {
  1291. GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSurveyPointStyleSettingDialog();
  1292. grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  1293. grainSurveyPointStyleSettingDialog.ShowDialog(this);
  1294. }
  1295. /// <summary>
  1296. /// 画布绘制
  1297. /// </summary>
  1298. /// <param name="sender"></param>
  1299. /// <param name="e"></param>
  1300. private void Panel_Paint(object sender, PaintEventArgs e)
  1301. {
  1302. if (this.documentWorkspace.CompositionSurface != null)
  1303. {
  1304. //
  1305. // 以下是计算绘制图片的位置和大小并绘制图片
  1306. //
  1307. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1308. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1309. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1310. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  1311. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  1312. //
  1313. // 以下是绘制网格、标注、测量、视场等开始
  1314. //
  1315. e.Graphics.TranslateTransform(x, y);
  1316. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1317. if (this.checkBox4_0.Checked || this.checkBox5_0.Checked)
  1318. Draw(e.Graphics);
  1319. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1320. e.Graphics.TranslateTransform(-x, -y);
  1321. }
  1322. }
  1323. /// <summary>
  1324. /// 绘制
  1325. /// </summary>
  1326. private void Draw(Graphics graphics)
  1327. {
  1328. // 抗锯齿
  1329. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  1330. //显示辅助线
  1331. if (checkBox4_0.Checked)
  1332. guideClass.DrawGuideLines(graphics, this.comboBox1.SelectedItem);
  1333. //显示截点
  1334. if (matOrg != null && this.checkBox5_0.Checked)
  1335. styleClass.DrawGuidePoints(graphics);
  1336. }
  1337. private string oldSelectItem = "";
  1338. /// <summary>
  1339. /// 切换辅助线
  1340. /// </summary>
  1341. /// <param name="sender"></param>
  1342. /// <param name="e"></param>
  1343. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  1344. {
  1345. if (!this.selectPicture)
  1346. {
  1347. int oldSelectIndex = -1;
  1348. for (int i = 0; i < this.comboBox1.Items.Count; i++)
  1349. {
  1350. if (this.oldSelectItem.Equals(this.comboBox1.Items[i]))
  1351. {
  1352. oldSelectIndex = i;
  1353. }
  1354. }
  1355. if (this.comboBox1.SelectedIndex > 0)
  1356. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1357. if (oldSelectIndex > -1)
  1358. this.comboBox1.SelectedIndex = oldSelectIndex;
  1359. else if (this.comboBox1.Items.Count > 0)
  1360. this.comboBox1.SelectedIndex = 0;
  1361. return;
  1362. }
  1363. if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
  1364. {
  1365. this.oldSelectItem = (string)this.comboBox1.SelectedItem;
  1366. // 更新辅助线及其样式
  1367. guideClass.UpdateGuideStyle(matOrg, this.comboBox1.SelectedItem);
  1368. if (this.selectPicture)
  1369. {
  1370. PointF pointF;
  1371. if (this.comboboxChange)
  1372. {
  1373. pointF = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  1374. this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
  1375. }
  1376. else
  1377. pointF = this.loctation;
  1378. InitRectangleF(pointF);
  1379. this.comboboxChange = true;
  1380. }
  1381. this.documentWorkspace.Refresh();
  1382. }
  1383. }
  1384. #region 矩形拖动
  1385. /// <summary>
  1386. /// 鼠标按下
  1387. /// </summary>
  1388. /// <param name="drawArea"></param>
  1389. /// <param name="e"></param>
  1390. private void OnMouseDown(object sender, MouseEventArgs e)
  1391. {
  1392. // 换算后的点
  1393. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  1394. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  1395. && point1.X >= 0
  1396. && point1.Y >= 0
  1397. && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  1398. {
  1399. RectangleF rectangleF;
  1400. // 复合辅助线
  1401. int add = guideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
  1402. if (add == 0 && styleClass.PointKb > 0)
  1403. rectangleF = guideClass.RectangleFLine;
  1404. //手动添加截点
  1405. styleClass.OnMouseDownFirst(point1, rectangleF, this.linePointList, sender, e);
  1406. }
  1407. //辅助线缩放
  1408. if (styleClass.PointKb == 0)
  1409. guideClass.OnMouseDown(point1, sender, e);
  1410. //辅助线移动
  1411. if (e.Button == MouseButtons.Left && e.Clicks == 1 && styleClass.PointKb == 0)//##############
  1412. {
  1413. if (guideClass.RectangleFLine.Contains(point1))
  1414. {
  1415. m_canMove = true;
  1416. this.m_StartPoint = point1;
  1417. }
  1418. }
  1419. //手动删除截点或取消添加截点
  1420. styleClass.OnMouseDownNext(point1, sender, e);
  1421. }
  1422. /// <summary>
  1423. /// 移动
  1424. /// </summary>
  1425. /// <param name="sender"></param>
  1426. /// <param name="e"></param>
  1427. private void onMouseMove(object sender, MouseEventArgs e)
  1428. {
  1429. // 换算后的点
  1430. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  1431. this.documentWorkspace.Refresh();//#########
  1432. if (guideClass.onMouseMove(point1, this.comboBox1.SelectedItem, e))// 矩形缩放
  1433. {
  1434. this.loctation = new PointF(guideClass.RectangleFLine.X + guideClass.RectangleFLine.Width / 2, guideClass.RectangleFLine.Y + guideClass.RectangleFLine.Height / 2);
  1435. this.AddRectangleToRectangleFCaps();
  1436. this.documentWorkspace.Refresh();
  1437. }
  1438. else if (e.Button == MouseButtons.Left && m_canMove)
  1439. {
  1440. // 矩形偏移
  1441. guideClass.rectangleFLine.Offset(point1.X - this.m_StartPoint.X, point1.Y - this.m_StartPoint.Y);
  1442. this.loctation = new PointF(guideClass.RectangleFLine.X + guideClass.RectangleFLine.Width / 2, guideClass.RectangleFLine.Y + guideClass.RectangleFLine.Height / 2);
  1443. this.m_StartPoint = point1;
  1444. this.AddRectangleToRectangleFCaps();
  1445. this.documentWorkspace.Refresh();
  1446. }
  1447. }
  1448. /// <summary>
  1449. /// 鼠标抬起
  1450. /// </summary>
  1451. /// <param name="sender"></param>
  1452. /// <param name="e"></param>
  1453. private void onMouseUp(object sender, MouseEventArgs e)
  1454. {
  1455. m_canMove = false;
  1456. guideClass.onMouseUp(sender, e);
  1457. }
  1458. #endregion
  1459. /// <summary>
  1460. /// surfaceBox双击事件
  1461. /// 目前是参考AxioVision
  1462. /// 应该是把每次选的点都取最高和最低的BGR
  1463. /// </summary>
  1464. /// <param name="sender"></param>
  1465. /// <param name="e"></param>
  1466. private unsafe void pictureBox1_Click(object sender, EventArgs e)
  1467. {
  1468. }
  1469. /// <summary>
  1470. /// 移除未完成的定义物体的轮廓的对象
  1471. /// </summary>
  1472. /// <param name="sender"></param>
  1473. /// <param name="e"></param>
  1474. private void GrainSizeDialog_FormClosing(object sender, FormClosingEventArgs e)
  1475. {
  1476. this.documentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.PhaseExtraction);
  1477. this.documentWorkspace.Refresh();
  1478. }
  1479. /// <summary>
  1480. /// 0.5截点添加
  1481. /// </summary>
  1482. /// <param name="sender"></param>
  1483. /// <param name="e"></param>
  1484. private void button6_0_Click(object sender, EventArgs e)
  1485. {
  1486. if (this.listView1.SelectedItems.Count > 0)
  1487. styleClass.PointKb = 1;
  1488. else
  1489. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1490. }
  1491. /// <summary>
  1492. /// 1截点添加
  1493. /// </summary>
  1494. /// <param name="sender"></param>
  1495. /// <param name="e"></param>
  1496. private void button7_0_Click(object sender, EventArgs e)
  1497. {
  1498. if (this.listView1.SelectedItems.Count > 0)
  1499. styleClass.PointKb = 2;
  1500. else
  1501. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1502. }
  1503. /// <summary>
  1504. /// 2截点添加
  1505. /// </summary>
  1506. /// <param name="sender"></param>
  1507. /// <param name="e"></param>
  1508. private void button8_Click(object sender, EventArgs e)
  1509. {
  1510. if (this.listView1.SelectedItems.Count > 0)
  1511. {
  1512. //垂直辅助线 / 水平辅助线
  1513. bool vGuideStylesOrHGuideStyles = guideClass.IsVGuideStylesOrHGuideStyles(this.comboBox1.SelectedItem);
  1514. if (vGuideStylesOrHGuideStyles)
  1515. styleClass.PointKb = 3;
  1516. else
  1517. styleClass.PointKb = 4;
  1518. }
  1519. else
  1520. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1521. }
  1522. /// <summary>
  1523. /// 是否显示截点
  1524. /// </summary>
  1525. /// <param name="sender"></param>
  1526. /// <param name="e"></param>
  1527. private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
  1528. {
  1529. if (!this.checkBox4_0.Checked)
  1530. MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
  1531. this.documentWorkspace.Refresh();
  1532. }
  1533. /// <summary>
  1534. /// 是否显示网格
  1535. /// </summary>
  1536. /// <param name="sender"></param>
  1537. /// <param name="e"></param>
  1538. private void checkBox4_0_CheckedChanged(object sender, EventArgs e)
  1539. {
  1540. this.documentWorkspace.Refresh();
  1541. }
  1542. /// <summary>
  1543. /// Panel2的调色板颜色改变
  1544. /// </summary>
  1545. /// <param name="sender"></param>
  1546. /// <param name="e"></param>
  1547. private void gridColorChanged(object sender, EventArgs e)
  1548. {
  1549. Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
  1550. //更改背景色,触发事件
  1551. this.panel1.BackColor = color;
  1552. this.documentWorkspace.PhaseModels[1].color = this.panel1.BackColor.ToArgb();
  1553. if (this.grainBoundryCheckBox.Checked)
  1554. {
  1555. this.applyDect();
  1556. this.documentWorkspace.Refresh();
  1557. }
  1558. //关闭色板
  1559. this.colorsFormGrid.Close();
  1560. }
  1561. /// <summary>
  1562. /// 设置按钮
  1563. /// </summary>
  1564. /// <param name="sender"></param>
  1565. /// <param name="e"></param>
  1566. private void button1_Click(object sender, EventArgs e)
  1567. {
  1568. string templateName = "Template.Manager.item3.GrainSizeCutOff6394Method";
  1569. switch (this.gbtType)
  1570. {
  1571. case 1:
  1572. templateName = "Template.Manager.item3.GrainSizeCutOff4335Method";
  1573. break;
  1574. case 2:
  1575. templateName = "Template.Manager.item3.GrainSizeCutOff24177Method";
  1576. break;
  1577. case 3:
  1578. templateName = "Template.Manager.item3.GrainSizeCutOff112Method";
  1579. break;
  1580. case 4:
  1581. templateName = "Template.Manager.item3.GrainSizeCutOff643Method";
  1582. break;
  1583. default:
  1584. break;
  1585. }
  1586. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);//#############001
  1587. if (metallographicMethodSetDialog.hasModule)
  1588. {
  1589. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1590. metallographicMethodSetDialog.ShowDialog();
  1591. }
  1592. else
  1593. {
  1594. metallographicMethodSetDialog = null;
  1595. }
  1596. }
  1597. /// <summary>
  1598. /// 生成报告按钮
  1599. /// </summary>
  1600. /// <param name="sender"></param>
  1601. /// <param name="e"></param>
  1602. private void button13_Click(object sender, EventArgs e)
  1603. {
  1604. if (this.checkBox2_0.Checked)
  1605. this.button1.PerformClick();
  1606. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1607. {
  1608. //获取word书签与excel单元格的关系,以字典方式存储
  1609. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1610. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1611. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1612. {
  1613. foreach (mic_module_infos info in mic_module_infos)
  1614. {
  1615. tagInfos.Add(info.tag_name, info.cell_position);
  1616. }
  1617. }
  1618. //分析结果
  1619. List<List<string>> analysisContent = new List<List<string>>();
  1620. analysisContent.Add(contentHead);
  1621. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1622. {
  1623. List<string> content = new List<string>();
  1624. for (int i = 0; i < contentHead.Count; i++)
  1625. {
  1626. content.Add(item.Cells[i].Value.ToString());
  1627. }
  1628. analysisContent.Add(content);
  1629. }
  1630. //图片
  1631. bitList = new List<Bitmap>();
  1632. if (this.allShow)
  1633. {
  1634. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1635. {
  1636. bitList.Add(kv.Value[0]);
  1637. bitList.Add(kv.Value[1]);
  1638. }
  1639. }
  1640. else
  1641. {
  1642. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1643. {
  1644. foreach (ListViewItem item in this.listView2.SelectedItems)
  1645. {
  1646. if (bitDic.ContainsKey(item.Name))
  1647. {
  1648. bitList.Add(bitDic[item.Name][0]);
  1649. bitList.Add(bitDic[item.Name][1]);
  1650. }
  1651. else if (bitDic.ContainsKey(item.Tag.ToString()))
  1652. {
  1653. bitList.Add(bitDic[item.Tag.ToString()][0]);
  1654. bitList.Add(bitDic[item.Tag.ToString()][1]);
  1655. }
  1656. }
  1657. }
  1658. else if (this.listView2.Items.Count > 0)//###
  1659. {
  1660. ListViewItem item = this.listView2.Items[0];
  1661. if (bitDic.ContainsKey(item.Name))
  1662. {
  1663. bitList.Add(bitDic[item.Name][0]);
  1664. bitList.Add(bitDic[item.Name][1]);
  1665. }
  1666. else if (bitDic.ContainsKey(item.Tag.ToString()))
  1667. {
  1668. bitList.Add(bitDic[item.Tag.ToString()][0]);
  1669. bitList.Add(bitDic[item.Tag.ToString()][1]);
  1670. }
  1671. }
  1672. }
  1673. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1674. }
  1675. else
  1676. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1677. }
  1678. /// <summary>
  1679. /// 导出结果按钮
  1680. /// </summary>
  1681. /// <param name="sender"></param>
  1682. /// <param name="e"></param>
  1683. private void button14_Click(object sender, EventArgs e)
  1684. {
  1685. if (this.listView2.Items.Count > 0)
  1686. {
  1687. SaveFileDialog exe = new SaveFileDialog();
  1688. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1689. exe.FilterIndex = 0;
  1690. exe.RestoreDirectory = true;
  1691. exe.Title = "Export Excel File";
  1692. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1693. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text")+"("+ PdnResources.GetString("Menu.sectionmethod.text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1694. DialogResult dr = exe.ShowDialog();
  1695. if (dr == DialogResult.OK)
  1696. {
  1697. DataTable dtb = new DataTable();
  1698. foreach (var item in this.contentHead)
  1699. {
  1700. dtb.Columns.Add(item);
  1701. }
  1702. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  1703. {
  1704. DataRow dataRow = dtb.NewRow();
  1705. for (int k = 0; k < this.contentHead.Count; k++)
  1706. {
  1707. dataRow[this.contentHead[k]] = this.dataGridView2.Rows[i].Cells[k].Value;
  1708. }
  1709. dtb.Rows.Add(dataRow);
  1710. }
  1711. List<DataTable> list = new List<DataTable>();
  1712. list.Add(dtb);
  1713. OfficeFileHandleHelper.ExportDataToExcel(exe.FileName, list);
  1714. MessageBox.Show(PdnResources.GetString("Menu.ResultsExportedsuccessfully.Text"));
  1715. }
  1716. }
  1717. else
  1718. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  1719. }
  1720. /// <summary>
  1721. /// 保存结果
  1722. /// </summary>
  1723. /// <param name="sender"></param>
  1724. /// <param name="e"></param>
  1725. private void button2_Click(object sender, EventArgs e)
  1726. {
  1727. if (this.listView1.SelectedItems.Count > 0)
  1728. {
  1729. if(this.comboBox1.SelectedItem != null && !PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
  1730. {
  1731. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1732. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1733. System.Data.DataTable dataTable = new System.Data.DataTable();
  1734. bool replace = false;
  1735. int add = 0;
  1736. foreach (ListViewItem item in this.listView2.Items)
  1737. {
  1738. if (item.Tag.Equals(tag))
  1739. {
  1740. add++;
  1741. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1742. if (dr == DialogResult.OK)
  1743. {
  1744. replace = true;
  1745. }
  1746. break;
  1747. }
  1748. }
  1749. if (replace || this.listView2.Items.Count == 0 || add == 0)
  1750. {
  1751. if(!replace)
  1752. {
  1753. ListViewItem listViewItem = new ListViewItem();
  1754. listViewItem.SubItems[0].Text = imgName;
  1755. listViewItem.Tag = "" + tag;
  1756. if (this.listView2.Items.Count == 0)
  1757. this.listView2.Items.Add(listViewItem);
  1758. else
  1759. this.listView2.Items.Insert(0, listViewItem);
  1760. }
  1761. this.dataGridView2.Rows.Clear();
  1762. DataGridViewRow dgvr = new DataGridViewRow();
  1763. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  1764. {
  1765. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  1766. }
  1767. dgvr.Cells[0].Value = imgName;
  1768. dgvr.Cells[1].Value = this.comboBox1.SelectedItem;
  1769. double length = guideClass.guideLength(this.comboBox1.SelectedItem);
  1770. dgvr.Cells[2].Value = length;
  1771. double countPoints = styleClass.getCountPoints();
  1772. decimal M = 1;// this.appWorkspace.GetGainMultiple() ;
  1773. double PL = (double)M * countPoints / length;
  1774. dgvr.Cells[3].Value = countPoints;
  1775. dgvr.Cells[4].Value = 1.0 / PL;
  1776. if (this.gbtType == 4)
  1777. {
  1778. dgvr.Cells[5].Value = 6.6439 * Math.Log10(PL * 1000.0) - 3.2877;
  1779. }
  1780. else
  1781. {
  1782. dgvr.Cells[5].Value = 6.643856 * Math.Log10(PL * 1000.0) - 3.288;
  1783. }
  1784. this.dataGridView2.Rows.Add(dgvr);
  1785. dataTable.TableName = tag;
  1786. foreach (System.Data.DataTable dataTable1 in dataTables)
  1787. {
  1788. if (dataTable1.TableName.Equals(dataTable.TableName))
  1789. {
  1790. dataTables.Remove(dataTable1);
  1791. break;
  1792. }
  1793. }
  1794. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  1795. {
  1796. dataTable.Columns.Add(c.HeaderText);
  1797. }
  1798. for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
  1799. {
  1800. DataRow dataRow = dataTable.NewRow();
  1801. for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
  1802. {
  1803. dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
  1804. }
  1805. dataTable.Rows.Add(dataRow);
  1806. }
  1807. this.dataTables.Add(dataTable);
  1808. }
  1809. this.RefreshDataGridView4();
  1810. //保存处理后的图片
  1811. List<Bitmap> tempBit = new List<Bitmap>();
  1812. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1813. tempBit.Add(originalBit);
  1814. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1815. Graphics graphics = Graphics.FromImage(newBit);
  1816. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  1817. {
  1818. Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
  1819. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1820. }
  1821. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  1822. {
  1823. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  1824. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1825. }
  1826. Draw(graphics);
  1827. tempBit.Add(newBit);
  1828. if (bitDic.ContainsKey(tag))
  1829. bitDic[tag] = tempBit;
  1830. else
  1831. bitDic.Add(tag, tempBit);
  1832. //拼接中间数据
  1833. List<List<string>> dataList = styleClass.getTableDataList();
  1834. bool isExist = false;//是否已存在进行替换
  1835. int modelIndex = -1;//要替换的下标
  1836. for (int j = 0; j < tempDataModel.Count; j++)
  1837. {
  1838. if (tempDataModel[j].tagName.Equals(tag))
  1839. {
  1840. isExist = true;
  1841. modelIndex = j;
  1842. break;
  1843. }
  1844. }
  1845. if (isExist && modelIndex > -1)
  1846. tempDataModel[modelIndex].dataList = dataList;
  1847. else
  1848. {
  1849. ExportProjectModel newModel = new ExportProjectModel();
  1850. newModel.tagName = tag;
  1851. newModel.picName = imgName;
  1852. newModel.dataList = dataList;
  1853. tempDataModel.Add(newModel);
  1854. }
  1855. }
  1856. else
  1857. {
  1858. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text")+"!");
  1859. }
  1860. }
  1861. else
  1862. {
  1863. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  1864. }
  1865. }
  1866. /// <summary>
  1867. /// 晶界重现
  1868. /// </summary>
  1869. /// <param name="sender"></param>
  1870. /// <param name="e"></param>
  1871. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  1872. {
  1873. if (this.grainBoundryCheckBox.Checked && !bcOriginChecked() && checkBox3_0.Checked)
  1874. {
  1875. this.documentWorkspace.PhaseModels[1].choise = true;
  1876. }
  1877. else
  1878. {
  1879. this.documentWorkspace.PhaseModels[1].choise = false;
  1880. this.documentWorkspace.Refresh();
  1881. }
  1882. if (this.grainBoundryCheckBox.Checked)
  1883. {
  1884. this.applyDect();
  1885. }
  1886. else
  1887. AddRectangleToRectangleFCaps();//1009###18946
  1888. }
  1889. ProgressThreadProcClass procClass;
  1890. double sigma = 0.5;
  1891. Mat OrgImg;// = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);// OpenCvSharp.Cv2.ImRead(inputImageFile);
  1892. int dark;// = this.comboBox2.SelectedIndex;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
  1893. int smooth_type;// = this.comboBox3.SelectedIndex;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
  1894. //double sigma = double.Parse(textBox6.Text);// 0.5;//如果是高斯平滑,则指定高斯sigma,如果是方向平滑 则忽略此参数
  1895. int enhance;// = this.checkBox2.Checked ? 1 : 0;// 1;//是否增强晶界?不增强:enhance=0; 增强: enhance=1
  1896. double[] cell_size;// = new double[2] { (double)numericUpDown1.Value, (double)numericUpDown2.Value }; ;// new double[2] { 0.01, 500 };//晶界大小
  1897. Mat OrgImg0;
  1898. private void applyDect()
  1899. {
  1900. if (this.bitmap == null)
  1901. {
  1902. return;
  1903. }
  1904. if (!double.TryParse(textBox6.Text, out sigma))
  1905. {
  1906. return;
  1907. }
  1908. /*Mat */OrgImg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);// OpenCvSharp.Cv2.ImRead(inputImageFile);
  1909. /*int */dark = this.comboBox2.SelectedIndex;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
  1910. /*int */smooth_type = this.comboBox3.SelectedIndex;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
  1911. /*int */enhance = this.checkBox2.Checked ? 1 : 0;// 1;//是否增强晶界?不增强:enhance=0; 增强: enhance=1
  1912. /*double[] */cell_size = new double[2] { (double)numericUpDown1.Value, (double)numericUpDown2.Value }; ;// new double[2] { 0.01, 500 };//晶界大小
  1913. procClass = new ProgressThreadProcClass();
  1914. procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
  1915. if (OrgImg0 != null)
  1916. {
  1917. this.documentWorkspace.PhaseModels[1].mat = OrgImg0.Clone();
  1918. this.documentWorkspace.Refresh();
  1919. OrgImg0 = null;
  1920. }
  1921. if (OrgImg != null)
  1922. {
  1923. OrgImg.Dispose();
  1924. OrgImg = null;
  1925. }
  1926. //this.runDect(OrgImg, dark, smooth_type, sigma, enhance, cell_size);
  1927. AddRectangleToRectangleFCaps();//0916###18747
  1928. }
  1929. private void applyDectAction()
  1930. {
  1931. OrgImg0 = this.runDect(OrgImg, dark, smooth_type, sigma, enhance, cell_size);
  1932. if (procClass != null) procClass.DismissProgressAction(this);
  1933. }
  1934. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  1935. {
  1936. if (this.grainBoundryCheckBox.Checked)
  1937. {
  1938. this.applyDect();
  1939. }
  1940. }
  1941. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  1942. {
  1943. if (this.grainBoundryCheckBox.Checked)
  1944. {
  1945. this.applyDect();
  1946. }
  1947. }
  1948. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  1949. {
  1950. if (this.grainBoundryCheckBox.Checked)
  1951. {
  1952. this.applyDect();
  1953. }
  1954. }
  1955. private void textBox6_TextChanged(object sender, EventArgs e)
  1956. {
  1957. if (this.grainBoundryCheckBox.Checked)
  1958. {
  1959. this.applyDect();
  1960. }
  1961. }
  1962. private void numericUpDown1_ValueChanged_1(object sender, EventArgs e)
  1963. {
  1964. if (this.grainBoundryCheckBox.Checked)
  1965. {
  1966. this.applyDect();
  1967. }
  1968. }
  1969. private void numericUpDown2_ValueChanged_1(object sender, EventArgs e)
  1970. {
  1971. if (this.grainBoundryCheckBox.Checked)
  1972. {
  1973. this.applyDect();
  1974. }
  1975. }
  1976. /// <summary>
  1977. /// 显示晶界
  1978. /// </summary>
  1979. /// <param name="sender"></param>
  1980. /// <param name="e"></param>
  1981. private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
  1982. {
  1983. if (!bcOriginChecked() && grainBoundryCheckBox.Checked && checkBox3_0.Checked)
  1984. {
  1985. this.documentWorkspace.PhaseModels[1].choise = true;
  1986. }
  1987. else
  1988. {
  1989. this.documentWorkspace.PhaseModels[1].choise = false;
  1990. }
  1991. this.documentWorkspace.Refresh();
  1992. }
  1993. /// <summary>
  1994. /// 晶界编辑
  1995. /// </summary>
  1996. /// <param name="sender"></param>
  1997. /// <param name="e"></param>
  1998. private void button3_Click(object sender, EventArgs e)
  1999. {
  2000. if (this.documentWorkspace.PhaseModels[1].mat == null)
  2001. {
  2002. MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
  2003. return;
  2004. }
  2005. GrainBoundaryEditingDialog boundaryEditingDialog = new GrainBoundaryEditingDialog(this.appWorkspace, this.listView1.FocusedItem.Index, this.panel1.BackColor
  2006. , this.documentWorkspace.PhaseModels[1].mat.Clone());
  2007. boundaryEditingDialog.GuideClass = this.guideClass;
  2008. boundaryEditingDialog.SelectedItem = this.comboBox1.SelectedItem;
  2009. if (boundaryEditingDialog.ShowDialog() == DialogResult.OK)
  2010. {
  2011. this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
  2012. AddRectangleToRectangleFCaps();
  2013. }
  2014. }
  2015. private void panel1_Click(object sender, EventArgs e)
  2016. {
  2017. this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  2018. this.colorsFormGrid.ShowDialog();
  2019. }
  2020. /// <summary>
  2021. /// 导出项目
  2022. /// </summary>
  2023. /// <param name="sender"></param>
  2024. /// <param name="e"></param>
  2025. private void button5_Click(object sender, EventArgs e)
  2026. {
  2027. if (this.checkBox2_0.Checked)
  2028. this.button1.PerformClick();
  2029. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2030. {
  2031. Instrument.ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text", this.analyzeSettingModel.savePath);
  2032. if (nodeItem == null) return;
  2033. //获取word书签与excel单元格的关系,以字典方式存储
  2034. List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2035. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2036. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2037. {
  2038. foreach (mic_module_infos info in mic_module_infos)
  2039. {
  2040. tagInfos.Add(info.tag_name, info.cell_position);
  2041. }
  2042. }
  2043. //分析结果
  2044. List<List<string>> analysisContent = new List<List<string>>();
  2045. analysisContent.Add(contentHead);
  2046. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  2047. {
  2048. List<string> content = new List<string>();
  2049. for (int i = 0; i < contentHead.Count; i++)
  2050. {
  2051. content.Add(item.Cells[i].Value.ToString());
  2052. }
  2053. analysisContent.Add(content);
  2054. }
  2055. //图片
  2056. bitList = new List<Bitmap>();
  2057. //中间数据
  2058. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2059. if (this.allShow)
  2060. {
  2061. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  2062. {
  2063. bitList.Add(kv.Value[0]);
  2064. bitList.Add(kv.Value[1]);
  2065. }
  2066. //中间数据
  2067. foreach (ExportProjectModel model in this.tempDataModel)
  2068. {
  2069. ExportProjectModel tempModel = new ExportProjectModel();
  2070. tempModel.tagName = model.tagName;
  2071. tempModel.picName = model.picName;
  2072. tempModel.dataList = model.dataList;
  2073. exportModel.Add(tempModel);
  2074. }
  2075. }
  2076. else
  2077. {
  2078. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2079. {
  2080. foreach (ListViewItem item in this.listView2.SelectedItems)
  2081. {
  2082. if (bitDic.ContainsKey(item.Name))
  2083. {
  2084. bitList.Add(bitDic[item.Name][0]);
  2085. bitList.Add(bitDic[item.Name][1]);
  2086. }
  2087. else if (bitDic.ContainsKey(item.Tag.ToString()))
  2088. {
  2089. bitList.Add(bitDic[item.Tag.ToString()][0]);
  2090. bitList.Add(bitDic[item.Tag.ToString()][1]);
  2091. }
  2092. }
  2093. //中间数据
  2094. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2095. {
  2096. foreach (ExportProjectModel model in this.tempDataModel)
  2097. {
  2098. if (model.tagName.Equals(rowItem.Name))
  2099. {
  2100. ExportProjectModel tempModel = new ExportProjectModel();
  2101. tempModel.tagName = model.tagName;
  2102. tempModel.picName = model.picName;
  2103. tempModel.dataList = model.dataList;
  2104. exportModel.Add(tempModel);
  2105. break;
  2106. }
  2107. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  2108. {
  2109. ExportProjectModel tempModel = new ExportProjectModel();
  2110. tempModel.tagName = model.tagName;
  2111. tempModel.picName = model.picName;
  2112. tempModel.dataList = model.dataList;
  2113. exportModel.Add(tempModel);
  2114. break;
  2115. }
  2116. }
  2117. }
  2118. }
  2119. else if (this.listView2.Items.Count > 0)
  2120. {
  2121. ListViewItem rowItem = this.listView2.Items[0];
  2122. if (bitDic.ContainsKey(rowItem.Name))
  2123. {
  2124. bitList.Add(bitDic[rowItem.Name][0]);
  2125. bitList.Add(bitDic[rowItem.Name][1]);
  2126. }
  2127. else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
  2128. {
  2129. bitList.Add(bitDic[rowItem.Tag.ToString()][0]);
  2130. bitList.Add(bitDic[rowItem.Tag.ToString()][1]);
  2131. }
  2132. //中间数据
  2133. {
  2134. foreach (ExportProjectModel model in this.tempDataModel)
  2135. {
  2136. if (model.tagName.Equals(rowItem.Name))
  2137. {
  2138. ExportProjectModel tempModel = new ExportProjectModel();
  2139. tempModel.tagName = model.tagName;
  2140. tempModel.picName = model.picName;
  2141. tempModel.dataList = model.dataList;
  2142. exportModel.Add(tempModel);
  2143. break;
  2144. }
  2145. else if (model.tagName.Equals(rowItem.Tag.ToString()))
  2146. {
  2147. ExportProjectModel tempModel = new ExportProjectModel();
  2148. tempModel.tagName = model.tagName;
  2149. tempModel.picName = model.picName;
  2150. tempModel.dataList = model.dataList;
  2151. exportModel.Add(tempModel);
  2152. break;
  2153. }
  2154. }
  2155. }
  2156. }
  2157. }
  2158. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
  2159. //保存项目信息到数据库
  2160. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
  2161. }
  2162. else
  2163. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2164. }
  2165. /// <summary>
  2166. /// 切换分析结果
  2167. /// </summary>
  2168. /// <param name="sender"></param>
  2169. /// <param name="e"></param>
  2170. private void listview2_SelectedIndexChanged(object sender, EventArgs e)
  2171. {
  2172. if(!this.allShow)
  2173. {
  2174. if (this.listView2.SelectedItems.Count <= 0)
  2175. return;
  2176. this.dataGridView2.Rows.Clear();
  2177. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  2178. {
  2179. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  2180. foreach (var dataTable in this.dataTables)
  2181. {
  2182. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  2183. dataTable1 = dataTable;
  2184. }
  2185. DataGridViewRow dgvr = new DataGridViewRow();
  2186. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2187. {
  2188. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2189. }
  2190. for (int c = 0; c < dataTable1.Columns.Count; c++)
  2191. {
  2192. dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
  2193. }
  2194. this.dataGridView2.Rows.Add(dgvr);
  2195. }
  2196. this.RefreshDataGridView4();
  2197. }
  2198. }
  2199. /// <summary>
  2200. /// 全部显示
  2201. /// </summary>
  2202. /// <param name="sender"></param>
  2203. /// <param name="e"></param>
  2204. private void button11_Click(object sender, EventArgs e)
  2205. {
  2206. if (this.listView2.Items.Count > 0)
  2207. {
  2208. this.button11.Visible = false;
  2209. this.button16.Visible = true;
  2210. this.button16.Focus();
  2211. this.allShow = true;
  2212. this.dataGridView2.Rows.Clear();
  2213. for (int i = 0; i < this.dataTables.Count; i++)
  2214. {
  2215. DataGridViewRow dgvr = new DataGridViewRow();
  2216. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2217. {
  2218. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2219. }
  2220. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  2221. {
  2222. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  2223. }
  2224. this.dataGridView2.Rows.Add(dgvr);
  2225. }
  2226. this.RefreshDataGridView4();
  2227. }
  2228. else
  2229. {
  2230. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  2231. }
  2232. }
  2233. /// <summary>
  2234. /// 取消全部显示
  2235. /// </summary>
  2236. /// <param name="sender"></param>
  2237. /// <param name="e"></param>
  2238. private void button16_Click(object sender, EventArgs e)
  2239. {
  2240. this.button11.Visible = true;
  2241. this.button16.Visible = false;
  2242. this.button11.Focus();
  2243. this.allShow = false;
  2244. if (this.listView2.SelectedItems.Count <= 0)
  2245. return;
  2246. this.dataGridView2.Rows.Clear();
  2247. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  2248. {
  2249. System.Data.DataTable dataTable1 = new System.Data.DataTable();
  2250. foreach (var dataTable in this.dataTables)
  2251. {
  2252. if (this.listView2.SelectedItems.Count > 0)
  2253. {
  2254. if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
  2255. dataTable1 = dataTable;
  2256. }
  2257. else
  2258. {
  2259. if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
  2260. dataTable1 = dataTable;
  2261. }
  2262. }
  2263. DataGridViewRow dgvr = new DataGridViewRow();
  2264. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2265. {
  2266. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2267. }
  2268. for (int c = 0; c < dataTable1.Columns.Count; c++)
  2269. {
  2270. dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
  2271. }
  2272. this.dataGridView2.Rows.Add(dgvr);
  2273. }
  2274. this.RefreshDataGridView4();
  2275. }
  2276. /// <summary>
  2277. /// 分析结果删除
  2278. /// </summary>
  2279. /// <param name="sender"></param>
  2280. /// <param name="e"></param>
  2281. private void button12_Click(object sender, EventArgs e)
  2282. {
  2283. if(this.listView2.Items.Count > 0)
  2284. {
  2285. if(this.listView2.SelectedItems.Count > 0)
  2286. {
  2287. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  2288. if (dr == DialogResult.OK)
  2289. {
  2290. if (this.listView2.SelectedItems.Count <= 0)
  2291. return;
  2292. for (int i = this.listView2.SelectedItems.Count - 1; i >= 0; i--)
  2293. {
  2294. int selectIndex = this.listView2.SelectedItems[i].Index;
  2295. foreach (var dataTable in this.dataTables)
  2296. {
  2297. if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
  2298. {
  2299. this.dataTables.Remove(dataTable);
  2300. break;
  2301. }
  2302. }
  2303. if (bitDic.ContainsKey((string)this.listView2.SelectedItems[i].Tag))
  2304. bitDic.Remove((string)this.listView2.SelectedItems[i].Tag);
  2305. //中间数据
  2306. foreach (ExportProjectModel model in this.tempDataModel)
  2307. {
  2308. if (model.tagName.Equals((string)this.listView2.SelectedItems[i].Tag))
  2309. {
  2310. this.tempDataModel.Remove(model);
  2311. break;
  2312. }
  2313. }
  2314. this.listView2.Items.RemoveAt(selectIndex);
  2315. }
  2316. if (this.listView2.Items.Count == 0)
  2317. this.dataGridView2.Rows.Clear();
  2318. else
  2319. {
  2320. //if (selectIndex == 0)
  2321. // this.listView2.Items[0].Selected = true;
  2322. //else
  2323. // this.listView2.Items[selectIndex - 1].Selected = true;
  2324. RefreshDataGridView4();
  2325. }
  2326. }
  2327. }
  2328. else
  2329. {
  2330. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
  2331. }
  2332. }
  2333. else
  2334. {
  2335. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  2336. }
  2337. }
  2338. /// <summary>
  2339. /// 刷新分析结果数据
  2340. /// </summary>
  2341. private void RefreshDataGridView4()
  2342. {
  2343. if (!this.allShow)
  2344. {
  2345. if (this.listView2.SelectedItems.Count > 0)
  2346. {
  2347. this.dataGridView2.Rows.Clear();
  2348. for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
  2349. {
  2350. int dataTableIndex = 0;
  2351. if (this.listView2.SelectedItems.Count > 0)
  2352. {
  2353. for (int i = 0; i < this.dataTables.Count; i++)
  2354. {
  2355. if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
  2356. dataTableIndex = i;
  2357. }
  2358. }
  2359. if (this.gbtType == 3 || this.gbtType == 4)
  2360. {
  2361. if (this.dataTables[dataTableIndex].Rows.Count > 0)
  2362. {
  2363. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2364. {
  2365. DataGridViewRow dgvr = new DataGridViewRow();
  2366. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2367. {
  2368. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2369. }
  2370. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2371. {
  2372. if (c == 2 || c == 3 || c == 4 || c == 5)
  2373. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2374. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2375. else
  2376. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2377. }
  2378. this.dataGridView2.Rows.Add(dgvr);
  2379. }
  2380. }
  2381. }
  2382. else
  2383. {
  2384. if (this.dataTables[dataTableIndex].Rows.Count > 0)
  2385. {
  2386. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2387. {
  2388. DataGridViewRow dgvr = new DataGridViewRow();
  2389. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2390. {
  2391. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2392. }
  2393. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2394. {
  2395. if (c == 2 || c == 4 || c == 5)
  2396. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2397. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2398. else
  2399. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2400. }
  2401. this.dataGridView2.Rows.Add(dgvr);
  2402. }
  2403. }
  2404. }
  2405. }
  2406. }
  2407. else if (this.listView2.Items.Count > 0)
  2408. {
  2409. this.dataGridView2.Rows.Clear();
  2410. var firstTag = this.listView2.Items[0].Tag;
  2411. int dataTableIndex = 0;
  2412. for (int i = 0; i < this.dataTables.Count; i++)
  2413. {
  2414. if (this.dataTables[i].TableName.Equals(firstTag))
  2415. dataTableIndex = i;
  2416. }
  2417. if (this.gbtType == 3 || this.gbtType == 4)
  2418. {
  2419. if (this.dataTables[dataTableIndex].Rows.Count > 0)
  2420. {
  2421. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2422. {
  2423. DataGridViewRow dgvr = new DataGridViewRow();
  2424. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2425. {
  2426. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2427. }
  2428. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2429. {
  2430. if (c == 2 || c == 3 || c == 4 || c == 5)
  2431. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2432. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2433. else
  2434. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2435. }
  2436. this.dataGridView2.Rows.Add(dgvr);
  2437. }
  2438. }
  2439. }
  2440. else
  2441. {
  2442. if (this.dataTables[dataTableIndex].Rows.Count > 0)
  2443. {
  2444. for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
  2445. {
  2446. DataGridViewRow dgvr = new DataGridViewRow();
  2447. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2448. {
  2449. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2450. }
  2451. for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
  2452. {
  2453. if (c == 2 || c == 4 || c == 5)
  2454. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
  2455. this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2456. else
  2457. dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
  2458. }
  2459. this.dataGridView2.Rows.Add(dgvr);
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465. else
  2466. {
  2467. this.dataGridView2.Rows.Clear();
  2468. DataTable dataTable = new DataTable();
  2469. if (this.gbtType == 3 || this.gbtType == 4)
  2470. for (int i = this.dataTables.Count - 1; i >= 0; i--)
  2471. {
  2472. dataTable = this.dataTables[i];
  2473. for (int r = 0; r < dataTable.Rows.Count; r++)
  2474. {
  2475. DataGridViewRow dgvr = new DataGridViewRow();
  2476. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2477. {
  2478. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2479. }
  2480. for (int c = 0; c < dataTable.Columns.Count; c++)
  2481. {
  2482. if (c == 2|| c == 3 || c == 4 || c == 5)
  2483. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
  2484. dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2485. else
  2486. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  2487. }
  2488. this.dataGridView2.Rows.Add(dgvr);
  2489. }
  2490. }
  2491. else
  2492. for (int i = this.dataTables.Count - 1; i >= 0; i--)
  2493. {
  2494. dataTable = this.dataTables[i];
  2495. for (int r = 0; r < dataTable.Rows.Count; r++)
  2496. {
  2497. DataGridViewRow dgvr = new DataGridViewRow();
  2498. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  2499. {
  2500. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  2501. }
  2502. for (int c = 0; c < dataTable.Columns.Count; c++)
  2503. {
  2504. if (c == 2 || c == 4 || c == 5)
  2505. dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
  2506. dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
  2507. else
  2508. dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
  2509. }
  2510. this.dataGridView2.Rows.Add(dgvr);
  2511. }
  2512. }
  2513. }
  2514. }
  2515. private Mat runDect(Mat OrgImg0, int dark, int smooth_type, double sigma, int enhance, double[] cell_size)
  2516. {
  2517. Mat GryImg = new Mat();
  2518. Mat OrgImg = new Mat();
  2519. /////
  2520. if (4 == OrgImg0.Channels())
  2521. {
  2522. Cv2.CvtColor(OrgImg0, OrgImg, ColorConversionCodes.BGRA2BGR);
  2523. }
  2524. else
  2525. {
  2526. OrgImg = OrgImg0.Clone();
  2527. }
  2528. In5segmsurf prm = new In5segmsurf();
  2529. prm.OrgImg = OrgImg;
  2530. /////
  2531. //Cv2.ImShow("src", OrgImg);//kkkkk
  2532. //Cv2.WaitKey(0);//kkkkk
  2533. //转为为灰度?
  2534. if (3 == OrgImg.Channels() || 4 == OrgImg.Channels())
  2535. {
  2536. Cv2.CvtColor(OrgImg, GryImg, ColorConversionCodes.RGB2GRAY);
  2537. }
  2538. else
  2539. {
  2540. if (1 == OrgImg.Channels())
  2541. {
  2542. GryImg = OrgImg.Clone();
  2543. }
  2544. else
  2545. {
  2546. return null;
  2547. }
  2548. }
  2549. if (1 == dark)
  2550. {
  2551. int Rows = GryImg.Rows;
  2552. int Cols = GryImg.Cols;
  2553. int[] point = new int[2];
  2554. //单通道图像的反色
  2555. for (point[0] = 0; point[0] < Rows; point[0]++)
  2556. {
  2557. for (point[1] = 0; point[1] < Cols; point[1]++)
  2558. {
  2559. byte bTemp = (byte)(255 - GryImg.At<byte>(point[0], point[1]));
  2560. GryImg.Set<byte>(point, bTemp);//mmmmm
  2561. }
  2562. }
  2563. }
  2564. if (2 == dark)
  2565. {
  2566. Mat TempImg = GryImg.Clone();
  2567. Cv2.Sobel(TempImg, GryImg, -1, 2, 2, 3);//mmmmm
  2568. }
  2569. //Cv2.ImShow("src", GryImg);//kkkkk
  2570. //Cv2.WaitKey(0);//kkkkk
  2571. //去噪
  2572. if (0 == smooth_type)
  2573. {
  2574. prm.smoothim_method = "gaussian";
  2575. }
  2576. else
  2577. {
  2578. if (1 == smooth_type)
  2579. {
  2580. prm.smoothim_method = "dirced";
  2581. }
  2582. else
  2583. {
  2584. return null;
  2585. }
  2586. }
  2587. //晶界增强
  2588. if (1 == enhance)
  2589. {
  2590. prm.filterridges = 1;
  2591. }
  2592. else
  2593. {
  2594. prm.filterridges = 0;
  2595. }
  2596. //调用算法
  2597. prm.gaussian_stdev = sigma;
  2598. prm.LEVEL = ".3";
  2599. prm.classifycells_convexarea = 0.50;
  2600. prm.classifycells_convexperim = 0.45;
  2601. OLDcellsegm cellsegm = new OLDcellsegm();
  2602. string[] namehere = new string[1] { "prm" };
  2603. In6segmsurf IN6BNImgs = new In6segmsurf();
  2604. OUTsegmsurf RSTss = cellsegm.mf_segmsurf_progress_auto(GryImg, cell_size[0], cell_size[1], namehere, prm, IN6BNImgs, this.panel1.BackColor, this);
  2605. cell_size = null;
  2606. cellsegm = null;
  2607. namehere = null;
  2608. Cv2.CvtColor(RSTss.wat, OrgImg0, ColorConversionCodes.BGR2BGRA);
  2609. //this.documentWorkspace.PhaseModels[1].mat = OrgImg0;// RSTss.wat;// action.PerformProcess(
  2610. //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
  2611. //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  2612. //////this.documentWorkspace.PhaseModels[1].color = this.panel2.BackColor.ToArgb();
  2613. //this.documentWorkspace.Refresh();
  2614. //return RSTss.wat;
  2615. //string filename = "D:\\result11.jpg";
  2616. //Cv2.ImWrite(filename, RSTss.wat);
  2617. return OrgImg0;
  2618. }
  2619. /// <summary>
  2620. /// 小数位数
  2621. /// </summary>
  2622. /// <param name="sender"></param>
  2623. /// <param name="e"></param>
  2624. private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
  2625. {
  2626. this.RefreshDataGridView4();
  2627. //this.dec = Convert.ToInt32(this.numericUpDown1_0.Value);
  2628. //if(this.dataTables.Count > 0)
  2629. //{
  2630. // foreach (var dataTable in this.dataTables)
  2631. // {
  2632. // }
  2633. //}
  2634. }
  2635. public void UpdateCupOffPointStyle()
  2636. {
  2637. styleClass.UpdateCupOffPointStyle();
  2638. AddRectangleToRectangleFCaps();
  2639. }
  2640. #region 内部类
  2641. internal class LocalListViewItem
  2642. {
  2643. public DocumentWorkspace Value { get; }
  2644. public string Display { get; }
  2645. public LocalListViewItem(DocumentWorkspace Value, string Display)
  2646. {
  2647. this.Value = Value;
  2648. this.Display = Display;
  2649. }
  2650. }
  2651. internal class DocumentItem
  2652. {
  2653. public Bitmap bitmap;
  2654. public GraphicsList graphicsList;
  2655. public List<PhaseModel> phaseModels;
  2656. //public AnalysisResult analysisResult;
  2657. public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
  2658. {
  2659. this.bitmap = bitmap;
  2660. this.graphicsList = graphicsList;
  2661. this.phaseModels = phaseModels;
  2662. }
  2663. }
  2664. #endregion
  2665. }
  2666. }