HighSpeedSteelCarbonBlockDialog.cs 157 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using OpenCvSharp.Extensions;
  4. using PaintDotNet.Annotation;
  5. using PaintDotNet.Annotation.Enum;
  6. using PaintDotNet.Base;
  7. using PaintDotNet.Base.CommTool;
  8. using PaintDotNet.Base.Functionodel;
  9. using PaintDotNet.CustomControl;
  10. using PaintDotNet.Data.Param;
  11. using PaintDotNet.DbOpreate.DbBll;
  12. using PaintDotNet.DbOpreate.DbModel;
  13. using PaintDotNet.DedicatedAnalysis.DuctileIron.Common;
  14. using PaintDotNet.Instrument;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.ComponentModel;
  18. using System.Data;
  19. using System.Data.Entity.Migrations.Infrastructure;
  20. using System.Diagnostics.Contracts;
  21. using System.Drawing;
  22. using System.Drawing.Drawing2D;
  23. using System.IO;
  24. using System.Linq;
  25. using System.Text;
  26. using System.Threading.Tasks;
  27. using System.Windows.Forms;
  28. namespace PaintDotNet.DedicatedAnalysis.HighSpeedSteelCarbonBlock.GB4462_84
  29. {
  30. /// <summary>
  31. /// 高速钢大块碳
  32. /// </summary>
  33. internal class HighSpeedSteelCarbonBlockDialog : PdnBaseForm
  34. {
  35. #region 基础控件
  36. private Button button1;
  37. private CheckBox checkBox1;
  38. private Button button2;
  39. private GroupBox groupBox2;
  40. private ListView listView1;
  41. private GroupBox groupBox3;
  42. private GroupBox groupBox5;
  43. private GroupBox groupBox6;
  44. private Panel panel2;
  45. private GroupBox groupBox8;
  46. private DataGridView dataGridView1;
  47. private GroupBox groupBox9;
  48. private Button button6;
  49. private Button button7;
  50. private ListView listView2;
  51. private DataGridView dataGridView2;
  52. private Button button9;
  53. private Button button8;
  54. private NumericUpDown numericUpDown1;
  55. private Label label8;
  56. private Label label9;
  57. private Label label10;
  58. private ImageList imageList1;
  59. private IContainer components;
  60. private GroupBox groupBox1;
  61. private TrackBar trackBar2;
  62. private NumericUpDown numericUpDown5;
  63. private NumericUpDown numericUpDown4;
  64. private Label label3;
  65. private CheckBox checkBox3;
  66. private Label label6;
  67. private Label label5;
  68. private Label label4;
  69. private Panel panel4;
  70. private Panel panel3;
  71. private RadioButton radioButton1;
  72. private RadioButton radioButton2;
  73. private RadioButton radioButton3;
  74. private RadioButton radioButton4;
  75. private TrackBar trackBar4;
  76. private Button button3;
  77. #endregion
  78. /// <summary>
  79. /// 调色板
  80. /// </summary>
  81. PaintDotNet.ColorsForm colorsForm1;
  82. PaintDotNet.ColorsForm colorsForm2;
  83. /// <summary>
  84. /// 主控件
  85. /// </summary>
  86. private AppWorkspace appWorkspace;
  87. /// <summary>
  88. /// 图像面板
  89. /// </summary>
  90. private DocumentWorkspaceWindow documentWorkspace;
  91. /// <summary>
  92. /// 公共按钮
  93. /// </summary>
  94. private CommonControlButtons commonControlButtons;
  95. /// <summary>
  96. /// 选中图片的bitmap
  97. /// </summary>
  98. private Bitmap bitmap;
  99. /// <summary>
  100. /// 计算结果的表格集合
  101. /// </summary>
  102. private List<DataTable> resultTableList = new List<DataTable>();
  103. /// <summary>
  104. /// 保存用于生成报告的图片
  105. /// </summary>
  106. private List<Bitmap> bitList;
  107. /// <summary>
  108. /// 储存点击保存结果后的所有原图与分析图
  109. /// </summary>
  110. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  111. /// <summary>
  112. /// 是否显示全部
  113. /// </summary>
  114. private bool showAll = false;
  115. /// <summary>
  116. /// 当前图片是否有视场
  117. /// </summary>
  118. private bool isHadView = false;
  119. /// <summary>
  120. /// 原图mat-包括视场
  121. /// </summary>
  122. private Mat mat;
  123. /// <summary>
  124. /// 相的集合
  125. /// </summary>
  126. //private PhaseModel phaseModel;
  127. /// <summary>
  128. /// 单位标尺
  129. /// </summary>
  130. private double unitLength = 1;
  131. /// <summary>
  132. /// 最大点碳化物点集合
  133. /// </summary>
  134. private List<List<OpenCvSharp.Point>> maxPoint;
  135. /// <summary>
  136. /// 钨系A标准
  137. /// </summary>
  138. private double[] tungstenA = new double[] { 18, 21, 23, 25 };
  139. /// <summary>
  140. /// 钨系B标准
  141. /// </summary>
  142. private double[] tungstenB = new double[] { 16, 18, 21, 23 };
  143. /// <summary>
  144. /// 钼系标准
  145. /// </summary>
  146. private double[] molybdenum = new double[] { 6.1, 8.3, 12.5, 15.6, 22.1 };
  147. /// <summary>
  148. /// 碳化物尺寸最大值
  149. /// </summary>
  150. private double maxSize = 0;
  151. /// <summary>
  152. /// 是否仅修改相的颜色
  153. /// </summary>
  154. private bool changeColor = false;
  155. /// <summary>
  156. /// 是否未对图片做其他操作
  157. /// </summary>
  158. private bool isFirstSwitch = false;
  159. /// <summary>
  160. /// 中间数据
  161. /// </summary>
  162. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  163. /// <summary>
  164. /// 面积
  165. /// </summary>
  166. private List<string> tempArea;
  167. private BinaryControl bc;
  168. //二值化集成1
  169. BinaryClass binaryClass;
  170. private int menuId;
  171. private string menuName;
  172. private DataGridView dataGridView3;
  173. private int defaultIndex = -1;
  174. /// <summary>
  175. /// 保存窗口参数
  176. /// </summary>
  177. /// <summary>
  178. /// 各个图片对应数据
  179. /// </summary>
  180. private Dictionary<string, GrainSizeAnalysisModel> eachData = new Dictionary<string, GrainSizeAnalysisModel>();
  181. private const string ParamKey_Report = "report";//报告设置
  182. private const string ParamKey_Screen = "screen";//筛选
  183. private const string ParamKey_ScreenMin = "screenMin";//面积最小值
  184. private const string ParamKey_ScreenMax = "screenMax";//面积最大值
  185. private const string ParamKey_Tungsten = "tungsten";//钨
  186. private const string ParamKey_Molybdenum = "molybdenum";//钼
  187. private const string ParamKey_ColumnA = "columnA";//A列
  188. private const string ParamKey_ColumnB = "columnB";//B列
  189. private const string ParamKey_MaxColour = "maxColour";//最大色
  190. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  191. private decimal areaMin = -1;//面积区间最小
  192. private decimal areaMax = -1;//面积区间最大
  193. private Button button4;
  194. private Button button5;
  195. private bool isExportResults = false;
  196. private bool isExportReports = false;
  197. private bool isExportProjects = false;
  198. /// <summary>
  199. /// 是否脚本运行
  200. /// </summary>
  201. private Boolean initScriptValues = false;
  202. /// <summary>
  203. /// 最大卡规直径
  204. /// </summary>
  205. private List<string> maxCaliperDiameter;
  206. public HighSpeedSteelCarbonBlockDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
  207. {
  208. this.appWorkspace = appWorkspace;
  209. NullKey();
  210. InitializeComponent();
  211. InitializeLanguageText();
  212. InitializeCustomControl();
  213. this.menuId = menuItem.MenuId;
  214. this.menuName = menuItem.Text;
  215. this.binaryClass = new BinaryClass(menuId);
  216. InitGridHeader();
  217. InitOtherTools();
  218. InitPicList();
  219. InitCommonButtonEvent();
  220. SetAnalyzeModelFromXml("Template.Manager.item3.HighSpeedSteelCarbonBlock");
  221. }
  222. private void ShowImgEvent(object sender, EventArgs e)
  223. {
  224. listView1.Focus();
  225. if (this.defaultIndex != -1)
  226. {
  227. //如果是脚本执行,将参数带入
  228. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  229. {
  230. this.initScriptValues = true;//ScriptAutomatic
  231. //Boolean initScriptValues = true;
  232. ////在这里反射出对应功能的参数类
  233. string className = InvariantData.path_Action + ".Action" + menuId;
  234. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  235. foreach (Args arg in param.Lists)
  236. {
  237. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  238. if (param1.value != null)
  239. arg.Value = param1.value;
  240. getValue(arg.key, arg.Value);
  241. }
  242. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  243. }
  244. else
  245. {//读取上次关闭窗口时保存的参数
  246. GetXmlParameter();
  247. GetListParamModel();
  248. }
  249. this.listView1.Items[defaultIndex].Focused = true;
  250. this.listView1.Items[defaultIndex].Selected = true;
  251. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  252. this.startScriptAutomaticAction();
  253. }
  254. }
  255. private void InitializeCustomControl()
  256. {
  257. //
  258. // bc
  259. //
  260. this.bc = new PaintDotNet.CustomControl.BinaryControl();
  261. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  262. this.bc.BinaryChecked = false;
  263. this.bc.BinaryStyle = 1;
  264. this.bc.Location = new System.Drawing.Point(150, 59);
  265. this.bc.Name = "bc";
  266. this.bc.OriginChecked = false;
  267. this.bc.scope1End = 0D;
  268. this.bc.scope1Start = 0D;
  269. this.bc.scope2End = 0D;
  270. this.bc.scope2Start = 0D;
  271. this.bc.scope3End = 0D;
  272. this.bc.scope3Start = 0D;
  273. this.bc.Size = new System.Drawing.Size(360, 292);
  274. this.bc.TabIndex = 19;
  275. this.Controls.Add(this.bc);
  276. this.Controls.SetChildIndex(this.bc, 0);
  277. }
  278. private void InitializeLanguageText()
  279. {
  280. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  281. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  282. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  283. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  284. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  285. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  286. this.groupBox5.Text = PdnResources.GetString("Menu.Particlescreening.text");
  287. this.label3.Text = PdnResources.GetString("Menu.range.text") + ":";
  288. this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");
  289. this.groupBox6.Text = PdnResources.GetString("Menu.paramssettings.text");
  290. this.radioButton4.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnB.text");
  291. this.radioButton3.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnA.text");
  292. this.radioButton2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Molybdenum.text");
  293. this.radioButton1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text");
  294. this.label6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Maximuecolor.text") + ":";
  295. this.label5.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.series.text") + ":";
  296. this.label4.Text = PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text") + ":";
  297. this.groupBox8.Text = PdnResources.GetString("Menu.Theesultshow.text");
  298. this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");
  299. this.button3.Text = PdnResources.GetString("Menu.Exportproject.text");
  300. this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  301. this.button9.Text = PdnResources.GetString("Menu.Exportresults.text");
  302. this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  303. this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  304. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  305. this.Text = "GB/T 4462-1984(" + PdnResources.GetString("Menu.Highspeedsteelbulkcarbo.Text") + ")";
  306. this.button4.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
  307. this.button5.Text = PdnResources.GetString("Menu.Applyall.text");
  308. }
  309. private void InitializeComponent()
  310. {
  311. this.components = new System.ComponentModel.Container();
  312. this.groupBox1 = new System.Windows.Forms.GroupBox();
  313. this.button2 = new System.Windows.Forms.Button();
  314. this.checkBox1 = new System.Windows.Forms.CheckBox();
  315. this.button1 = new System.Windows.Forms.Button();
  316. this.groupBox2 = new System.Windows.Forms.GroupBox();
  317. this.listView1 = new System.Windows.Forms.ListView();
  318. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  319. this.groupBox3 = new System.Windows.Forms.GroupBox();
  320. this.groupBox5 = new System.Windows.Forms.GroupBox();
  321. this.trackBar4 = new System.Windows.Forms.TrackBar();
  322. this.trackBar2 = new System.Windows.Forms.TrackBar();
  323. this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
  324. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  325. this.label3 = new System.Windows.Forms.Label();
  326. this.checkBox3 = new System.Windows.Forms.CheckBox();
  327. this.groupBox6 = new System.Windows.Forms.GroupBox();
  328. this.panel4 = new System.Windows.Forms.Panel();
  329. this.radioButton4 = new System.Windows.Forms.RadioButton();
  330. this.radioButton3 = new System.Windows.Forms.RadioButton();
  331. this.panel3 = new System.Windows.Forms.Panel();
  332. this.radioButton2 = new System.Windows.Forms.RadioButton();
  333. this.radioButton1 = new System.Windows.Forms.RadioButton();
  334. this.label6 = new System.Windows.Forms.Label();
  335. this.label5 = new System.Windows.Forms.Label();
  336. this.label4 = new System.Windows.Forms.Label();
  337. this.panel2 = new System.Windows.Forms.Panel();
  338. this.groupBox8 = new System.Windows.Forms.GroupBox();
  339. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  340. this.groupBox9 = new System.Windows.Forms.GroupBox();
  341. this.dataGridView3 = new System.Windows.Forms.DataGridView();
  342. this.button3 = new System.Windows.Forms.Button();
  343. this.label10 = new System.Windows.Forms.Label();
  344. this.label9 = new System.Windows.Forms.Label();
  345. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  346. this.label8 = new System.Windows.Forms.Label();
  347. this.button9 = new System.Windows.Forms.Button();
  348. this.button8 = new System.Windows.Forms.Button();
  349. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  350. this.listView2 = new System.Windows.Forms.ListView();
  351. this.button7 = new System.Windows.Forms.Button();
  352. this.button6 = new System.Windows.Forms.Button();
  353. this.button4 = new System.Windows.Forms.Button();
  354. this.button5 = new System.Windows.Forms.Button();
  355. this.groupBox1.SuspendLayout();
  356. this.groupBox2.SuspendLayout();
  357. this.groupBox5.SuspendLayout();
  358. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();
  359. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
  360. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
  361. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  362. this.groupBox6.SuspendLayout();
  363. this.panel4.SuspendLayout();
  364. this.panel3.SuspendLayout();
  365. this.groupBox8.SuspendLayout();
  366. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  367. this.groupBox9.SuspendLayout();
  368. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).BeginInit();
  369. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  370. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  371. this.SuspendLayout();
  372. //
  373. // groupBox1
  374. //
  375. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  376. | System.Windows.Forms.AnchorStyles.Right)));
  377. this.groupBox1.Controls.Add(this.button4);
  378. this.groupBox1.Controls.Add(this.button5);
  379. this.groupBox1.Controls.Add(this.button2);
  380. this.groupBox1.Controls.Add(this.checkBox1);
  381. this.groupBox1.Controls.Add(this.button1);
  382. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  383. this.groupBox1.Name = "groupBox1";
  384. this.groupBox1.Size = new System.Drawing.Size(1107, 50);
  385. this.groupBox1.TabIndex = 1;
  386. this.groupBox1.TabStop = false;
  387. //
  388. // button2
  389. //
  390. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  391. | System.Windows.Forms.AnchorStyles.Right)));
  392. this.button2.Location = new System.Drawing.Point(925, 13);
  393. this.button2.Name = "button2";
  394. this.button2.Size = new System.Drawing.Size(84, 30);
  395. this.button2.TabIndex = 2;
  396. this.button2.UseVisualStyleBackColor = true;
  397. this.button2.Click += new System.EventHandler(this.button2_Click);
  398. //
  399. // checkBox1
  400. //
  401. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  402. | System.Windows.Forms.AnchorStyles.Left)));
  403. this.checkBox1.AutoSize = true;
  404. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  405. this.checkBox1.Name = "checkBox1";
  406. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  407. this.checkBox1.TabIndex = 1;
  408. this.checkBox1.UseVisualStyleBackColor = true;
  409. //
  410. // button1
  411. //
  412. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  413. | System.Windows.Forms.AnchorStyles.Left)));
  414. this.button1.Location = new System.Drawing.Point(15, 14);
  415. this.button1.Name = "button1";
  416. this.button1.Size = new System.Drawing.Size(84, 30);
  417. this.button1.TabIndex = 0;
  418. this.button1.UseVisualStyleBackColor = true;
  419. this.button1.Click += new System.EventHandler(this.button1_Click);
  420. //
  421. // groupBox2
  422. //
  423. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  424. | System.Windows.Forms.AnchorStyles.Left)));
  425. this.groupBox2.Controls.Add(this.listView1);
  426. this.groupBox2.Location = new System.Drawing.Point(14, 60);
  427. this.groupBox2.Name = "groupBox2";
  428. this.groupBox2.Size = new System.Drawing.Size(135, 607);
  429. this.groupBox2.TabIndex = 2;
  430. this.groupBox2.TabStop = false;
  431. //
  432. // listView1
  433. //
  434. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  435. | System.Windows.Forms.AnchorStyles.Left)
  436. | System.Windows.Forms.AnchorStyles.Right)));
  437. this.listView1.HideSelection = false;
  438. this.listView1.LargeImageList = this.imageList1;
  439. this.listView1.Location = new System.Drawing.Point(5, 17);
  440. this.listView1.MultiSelect = false;
  441. this.listView1.Name = "listView1";
  442. this.listView1.Size = new System.Drawing.Size(124, 584);
  443. this.listView1.TabIndex = 0;
  444. this.listView1.UseCompatibleStateImageBehavior = false;
  445. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  446. this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
  447. //
  448. // imageList1
  449. //
  450. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  451. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  452. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  453. //
  454. // groupBox3
  455. //
  456. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  457. | System.Windows.Forms.AnchorStyles.Left)
  458. | System.Windows.Forms.AnchorStyles.Right)));
  459. this.groupBox3.Location = new System.Drawing.Point(515, 59);
  460. this.groupBox3.Name = "groupBox3";
  461. this.groupBox3.Size = new System.Drawing.Size(606, 606);
  462. this.groupBox3.TabIndex = 3;
  463. this.groupBox3.TabStop = false;
  464. //
  465. // groupBox5
  466. //
  467. this.groupBox5.Controls.Add(this.trackBar4);
  468. this.groupBox5.Controls.Add(this.trackBar2);
  469. this.groupBox5.Controls.Add(this.numericUpDown5);
  470. this.groupBox5.Controls.Add(this.numericUpDown4);
  471. this.groupBox5.Controls.Add(this.label3);
  472. this.groupBox5.Controls.Add(this.checkBox3);
  473. this.groupBox5.Location = new System.Drawing.Point(155, 351);
  474. this.groupBox5.Name = "groupBox5";
  475. this.groupBox5.Size = new System.Drawing.Size(353, 88);
  476. this.groupBox5.TabIndex = 5;
  477. this.groupBox5.TabStop = false;
  478. //
  479. // trackBar4
  480. //
  481. this.trackBar4.Cursor = System.Windows.Forms.Cursors.Hand;
  482. this.trackBar4.Location = new System.Drawing.Point(257, 41);
  483. this.trackBar4.Maximum = 0;
  484. this.trackBar4.Name = "trackBar4";
  485. this.trackBar4.Size = new System.Drawing.Size(92, 45);
  486. this.trackBar4.TabIndex = 14;
  487. this.trackBar4.TickStyle = System.Windows.Forms.TickStyle.None;
  488. this.trackBar4.Scroll += new System.EventHandler(this.trackBar4_Scroll);
  489. //
  490. // trackBar2
  491. //
  492. this.trackBar2.Cursor = System.Windows.Forms.Cursors.Hand;
  493. this.trackBar2.Location = new System.Drawing.Point(104, 41);
  494. this.trackBar2.Maximum = 0;
  495. this.trackBar2.Name = "trackBar2";
  496. this.trackBar2.Size = new System.Drawing.Size(92, 45);
  497. this.trackBar2.TabIndex = 13;
  498. this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None;
  499. this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll);
  500. //
  501. // numericUpDown5
  502. //
  503. this.numericUpDown5.Location = new System.Drawing.Point(197, 41);
  504. this.numericUpDown5.Maximum = new decimal(new int[] {
  505. 0,
  506. 0,
  507. 0,
  508. 0});
  509. this.numericUpDown5.Name = "numericUpDown5";
  510. this.numericUpDown5.Size = new System.Drawing.Size(62, 21);
  511. this.numericUpDown5.TabIndex = 12;
  512. this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
  513. //
  514. // numericUpDown4
  515. //
  516. this.numericUpDown4.Location = new System.Drawing.Point(44, 41);
  517. this.numericUpDown4.Maximum = new decimal(new int[] {
  518. 0,
  519. 0,
  520. 0,
  521. 0});
  522. this.numericUpDown4.Name = "numericUpDown4";
  523. this.numericUpDown4.Size = new System.Drawing.Size(62, 21);
  524. this.numericUpDown4.TabIndex = 10;
  525. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  526. //
  527. // label3
  528. //
  529. this.label3.AutoSize = true;
  530. this.label3.Location = new System.Drawing.Point(9, 45);
  531. this.label3.Name = "label3";
  532. this.label3.Size = new System.Drawing.Size(0, 12);
  533. this.label3.TabIndex = 9;
  534. //
  535. // checkBox3
  536. //
  537. this.checkBox3.AutoSize = true;
  538. this.checkBox3.Location = new System.Drawing.Point(30, 21);
  539. this.checkBox3.Name = "checkBox3";
  540. this.checkBox3.Size = new System.Drawing.Size(15, 14);
  541. this.checkBox3.TabIndex = 0;
  542. this.checkBox3.UseVisualStyleBackColor = true;
  543. this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
  544. //
  545. // groupBox6
  546. //
  547. this.groupBox6.Controls.Add(this.panel4);
  548. this.groupBox6.Controls.Add(this.panel3);
  549. this.groupBox6.Controls.Add(this.label6);
  550. this.groupBox6.Controls.Add(this.label5);
  551. this.groupBox6.Controls.Add(this.label4);
  552. this.groupBox6.Controls.Add(this.panel2);
  553. this.groupBox6.Location = new System.Drawing.Point(155, 443);
  554. this.groupBox6.Name = "groupBox6";
  555. this.groupBox6.Size = new System.Drawing.Size(353, 103);
  556. this.groupBox6.TabIndex = 6;
  557. this.groupBox6.TabStop = false;
  558. //
  559. // panel4
  560. //
  561. this.panel4.Controls.Add(this.radioButton4);
  562. this.panel4.Controls.Add(this.radioButton3);
  563. this.panel4.Location = new System.Drawing.Point(77, 41);
  564. this.panel4.Name = "panel4";
  565. this.panel4.Size = new System.Drawing.Size(170, 22);
  566. this.panel4.TabIndex = 11;
  567. //
  568. // radioButton4
  569. //
  570. this.radioButton4.AutoSize = true;
  571. this.radioButton4.Location = new System.Drawing.Point(72, 2);
  572. this.radioButton4.Name = "radioButton4";
  573. this.radioButton4.Size = new System.Drawing.Size(14, 13);
  574. this.radioButton4.TabIndex = 1;
  575. this.radioButton4.TabStop = true;
  576. this.radioButton4.UseVisualStyleBackColor = true;
  577. this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
  578. //
  579. // radioButton3
  580. //
  581. this.radioButton3.AutoSize = true;
  582. this.radioButton3.Checked = true;
  583. this.radioButton3.Location = new System.Drawing.Point(5, 2);
  584. this.radioButton3.Name = "radioButton3";
  585. this.radioButton3.Size = new System.Drawing.Size(14, 13);
  586. this.radioButton3.TabIndex = 0;
  587. this.radioButton3.TabStop = true;
  588. this.radioButton3.UseVisualStyleBackColor = true;
  589. this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
  590. //
  591. // panel3
  592. //
  593. this.panel3.Controls.Add(this.radioButton2);
  594. this.panel3.Controls.Add(this.radioButton1);
  595. this.panel3.Location = new System.Drawing.Point(137, 16);
  596. this.panel3.Name = "panel3";
  597. this.panel3.Size = new System.Drawing.Size(170, 22);
  598. this.panel3.TabIndex = 10;
  599. //
  600. // radioButton2
  601. //
  602. this.radioButton2.AutoSize = true;
  603. this.radioButton2.Location = new System.Drawing.Point(72, 2);
  604. this.radioButton2.Name = "radioButton2";
  605. this.radioButton2.Size = new System.Drawing.Size(14, 13);
  606. this.radioButton2.TabIndex = 1;
  607. this.radioButton2.TabStop = true;
  608. this.radioButton2.UseVisualStyleBackColor = true;
  609. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  610. //
  611. // radioButton1
  612. //
  613. this.radioButton1.AutoSize = true;
  614. this.radioButton1.Checked = true;
  615. this.radioButton1.Location = new System.Drawing.Point(5, 2);
  616. this.radioButton1.Name = "radioButton1";
  617. this.radioButton1.Size = new System.Drawing.Size(14, 13);
  618. this.radioButton1.TabIndex = 0;
  619. this.radioButton1.TabStop = true;
  620. this.radioButton1.UseVisualStyleBackColor = true;
  621. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  622. //
  623. // label6
  624. //
  625. this.label6.AutoSize = true;
  626. this.label6.Location = new System.Drawing.Point(30, 71);
  627. this.label6.Name = "label6";
  628. this.label6.Size = new System.Drawing.Size(0, 12);
  629. this.label6.TabIndex = 9;
  630. //
  631. // label5
  632. //
  633. this.label5.AutoSize = true;
  634. this.label5.Location = new System.Drawing.Point(30, 46);
  635. this.label5.Name = "label5";
  636. this.label5.Size = new System.Drawing.Size(0, 12);
  637. this.label5.TabIndex = 8;
  638. //
  639. // label4
  640. //
  641. this.label4.AutoSize = true;
  642. this.label4.Location = new System.Drawing.Point(30, 21);
  643. this.label4.Name = "label4";
  644. this.label4.Size = new System.Drawing.Size(0, 12);
  645. this.label4.TabIndex = 7;
  646. //
  647. // panel2
  648. //
  649. this.panel2.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  650. this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  651. this.panel2.Location = new System.Drawing.Point(156, 68);
  652. this.panel2.Name = "panel2";
  653. this.panel2.Size = new System.Drawing.Size(101, 18);
  654. this.panel2.TabIndex = 6;
  655. this.panel2.Click += new System.EventHandler(this.panel2_Click);
  656. //
  657. // groupBox8
  658. //
  659. this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  660. | System.Windows.Forms.AnchorStyles.Left)));
  661. this.groupBox8.Controls.Add(this.dataGridView1);
  662. this.groupBox8.Location = new System.Drawing.Point(155, 547);
  663. this.groupBox8.Name = "groupBox8";
  664. this.groupBox8.Size = new System.Drawing.Size(353, 119);
  665. this.groupBox8.TabIndex = 8;
  666. this.groupBox8.TabStop = false;
  667. //
  668. // dataGridView1
  669. //
  670. this.dataGridView1.AllowUserToAddRows = false;
  671. this.dataGridView1.AllowUserToDeleteRows = false;
  672. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  673. | System.Windows.Forms.AnchorStyles.Left)
  674. | System.Windows.Forms.AnchorStyles.Right)));
  675. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  676. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  677. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  678. this.dataGridView1.Location = new System.Drawing.Point(7, 17);
  679. this.dataGridView1.MultiSelect = false;
  680. this.dataGridView1.Name = "dataGridView1";
  681. this.dataGridView1.RowHeadersVisible = false;
  682. this.dataGridView1.RowTemplate.Height = 23;
  683. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  684. this.dataGridView1.Size = new System.Drawing.Size(340, 96);
  685. this.dataGridView1.TabIndex = 0;
  686. //
  687. // groupBox9
  688. //
  689. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  690. | System.Windows.Forms.AnchorStyles.Right)));
  691. this.groupBox9.Controls.Add(this.dataGridView3);
  692. this.groupBox9.Controls.Add(this.button3);
  693. this.groupBox9.Controls.Add(this.label10);
  694. this.groupBox9.Controls.Add(this.label9);
  695. this.groupBox9.Controls.Add(this.numericUpDown1);
  696. this.groupBox9.Controls.Add(this.label8);
  697. this.groupBox9.Controls.Add(this.button9);
  698. this.groupBox9.Controls.Add(this.button8);
  699. this.groupBox9.Controls.Add(this.dataGridView2);
  700. this.groupBox9.Controls.Add(this.listView2);
  701. this.groupBox9.Controls.Add(this.button7);
  702. this.groupBox9.Controls.Add(this.button6);
  703. this.groupBox9.Location = new System.Drawing.Point(14, 672);
  704. this.groupBox9.Name = "groupBox9";
  705. this.groupBox9.Size = new System.Drawing.Size(1107, 204);
  706. this.groupBox9.TabIndex = 9;
  707. this.groupBox9.TabStop = false;
  708. //
  709. // dataGridView3
  710. //
  711. this.dataGridView3.AllowUserToAddRows = false;
  712. this.dataGridView3.AllowUserToDeleteRows = false;
  713. this.dataGridView3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  714. | System.Windows.Forms.AnchorStyles.Left)
  715. | System.Windows.Forms.AnchorStyles.Right)));
  716. this.dataGridView3.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  717. this.dataGridView3.BackgroundColor = System.Drawing.Color.White;
  718. this.dataGridView3.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  719. this.dataGridView3.Location = new System.Drawing.Point(228, 121);
  720. this.dataGridView3.MultiSelect = false;
  721. this.dataGridView3.Name = "dataGridView3";
  722. this.dataGridView3.RowHeadersVisible = false;
  723. this.dataGridView3.RowTemplate.Height = 23;
  724. this.dataGridView3.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  725. this.dataGridView3.Size = new System.Drawing.Size(719, 76);
  726. this.dataGridView3.TabIndex = 12;
  727. //
  728. // button3
  729. //
  730. this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  731. this.button3.Location = new System.Drawing.Point(967, 102);
  732. this.button3.Name = "button3";
  733. this.button3.Size = new System.Drawing.Size(128, 26);
  734. this.button3.TabIndex = 10;
  735. this.button3.UseVisualStyleBackColor = true;
  736. this.button3.Click += new System.EventHandler(this.button3_Click);
  737. //
  738. // label10
  739. //
  740. this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  741. this.label10.AutoSize = true;
  742. this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
  743. this.label10.Location = new System.Drawing.Point(953, 9);
  744. this.label10.Name = "label10";
  745. this.label10.Size = new System.Drawing.Size(11, 192);
  746. this.label10.TabIndex = 9;
  747. this.label10.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|";
  748. //
  749. // label9
  750. //
  751. this.label9.AutoSize = true;
  752. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  753. this.label9.Location = new System.Drawing.Point(210, 9);
  754. this.label9.Name = "label9";
  755. this.label9.Size = new System.Drawing.Size(11, 192);
  756. this.label9.TabIndex = 8;
  757. this.label9.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|";
  758. //
  759. // numericUpDown1
  760. //
  761. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  762. this.numericUpDown1.Location = new System.Drawing.Point(1019, 162);
  763. this.numericUpDown1.Maximum = new decimal(new int[] {
  764. 10,
  765. 0,
  766. 0,
  767. 0});
  768. this.numericUpDown1.Name = "numericUpDown1";
  769. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  770. this.numericUpDown1.TabIndex = 7;
  771. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  772. //
  773. // label8
  774. //
  775. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  776. this.label8.AutoSize = true;
  777. this.label8.Location = new System.Drawing.Point(983, 167);
  778. this.label8.Name = "label8";
  779. this.label8.Size = new System.Drawing.Size(0, 12);
  780. this.label8.TabIndex = 6;
  781. //
  782. // button9
  783. //
  784. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  785. this.button9.Location = new System.Drawing.Point(967, 68);
  786. this.button9.Name = "button9";
  787. this.button9.Size = new System.Drawing.Size(128, 26);
  788. this.button9.TabIndex = 5;
  789. this.button9.UseVisualStyleBackColor = true;
  790. this.button9.Click += new System.EventHandler(this.button9_Click);
  791. //
  792. // button8
  793. //
  794. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  795. this.button8.Location = new System.Drawing.Point(967, 34);
  796. this.button8.Name = "button8";
  797. this.button8.Size = new System.Drawing.Size(128, 26);
  798. this.button8.TabIndex = 4;
  799. this.button8.UseVisualStyleBackColor = true;
  800. this.button8.Click += new System.EventHandler(this.button8_Click);
  801. //
  802. // dataGridView2
  803. //
  804. this.dataGridView2.AllowUserToAddRows = false;
  805. this.dataGridView2.AllowUserToDeleteRows = false;
  806. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  807. | System.Windows.Forms.AnchorStyles.Left)
  808. | System.Windows.Forms.AnchorStyles.Right)));
  809. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  810. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  811. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  812. this.dataGridView2.Location = new System.Drawing.Point(228, 13);
  813. this.dataGridView2.MultiSelect = false;
  814. this.dataGridView2.Name = "dataGridView2";
  815. this.dataGridView2.RowHeadersVisible = false;
  816. this.dataGridView2.RowTemplate.Height = 23;
  817. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  818. this.dataGridView2.Size = new System.Drawing.Size(719, 102);
  819. this.dataGridView2.TabIndex = 3;
  820. //
  821. // listView2
  822. //
  823. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  824. | System.Windows.Forms.AnchorStyles.Left)));
  825. this.listView2.HideSelection = false;
  826. this.listView2.Location = new System.Drawing.Point(16, 56);
  827. this.listView2.Name = "listView2";
  828. this.listView2.Size = new System.Drawing.Size(181, 140);
  829. this.listView2.TabIndex = 2;
  830. this.listView2.UseCompatibleStateImageBehavior = false;
  831. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  832. //
  833. // button7
  834. //
  835. this.button7.Location = new System.Drawing.Point(145, 20);
  836. this.button7.Name = "button7";
  837. this.button7.Size = new System.Drawing.Size(52, 26);
  838. this.button7.TabIndex = 1;
  839. this.button7.UseVisualStyleBackColor = true;
  840. this.button7.Click += new System.EventHandler(this.button7_Click);
  841. //
  842. // button6
  843. //
  844. this.button6.Location = new System.Drawing.Point(16, 20);
  845. this.button6.Name = "button6";
  846. this.button6.Size = new System.Drawing.Size(93, 26);
  847. this.button6.TabIndex = 0;
  848. this.button6.UseVisualStyleBackColor = true;
  849. this.button6.Click += new System.EventHandler(this.button6_Click);
  850. //
  851. // button4
  852. //
  853. this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  854. this.button4.Location = new System.Drawing.Point(1015, 13);
  855. this.button4.Name = "button4";
  856. this.button4.Size = new System.Drawing.Size(84, 30);
  857. this.button4.TabIndex = 19;
  858. this.button4.Text = "保存全部";
  859. this.button4.UseVisualStyleBackColor = true;
  860. this.button4.Click += new System.EventHandler(this.button4_Click);
  861. //
  862. // button5
  863. //
  864. this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  865. this.button5.Location = new System.Drawing.Point(835, 13);
  866. this.button5.Name = "button5";
  867. this.button5.Size = new System.Drawing.Size(84, 30);
  868. this.button5.TabIndex = 18;
  869. this.button5.Text = "应用全部";
  870. this.button5.UseVisualStyleBackColor = true;
  871. this.button5.Click += new System.EventHandler(this.button5_Click);
  872. //
  873. // HighSpeedSteelCarbonBlockDialog
  874. //
  875. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  876. this.ClientSize = new System.Drawing.Size(1133, 881);
  877. this.Controls.Add(this.groupBox9);
  878. this.Controls.Add(this.groupBox8);
  879. this.Controls.Add(this.groupBox6);
  880. this.Controls.Add(this.groupBox5);
  881. this.Controls.Add(this.groupBox3);
  882. this.Controls.Add(this.groupBox2);
  883. this.Controls.Add(this.groupBox1);
  884. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  885. this.Name = "HighSpeedSteelCarbonBlockDialog";
  886. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Dialog_FormClosing);
  887. this.Load += new System.EventHandler(this.MicrostructureBandDialog_Load);
  888. this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
  889. this.Controls.SetChildIndex(this.groupBox1, 0);
  890. this.Controls.SetChildIndex(this.groupBox2, 0);
  891. this.Controls.SetChildIndex(this.groupBox3, 0);
  892. this.Controls.SetChildIndex(this.groupBox5, 0);
  893. this.Controls.SetChildIndex(this.groupBox6, 0);
  894. this.Controls.SetChildIndex(this.groupBox8, 0);
  895. this.Controls.SetChildIndex(this.groupBox9, 0);
  896. this.groupBox1.ResumeLayout(false);
  897. this.groupBox1.PerformLayout();
  898. this.groupBox2.ResumeLayout(false);
  899. this.groupBox5.ResumeLayout(false);
  900. this.groupBox5.PerformLayout();
  901. ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();
  902. ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
  903. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
  904. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  905. this.groupBox6.ResumeLayout(false);
  906. this.groupBox6.PerformLayout();
  907. this.panel4.ResumeLayout(false);
  908. this.panel4.PerformLayout();
  909. this.panel3.ResumeLayout(false);
  910. this.panel3.PerformLayout();
  911. this.groupBox8.ResumeLayout(false);
  912. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  913. this.groupBox9.ResumeLayout(false);
  914. this.groupBox9.PerformLayout();
  915. ((System.ComponentModel.ISupportInitialize)(this.dataGridView3)).EndInit();
  916. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  917. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  918. this.ResumeLayout(false);
  919. }
  920. private void HighSpeedSteelCarbonBlockDialog_Load(object sender, EventArgs e)
  921. {
  922. this.binaryClass.loadParams();
  923. if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
  924. this.startScriptAutomaticAction();
  925. }
  926. /// <summary>
  927. /// 初始化其他控件
  928. /// </summary>
  929. private void InitOtherTools()
  930. {
  931. //
  932. //初始化图像控件
  933. //
  934. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  935. this.documentWorkspace.Dock = DockStyle.Fill;
  936. this.documentWorkspace.HookMouseEvents();
  937. this.documentWorkspace.AuxiliaryLineEnabled = false;
  938. this.documentWorkspace.Visible = false;
  939. this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.NullTool;
  940. this.groupBox3.Controls.Add(documentWorkspace);
  941. //
  942. //初始化操作按钮
  943. //
  944. this.commonControlButtons = new CommonControlButtons();
  945. this.commonControlButtons.Dock = DockStyle.Top;
  946. this.commonControlButtons.Height = 30;
  947. this.commonControlButtons.HideZoomToWindowAndActualSize();
  948. this.commonControlButtons.Visible = false;
  949. this.groupBox3.Controls.Add(commonControlButtons);
  950. //
  951. //调色板
  952. //
  953. this.colorsForm1 = new ColorsForm();
  954. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  955. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  956. this.colorsForm2 = new ColorsForm();
  957. this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed));
  958. this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;
  959. //
  960. //颜色pane2给定初始值
  961. //
  962. this.panel2.BackColor = Color.Green;
  963. ////
  964. ////获取系统标尺-微米
  965. ////
  966. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
  967. //二值化集成2
  968. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  969. binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Particlescreening.text") }
  970. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  971. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  972. }
  973. /// <summary>
  974. /// 初始化图片列表数据
  975. /// </summary>
  976. public void InitPicList()
  977. {
  978. //初始化图片列表
  979. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  980. {
  981. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  982. this.listView1.Items.Add("", i);
  983. this.listView1.Items[i].ImageIndex = i;
  984. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  985. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  986. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  987. {
  988. defaultIndex = i;
  989. }
  990. }
  991. this.Shown += ShowImgEvent;
  992. }
  993. /// <summary>
  994. /// 初始化表头
  995. /// </summary>
  996. private void InitGridHeader()
  997. {
  998. //
  999. //结果展示表
  1000. //
  1001. this.dataGridView1.ColumnHeadersHeight = 30;
  1002. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1003. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1004. h1.Width = 66;
  1005. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1006. h2.Width = 138;
  1007. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1008. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1009. h3.Width = 66;
  1010. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1011. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1012. h4.Width = 66;
  1013. this.dataGridView1.Columns.Add(h1);
  1014. this.dataGridView1.Columns.Add(h2);
  1015. this.dataGridView1.Columns.Add(h3);
  1016. this.dataGridView1.Columns.Add(h4);
  1017. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  1018. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.view.text")));
  1019. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text")));
  1020. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.sizeed.text")));
  1021. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.levdel.Text")));
  1022. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1023. this.dataGridView1.Columns[0].ReadOnly = true;
  1024. this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  1025. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1026. this.dataGridView1.Columns[1].ReadOnly = true;
  1027. this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1028. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1029. this.dataGridView1.Columns[2].ReadOnly = true;
  1030. this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1031. this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1032. this.dataGridView1.Columns[3].ReadOnly = true;
  1033. this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  1034. this.dataGridView1.AllowUserToResizeRows = false;
  1035. this.dataGridView1.AllowUserToResizeColumns = false;
  1036. //
  1037. //分析结果表
  1038. //
  1039. this.dataGridView2.ColumnHeadersHeight = 30;
  1040. DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();
  1041. //h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1042. h5.Width = 115;
  1043. DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();
  1044. h6.Width = 155;
  1045. DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();
  1046. //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1047. h7.Width = 190;
  1048. DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();
  1049. //h8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1050. h8.Width = 115;
  1051. DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();
  1052. //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1053. h9.Width = 115;
  1054. this.dataGridView2.Columns.Add(h5);
  1055. this.dataGridView2.Columns.Add(h6);
  1056. this.dataGridView2.Columns.Add(h7);
  1057. this.dataGridView2.Columns.Add(h8);
  1058. this.dataGridView2.Columns.Add(h9);
  1059. DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  1060. helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1061. helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.view.text")));
  1062. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text")));
  1063. helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.sizeed.text")));
  1064. helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.levdel.Text")));
  1065. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1066. this.dataGridView2.Columns[0].ReadOnly = true;
  1067. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1068. this.dataGridView2.Columns[1].ReadOnly = true;
  1069. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1070. this.dataGridView2.Columns[2].ReadOnly = true;
  1071. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1072. this.dataGridView2.Columns[3].ReadOnly = true;
  1073. this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1074. this.dataGridView2.Columns[4].ReadOnly = true;
  1075. this.dataGridView2.AllowUserToResizeRows = false;
  1076. this.dataGridView2.AllowUserToResizeColumns = false;
  1077. this.dataGridView3.ColumnHeadersHeight = 30;
  1078. DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn();
  1079. //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1080. h10.Width = 115;
  1081. DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
  1082. h11.Width = 155;
  1083. DataGridViewTextBoxColumn h12 = new DataGridViewTextBoxColumn();
  1084. //h12.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1085. h12.Width = 190;
  1086. DataGridViewTextBoxColumn h13 = new DataGridViewTextBoxColumn();
  1087. //h13.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1088. h13.Width = 115;
  1089. DataGridViewTextBoxColumn h14 = new DataGridViewTextBoxColumn();
  1090. //h14.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1091. h14.Width = 115;
  1092. this.dataGridView3.Columns.Add(h10);
  1093. this.dataGridView3.Columns.Add(h11);
  1094. this.dataGridView3.Columns.Add(h12);
  1095. this.dataGridView3.Columns.Add(h13);
  1096. this.dataGridView3.Columns.Add(h14);
  1097. DataGridViewHelper helper3 = new DataGridViewHelper(this.dataGridView3);
  1098. helper3.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1099. helper3.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.view.text")));
  1100. helper3.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text")));
  1101. helper3.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.sizeed.text")));
  1102. helper3.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.levdel.Text")));
  1103. this.dataGridView3.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1104. this.dataGridView3.Columns[0].ReadOnly = true;
  1105. this.dataGridView3.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1106. this.dataGridView3.Columns[1].ReadOnly = true;
  1107. this.dataGridView3.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1108. this.dataGridView3.Columns[2].ReadOnly = true;
  1109. this.dataGridView3.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1110. this.dataGridView3.Columns[3].ReadOnly = true;
  1111. this.dataGridView3.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
  1112. this.dataGridView3.Columns[4].ReadOnly = true;
  1113. this.dataGridView3.AllowUserToResizeRows = false;
  1114. this.dataGridView3.AllowUserToResizeColumns = false;
  1115. //
  1116. //左下表
  1117. //
  1118. this.listView2.View = View.Details;
  1119. ColumnHeader header0 = new ColumnHeader();
  1120. header0.Text = PdnResources.GetString("Menu.Imagelist.Text");
  1121. header0.Width = 175;
  1122. this.listView2.Columns.Add(header0);
  1123. }
  1124. /// <summary>
  1125. /// 初始化画布按键功能
  1126. /// </summary>
  1127. private void InitCommonButtonEvent()
  1128. {
  1129. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1130. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1131. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1132. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1133. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1134. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1135. }
  1136. //二值化集成3
  1137. #region 二值化相关方法
  1138. private void Dialog_FormClosing(object sender, FormClosingEventArgs e)
  1139. {
  1140. #region [开启脚本录制]
  1141. if (appWorkspace.startScriptRecording)
  1142. {
  1143. getScriptRecording();
  1144. }
  1145. #endregion
  1146. binaryClass.saveParams();
  1147. this.saveDialogParamValues();
  1148. //xml保存路径
  1149. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  1150. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  1151. foreach (var analysisItem in this.eachData[GetImgKey()].ListParam)
  1152. {
  1153. bool foundItem = false;
  1154. foreach (var item in analysisModelXml.ListParam)
  1155. {
  1156. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  1157. {
  1158. item.param_value = analysisItem.param_value;
  1159. foundItem = true;
  1160. break;
  1161. }
  1162. }
  1163. if (!foundItem)
  1164. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  1165. }
  1166. //按路径和名称保存xml文件
  1167. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  1168. //保存xml
  1169. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  1170. }
  1171. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  1172. {
  1173. binaryClass.RefreshHistogramControl1Values();
  1174. }
  1175. /// <summary>
  1176. /// 添加参数改变的监听
  1177. /// </summary>
  1178. /// <param name="sender"></param>
  1179. /// <param name="e"></param>
  1180. private void MicrostructureBandDialog_Load(object sender, EventArgs e)
  1181. {
  1182. this.binaryClass.loadParams();
  1183. }
  1184. private bool bcBinaryChecked()
  1185. {
  1186. return bc != null && bc.BinaryChecked;
  1187. }
  1188. private bool bcOriginChecked()
  1189. {
  1190. return bc != null && bc.OriginChecked;
  1191. }
  1192. /// <summary>
  1193. /// 参数改变时,重新处理图像
  1194. /// </summary>
  1195. /// <param name="sender"></param>
  1196. /// <param name="e"></param>
  1197. //AppCommon appCommonDisplay = new AppCommon();
  1198. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  1199. {
  1200. if (this.documentWorkspace.CompositionSurface == null)
  1201. return;
  1202. sum++;
  1203. if (bcBinaryChecked())
  1204. {
  1205. if (bcOriginChecked())
  1206. {
  1207. this.documentWorkspace.PhaseModels[1].choise = false;
  1208. }
  1209. else
  1210. {
  1211. this.documentWorkspace.PhaseModels[1].choise = true;
  1212. }
  1213. ResetAreaAndContent();
  1214. ReloadDebrisSelection();
  1215. changeColor = false;
  1216. this.documentWorkspace.PhaseModels[0].choise = false;
  1217. }
  1218. else
  1219. {
  1220. this.documentWorkspace.PhaseModels[0].choise = false;
  1221. this.documentWorkspace.PhaseModels[1].choise = false;
  1222. appCommon.DisplayData(this.dataGridView1, false);
  1223. }
  1224. //this.documentWorkspace.Refresh();
  1225. }
  1226. /// <summary>
  1227. /// 显示原图/原图+二值图
  1228. /// </summary>
  1229. /// <param name="sender"></param>
  1230. /// <param name="e"></param>
  1231. private void bcOriginCheckedChanged(object sender, EventArgs e)
  1232. {
  1233. if (!bcOriginChecked())
  1234. {
  1235. if (bcBinaryChecked())
  1236. {
  1237. //this.documentWorkspace.PhaseModels[0].choise = false;
  1238. this.documentWorkspace.PhaseModels[1].choise = true;
  1239. appCommon.DisplayData(this.dataGridView1, true);
  1240. }
  1241. }
  1242. else
  1243. {
  1244. this.documentWorkspace.PhaseModels[0].choise = false;
  1245. this.documentWorkspace.PhaseModels[1].choise = false;
  1246. appCommon.DisplayData(this.dataGridView1, false);
  1247. }
  1248. this.documentWorkspace.Refresh();
  1249. }
  1250. #endregion
  1251. private void zoomInButton_Click(object sender, EventArgs e)
  1252. {
  1253. this.documentWorkspace.ZoomIn();
  1254. }
  1255. private void zoomOutButton_Click(object sender, EventArgs e)
  1256. {
  1257. this.documentWorkspace.ZoomOut();
  1258. }
  1259. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1260. {
  1261. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1262. }
  1263. private void actualSizeButton_Click(object sender, EventArgs e)
  1264. {
  1265. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1266. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1267. }
  1268. private void pointerButton_Click(object sender, EventArgs e)
  1269. {
  1270. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1271. }
  1272. private void mobileModeButton_Click(object sender, EventArgs e)
  1273. {
  1274. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1275. }
  1276. /// <summary>
  1277. /// 添加内容单元格
  1278. /// </summary>
  1279. /// <param name="text"></param>
  1280. /// <param name="tag"></param>
  1281. /// <returns></returns>
  1282. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  1283. {
  1284. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1285. textboxcell.Value = text;
  1286. textboxcell.Tag = tag;
  1287. return textboxcell;
  1288. }
  1289. /// <summary>
  1290. /// 设置按钮
  1291. /// </summary>
  1292. /// <param name="sender"></param>
  1293. /// <param name="e"></param>
  1294. private void button1_Click(object sender, EventArgs e)
  1295. {
  1296. AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.HighSpeedSteelCarbonBlock");
  1297. if (metallographicMethodSetDialog.hasModule)
  1298. {
  1299. metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1300. metallographicMethodSetDialog.ShowDialog();
  1301. }
  1302. else
  1303. {
  1304. metallographicMethodSetDialog = null;
  1305. }
  1306. }
  1307. DialogResult dr;
  1308. /// <summary>
  1309. /// 保存结果按钮
  1310. /// </summary>
  1311. /// <param name="sender"></param>
  1312. /// <param name="e"></param>
  1313. private void button2_Click(object sender, EventArgs e)
  1314. {
  1315. if (this.listView1.SelectedItems.Count > 0)
  1316. {
  1317. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1318. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1319. bool replace = false;
  1320. int rowIndex = 0;
  1321. if (this.dataGridView1.Rows.Count > 0)
  1322. {
  1323. if (this.listView2.Items.Count > 0)
  1324. {
  1325. foreach (ListViewItem item in this.listView2.Items)
  1326. {
  1327. if (!blSaveAll && item.Name.Equals(tag))
  1328. {
  1329. dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1330. break;
  1331. }
  1332. }
  1333. foreach (ListViewItem item in this.listView2.Items)
  1334. {
  1335. if (item.Name.Equals(tag))
  1336. {
  1337. if (dr == DialogResult.OK || blSaveAll)
  1338. {
  1339. replace = true;
  1340. }
  1341. else
  1342. {
  1343. return;
  1344. }
  1345. break;
  1346. }
  1347. }
  1348. }
  1349. //有重名需要替换
  1350. if (replace)
  1351. {
  1352. for (int i = 0; i < this.resultTableList.Count; i++)
  1353. {
  1354. if (this.resultTableList[i].TableName.Equals(tag))
  1355. {
  1356. rowIndex = i;
  1357. this.resultTableList.Remove(this.resultTableList[i]);
  1358. if (this.maxSize > 0)
  1359. {
  1360. resultTableList.Insert(rowIndex, dtResult);
  1361. }
  1362. }
  1363. }
  1364. }
  1365. //新增
  1366. else
  1367. {
  1368. ListViewItem listViewItem = new ListViewItem();
  1369. listViewItem.Name = tag;
  1370. listViewItem.SubItems[0].Text = imgName;
  1371. this.listView2.Items.Add(listViewItem);
  1372. this.listView2.SelectedItems.Clear();
  1373. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1374. if (this.maxSize > 0)
  1375. {
  1376. resultTableList.Insert(rowIndex, dtResult);
  1377. }
  1378. }
  1379. RefreshDataGridView2();
  1380. //保存处理后的图片
  1381. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1382. List<Bitmap> tempBit = new List<Bitmap>();
  1383. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1384. originalBit.Tag = pantographRatio;
  1385. tempBit.Add(originalBit);
  1386. Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[1].mat);
  1387. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1388. Graphics graphics = Graphics.FromImage(newBit);
  1389. graphics.DrawImage(processedBit, new PointF(0, 0));
  1390. newBit.Tag = pantographRatio;
  1391. tempBit.Add(newBit);
  1392. if (bitDic.ContainsKey(tag))
  1393. bitDic[tag] = tempBit;
  1394. else
  1395. bitDic.Add(tag, tempBit);
  1396. //拼接中间数据
  1397. List<List<string>> dataList = new List<List<string>>();
  1398. List<string> columnName = new List<string>();
  1399. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  1400. columnName.Add(PdnResources.GetString("Menu.area.text"));
  1401. columnName.Add(PdnResources.GetString("Menu.Maximumcaliperdiameter.text"));
  1402. dataList.Add(columnName);
  1403. if (this.tempArea.Count > 0)
  1404. {
  1405. for (int i = 0; i < this.tempArea.Count; i++)
  1406. {
  1407. List<string> strList = new List<string>();
  1408. strList.Add((i + 1).ToString());
  1409. strList.Add(this.tempArea[i]);
  1410. strList.Add(this.maxCaliperDiameter[i]);
  1411. dataList.Add(strList);
  1412. }
  1413. }
  1414. bool isExist = false;//是否已存在进行替换
  1415. int modelIndex = -1;//要替换的下标
  1416. for (int j = 0; j < tempDataModel.Count; j++)
  1417. {
  1418. if (tempDataModel[j].tagName.Equals(tag))
  1419. {
  1420. isExist = true;
  1421. modelIndex = j;
  1422. break;
  1423. }
  1424. }
  1425. if (isExist && modelIndex > -1)
  1426. tempDataModel[modelIndex].dataList = dataList;
  1427. else
  1428. {
  1429. ExportProjectModel newModel = new ExportProjectModel();
  1430. newModel.tagName = tag;
  1431. newModel.picName = imgName;
  1432. newModel.dataList = dataList;
  1433. tempDataModel.Add(newModel);
  1434. }
  1435. }
  1436. else
  1437. {
  1438. MessageBox.Show(PdnResources.GetString("Menu.Nocarbidtosave.text"));
  1439. }
  1440. }
  1441. else
  1442. {
  1443. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1444. }
  1445. }
  1446. /// <summary>
  1447. /// 刷新分析结果表
  1448. /// </summary>
  1449. private void RefreshDataGridView2()
  1450. {
  1451. //需要计算平均值的集合
  1452. List<double> lstSize = new List<double>();
  1453. //综合平均值
  1454. double avglstSize = 0;
  1455. dataGridView2.Rows.Clear();
  1456. dataGridView3.Rows.Clear();
  1457. if (resultTableList.Count > 0)
  1458. {
  1459. if (this.showAll)
  1460. {
  1461. //dataGridView2.Rows.Clear();
  1462. int i = 0;
  1463. for (int k = 0; k < resultTableList.Count; k++)
  1464. {
  1465. dataGridView2.Rows.Add(resultTableList[k].Rows.Count);//增加同等数量的行数
  1466. foreach (DataRow row in resultTableList[k].Rows)//逐个读取单元格的内容;
  1467. {
  1468. DataGridViewRow r1 = dataGridView2.Rows[i];
  1469. r1.Cells[0].Value = row.RowState.ToString();
  1470. for (int j = 0; j < resultTableList[k].Columns.Count; j++)
  1471. {
  1472. if (j == 0 || j == 1 || j == 2 || j == 4)
  1473. {
  1474. r1.Cells[j].Value = row[j].ToString();
  1475. }
  1476. else
  1477. {
  1478. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  1479. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  1480. }
  1481. //r1.Cells[j].Value = row[j];
  1482. if (!row[1].Equals(PdnResources.GetString("Menu.Image.Average.Text")))
  1483. {
  1484. if (j == 3)
  1485. {
  1486. lstSize.Add(double.Parse(row[j].ToString()));
  1487. }
  1488. }
  1489. }
  1490. i++;
  1491. }
  1492. }
  1493. }
  1494. else
  1495. {
  1496. //dataGridView2.Rows.Clear();
  1497. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1498. {
  1499. int h = 0;
  1500. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1501. {
  1502. string tableName = this.listView2.SelectedItems[i].Name;
  1503. foreach (DataTable dt in resultTableList)
  1504. {
  1505. if (dt.TableName.Equals(tableName))
  1506. {
  1507. dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
  1508. foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
  1509. {
  1510. DataGridViewRow r1 = dataGridView2.Rows[h];
  1511. r1.Cells[0].Value = row.RowState.ToString();
  1512. for (int j = 0; j < dt.Columns.Count; j++)
  1513. {
  1514. if (j == 0 || j == 1 || j == 2 || j == 4)
  1515. {
  1516. r1.Cells[j].Value = row[j].ToString();
  1517. }
  1518. else
  1519. {
  1520. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  1521. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  1522. }
  1523. //r1.Cells[j].Value = row[j];
  1524. if (!row[1].Equals(PdnResources.GetString("Menu.Image.Average.Text")))
  1525. {
  1526. if (j == 3)
  1527. {
  1528. lstSize.Add(double.Parse(row[j].ToString()));
  1529. }
  1530. }
  1531. }
  1532. h++;
  1533. }
  1534. }
  1535. }
  1536. }
  1537. }
  1538. }
  1539. if (dataGridView2.Rows.Count > 0)
  1540. {
  1541. string series = string.Empty;
  1542. if (this.radioButton1.Checked)
  1543. {
  1544. if (this.radioButton3.Checked)
  1545. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnA.text");
  1546. else
  1547. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnB.text");
  1548. }
  1549. else
  1550. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Molybdenum.text");
  1551. if (lstSize.Count > 0)
  1552. {
  1553. avglstSize = (double)lstSize.Average();
  1554. }
  1555. string avgLevel = string.Empty;
  1556. if (this.radioButton1.Checked)
  1557. {
  1558. if (this.radioButton3.Checked)
  1559. {
  1560. if (avglstSize < tungstenA[0])
  1561. avgLevel = "1";
  1562. else if (avglstSize >= tungstenA[0] && avglstSize <= tungstenA[1])
  1563. avgLevel = "2";
  1564. else if (avglstSize >= tungstenA[1] && avglstSize <= tungstenA[2])
  1565. avgLevel = "3";
  1566. else if (avglstSize >= tungstenA[2] && avglstSize <= tungstenA[3])
  1567. avgLevel = "4";
  1568. else
  1569. avgLevel = "S";
  1570. }
  1571. else
  1572. {
  1573. if (avglstSize < tungstenB[0])
  1574. avgLevel = "1";
  1575. else if (avglstSize >= tungstenB[0] && avglstSize <= tungstenB[1])
  1576. avgLevel = "2";
  1577. else if (avglstSize >= tungstenB[1] && avglstSize <= tungstenB[2])
  1578. avgLevel = "3";
  1579. else if (avglstSize >= tungstenB[2] && avglstSize <= tungstenB[3])
  1580. avgLevel = "4";
  1581. else
  1582. avgLevel = "S";
  1583. }
  1584. }
  1585. else
  1586. {
  1587. if (avglstSize < molybdenum[0])
  1588. avgLevel = "2";
  1589. else if (avglstSize >= molybdenum[0] && avglstSize < molybdenum[1])
  1590. avgLevel = "3";
  1591. else if (avglstSize >= molybdenum[1] && avglstSize < molybdenum[2])
  1592. avgLevel = "4";
  1593. else if (avglstSize >= molybdenum[2] && avglstSize < molybdenum[3])
  1594. avgLevel = "5";
  1595. else if (avglstSize >= molybdenum[3] && avglstSize < molybdenum[4])
  1596. avgLevel = "6";
  1597. else
  1598. avgLevel = "S";
  1599. }
  1600. this.dataGridView3.Rows.Add(PdnResources.GetString("Menu.comprehensive.text"), PdnResources.GetString("Menu.Comprehensivaverage.text"), series, Math.Round(double.Parse(string.IsNullOrEmpty(avglstSize.ToString()) ? "0" : avglstSize.ToString()), Convert.ToInt32(this.numericUpDown1.Value)), avgLevel);
  1601. }
  1602. }
  1603. }
  1604. /// <summary>
  1605. /// 全部显示按钮
  1606. /// </summary>
  1607. /// <param name="sender"></param>
  1608. /// <param name="e"></param>
  1609. private void button6_Click(object sender, EventArgs e)
  1610. {
  1611. if (this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1612. {
  1613. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1614. this.showAll = true;
  1615. RefreshDataGridView2();
  1616. }
  1617. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1618. {
  1619. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1620. this.showAll = false;
  1621. RefreshDataGridView2();
  1622. }
  1623. }
  1624. /// <summary>
  1625. /// 删除按钮
  1626. /// </summary>
  1627. /// <param name="sender"></param>
  1628. /// <param name="e"></param>
  1629. private void button7_Click(object sender, EventArgs e)
  1630. {
  1631. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1632. {
  1633. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1634. if (dr == DialogResult.OK)
  1635. {
  1636. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1637. {
  1638. string tableName = this.listView2.SelectedItems[i].Name;
  1639. foreach (DataTable dt in resultTableList)
  1640. {
  1641. if (dt.TableName.Equals(tableName))
  1642. {
  1643. resultTableList.Remove(dt);
  1644. break;
  1645. }
  1646. }
  1647. if (bitDic.ContainsKey(tableName))
  1648. bitDic.Remove(tableName);
  1649. foreach (ExportProjectModel model in this.tempDataModel)
  1650. {
  1651. if (model.tagName.Equals(tableName))
  1652. {
  1653. this.tempDataModel.Remove(model);
  1654. break;
  1655. }
  1656. }
  1657. }
  1658. foreach (ListViewItem item in this.listView2.Items)
  1659. {
  1660. if (item.Selected)
  1661. this.listView2.Items.Remove(item);
  1662. }
  1663. RefreshDataGridView2();
  1664. }
  1665. }
  1666. }
  1667. /// <summary>
  1668. /// 生成报告按钮
  1669. /// </summary>
  1670. /// <param name="sender"></param>
  1671. /// <param name="e"></param>
  1672. private void button8_Click(object sender, EventArgs e)
  1673. {
  1674. if (dataGridView2.Rows.Count == 0)
  1675. {
  1676. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  1677. return;
  1678. }
  1679. if (this.checkBox1.Checked)
  1680. this.button1.PerformClick();
  1681. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1682. {
  1683. //获取word书签与excel单元格的关系,以字典方式存储
  1684. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1685. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1686. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1687. {
  1688. foreach (mic_module_infos info in mic_module_infos)
  1689. {
  1690. tagInfos.Add(info.tag_name, info.cell_position);
  1691. }
  1692. }
  1693. //分析结果
  1694. List<List<string>> analysisContent = new List<List<string>>();
  1695. List<string> contentHead = new List<string>();
  1696. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  1697. contentHead.Add(PdnResources.GetString("Menu.view.text"));
  1698. contentHead.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
  1699. contentHead.Add(PdnResources.GetString("Menu.sizeed.text"));
  1700. contentHead.Add(PdnResources.GetString("Menu.levdel.Text"));
  1701. analysisContent.Add(contentHead);
  1702. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1703. {
  1704. List<string> content = new List<string>();
  1705. content.Add(item.Cells[0].Value.ToString());
  1706. content.Add(item.Cells[1].Value.ToString());
  1707. content.Add(item.Cells[2].Value.ToString());
  1708. content.Add(item.Cells[3].Value.ToString());
  1709. content.Add(item.Cells[4].Value.ToString());
  1710. analysisContent.Add(content);
  1711. }
  1712. analysisContent.Add(new List<string>() { "\r" });
  1713. foreach (DataGridViewRow item in this.dataGridView3.Rows)
  1714. {
  1715. List<string> content = new List<string>();
  1716. content.Add(item.Cells[0].Value.ToString());
  1717. content.Add(item.Cells[1].Value.ToString());
  1718. content.Add(item.Cells[2].Value.ToString());
  1719. content.Add(item.Cells[3].Value.ToString());
  1720. content.Add(item.Cells[4].Value.ToString());
  1721. analysisContent.Add(content);
  1722. }
  1723. //图片
  1724. bitList = new List<Bitmap>();
  1725. if (this.showAll)
  1726. {
  1727. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1728. {
  1729. bitList.Add(kv.Value[0]);
  1730. bitList.Add(kv.Value[1]);
  1731. }
  1732. }
  1733. else
  1734. {
  1735. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1736. {
  1737. foreach (ListViewItem item in this.listView2.SelectedItems)
  1738. {
  1739. if (bitDic.ContainsKey(item.Name))
  1740. {
  1741. bitList.Add(bitDic[item.Name][0]);
  1742. bitList.Add(bitDic[item.Name][1]);
  1743. }
  1744. }
  1745. }
  1746. }
  1747. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1748. }
  1749. else
  1750. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  1751. }
  1752. /// <summary>
  1753. /// 导出结果按钮
  1754. /// </summary>
  1755. /// <param name="sender"></param>
  1756. /// <param name="e"></param>
  1757. private void button9_Click(object sender, EventArgs e)
  1758. {
  1759. if (this.dataGridView2.Rows.Count > 0)
  1760. {
  1761. SaveFileDialog exe = new SaveFileDialog();
  1762. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1763. exe.FilterIndex = 0;
  1764. exe.RestoreDirectory = true;
  1765. //exe.CreatePrompt = true;
  1766. exe.Title = "Export Excel File";
  1767. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1768. exe.FileName = PdnResources.GetString("Menu.Highspeedsteelbulkcarbo.Text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1769. DialogResult dr = exe.ShowDialog();
  1770. if (dr != DialogResult.OK)
  1771. return;
  1772. DataTable dtb = new DataTable();
  1773. dtb.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1774. dtb.Columns.Add(PdnResources.GetString("Menu.view.text"));
  1775. dtb.Columns.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
  1776. dtb.Columns.Add(PdnResources.GetString("Menu.sizeed.text"));
  1777. dtb.Columns.Add(PdnResources.GetString("Menu.levdel.Text"));
  1778. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  1779. {
  1780. DataRow dataRow = dtb.NewRow();
  1781. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView2.Rows[i].Cells[0].Value;
  1782. dataRow[PdnResources.GetString("Menu.view.text")] = this.dataGridView2.Rows[i].Cells[1].Value;
  1783. dataRow[PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text")] = this.dataGridView2.Rows[i].Cells[2].Value;
  1784. dataRow[PdnResources.GetString("Menu.sizeed.text")] = this.dataGridView2.Rows[i].Cells[3].Value;
  1785. dataRow[PdnResources.GetString("Menu.levdel.Text")] = this.dataGridView2.Rows[i].Cells[4].Value;
  1786. dtb.Rows.Add(dataRow);
  1787. }
  1788. DataTable dtb1 = new DataTable();
  1789. dtb1.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1790. dtb1.Columns.Add(PdnResources.GetString("Menu.view.text"));
  1791. dtb1.Columns.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
  1792. dtb1.Columns.Add(PdnResources.GetString("Menu.sizeed.text"));
  1793. dtb1.Columns.Add(PdnResources.GetString("Menu.levdel.Text"));
  1794. for (int i = 0; i < this.dataGridView3.Rows.Count; i++)
  1795. {
  1796. DataRow dataRow = dtb1.NewRow();
  1797. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView3.Rows[i].Cells[0].Value;
  1798. dataRow[PdnResources.GetString("Menu.view.text")] = this.dataGridView3.Rows[i].Cells[1].Value;
  1799. dataRow[PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text")] = this.dataGridView3.Rows[i].Cells[2].Value;
  1800. dataRow[PdnResources.GetString("Menu.sizeed.text")] = this.dataGridView3.Rows[i].Cells[3].Value;
  1801. dataRow[PdnResources.GetString("Menu.levdel.Text")] = this.dataGridView3.Rows[i].Cells[4].Value;
  1802. dtb1.Rows.Add(dataRow);
  1803. }
  1804. List<DataTable> list = new List<DataTable>();
  1805. list.Add(dtb);
  1806. list.Add(dtb1);
  1807. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1808. }
  1809. else
  1810. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  1811. }
  1812. /// <summary>
  1813. /// 图像索引切换选中事件
  1814. /// </summary>
  1815. /// <param name="sender"></param>
  1816. /// <param name="e"></param>
  1817. int sum;//判断是否二值过
  1818. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1819. {
  1820. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1821. {
  1822. //获取标尺-微米
  1823. unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
  1824. GetListParamModel();
  1825. sum = 0;
  1826. this.dataGridView1.Rows.Clear();
  1827. if (this.documentWorkspace.PhaseModels.Count > 1)
  1828. this.documentWorkspace.PhaseModels.Remove(this.documentWorkspace.PhaseModels[1]);
  1829. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
  1830. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1831. //二值化集成5
  1832. binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.bitmap, this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]);
  1833. this.documentWorkspace.Visible = true;
  1834. this.commonControlButtons.Visible = true;
  1835. changeColor = false;
  1836. isFirstSwitch = true;
  1837. if (sum == 0)
  1838. {
  1839. if (bcOriginChecked() || !bcBinaryChecked())
  1840. {
  1841. this.documentWorkspace.PhaseModels[1].choise = false;
  1842. }
  1843. else
  1844. {
  1845. this.documentWorkspace.PhaseModels[1].choise = true;
  1846. }
  1847. ResetAreaAndContent();
  1848. ReloadDebrisSelection();
  1849. }
  1850. else
  1851. {
  1852. if (bcOriginChecked() || !bcBinaryChecked())
  1853. {
  1854. this.documentWorkspace.PhaseModels[1].choise = false;
  1855. }
  1856. else
  1857. {
  1858. this.documentWorkspace.PhaseModels[1].choise = true;
  1859. }
  1860. this.documentWorkspace.Refresh();
  1861. }
  1862. sum = 0;
  1863. }
  1864. }
  1865. /// <summary>
  1866. /// 计算指定索引列的平均值-暂时没用到
  1867. /// </summary>
  1868. /// <param name="ColumnIndex"></param>
  1869. /// <returns></returns>
  1870. private double CalculateAverage(int ColumnIndex)
  1871. {
  1872. double sum = 0;
  1873. double avg = 0;
  1874. if (this.dataGridView1.Rows.Count > 0)
  1875. {
  1876. for (int i = 0; i < this.dataGridView1.Rows.Count - 1; i++)
  1877. {
  1878. try
  1879. {
  1880. double cellValue = double.Parse(this.dataGridView1.Rows[i].Cells[ColumnIndex].Value.ToString());
  1881. sum += cellValue;
  1882. }
  1883. catch (Exception e)
  1884. {
  1885. continue;
  1886. }
  1887. }
  1888. avg = sum / this.dataGridView1.Rows.Count - 1;
  1889. }
  1890. return avg;
  1891. }
  1892. /// <summary>
  1893. /// 分析结果列表选择切换
  1894. /// </summary>
  1895. /// <param name="sender"></param>
  1896. /// <param name="e"></param>
  1897. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  1898. {
  1899. if (this.showAll)
  1900. return;
  1901. RefreshDataGridView2();
  1902. }
  1903. /// <summary>
  1904. /// 刷新数据展示表
  1905. /// </summary>
  1906. private void RefreshDataGridView1()
  1907. {
  1908. this.dataGridView1.Rows.Clear();
  1909. if (dtDataGridView1 != null && dtDataGridView1.Rows.Count > 0)
  1910. {
  1911. dataGridView1.Rows.Add(dtDataGridView1.Rows.Count);//增加同等数量的行数
  1912. int i = 0;
  1913. foreach (DataRow row in dtDataGridView1.Rows)//逐个读取单元格的内容;
  1914. {
  1915. DataGridViewRow r1 = dataGridView1.Rows[i];
  1916. r1.Cells[0].Value = row.RowState.ToString();
  1917. for (int j = 0; j < dtDataGridView1.Columns.Count; j++)
  1918. {
  1919. if (j == 0 || j == 1 || j == 3)
  1920. {
  1921. r1.Cells[j].Value = row[j].ToString();
  1922. }
  1923. else
  1924. {
  1925. r1.Cells[j].Value = Math.Round(double.Parse(string.IsNullOrEmpty(row[j].ToString()) ? "0" :
  1926. row[j].ToString()), Convert.ToInt32(this.numericUpDown1.Value));
  1927. }
  1928. }
  1929. i++;
  1930. }
  1931. }
  1932. }
  1933. private void colorsForm1Changed(object sender, EventArgs e)
  1934. {
  1935. binaryClass.SetBinaryBackColor(this.colorsForm1.UserPrimaryColor.ToColor());
  1936. this.colorsForm1.Close();
  1937. changeColor = true;
  1938. ReLoadBinarization();
  1939. this.documentWorkspace.Refresh();
  1940. }
  1941. /// <summary>
  1942. /// 最大尺寸碳化物颜色panel被点击
  1943. /// </summary>
  1944. /// <param name="sender"></param>
  1945. /// <param name="e"></param>
  1946. private void panel2_Click(object sender, EventArgs e)
  1947. {
  1948. this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
  1949. this.colorsForm2.ShowDialog();
  1950. }
  1951. private void colorsForm2Changed(object sender, EventArgs e)
  1952. {
  1953. this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();
  1954. this.colorsForm2.Close();
  1955. changeColor = true;
  1956. ReLoadBinarization();
  1957. this.documentWorkspace.Refresh();
  1958. }
  1959. /// <summary>
  1960. /// 小数数字框值改变
  1961. /// </summary>
  1962. /// <param name="sender"></param>
  1963. /// <param name="e"></param>
  1964. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1965. {
  1966. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  1967. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  1968. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  1969. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  1970. RefreshDataGridView1();
  1971. RefreshDataGridView2();
  1972. }
  1973. /// <summary>
  1974. /// 是否筛选
  1975. /// </summary>
  1976. /// <param name="sender"></param>
  1977. /// <param name="e"></param>
  1978. private void checkBox3_CheckedChanged(object sender, EventArgs e)
  1979. {
  1980. if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
  1981. return;
  1982. if (bcBinaryChecked() && this.checkBox3.Checked)
  1983. {
  1984. ReloadDebrisSelection();
  1985. changeColor = false;
  1986. if (!bcOriginChecked())
  1987. {
  1988. if (bcBinaryChecked())
  1989. {
  1990. this.documentWorkspace.PhaseModels[0].choise = false;
  1991. this.documentWorkspace.PhaseModels[1].choise = true;
  1992. }
  1993. }
  1994. }
  1995. else if (bcBinaryChecked() && !this.checkBox3.Checked)
  1996. {
  1997. changeColor = false;
  1998. ReLoadBinarization();
  1999. if (!bcOriginChecked())
  2000. {
  2001. if (bcBinaryChecked())
  2002. {
  2003. this.documentWorkspace.PhaseModels[0].choise = false;
  2004. this.documentWorkspace.PhaseModels[1].choise = true;
  2005. }
  2006. }
  2007. }
  2008. this.documentWorkspace.Refresh();
  2009. }
  2010. /// <summary>
  2011. /// 二值处理
  2012. /// </summary>
  2013. /// <param name="colorOneStart"></param>
  2014. /// <param name="colorOneEnd"></param>
  2015. /// <param name="phaseColor"></param>
  2016. /// <returns></returns>
  2017. private unsafe Mat Binarization(int colorOneStart, int colorOneEnd, Color phaseColor)
  2018. {
  2019. Mat srcGray;
  2020. if (mat.Type() == MatType.CV_8UC1)
  2021. srcGray = mat;
  2022. else
  2023. srcGray = mat.CvtColor(ColorConversionCodes.BGR2GRAY);
  2024. Mat src = new Mat(mat.Rows, mat.Cols, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
  2025. int index0 = 0;
  2026. byte* ptr0 = (byte*)mat.Data;
  2027. int index1 = 0;
  2028. byte* ptr1 = (byte*)srcGray.Data;
  2029. int index2 = 0;
  2030. byte* ptr2 = (byte*)src.Data;
  2031. for (int o = 0; o < srcGray.Height; o++)
  2032. {
  2033. for (int p = 0; p < srcGray.Width; p++)
  2034. {
  2035. index0 = (int)((mat.Step() * o) + (p * 4));
  2036. index1 = (int)((srcGray.Step() * o) + (p * 1));
  2037. index2 = (int)((src.Step() * o) + (p * 4));
  2038. if (ptr1[index1] >= colorOneStart && ptr1[index1] <= colorOneEnd)
  2039. {
  2040. if (isHadView)
  2041. {
  2042. if (ptr0[index0 + 3] != 0)
  2043. {
  2044. ptr2[index2] = phaseColor.B;
  2045. ptr2[index2 + 1] = phaseColor.G;
  2046. ptr2[index2 + 2] = phaseColor.R;
  2047. ptr2[index2 + 3] = 255;
  2048. }
  2049. }
  2050. else
  2051. {
  2052. ptr2[index2] = phaseColor.B;
  2053. ptr2[index2 + 1] = phaseColor.G;
  2054. ptr2[index2 + 2] = phaseColor.R;
  2055. ptr2[index2 + 3] = 255;
  2056. }
  2057. }
  2058. }
  2059. }
  2060. return src;
  2061. }
  2062. /// <summary>
  2063. /// 刷新二值效果
  2064. /// </summary>
  2065. private void ReLoadBinarization()
  2066. {
  2067. if (this.documentWorkspace.CompositionSurface == null)
  2068. return;
  2069. if (bcBinaryChecked())
  2070. {
  2071. ResetAreaAndContent();
  2072. //if (this.checkBox3.Checked)
  2073. ReloadDebrisSelection();
  2074. }
  2075. else
  2076. {
  2077. this.documentWorkspace.PhaseModels[0].mat = null;
  2078. //phaseModel.choise = false;
  2079. isFirstSwitch = false;
  2080. this.dataGridView1.Rows.Clear();
  2081. maxSize = 0;
  2082. tempArea = null;
  2083. maxCaliperDiameter = null;
  2084. }
  2085. this.documentWorkspace.Refresh();
  2086. }
  2087. DataTable dtDataGridView1 = null;
  2088. DataTable dtResult = null;
  2089. AppCommon appCommon = new AppCommon();
  2090. /// <summary>
  2091. /// 刷新颗粒筛选效果
  2092. /// </summary>
  2093. private void ReloadDebrisSelection()
  2094. {
  2095. if (this.documentWorkspace != null && this.documentWorkspace.PhaseModels[0].mat != null)
  2096. {
  2097. this.dataGridView1.Rows.Clear();
  2098. dtDataGridView1 = new DataTable();
  2099. double sumFinalSize = 0;
  2100. List<List<OpenCvSharp.Point>> ps = new List<List<OpenCvSharp.Point>>();//轮廓的拓扑信息
  2101. Mat temp = new Mat();//中间变量
  2102. this.documentWorkspace.PhaseModels[0].mat.CopyTo(temp);
  2103. if (this.documentWorkspace.GraphicsList.IsExsitView())
  2104. {
  2105. List<OpenCvSharp.Point[][]> points;//各石墨轮廓集合
  2106. List<List<int>> lstAttribute;//各个视场属性集合,索引0-横坐标,1-纵坐标,2-视场宽度,3-视场高度,4-视场面积
  2107. List<HierarchyIndex[]> hierarchyIndices;
  2108. int sumFieldl; //视场个数
  2109. Mat tempCopy = BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat);
  2110. Rect rectCopy;
  2111. //调用处理视场方法
  2112. appCommon.MultiFieldView(appWorkspace, this.documentWorkspace.PhaseModels[0].mat, listView1, documentWorkspace, out points, out lstAttribute, out sumFieldl,out hierarchyIndices);
  2113. tempArea = new List<string>();
  2114. maxCaliperDiameter = new List<string>();
  2115. int h = 0;
  2116. foreach (OpenCvSharp.Point[][] contours in points)
  2117. {
  2118. h++;
  2119. maxSize = 0;
  2120. maxPoint = new List<List<OpenCvSharp.Point>>();
  2121. for (int i = 0; i < contours.Length; i++)
  2122. {
  2123. if (hierarchyIndices[h-1][i].Parent == -1)
  2124. {
  2125. for (int f = 0; f < contours[i].Length; f++)
  2126. {
  2127. contours[i][f].X = contours[i][f].X + lstAttribute[h - 1][0];
  2128. contours[i][f].Y = contours[i][f].Y + lstAttribute[h - 1][1];
  2129. }
  2130. //int length = Cv2.FloodFill(tempCopy, contours[i][0], new Scalar(0, 0, 0, 0), out rectCopy, null, null, FloodFillFlags.Link8);
  2131. double area = appCommon.Area(tempCopy, contours[i][0]);
  2132. if (this.checkBox3.Checked)
  2133. {
  2134. if (area >= (this.trackBar2.Value / unitLength / unitLength) && area <= (this.trackBar4.Value / unitLength / unitLength))
  2135. {
  2136. ps.Add(contours[i].ToList());
  2137. }
  2138. else
  2139. {
  2140. if (contours[i].Length <= 5)
  2141. continue;
  2142. else
  2143. {
  2144. tempArea.Add((area * unitLength * unitLength).ToString());
  2145. maxCaliperDiameter.Add((BasicCalculationHelper.CalcLongTrail(contours[i]) * 2 * unitLength).ToString());
  2146. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2147. float tempMax = (rect.Size.Width + rect.Size.Height) / 2f;
  2148. if (maxSize < tempMax)
  2149. {
  2150. maxSize = tempMax;
  2151. if (maxPoint.Count > 0)
  2152. {
  2153. maxPoint.Clear();
  2154. maxPoint.Add(contours[i].ToList());
  2155. }
  2156. else
  2157. maxPoint.Add(contours[i].ToList());
  2158. }
  2159. }
  2160. }
  2161. }
  2162. else
  2163. {
  2164. if (contours[i].Length <= 5)
  2165. continue;
  2166. else
  2167. {
  2168. tempArea.Add((area * unitLength * unitLength).ToString());
  2169. maxCaliperDiameter.Add((BasicCalculationHelper.CalcLongTrail(contours[i]) * 2 * unitLength).ToString());
  2170. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2171. float tempMax = (rect.Size.Width + rect.Size.Height) / 2f;//计算碳化物尺寸
  2172. if (maxSize < tempMax)
  2173. {
  2174. maxSize = tempMax;
  2175. if (maxPoint.Count > 0)
  2176. {
  2177. maxPoint.Clear();
  2178. maxPoint.Add(contours[i].ToList());
  2179. }
  2180. else
  2181. maxPoint.Add(contours[i].ToList());
  2182. }
  2183. }
  2184. }
  2185. }
  2186. }
  2187. string series = string.Empty;
  2188. if (this.radioButton1.Checked)
  2189. {
  2190. if (this.radioButton3.Checked)
  2191. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnA.text");
  2192. else
  2193. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnB.text");
  2194. }
  2195. else
  2196. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Molybdenum.text");
  2197. double finalSize = maxSize * unitLength;
  2198. string level = string.Empty;
  2199. if (this.radioButton1.Checked)
  2200. {
  2201. if (this.radioButton3.Checked)
  2202. {
  2203. if (finalSize < tungstenA[0])
  2204. level = "1";
  2205. else if (finalSize >= tungstenA[0] && finalSize <= tungstenA[1])
  2206. level = "2";
  2207. else if (finalSize >= tungstenA[1] && finalSize <= tungstenA[2])
  2208. level = "3";
  2209. else if (finalSize >= tungstenA[2] && finalSize <= tungstenA[3])
  2210. level = "4";
  2211. else
  2212. level = "S";
  2213. }
  2214. else
  2215. {
  2216. if (finalSize < tungstenB[0])
  2217. level = "1";
  2218. else if (finalSize >= tungstenB[0] && finalSize <= tungstenB[1])
  2219. level = "2";
  2220. else if (finalSize >= tungstenB[1] && finalSize <= tungstenB[2])
  2221. level = "3";
  2222. else if (finalSize >= tungstenB[2] && finalSize <= tungstenB[3])
  2223. level = "4";
  2224. else
  2225. level = "S";
  2226. }
  2227. }
  2228. else
  2229. {
  2230. if (finalSize < molybdenum[0])
  2231. level = "2";
  2232. else if (finalSize >= molybdenum[0] && finalSize < molybdenum[1])
  2233. level = "3";
  2234. else if (finalSize >= molybdenum[1] && finalSize < molybdenum[2])
  2235. level = "4";
  2236. else if (finalSize >= molybdenum[2] && finalSize < molybdenum[3])
  2237. level = "5";
  2238. else if (finalSize >= molybdenum[3] && finalSize < molybdenum[4])
  2239. level = "6";
  2240. else
  2241. level = "S";
  2242. }
  2243. this.dataGridView1.Rows.Add($"{PdnResources.GetString("Menu.view.text")}{h}", series, finalSize, level);
  2244. sumFinalSize += finalSize;
  2245. Cv2.FillPoly(temp, ps, new Scalar(0, 0, 0, 0));
  2246. if (maxPoint.Count > 0)
  2247. {
  2248. Mat[] arr = temp.Split();
  2249. temp = temp.CvtColor(ColorConversionCodes.BGRA2BGR);
  2250. int hh = Cv2.FloodFill(temp, maxPoint[0][maxPoint[0].Count - 1], new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255));
  2251. Mat[] arr2 = temp.Split();
  2252. arr[0] = arr2[0];
  2253. arr[1] = arr2[1];
  2254. arr[2] = arr2[2];
  2255. Cv2.Merge(arr, temp);
  2256. }
  2257. }
  2258. if (sumFieldl > 1 && maxSize > 0)
  2259. {
  2260. string series = string.Empty;
  2261. if (this.radioButton1.Checked)
  2262. {
  2263. if (this.radioButton3.Checked)
  2264. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnA.text");
  2265. else
  2266. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnB.text");
  2267. }
  2268. else
  2269. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Molybdenum.text");
  2270. double avgFinalSize = sumFinalSize / sumFieldl;
  2271. string avgLevel = string.Empty;
  2272. if (this.radioButton1.Checked)
  2273. {
  2274. if (this.radioButton3.Checked)
  2275. {
  2276. if (avgFinalSize < tungstenA[0])
  2277. avgLevel = "1";
  2278. else if (avgFinalSize >= tungstenA[0] && avgFinalSize <= tungstenA[1])
  2279. avgLevel = "2";
  2280. else if (avgFinalSize >= tungstenA[1] && avgFinalSize <= tungstenA[2])
  2281. avgLevel = "3";
  2282. else if (avgFinalSize >= tungstenA[2] && avgFinalSize <= tungstenA[3])
  2283. avgLevel = "4";
  2284. else
  2285. avgLevel = "S";
  2286. }
  2287. else
  2288. {
  2289. if (avgFinalSize < tungstenB[0])
  2290. avgLevel = "1";
  2291. else if (avgFinalSize >= tungstenB[0] && avgFinalSize <= tungstenB[1])
  2292. avgLevel = "2";
  2293. else if (avgFinalSize >= tungstenB[1] && avgFinalSize <= tungstenB[2])
  2294. avgLevel = "3";
  2295. else if (avgFinalSize >= tungstenB[2] && avgFinalSize <= tungstenB[3])
  2296. avgLevel = "4";
  2297. else
  2298. avgLevel = "S";
  2299. }
  2300. }
  2301. else
  2302. {
  2303. if (avgFinalSize < molybdenum[0])
  2304. avgLevel = "2";
  2305. else if (avgFinalSize >= molybdenum[0] && avgFinalSize < molybdenum[1])
  2306. avgLevel = "3";
  2307. else if (avgFinalSize >= molybdenum[1] && avgFinalSize < molybdenum[2])
  2308. avgLevel = "4";
  2309. else if (avgFinalSize >= molybdenum[2] && avgFinalSize < molybdenum[3])
  2310. avgLevel = "5";
  2311. else if (avgFinalSize >= molybdenum[3] && avgFinalSize < molybdenum[4])
  2312. avgLevel = "6";
  2313. else
  2314. avgLevel = "S";
  2315. }
  2316. this.dataGridView1.Rows.Add(PdnResources.GetString("Menu.Image.Average.Text"), series, avgFinalSize, avgLevel);
  2317. }
  2318. if (tempCopy != null)
  2319. {
  2320. tempCopy.Release();
  2321. }
  2322. }
  2323. else
  2324. {
  2325. OpenCvSharp.Point[][] contours;//原始轮廓信息
  2326. HierarchyIndex[] hierachy;
  2327. Mat tempCopy = BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat);
  2328. //Rect rectCopy;
  2329. Cv2.FindContours(BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  2330. maxSize = 0;
  2331. maxPoint = new List<List<OpenCvSharp.Point>>();
  2332. for (int i = 0; i < hierachy.Length; i++)
  2333. {
  2334. if (hierachy[i].Parent == -1)
  2335. {
  2336. //int length = Cv2.FloodFill(tempCopy, contours[i][0], new Scalar(0, 0, 0, 0), out rectCopy, null, null, FloodFillFlags.Link8);
  2337. double area = appCommon.Area(tempCopy, contours[i][0]);
  2338. if (this.checkBox3.Checked)
  2339. {
  2340. if (area >= (this.trackBar2.Value / unitLength / unitLength) && area <= (this.trackBar4.Value / unitLength / unitLength))
  2341. {
  2342. ps.Add(contours[i].ToList());
  2343. }
  2344. else
  2345. {
  2346. if (contours[i].Length <= 5)
  2347. continue;
  2348. else
  2349. {
  2350. tempArea.Add((area * unitLength * unitLength).ToString());
  2351. maxCaliperDiameter.Add((BasicCalculationHelper.CalcLongTrail(contours[i]) * 2 * unitLength).ToString());
  2352. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2353. float tempMax = (rect.Size.Width + rect.Size.Height) / 2f;
  2354. if (maxSize < tempMax)
  2355. {
  2356. maxSize = tempMax;
  2357. if (maxPoint.Count > 0)
  2358. {
  2359. maxPoint.Clear();
  2360. maxPoint.Add(contours[i].ToList());
  2361. }
  2362. else
  2363. maxPoint.Add(contours[i].ToList());
  2364. }
  2365. }
  2366. }
  2367. }
  2368. else
  2369. {
  2370. if (contours[i].Length <= 5)
  2371. continue;
  2372. else
  2373. {
  2374. tempArea.Add((area * unitLength * unitLength).ToString());
  2375. maxCaliperDiameter.Add((BasicCalculationHelper.CalcLongTrail(contours[i]) * 2 * unitLength).ToString());
  2376. OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2377. float tempMax = (rect.Size.Width + rect.Size.Height) / 2f;//计算碳化物尺寸
  2378. if (maxSize < tempMax)
  2379. {
  2380. maxSize = tempMax;
  2381. if (maxPoint.Count > 0)
  2382. {
  2383. maxPoint.Clear();
  2384. maxPoint.Add(contours[i].ToList());
  2385. }
  2386. else
  2387. maxPoint.Add(contours[i].ToList());
  2388. }
  2389. }
  2390. }
  2391. }
  2392. }
  2393. if (maxSize > 0)
  2394. {
  2395. string series = string.Empty;
  2396. if (this.radioButton1.Checked)
  2397. {
  2398. if (this.radioButton3.Checked)
  2399. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnA.text");
  2400. else
  2401. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Tungsten.text") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.ColumnB.text");
  2402. }
  2403. else
  2404. series = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Molybdenum.text");
  2405. double finalSize = maxSize * unitLength;
  2406. string level = string.Empty;
  2407. if (this.radioButton1.Checked)
  2408. {
  2409. if (this.radioButton3.Checked)
  2410. {
  2411. if (finalSize < tungstenA[0])
  2412. level = "1";
  2413. else if (finalSize >= tungstenA[0] && finalSize <= tungstenA[1])
  2414. level = "2";
  2415. else if (finalSize >= tungstenA[1] && finalSize <= tungstenA[2])
  2416. level = "3";
  2417. else if (finalSize >= tungstenA[2] && finalSize <= tungstenA[3])
  2418. level = "4";
  2419. else
  2420. level = "S";
  2421. }
  2422. else
  2423. {
  2424. if (finalSize < tungstenB[0])
  2425. level = "1";
  2426. else if (finalSize >= tungstenB[0] && finalSize <= tungstenB[1])
  2427. level = "2";
  2428. else if (finalSize >= tungstenB[1] && finalSize <= tungstenB[2])
  2429. level = "3";
  2430. else if (finalSize >= tungstenB[2] && finalSize <= tungstenB[3])
  2431. level = "4";
  2432. else
  2433. level = "S";
  2434. }
  2435. }
  2436. else
  2437. {
  2438. if (finalSize < molybdenum[0])
  2439. level = "2";
  2440. else if (finalSize >= molybdenum[0] && finalSize < molybdenum[1])
  2441. level = "3";
  2442. else if (finalSize >= molybdenum[1] && finalSize < molybdenum[2])
  2443. level = "4";
  2444. else if (finalSize >= molybdenum[2] && finalSize < molybdenum[3])
  2445. level = "5";
  2446. else if (finalSize >= molybdenum[3] && finalSize < molybdenum[4])
  2447. level = "6";
  2448. else
  2449. level = "S";
  2450. }
  2451. this.dataGridView1.Rows.Add(PdnResources.GetString("Menu.view.text") + "1", series, finalSize, level);
  2452. }
  2453. Cv2.FillPoly(temp, ps, new Scalar(0, 0, 0, 0));
  2454. if (maxPoint.Count > 0)
  2455. {
  2456. Mat[] arr = temp.Split();
  2457. temp = temp.CvtColor(ColorConversionCodes.BGRA2BGR);
  2458. int h = Cv2.FloodFill(temp, maxPoint[0][maxPoint[0].Count - 1], new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255));
  2459. Mat[] arr2 = temp.Split();
  2460. arr[0] = arr2[0];
  2461. arr[1] = arr2[1];
  2462. arr[2] = arr2[2];
  2463. Cv2.Merge(arr, temp);
  2464. }
  2465. if (tempCopy != null)
  2466. {
  2467. tempCopy.Release();
  2468. }
  2469. //Cv2.FillPoly(temp, maxPoint, new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255));
  2470. }
  2471. this.documentWorkspace.PhaseModels[1].mat = temp;
  2472. this.documentWorkspace.Refresh();
  2473. //数据结果保存
  2474. dtDataGridView1 = appCommon.ResultDataSaving(dataGridView1);
  2475. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  2476. string tag = this.imageList1.Images.Keys[this.listView1.FocusedItem.Index];
  2477. //dtResult = new DataTable(tag);
  2478. //分析数据保存
  2479. dtResult = appCommon.AnalysisDataSaving(dataGridView1, imgName, tag);
  2480. if (dtDataGridView1.Rows.Count > 0)
  2481. {
  2482. RefreshDataGridView1();
  2483. }
  2484. if (bcOriginChecked())
  2485. {
  2486. appCommon.DisplayData(this.dataGridView1, false);
  2487. }
  2488. }
  2489. }
  2490. /// <summary>
  2491. /// 刷新其他信息
  2492. /// </summary>
  2493. private void ResetAreaAndContent()
  2494. {
  2495. if (this.documentWorkspace.PhaseModels[0].mat != null && bcBinaryChecked())
  2496. {
  2497. OpenCvSharp.Point[][] contours;//原始轮廓信息
  2498. HierarchyIndex[] hierachy;
  2499. Mat temp = new Mat();
  2500. this.documentWorkspace.PhaseModels[0].mat.CopyTo(temp);
  2501. Mat tempCopy = BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat);
  2502. //Rect rectCopy;
  2503. Cv2.FindContours(BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);
  2504. if (hierachy.Length > 0)
  2505. {
  2506. double maxArea = 0;//面积最大值
  2507. double minArea = 9999999999;//面积最小值
  2508. maxSize = 0;
  2509. maxPoint = new List<List<OpenCvSharp.Point>>();
  2510. tempArea = new List<string>();
  2511. maxCaliperDiameter = new List<string>();
  2512. for (int i = 0; i < hierachy.Length; i++)
  2513. {
  2514. if (hierachy[i].Parent == -1)
  2515. {
  2516. //int length = Cv2.FloodFill(tempCopy, contours[i][0], new Scalar(0, 0, 0, 0), out rectCopy, null, null, FloodFillFlags.Link8);
  2517. double area = appCommon.Area(tempCopy, contours[i][0]);
  2518. if (maxArea < area)
  2519. maxArea = area;
  2520. if (minArea > area)
  2521. minArea = area;
  2522. }
  2523. //if (contours[i].Length <= 5)
  2524. // continue;
  2525. //else
  2526. //{
  2527. // tempArea.Add((area * unitLength).ToString());
  2528. // maxCaliperDiameter.Add((BasicCalculationHelper.CalcLongTrail(contours[i]) * 2 * unitLength).ToString());
  2529. // OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]);
  2530. // float tempMax = (rect.Size.Width + rect.Size.Height) / 2f;//计算碳化物尺寸
  2531. // if(maxSize < tempMax)
  2532. // {
  2533. // maxSize = tempMax;
  2534. // if (maxPoint.Count > 0)
  2535. // {
  2536. // maxPoint.Clear();
  2537. // maxPoint.Add(contours[i].ToList());
  2538. // }
  2539. // else
  2540. // maxPoint.Add(contours[i].ToList());
  2541. // }
  2542. //}
  2543. }
  2544. ////填充最大碳化物
  2545. //Cv2.FillPoly(temp, maxPoint, new Scalar(this.panel2.BackColor.B, this.panel2.BackColor.G, this.panel2.BackColor.R, 255));
  2546. //this.documentWorkspace.PhaseModels[1].mat = temp;
  2547. if (!changeColor)
  2548. {
  2549. maxArea = maxArea * unitLength * unitLength;
  2550. minArea = minArea * unitLength * unitLength;
  2551. int maxNum = (int)Math.Ceiling(maxArea);//获取面积最大值
  2552. int minNum = (int)Math.Floor(minArea);//获取面积最小值
  2553. //先解绑事件以防数据赋值异常
  2554. this.numericUpDown4.ValueChanged -= numericUpDown4_ValueChanged;
  2555. this.numericUpDown5.ValueChanged -= numericUpDown5_ValueChanged;
  2556. this.trackBar2.Scroll -= trackBar2_Scroll;
  2557. this.trackBar4.Scroll -= trackBar4_Scroll;
  2558. this.numericUpDown4.Maximum = maxNum;
  2559. this.numericUpDown4.Minimum = minNum;
  2560. this.trackBar2.Maximum = maxNum;
  2561. this.trackBar2.Minimum = minNum;
  2562. this.numericUpDown5.Maximum = maxNum;
  2563. this.numericUpDown5.Minimum = minNum;
  2564. this.trackBar4.Maximum = maxNum;
  2565. this.trackBar4.Minimum = minNum;
  2566. this.numericUpDown4.Value = minNum;
  2567. this.trackBar2.Value = minNum;
  2568. this.numericUpDown5.Value = maxNum;
  2569. this.trackBar4.Value = maxNum;
  2570. if (areaMin != -1 && areaMin >= this.numericUpDown4.Minimum && areaMin <= this.numericUpDown5.Maximum)
  2571. {
  2572. trackBar2.Value = (int)areaMin;
  2573. this.numericUpDown4.Value = areaMin;
  2574. }
  2575. if (areaMax != -1 && areaMax >= this.numericUpDown4.Value && areaMax <= this.numericUpDown5.Maximum)
  2576. {
  2577. trackBar4.Value = (int)areaMax;
  2578. this.numericUpDown5.Value = areaMax;
  2579. }
  2580. this.numericUpDown4.ValueChanged += new EventHandler(numericUpDown4_ValueChanged);
  2581. this.numericUpDown5.ValueChanged += new EventHandler(numericUpDown5_ValueChanged);
  2582. this.trackBar2.Scroll += new EventHandler(trackBar2_Scroll);
  2583. this.trackBar4.Scroll += new EventHandler(trackBar4_Scroll);
  2584. //if (dtDataGridView1.Rows.Count > 0)
  2585. //{
  2586. // RefreshDataGridView1();
  2587. //}
  2588. }
  2589. }
  2590. if (tempCopy != null)
  2591. {
  2592. tempCopy.Release();
  2593. }
  2594. }
  2595. }
  2596. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  2597. {
  2598. //this.radioButton3.Enabled = true;
  2599. //this.radioButton4.Enabled = true;
  2600. //ReloadDebrisSelection();
  2601. }
  2602. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  2603. {
  2604. if (this.radioButton2.Checked)
  2605. {
  2606. this.radioButton3.Enabled = false;
  2607. this.radioButton4.Enabled = false;
  2608. }
  2609. else
  2610. {
  2611. this.radioButton3.Enabled = true;
  2612. this.radioButton4.Enabled = true;
  2613. }
  2614. ReloadDebrisSelection();
  2615. }
  2616. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  2617. {
  2618. ReloadDebrisSelection();
  2619. }
  2620. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  2621. {
  2622. //RefreshDataGridView1();
  2623. }
  2624. /// <summary>
  2625. /// 颗粒筛选范围最小值
  2626. /// </summary>
  2627. /// <param name="sender"></param>
  2628. /// <param name="e"></param>
  2629. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2630. {
  2631. if (this.numericUpDown4.Value > this.numericUpDown5.Value)
  2632. this.numericUpDown4.Value = this.numericUpDown5.Value;
  2633. this.trackBar2.Value = Convert.ToInt32(this.numericUpDown4.Value);
  2634. areaMin = this.numericUpDown4.Value;
  2635. areaMax = this.numericUpDown5.Value;
  2636. if (this.checkBox3.Checked && bcBinaryChecked())
  2637. ReloadDebrisSelection();
  2638. }
  2639. /// <summary>
  2640. /// 颗粒筛选范围最大值
  2641. /// </summary>
  2642. /// <param name="sender"></param>
  2643. /// <param name="e"></param>
  2644. private void numericUpDown5_ValueChanged(object sender, EventArgs e)
  2645. {
  2646. if (this.numericUpDown5.Value < this.numericUpDown4.Value)
  2647. this.numericUpDown5.Value = this.numericUpDown4.Value;
  2648. this.trackBar4.Value = Convert.ToInt32(this.numericUpDown5.Value);
  2649. areaMin = this.numericUpDown4.Value;
  2650. areaMax = this.numericUpDown5.Value;
  2651. if (this.checkBox3.Checked && bcBinaryChecked())
  2652. ReloadDebrisSelection();
  2653. }
  2654. /// <summary>
  2655. /// 颗粒筛选最小值滚动条
  2656. /// </summary>
  2657. /// <param name="sender"></param>
  2658. /// <param name="e"></param>
  2659. private void trackBar2_Scroll(object sender, EventArgs e)
  2660. {
  2661. this.numericUpDown4.Value = this.trackBar2.Value;
  2662. }
  2663. /// <summary>
  2664. /// 颗粒筛选最大值滚动条
  2665. /// </summary>
  2666. /// <param name="sender"></param>
  2667. /// <param name="e"></param>
  2668. private void trackBar4_Scroll(object sender, EventArgs e)
  2669. {
  2670. this.numericUpDown5.Value = this.trackBar4.Value;
  2671. }
  2672. /// <summary>
  2673. /// 是否二值化
  2674. /// </summary>
  2675. /// <param name="sender"></param>
  2676. /// <param name="e"></param>
  2677. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  2678. {
  2679. if (this.documentWorkspace.CompositionSurface == null)
  2680. return;
  2681. if (!bcBinaryChecked())
  2682. this.checkBox3.Checked = false;
  2683. changeColor = false;
  2684. ReLoadBinarization();
  2685. }
  2686. /// <summary>
  2687. /// 导出项目到项目工程
  2688. /// </summary>
  2689. /// <param name="sender"></param>
  2690. /// <param name="e"></param>
  2691. private void button3_Click(object sender, EventArgs e)
  2692. {
  2693. try
  2694. {
  2695. if (dataGridView2.Rows.Count == 0)
  2696. {
  2697. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
  2698. return;
  2699. }
  2700. if (this.analyzeSettingModel == null)
  2701. {
  2702. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2703. return;
  2704. }
  2705. //获取项目工程内的文件夹路径
  2706. ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.HighSpeedSteelCarbonBlock.Text", this.analyzeSettingModel.savePath);
  2707. if (item != null)
  2708. {
  2709. //向文件夹内保存图片和报告
  2710. if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2711. {
  2712. //获取word书签与excel单元格的关系,以字典方式存储
  2713. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2714. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2715. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2716. {
  2717. foreach (mic_module_infos info in mic_module_infos)
  2718. {
  2719. tagInfos.Add(info.tag_name, info.cell_position);
  2720. }
  2721. }
  2722. //分析结果
  2723. List<List<string>> analysisContent = new List<List<string>>();
  2724. List<string> contentHead = new List<string>();
  2725. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  2726. contentHead.Add(PdnResources.GetString("Menu.view.text"));
  2727. contentHead.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
  2728. contentHead.Add(PdnResources.GetString("Menu.sizeed.text"));
  2729. contentHead.Add(PdnResources.GetString("Menu.levdel.Text"));
  2730. analysisContent.Add(contentHead);
  2731. foreach (DataGridViewRow rowItem in this.dataGridView2.Rows)
  2732. {
  2733. List<string> content = new List<string>();
  2734. content.Add(rowItem.Cells[0].Value.ToString());
  2735. content.Add(rowItem.Cells[1].Value.ToString());
  2736. content.Add(rowItem.Cells[2].Value.ToString());
  2737. content.Add(rowItem.Cells[3].Value.ToString());
  2738. content.Add(rowItem.Cells[4].Value.ToString());
  2739. analysisContent.Add(content);
  2740. }
  2741. analysisContent.Add(new List<string>() { "\r" });
  2742. foreach (DataGridViewRow rowItem in this.dataGridView3.Rows)
  2743. {
  2744. List<string> content = new List<string>();
  2745. content.Add(rowItem.Cells[0].Value.ToString());
  2746. content.Add(rowItem.Cells[1].Value.ToString());
  2747. content.Add(rowItem.Cells[2].Value.ToString());
  2748. content.Add(rowItem.Cells[3].Value.ToString());
  2749. content.Add(rowItem.Cells[4].Value.ToString());
  2750. analysisContent.Add(content);
  2751. }
  2752. //图片
  2753. bitList = new List<Bitmap>();
  2754. if (this.showAll)
  2755. {
  2756. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  2757. {
  2758. bitList.Add(kv.Value[0]);
  2759. bitList.Add(kv.Value[1]);
  2760. }
  2761. }
  2762. else
  2763. {
  2764. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2765. {
  2766. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2767. {
  2768. if (bitDic.ContainsKey(rowItem.Name))
  2769. {
  2770. bitList.Add(bitDic[rowItem.Name][0]);
  2771. bitList.Add(bitDic[rowItem.Name][1]);
  2772. }
  2773. }
  2774. }
  2775. }
  2776. //中间数据
  2777. if (!this.showAll)
  2778. {
  2779. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2780. {
  2781. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2782. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2783. {
  2784. foreach (ExportProjectModel model in this.tempDataModel)
  2785. {
  2786. if (model.tagName.Equals(rowItem.Name))
  2787. {
  2788. ExportProjectModel tempModel = new ExportProjectModel();
  2789. tempModel.tagName = model.tagName;
  2790. tempModel.picName = model.picName;
  2791. tempModel.dataList = model.dataList;
  2792. exportModel.Add(tempModel);
  2793. break;
  2794. }
  2795. }
  2796. }
  2797. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
  2798. }
  2799. }
  2800. else
  2801. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
  2802. }
  2803. else
  2804. {
  2805. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
  2806. return;
  2807. }
  2808. //保存项目信息到数据库
  2809. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
  2810. }
  2811. }
  2812. catch (Exception)
  2813. {
  2814. }
  2815. }
  2816. #region 参数保存及提取
  2817. /// <summary>
  2818. /// 保存参数的key,value和type
  2819. /// </summary>
  2820. /// <param name="param_key"></param>
  2821. /// <param name="param_value"></param>
  2822. /// <param name="param_type"></param>
  2823. private void saveParamValue(string param_key, string param_value, int param_type)
  2824. {
  2825. bool foundItem = false;
  2826. if (!this.eachData.ContainsKey(GetImgKey())) {
  2827. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  2828. analysisItem.menuId = this.menuId;
  2829. analysisItem.param_key = param_key;
  2830. analysisItem.param_type = param_type;
  2831. analysisItem.param_value = param_value;
  2832. analysisItem.setValue();
  2833. analysisItem.ListParam = new List<GrainSizeAnalysisModel>();
  2834. analysisItem.ListParam.Add(analysisItem);
  2835. this.eachData.Add(GetImgKey(), analysisItem);
  2836. }
  2837. foreach (var item in this.eachData[GetImgKey()].ListParam)
  2838. {
  2839. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  2840. {
  2841. item.param_value = param_value;
  2842. item.setValue();
  2843. foundItem = true;
  2844. break;
  2845. }
  2846. }
  2847. if (!foundItem)
  2848. {
  2849. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  2850. analysisItem.menuId = this.menuId;
  2851. analysisItem.param_key = param_key;
  2852. analysisItem.param_type = param_type;
  2853. analysisItem.param_value = param_value;
  2854. analysisItem.setValue();
  2855. this.eachData[GetImgKey()].ListParam.Add(analysisItem);
  2856. }
  2857. }
  2858. /// <summary>
  2859. /// 保存界面中的参数到model
  2860. /// </summary>
  2861. private void saveDialogParamValues()
  2862. {
  2863. saveParamValue(ParamKey_Report, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置
  2864. saveParamValue(ParamKey_Screen, checkBox3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//筛选
  2865. saveParamValue(ParamKey_ScreenMin, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最小值
  2866. saveParamValue(ParamKey_ScreenMax, numericUpDown5 != null ? numericUpDown5.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最大值
  2867. saveParamValue(ParamKey_Tungsten, radioButton1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//钨
  2868. saveParamValue(ParamKey_Molybdenum, radioButton2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//钼
  2869. saveParamValue(ParamKey_ColumnA, radioButton3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//A列
  2870. saveParamValue(ParamKey_ColumnB, radioButton4.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//B列
  2871. saveParamValue(ParamKey_MaxColour, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//最大色
  2872. saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
  2873. }
  2874. /// <summary>
  2875. /// 获取保存的参数
  2876. /// </summary>
  2877. private void GetListParamModel()
  2878. {
  2879. if (this.eachData.ContainsKey(GetImgKey()) && this.eachData[GetImgKey()] != null )
  2880. {
  2881. for (int i = 0; i < this.eachData[GetImgKey()].ListParam.Count; i++)
  2882. {
  2883. switch (this.eachData[GetImgKey()].ListParam[i].param_key)
  2884. {
  2885. case ParamKey_Report:
  2886. checkBox1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2887. break;
  2888. case ParamKey_Screen:
  2889. checkBox3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2890. break;
  2891. case ParamKey_ScreenMin:
  2892. areaMin = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2893. break;
  2894. case ParamKey_ScreenMax:
  2895. areaMax = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2896. break;
  2897. case ParamKey_Tungsten:
  2898. radioButton1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2899. break;
  2900. case ParamKey_Molybdenum:
  2901. radioButton2.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2902. break;
  2903. case ParamKey_ColumnA:
  2904. radioButton3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2905. break;
  2906. case ParamKey_ColumnB:
  2907. radioButton4.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
  2908. break;
  2909. case ParamKey_MaxColour:
  2910. panel2.BackColor = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value);
  2911. break;
  2912. case ParamKey_DecimalPlace:
  2913. numericUpDown1.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
  2914. break;
  2915. }
  2916. }
  2917. }
  2918. }
  2919. /// <summary>
  2920. /// 获取XML保存的参数
  2921. /// </summary>
  2922. private void GetXmlParameter()
  2923. {
  2924. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  2925. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  2926. for (int i = 0; i < listView1.Items.Count; i++)
  2927. {
  2928. if (this.eachData.ContainsKey(listView1.Items[i].Index.ToString()))
  2929. {
  2930. this.eachData[listView1.Items[i].Index.ToString()] = analysisModelXml.cloneListParamModel(this.menuId);
  2931. }
  2932. else {
  2933. this.eachData.Add(listView1.Items[i].Index.ToString(), analysisModelXml.cloneListParamModel(this.menuId));
  2934. }
  2935. }
  2936. foreach (var item in this.eachData[GetImgKey()].ListParam)
  2937. item.setValue();
  2938. }
  2939. /// <summary>
  2940. /// 保存参数,防止没有图片
  2941. /// </summary>
  2942. private void NullKey()
  2943. {
  2944. GrainSizeAnalysisModel grainsizeanalysismodel = new GrainSizeAnalysisModel();
  2945. grainsizeanalysismodel.ListParam = new List<GrainSizeAnalysisModel>();
  2946. this.eachData.Add("null", grainsizeanalysismodel);
  2947. }
  2948. private string GetImgKey()
  2949. {
  2950. string key = this.listView1.FocusedItem != null ? this.listView1.FocusedItem.Index.ToString() : "null";
  2951. return key;
  2952. }
  2953. #endregion
  2954. private void button5_Click(object sender, EventArgs e)
  2955. {
  2956. if (this.listView1.FocusedItem == null)
  2957. {
  2958. return;
  2959. }
  2960. binaryClass.saveParams();
  2961. binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[int.Parse(GetImgKey())]);
  2962. saveDialogParamValues();
  2963. GrainSizeAnalysisModel data = new GrainSizeAnalysisModel();
  2964. if (eachData.ContainsKey(GetImgKey()))
  2965. {
  2966. data = eachData[GetImgKey()];
  2967. }
  2968. for (int i = 0; i < listView1.Items.Count; i++)
  2969. {
  2970. eachData[i.ToString()] = data.cloneListParamModel(this.menuId);
  2971. this.listView1.EnsureVisible(i);
  2972. this.listView1.Items[i].Focused = true;
  2973. this.listView1.Items[i].Selected = true;
  2974. }
  2975. }
  2976. private bool blSaveAll = false;
  2977. private void button4_Click(object sender, EventArgs e)
  2978. {
  2979. if (this.listView1.FocusedItem == null)
  2980. {
  2981. return;
  2982. }
  2983. if (eachData.Count - 1 != listView1.Items.Count)
  2984. {
  2985. MessageBox.Show("请先点击应用全部!");
  2986. return;
  2987. }
  2988. saveDialogParamValues();
  2989. int current = int.Parse(GetImgKey());
  2990. for (int i = 0; i < listView1.Items.Count; i++)
  2991. {
  2992. this.listView1.EnsureVisible(i);
  2993. this.listView1.Items[i].Focused = true;
  2994. this.listView1.Items[i].Selected = true;
  2995. this.button2.PerformClick();
  2996. blSaveAll = true;
  2997. }
  2998. this.listView1.EnsureVisible(current);
  2999. this.listView1.Items[current].Focused = true;
  3000. this.listView1.Items[current].Selected = true;
  3001. blSaveAll = false;
  3002. }
  3003. private void listView1_MouseDown(object sender, MouseEventArgs e)
  3004. {
  3005. if (this.listView1.FocusedItem != null)
  3006. saveDialogParamValues();
  3007. }
  3008. #region [脚本相关]
  3009. private void getValue(string key, object value) {
  3010. switch (key)
  3011. {
  3012. case "parameter1":
  3013. checkBox3.Checked = Convert.ToBoolean(value);
  3014. break;
  3015. case "parameter2":
  3016. int min = Convert.ToInt32(value);
  3017. decimal minDec = Convert.ToDecimal(value);
  3018. if (bcBinaryChecked())
  3019. {
  3020. if (trackBar2.Minimum > min || trackBar2.Maximum < min)
  3021. {
  3022. trackBar2.Value = trackBar2.Minimum;
  3023. }
  3024. else {
  3025. trackBar2.Value = min;
  3026. }
  3027. if (numericUpDown4.Minimum > min || numericUpDown4.Maximum < min)
  3028. {
  3029. numericUpDown4.Value = numericUpDown4.Minimum;
  3030. }
  3031. else {
  3032. numericUpDown4.Value = minDec;
  3033. }
  3034. }
  3035. break;
  3036. case "parameter3":
  3037. int max = Convert.ToInt32(value);
  3038. decimal maxDec = Convert.ToDecimal(value);
  3039. if (bcBinaryChecked())
  3040. {
  3041. if (trackBar4.Minimum > max || trackBar4.Maximum < max)
  3042. {
  3043. trackBar4.Value = trackBar4.Maximum;
  3044. }
  3045. else
  3046. {
  3047. trackBar4.Value = max;
  3048. }
  3049. if (numericUpDown5.Minimum > max || numericUpDown5.Maximum < max)
  3050. {
  3051. numericUpDown5.Value = numericUpDown5.Maximum;
  3052. }
  3053. else
  3054. {
  3055. numericUpDown5.Value = maxDec;
  3056. }
  3057. }
  3058. break;
  3059. case "parameter4":
  3060. int val = (int)value;
  3061. radioButton1.Checked = val == 1 ? true : false;
  3062. radioButton2.Checked = val == 1 ? false : true;
  3063. break;
  3064. case "parameter5":
  3065. int val1 = (int)value;
  3066. radioButton3.Checked = val1 == 1 ? true : false;
  3067. radioButton4.Checked = val1 == 1 ? false : true;
  3068. break;
  3069. case "parameter6":
  3070. int val2 = (int)value;
  3071. panel2.BackColor = Color.FromArgb(val2);
  3072. break;
  3073. case "OpenWhileExportReport":
  3074. checkBox1.Checked = Convert.ToBoolean(value);
  3075. break;
  3076. case "CalculatorDecimalDigits":
  3077. numericUpDown1.Value = Convert.ToDecimal(value);
  3078. break;
  3079. case "ExportResults":
  3080. isExportResults = Convert.ToBoolean(value);
  3081. break;
  3082. case "ExportReports":
  3083. isExportReports = Convert.ToBoolean(value);
  3084. break;
  3085. case "ExportProjects":
  3086. isExportProjects = Convert.ToBoolean(value);
  3087. break;
  3088. }
  3089. }
  3090. private void startScriptAutomaticAction() {
  3091. this.button5.PerformClick();
  3092. this.button4.PerformClick();
  3093. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  3094. this.showAll = true;
  3095. RefreshDataGridView2();
  3096. if (isExportResults)//导出结果
  3097. this.button8.PerformClick();
  3098. if (isExportReports)//生成报告
  3099. this.button9.PerformClick();
  3100. if (isExportProjects)//导出项目
  3101. this.button3.PerformClick();
  3102. this.appWorkspace.ScriptAutomatic = false;
  3103. this.Close();
  3104. }
  3105. #endregion
  3106. #region [脚本录制]
  3107. private void getScriptRecording()
  3108. {
  3109. string className = InvariantData.path_Action + ".Action" + menuId;
  3110. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  3111. List<Args> args = param.Lists;
  3112. foreach (var item in args)
  3113. {
  3114. item.value = setScriptRecording(item.key);
  3115. }
  3116. //找出二值相关参数 进行赋值
  3117. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  3118. foreach (var item in isNullList)
  3119. {
  3120. item.value = binaryClass.setScriptRecording(item.key);
  3121. }
  3122. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  3123. }
  3124. private object setScriptRecording(string key)
  3125. {
  3126. object value = null;
  3127. switch (key)
  3128. {
  3129. case "parameter1":
  3130. value = checkBox3.Checked;
  3131. break;
  3132. case "parameter2":
  3133. value = trackBar2.Value;
  3134. break;
  3135. case "parameter3":
  3136. value = trackBar4.Value;
  3137. break;
  3138. case "parameter4":
  3139. value = radioButton1.Checked ? 1 : 2;
  3140. break;
  3141. case "parameter5":
  3142. value = radioButton3.Checked ? 1 : 2;
  3143. break;
  3144. case "parameter6":
  3145. value = panel2.BackColor.ToArgb();
  3146. break;
  3147. case "OpenWhileExportReport":
  3148. value = checkBox1.Checked;
  3149. break;
  3150. case "CalculatorDecimalDigits":
  3151. value = numericUpDown1.Value;
  3152. break;
  3153. case "ExportResults":
  3154. value = isExportResults;
  3155. break;
  3156. case "ExportReports":
  3157. value = isExportReports;
  3158. break;
  3159. case "ExportProjects":
  3160. value = isExportProjects;
  3161. break;
  3162. }
  3163. return value;
  3164. }
  3165. #endregion
  3166. }
  3167. }