GrainSizeMeasurementDialog.cs 129 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using PaintDotNet.Base;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.Base.Functionodel;
  6. using PaintDotNet.Base.SettingModel;
  7. using PaintDotNet.CustomControl;
  8. using PaintDotNet.Data.Param;
  9. using PaintDotNet.DbOpreate.DbBll;
  10. using PaintDotNet.DbOpreate.DbModel;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Data;
  15. using System.Drawing;
  16. using System.Drawing.Drawing2D;
  17. using System.Linq;
  18. using System.Windows.Forms;
  19. namespace PaintDotNet.DedicatedAnalysis.GrainSize.YBT4290_2012
  20. {
  21. /// <summary>
  22. /// 测量法
  23. /// </summary>
  24. internal class GrainSizeMeasurementDialog : PdnBaseForm
  25. {
  26. #region 基础控件
  27. private Button button1;
  28. private CheckBox checkBox1;
  29. private Button button2;
  30. private Button button32;
  31. private GroupBox groupBox2;
  32. private ListView listView1;
  33. private GroupBox groupBox3;
  34. private Panel panel1;
  35. private Label label3;
  36. private GroupBox groupBox7;
  37. private GroupBox groupBox8;
  38. private GroupBox groupBox9;
  39. private Button button6;
  40. private Button button7;
  41. private ListView listView2;
  42. private DataGridView dataGridView2;
  43. private Button button9;
  44. private Button button8;
  45. private NumericUpDown numericUpDown1;
  46. private Label label8;
  47. private Label label9;
  48. private Label label10;
  49. private ImageList imageList1;
  50. private IContainer components;
  51. private GroupBox groupBox1;
  52. private Button button3;
  53. private NumericUpDown numericUpDown4;
  54. private Label label4;
  55. private Label label2;
  56. private NumericUpDown numericUpDown3;
  57. private NumericUpDown numericUpDown2;
  58. private Label label1;
  59. private Label label7;
  60. private Label label6;
  61. private Label label5;
  62. private TextBox textBox3;
  63. private TextBox textBox2;
  64. private TextBox textBox1;
  65. private Button button10;
  66. #endregion
  67. /// <summary>
  68. /// 调色板
  69. /// </summary>
  70. PaintDotNet.ColorsForm colorsForm1;
  71. /// <summary>
  72. /// 主控件
  73. /// </summary>
  74. private AppWorkspace appWorkspace;
  75. /// <summary>
  76. /// 图像面板
  77. /// </summary>
  78. private DocumentWorkspaceWindow documentWorkspace;
  79. /// <summary>
  80. /// 公共按钮
  81. /// </summary>
  82. private CommonControlButtons commonControlButtons;
  83. //二值化集成1
  84. BinaryClass binaryClass;
  85. private int menuId;
  86. private string menuName;
  87. protected static string ParamKey_lineWidth = "lineWidth";//线宽
  88. protected static string ParamKey_lineColor = "lineColor";//颜色
  89. protected static string ParamKey_maxDiameter = "maxDiameter";//最大卡尺直径
  90. protected static string ParamKey_minDiameter = "minDiameter";//最小卡尺直径
  91. protected static string ParamKey_CalculatorDecimalDigits = "CalculatorDecimalDigits";//小数点位数
  92. protected static string ParamKey_OpenWhileExportReport = "OpenWhileExportReport";//生成报告时打开设置
  93. /// <summary>
  94. /// 保存所有窗口的参数
  95. /// </summary>
  96. private Dictionary<string, GrainSizeAnalysisModel> analysisDict = new Dictionary<string, GrainSizeAnalysisModel>();
  97. /// <summary>
  98. /// 晶界重现-保存所有窗口的参数 应用则计算,不应用则清空Mat。应用到全部则提前清空Mat和Model
  99. /// </summary>
  100. private Dictionary<string, GrainBoundryDectModel> grainBoundaryDict = new Dictionary<string, GrainBoundryDectModel>();
  101. /// <summary>
  102. /// 晶界重现-保存所有窗口的计算结果 应用则计算,不应用则清空
  103. /// </summary>
  104. private Dictionary<string, Mat> grainBoundaryMatDict = new Dictionary<string, Mat>();
  105. /// <summary>
  106. /// 选中图片的bitmap
  107. /// </summary>
  108. private Bitmap bitmap;
  109. /// <summary>
  110. /// 起止点
  111. /// </summary>
  112. private System.Drawing.PointF startPoint, endPoint;
  113. /// <summary>
  114. /// 测量点
  115. /// </summary>
  116. public RectangleF rectangleFBorder;
  117. /// <summary>
  118. /// 存储当前线的点集合
  119. /// </summary>
  120. private PointF[] nowLine;
  121. /// <summary>
  122. /// 计算结果的表格集合
  123. /// </summary>
  124. private List<DataTable> resultTableList = new List<DataTable>();
  125. /// <summary>
  126. /// 保存用于生成报告的图片
  127. /// </summary>
  128. private List<Bitmap> bitList;
  129. /// <summary>
  130. /// 储存点击保存结果后的所有原图与分析图
  131. /// </summary>
  132. private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
  133. /// <summary>
  134. /// 是否显示全部
  135. /// </summary>
  136. private bool showAll = false;
  137. /// <summary>
  138. /// 辅助计算偏移量-移动线两端的点
  139. /// </summary>
  140. private PointF lastPoint = new PointF(0, 0);
  141. /// <summary>
  142. /// 辅助计算偏移量-移动线中间的点
  143. /// </summary>
  144. private PointF tempPoint = new PointF(0, 0);
  145. /// <summary>
  146. /// 判断图形是否可移动
  147. /// </summary>
  148. private bool canMove = false;
  149. /// <summary>
  150. /// 判断图形是否可绘制
  151. /// </summary>
  152. private bool canDraw = false;
  153. /// <summary>
  154. /// 是否已选中
  155. /// </summary>
  156. private bool selected = false;
  157. /// <summary>
  158. /// 移动线上的哪一个点
  159. /// </summary>
  160. private int movePointIndex = -1;
  161. /// <summary>
  162. /// 点击次数
  163. /// </summary>
  164. private int clickCount = 0;
  165. ///// <summary>
  166. ///// 单位标尺
  167. ///// </summary>
  168. //private double unitLength = 1;
  169. /// <summary>
  170. /// 放大倍数
  171. /// </summary>
  172. private decimal gainNumber = 1;
  173. /// <summary>
  174. /// 分级数组
  175. /// </summary>
  176. private decimal[] levelArr = new decimal[] { 0.00101m, 0.00143m, 0.00202m, 0.00285m, 0.00403m, 0.00570m, 0.00807m, 0.0114m, 0.0161m, 0.0228m, 0.0323m,
  177. 0.0456m, 0.0645m, 0.0912m, 0.129m, 0.182m, 0.258m, 0.365m, 0.516m, 0.730m, 1.03m, 1.46m, 2.06m};
  178. /// <summary>
  179. /// 是否选择了图片
  180. /// </summary>
  181. private int selectPicture = -1;
  182. /// <summary>
  183. /// 存在视场标记
  184. /// </summary>
  185. private bool existViewFlag = false;
  186. /// <summary>
  187. /// 当前选择的图片
  188. /// </summary>
  189. private Mat mat;
  190. private BinaryControlSmaller bc;
  191. /// <summary>
  192. /// 中间数据
  193. /// </summary>
  194. private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
  195. private Button button_ApplyToAll;
  196. /// <summary>
  197. /// 0,E93099; 2,YBT4290;
  198. /// </summary>
  199. int gbtType;
  200. /// <summary>
  201. ///
  202. /// </summary>
  203. /// <param name="appWorkspace"></param>
  204. /// <param name="gbtType">>0,E93099; 2,YBT4290;</param>
  205. public GrainSizeMeasurementDialog(AppWorkspace appWorkspace, int gbtType, PdnMenuItem menuItem)
  206. {
  207. this.menuId = menuItem.MenuId;
  208. this.menuName = menuItem.Text;
  209. binaryClass = new BinaryClass(menuId);
  210. this.appWorkspace = appWorkspace;
  211. this.gbtType = gbtType;
  212. if (this.gbtType == 2)
  213. this.Text = "YBT4290_2012(" + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Measurementmethod.text") + ")";
  214. else if (this.gbtType == 0)
  215. this.Text = "ASTM_E93099_2007(" + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Measurementmethod.text") + ")";
  216. else
  217. this.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Measurementmethod.text");
  218. InitializeComponent();
  219. InitializeLanguageText();
  220. InitGridHeader();
  221. InitPicList();
  222. //初始化图片列表
  223. int imgIndex = -1;
  224. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  225. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  226. {
  227. imgIndex = i;
  228. break;
  229. }
  230. InitOtherTools();
  231. //如果是脚本执行,将参数带入
  232. if (imgIndex != -1 && appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null && (int)appWorkspace.ScriptCurrentParam.MenuId == menuId)
  233. {
  234. ////在这里反射出对应功能的参数类
  235. string className = InvariantData.path_Action + ".Action" + menuId;
  236. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  237. foreach (Args arg in param.Lists)
  238. {
  239. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  240. if (param1.value != null)
  241. arg.Value = param1.value;
  242. }
  243. GrainSizeAnalysisModel analysisModel = GrainSizeAnalysisModel.cloneListParamScript(param);
  244. foreach (var item in analysisModel.ListParam)
  245. item.setValue();
  246. this.analysisDict.Add(this.imageList1.Images.Keys[imgIndex], analysisModel);
  247. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  248. }
  249. else if (imgIndex != -1)
  250. {//读取上次关闭窗口时保存的参数
  251. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  252. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  253. GrainSizeAnalysisModel analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  254. foreach (var item in analysisModel.ListParam)
  255. item.setValue();
  256. this.analysisDict.Add(this.imageList1.Images.Keys[imgIndex], analysisModel);
  257. }
  258. InitCommonButtonEvent();
  259. AddPictureBoxEvent();
  260. SetAnalyzeModelFromXml(getModelName());
  261. }
  262. private void ShownChoiseItemAndInitData(object sender, EventArgs e)
  263. {
  264. binaryClass.RefreshHistogramControl1Values();
  265. int imgIndex = -1;
  266. this.listView1.Focus();
  267. //初始化图片列表
  268. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  269. {
  270. //this.imageList1.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  271. //this.listView1.Items.Add("", i);
  272. //this.lstView_img.Items[i].ImageIndex = i;
  273. //this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  274. //this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  275. if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
  276. {
  277. imgIndex = i;
  278. break;
  279. }
  280. }
  281. if (imgIndex != -1)//#21538
  282. {
  283. //滚动到指定的行位置
  284. this.listView1.EnsureVisible(imgIndex);
  285. this.listView1.Items[imgIndex].Focused = true;
  286. this.listView1.Items[imgIndex].Selected = true;
  287. }
  288. //getLastData();
  289. //bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  290. //binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  291. }
  292. private string getModelName()
  293. {
  294. if (this.gbtType == 2)
  295. return "Template.Manager.item3.GrainSizeMeasurement";
  296. else if (this.gbtType == 0)
  297. return "Template.Manager.item3.GrainSizeMeasure93099Method";
  298. else
  299. return "Template.Manager.item3.GrainSizeMeasurement";
  300. }
  301. private void InitializeLanguageText()
  302. {
  303. this.bc = new PaintDotNet.CustomControl.BinaryControlSmaller();
  304. //
  305. // bc
  306. //
  307. this.bc.BinaryBackColor = System.Drawing.Color.Red;
  308. this.bc.BinaryChecked = false;
  309. this.bc.BinaryStyle = 1;
  310. this.bc.Location = new System.Drawing.Point(150, 58);
  311. this.bc.Name = "bc";
  312. this.bc.OriginChecked = false;
  313. this.bc.scope1End = 0D;
  314. this.bc.scope1Start = 0D;
  315. this.bc.scope2End = 0D;
  316. this.bc.scope2Start = 0D;
  317. this.bc.scope3End = 0D;
  318. this.bc.scope3Start = 0D;
  319. this.bc.Size = new System.Drawing.Size(360, 247);
  320. this.bc.TabIndex = 31;
  321. this.Controls.Add(this.bc);
  322. this.Controls.SetChildIndex(this.bc, 0);
  323. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  324. this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
  325. this.button32.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  326. this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
  327. this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
  328. this.button_ApplyToAll.Text = "应用到全部";
  329. this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
  330. this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text");
  331. this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  332. this.groupBox7.Text = PdnResources.GetString("Menu.measuring.text");
  333. this.button3.Text = PdnResources.GetString("Menu.measuring.text");
  334. this.label4.Text = PdnResources.GetString("Menu.Verticalcaliperdiameter.Text") + ":";
  335. this.label2.Text = PdnResources.GetString("Menu.color.text") + ":";
  336. this.label1.Text = PdnResources.GetString("Menu.Maximumcalipddderdiameter.Text") + ":";
  337. this.groupBox8.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Previewresults.text");
  338. this.label7.Text = PdnResources.GetString("Menu.ALAgrainlevel.text") + ":";
  339. this.label6.Text = PdnResources.GetString("Menu.Actualarea.text") + ":";
  340. this.label5.Text = PdnResources.GetString("Menu.Ellipsearea.text") + ":";
  341. this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");
  342. this.button10.Text = PdnResources.GetString("Menu.Exportproject.text");
  343. this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
  344. this.button9.Text = PdnResources.GetString("Menu.Exportresults.text");
  345. this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
  346. this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  347. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  348. }
  349. private void InitializeComponent()
  350. {
  351. this.components = new System.ComponentModel.Container();
  352. this.groupBox1 = new System.Windows.Forms.GroupBox();
  353. this.button2 = new System.Windows.Forms.Button();
  354. this.button32 = new System.Windows.Forms.Button();
  355. this.checkBox1 = new System.Windows.Forms.CheckBox();
  356. this.button1 = new System.Windows.Forms.Button();
  357. this.groupBox2 = new System.Windows.Forms.GroupBox();
  358. this.listView1 = new System.Windows.Forms.ListView();
  359. this.imageList1 = new System.Windows.Forms.ImageList(this.components);
  360. this.groupBox3 = new System.Windows.Forms.GroupBox();
  361. this.panel1 = new System.Windows.Forms.Panel();
  362. this.label3 = new System.Windows.Forms.Label();
  363. this.groupBox7 = new System.Windows.Forms.GroupBox();
  364. this.button3 = new System.Windows.Forms.Button();
  365. this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
  366. this.label4 = new System.Windows.Forms.Label();
  367. this.label2 = new System.Windows.Forms.Label();
  368. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  369. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  370. this.label1 = new System.Windows.Forms.Label();
  371. this.groupBox8 = new System.Windows.Forms.GroupBox();
  372. this.textBox3 = new System.Windows.Forms.TextBox();
  373. this.textBox2 = new System.Windows.Forms.TextBox();
  374. this.textBox1 = new System.Windows.Forms.TextBox();
  375. this.label7 = new System.Windows.Forms.Label();
  376. this.label6 = new System.Windows.Forms.Label();
  377. this.label5 = new System.Windows.Forms.Label();
  378. this.groupBox9 = new System.Windows.Forms.GroupBox();
  379. this.button10 = new System.Windows.Forms.Button();
  380. this.label10 = new System.Windows.Forms.Label();
  381. this.label9 = new System.Windows.Forms.Label();
  382. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  383. this.label8 = new System.Windows.Forms.Label();
  384. this.button9 = new System.Windows.Forms.Button();
  385. this.button8 = new System.Windows.Forms.Button();
  386. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  387. this.listView2 = new System.Windows.Forms.ListView();
  388. this.button7 = new System.Windows.Forms.Button();
  389. this.button6 = new System.Windows.Forms.Button();
  390. this.button_ApplyToAll = new System.Windows.Forms.Button();
  391. this.groupBox1.SuspendLayout();
  392. this.groupBox2.SuspendLayout();
  393. this.groupBox7.SuspendLayout();
  394. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
  395. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  396. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  397. this.groupBox8.SuspendLayout();
  398. this.groupBox9.SuspendLayout();
  399. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  400. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  401. this.SuspendLayout();
  402. //
  403. // groupBox1
  404. //
  405. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  406. | System.Windows.Forms.AnchorStyles.Right)));
  407. this.groupBox1.Controls.Add(this.button_ApplyToAll);
  408. this.groupBox1.Controls.Add(this.button2);
  409. this.groupBox1.Controls.Add(this.button32);
  410. this.groupBox1.Controls.Add(this.checkBox1);
  411. this.groupBox1.Controls.Add(this.button1);
  412. this.groupBox1.Location = new System.Drawing.Point(14, 3);
  413. this.groupBox1.Name = "groupBox1";
  414. this.groupBox1.Size = new System.Drawing.Size(1081, 50);
  415. this.groupBox1.TabIndex = 1;
  416. this.groupBox1.TabStop = false;
  417. //
  418. // button2
  419. //
  420. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  421. | System.Windows.Forms.AnchorStyles.Right)));
  422. this.button2.Location = new System.Drawing.Point(895, 17);
  423. this.button2.Name = "button2";
  424. this.button2.Size = new System.Drawing.Size(84, 24);
  425. this.button2.TabIndex = 2;
  426. this.button2.UseVisualStyleBackColor = true;
  427. this.button2.Click += new System.EventHandler(this.button2_Click);
  428. //
  429. // button32
  430. //
  431. this.button32.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  432. | System.Windows.Forms.AnchorStyles.Right)));
  433. this.button32.Location = new System.Drawing.Point(805, 17);
  434. this.button32.Name = "button32";
  435. this.button32.Size = new System.Drawing.Size(84, 24);
  436. this.button32.TabIndex = 2;
  437. this.button32.UseVisualStyleBackColor = true;
  438. this.button32.Click += new System.EventHandler(this.button32_Click);
  439. //
  440. // checkBox1
  441. //
  442. this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  443. | System.Windows.Forms.AnchorStyles.Left)));
  444. this.checkBox1.AutoSize = true;
  445. this.checkBox1.Location = new System.Drawing.Point(141, 21);
  446. this.checkBox1.Name = "checkBox1";
  447. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  448. this.checkBox1.TabIndex = 1;
  449. this.checkBox1.UseVisualStyleBackColor = true;
  450. //
  451. // button1
  452. //
  453. this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  454. | System.Windows.Forms.AnchorStyles.Left)));
  455. this.button1.Location = new System.Drawing.Point(15, 14);
  456. this.button1.Name = "button1";
  457. this.button1.Size = new System.Drawing.Size(84, 30);
  458. this.button1.TabIndex = 0;
  459. this.button1.UseVisualStyleBackColor = true;
  460. this.button1.Click += new System.EventHandler(this.button1_Click);
  461. //
  462. // groupBox2
  463. //
  464. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  465. | System.Windows.Forms.AnchorStyles.Left)));
  466. this.groupBox2.Controls.Add(this.listView1);
  467. this.groupBox2.Location = new System.Drawing.Point(14, 60);
  468. this.groupBox2.Name = "groupBox2";
  469. this.groupBox2.Size = new System.Drawing.Size(135, 544);
  470. this.groupBox2.TabIndex = 2;
  471. this.groupBox2.TabStop = false;
  472. //
  473. // listView1
  474. //
  475. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  476. | System.Windows.Forms.AnchorStyles.Left)
  477. | System.Windows.Forms.AnchorStyles.Right)));
  478. this.listView1.HideSelection = false;
  479. this.listView1.LargeImageList = this.imageList1;
  480. this.listView1.Location = new System.Drawing.Point(5, 17);
  481. this.listView1.MultiSelect = false;
  482. this.listView1.Name = "listView1";
  483. this.listView1.Size = new System.Drawing.Size(124, 521);
  484. this.listView1.TabIndex = 0;
  485. this.listView1.UseCompatibleStateImageBehavior = false;
  486. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  487. //
  488. // imageList1
  489. //
  490. this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  491. this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
  492. this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
  493. //
  494. // groupBox3
  495. //
  496. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  497. | System.Windows.Forms.AnchorStyles.Left)
  498. | System.Windows.Forms.AnchorStyles.Right)));
  499. this.groupBox3.Location = new System.Drawing.Point(515, 60);
  500. this.groupBox3.Name = "groupBox3";
  501. this.groupBox3.Size = new System.Drawing.Size(580, 543);
  502. this.groupBox3.TabIndex = 3;
  503. this.groupBox3.TabStop = false;
  504. //
  505. // panel1
  506. //
  507. this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight;
  508. this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
  509. this.panel1.Location = new System.Drawing.Point(233, 20);
  510. this.panel1.Name = "panel1";
  511. this.panel1.Size = new System.Drawing.Size(84, 18);
  512. this.panel1.TabIndex = 5;
  513. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  514. //
  515. // label3
  516. //
  517. this.label3.AutoSize = true;
  518. this.label3.Location = new System.Drawing.Point(16, 23);
  519. this.label3.Name = "label3";
  520. this.label3.Size = new System.Drawing.Size(0, 12);
  521. this.label3.TabIndex = 0;
  522. //
  523. // groupBox7
  524. //
  525. this.groupBox7.Controls.Add(this.button3);
  526. this.groupBox7.Controls.Add(this.numericUpDown4);
  527. this.groupBox7.Controls.Add(this.label4);
  528. this.groupBox7.Controls.Add(this.label2);
  529. this.groupBox7.Controls.Add(this.numericUpDown3);
  530. this.groupBox7.Controls.Add(this.numericUpDown2);
  531. this.groupBox7.Controls.Add(this.label1);
  532. this.groupBox7.Controls.Add(this.label3);
  533. this.groupBox7.Controls.Add(this.panel1);
  534. this.groupBox7.Location = new System.Drawing.Point(154, 318);
  535. this.groupBox7.Name = "groupBox7";
  536. this.groupBox7.Size = new System.Drawing.Size(356, 94);
  537. this.groupBox7.TabIndex = 7;
  538. this.groupBox7.TabStop = false;
  539. //
  540. // button3
  541. //
  542. this.button3.Location = new System.Drawing.Point(236, 53);
  543. this.button3.Name = "button3";
  544. this.button3.Size = new System.Drawing.Size(75, 23);
  545. this.button3.TabIndex = 12;
  546. this.button3.UseVisualStyleBackColor = true;
  547. this.button3.Click += new System.EventHandler(this.button3_Click);
  548. //
  549. // numericUpDown4
  550. //
  551. this.numericUpDown4.DecimalPlaces = 5;
  552. this.numericUpDown4.Increment = new decimal(new int[] {
  553. 1,
  554. 0,
  555. 0,
  556. 131072});
  557. this.numericUpDown4.Location = new System.Drawing.Point(125, 67);
  558. this.numericUpDown4.Maximum = new decimal(new int[] {
  559. 99999999,
  560. 0,
  561. 0,
  562. 0});
  563. this.numericUpDown4.Name = "numericUpDown4";
  564. this.numericUpDown4.ReadOnly = true;
  565. this.numericUpDown4.Size = new System.Drawing.Size(98, 21);
  566. this.numericUpDown4.TabIndex = 11;
  567. this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
  568. //
  569. // label4
  570. //
  571. this.label4.AutoSize = true;
  572. this.label4.Location = new System.Drawing.Point(16, 71);
  573. this.label4.Name = "label4";
  574. this.label4.Size = new System.Drawing.Size(0, 12);
  575. this.label4.TabIndex = 10;
  576. //
  577. // label2
  578. //
  579. this.label2.AutoSize = true;
  580. this.label2.Location = new System.Drawing.Point(189, 23);
  581. this.label2.Name = "label2";
  582. this.label2.Size = new System.Drawing.Size(0, 12);
  583. this.label2.TabIndex = 9;
  584. //
  585. // numericUpDown3
  586. //
  587. this.numericUpDown3.DecimalPlaces = 5;
  588. this.numericUpDown3.Increment = new decimal(new int[] {
  589. 1,
  590. 0,
  591. 0,
  592. 131072});
  593. this.numericUpDown3.Location = new System.Drawing.Point(125, 43);
  594. this.numericUpDown3.Maximum = new decimal(new int[] {
  595. 99999999,
  596. 0,
  597. 0,
  598. 0});
  599. this.numericUpDown3.Name = "numericUpDown3";
  600. this.numericUpDown3.ReadOnly = true;
  601. this.numericUpDown3.Size = new System.Drawing.Size(98, 21);
  602. this.numericUpDown3.TabIndex = 8;
  603. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  604. //
  605. // numericUpDown2
  606. //
  607. this.numericUpDown2.Location = new System.Drawing.Point(59, 19);
  608. this.numericUpDown2.Maximum = new decimal(new int[] {
  609. 50,
  610. 0,
  611. 0,
  612. 0});
  613. this.numericUpDown2.Minimum = new decimal(new int[] {
  614. 1,
  615. 0,
  616. 0,
  617. 0});
  618. this.numericUpDown2.Name = "numericUpDown2";
  619. this.numericUpDown2.Size = new System.Drawing.Size(69, 21);
  620. this.numericUpDown2.TabIndex = 7;
  621. this.numericUpDown2.Value = new decimal(new int[] {
  622. 3,
  623. 0,
  624. 0,
  625. 0});
  626. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  627. //
  628. // label1
  629. //
  630. this.label1.AutoSize = true;
  631. this.label1.Location = new System.Drawing.Point(16, 47);
  632. this.label1.Name = "label1";
  633. this.label1.Size = new System.Drawing.Size(0, 12);
  634. this.label1.TabIndex = 6;
  635. //
  636. // groupBox8
  637. //
  638. this.groupBox8.Controls.Add(this.textBox3);
  639. this.groupBox8.Controls.Add(this.textBox2);
  640. this.groupBox8.Controls.Add(this.textBox1);
  641. this.groupBox8.Controls.Add(this.label7);
  642. this.groupBox8.Controls.Add(this.label6);
  643. this.groupBox8.Controls.Add(this.label5);
  644. this.groupBox8.Location = new System.Drawing.Point(154, 418);
  645. this.groupBox8.Name = "groupBox8";
  646. this.groupBox8.Size = new System.Drawing.Size(356, 75);
  647. this.groupBox8.TabIndex = 8;
  648. this.groupBox8.TabStop = false;
  649. //
  650. // textBox3
  651. //
  652. this.textBox3.Location = new System.Drawing.Point(112, 45);
  653. this.textBox3.Name = "textBox3";
  654. this.textBox3.ReadOnly = true;
  655. this.textBox3.Size = new System.Drawing.Size(142, 21);
  656. this.textBox3.TabIndex = 5;
  657. //
  658. // textBox2
  659. //
  660. this.textBox2.Location = new System.Drawing.Point(237, 16);
  661. this.textBox2.Name = "textBox2";
  662. this.textBox2.ReadOnly = true;
  663. this.textBox2.Size = new System.Drawing.Size(88, 21);
  664. this.textBox2.TabIndex = 4;
  665. //
  666. // textBox1
  667. //
  668. this.textBox1.Location = new System.Drawing.Point(73, 16);
  669. this.textBox1.Name = "textBox1";
  670. this.textBox1.ReadOnly = true;
  671. this.textBox1.Size = new System.Drawing.Size(88, 21);
  672. this.textBox1.TabIndex = 3;
  673. //
  674. // label7
  675. //
  676. this.label7.AutoSize = true;
  677. this.label7.Location = new System.Drawing.Point(16, 49);
  678. this.label7.Name = "label7";
  679. this.label7.Size = new System.Drawing.Size(0, 12);
  680. this.label7.TabIndex = 2;
  681. //
  682. // label6
  683. //
  684. this.label6.AutoSize = true;
  685. this.label6.Location = new System.Drawing.Point(180, 21);
  686. this.label6.Name = "label6";
  687. this.label6.Size = new System.Drawing.Size(0, 12);
  688. this.label6.TabIndex = 1;
  689. //
  690. // label5
  691. //
  692. this.label5.AutoSize = true;
  693. this.label5.Location = new System.Drawing.Point(16, 21);
  694. this.label5.Name = "label5";
  695. this.label5.Size = new System.Drawing.Size(0, 12);
  696. this.label5.TabIndex = 0;
  697. //
  698. // groupBox9
  699. //
  700. this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  701. | System.Windows.Forms.AnchorStyles.Right)));
  702. this.groupBox9.Controls.Add(this.button10);
  703. this.groupBox9.Controls.Add(this.label10);
  704. this.groupBox9.Controls.Add(this.label9);
  705. this.groupBox9.Controls.Add(this.numericUpDown1);
  706. this.groupBox9.Controls.Add(this.label8);
  707. this.groupBox9.Controls.Add(this.button9);
  708. this.groupBox9.Controls.Add(this.button8);
  709. this.groupBox9.Controls.Add(this.dataGridView2);
  710. this.groupBox9.Controls.Add(this.listView2);
  711. this.groupBox9.Controls.Add(this.button7);
  712. this.groupBox9.Controls.Add(this.button6);
  713. this.groupBox9.Location = new System.Drawing.Point(14, 609);
  714. this.groupBox9.Name = "groupBox9";
  715. this.groupBox9.Size = new System.Drawing.Size(1081, 204);
  716. this.groupBox9.TabIndex = 9;
  717. this.groupBox9.TabStop = false;
  718. //
  719. // button10
  720. //
  721. this.button10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  722. this.button10.Location = new System.Drawing.Point(941, 109);
  723. this.button10.Name = "button10";
  724. this.button10.Size = new System.Drawing.Size(128, 26);
  725. this.button10.TabIndex = 10;
  726. this.button10.UseVisualStyleBackColor = true;
  727. this.button10.Click += new System.EventHandler(this.button10_Click);
  728. //
  729. // label10
  730. //
  731. this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  732. this.label10.AutoSize = true;
  733. this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
  734. this.label10.Location = new System.Drawing.Point(927, 9);
  735. this.label10.Name = "label10";
  736. this.label10.Size = new System.Drawing.Size(11, 192);
  737. this.label10.TabIndex = 9;
  738. 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|";
  739. //
  740. // label9
  741. //
  742. this.label9.AutoSize = true;
  743. this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
  744. this.label9.Location = new System.Drawing.Point(210, 9);
  745. this.label9.Name = "label9";
  746. this.label9.Size = new System.Drawing.Size(11, 192);
  747. this.label9.TabIndex = 8;
  748. 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|";
  749. //
  750. // numericUpDown1
  751. //
  752. this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  753. this.numericUpDown1.Location = new System.Drawing.Point(993, 162);
  754. this.numericUpDown1.Maximum = new decimal(new int[] {
  755. 10,
  756. 0,
  757. 0,
  758. 0});
  759. this.numericUpDown1.Minimum = new decimal(new int[] {
  760. 1,
  761. 0,
  762. 0,
  763. 0});
  764. this.numericUpDown1.Name = "numericUpDown1";
  765. this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
  766. this.numericUpDown1.TabIndex = 7;
  767. this.numericUpDown1.Value = new decimal(new int[] {
  768. 3,
  769. 0,
  770. 0,
  771. 0});
  772. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  773. //
  774. // label8
  775. //
  776. this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
  777. this.label8.AutoSize = true;
  778. this.label8.Location = new System.Drawing.Point(957, 167);
  779. this.label8.Name = "label8";
  780. this.label8.Size = new System.Drawing.Size(0, 12);
  781. this.label8.TabIndex = 6;
  782. //
  783. // button9
  784. //
  785. this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  786. this.button9.Location = new System.Drawing.Point(941, 71);
  787. this.button9.Name = "button9";
  788. this.button9.Size = new System.Drawing.Size(128, 26);
  789. this.button9.TabIndex = 5;
  790. this.button9.UseVisualStyleBackColor = true;
  791. this.button9.Click += new System.EventHandler(this.button9_Click);
  792. //
  793. // button8
  794. //
  795. this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  796. this.button8.Location = new System.Drawing.Point(941, 34);
  797. this.button8.Name = "button8";
  798. this.button8.Size = new System.Drawing.Size(128, 26);
  799. this.button8.TabIndex = 4;
  800. this.button8.UseVisualStyleBackColor = true;
  801. this.button8.Click += new System.EventHandler(this.button8_Click);
  802. //
  803. // dataGridView2
  804. //
  805. this.dataGridView2.AllowUserToAddRows = false;
  806. this.dataGridView2.AllowUserToDeleteRows = false;
  807. this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  808. | System.Windows.Forms.AnchorStyles.Left)
  809. | System.Windows.Forms.AnchorStyles.Right)));
  810. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  811. this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
  812. this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  813. this.dataGridView2.Location = new System.Drawing.Point(228, 20);
  814. this.dataGridView2.MultiSelect = false;
  815. this.dataGridView2.Name = "dataGridView2";
  816. this.dataGridView2.RowHeadersVisible = false;
  817. this.dataGridView2.RowTemplate.Height = 23;
  818. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  819. this.dataGridView2.Size = new System.Drawing.Size(693, 176);
  820. this.dataGridView2.TabIndex = 3;
  821. //
  822. // listView2
  823. //
  824. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  825. | System.Windows.Forms.AnchorStyles.Left)));
  826. this.listView2.HideSelection = false;
  827. this.listView2.Location = new System.Drawing.Point(16, 56);
  828. this.listView2.Name = "listView2";
  829. this.listView2.Size = new System.Drawing.Size(181, 140);
  830. this.listView2.TabIndex = 2;
  831. this.listView2.UseCompatibleStateImageBehavior = false;
  832. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  833. //
  834. // button7
  835. //
  836. this.button7.Location = new System.Drawing.Point(145, 20);
  837. this.button7.Name = "button7";
  838. this.button7.Size = new System.Drawing.Size(52, 26);
  839. this.button7.TabIndex = 1;
  840. this.button7.UseVisualStyleBackColor = true;
  841. this.button7.Click += new System.EventHandler(this.button7_Click);
  842. //
  843. // button6
  844. //
  845. this.button6.Location = new System.Drawing.Point(16, 20);
  846. this.button6.Name = "button6";
  847. this.button6.Size = new System.Drawing.Size(93, 26);
  848. this.button6.TabIndex = 0;
  849. this.button6.UseVisualStyleBackColor = true;
  850. this.button6.Click += new System.EventHandler(this.button6_Click);
  851. //
  852. // button_ApplyToAll
  853. //
  854. this.button_ApplyToAll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  855. | System.Windows.Forms.AnchorStyles.Right)));
  856. this.button_ApplyToAll.Location = new System.Drawing.Point(985, 17);
  857. this.button_ApplyToAll.Name = "button_ApplyToAll";
  858. this.button_ApplyToAll.Size = new System.Drawing.Size(84, 24);
  859. this.button_ApplyToAll.TabIndex = 3;
  860. this.button_ApplyToAll.UseVisualStyleBackColor = true;
  861. this.button_ApplyToAll.Click += new System.EventHandler(this.button_ApplyToAll_Click);
  862. //
  863. // GrainSizeMeasurementDialog
  864. //
  865. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  866. this.ClientSize = new System.Drawing.Size(1107, 818);
  867. this.Controls.Add(this.groupBox9);
  868. this.Controls.Add(this.groupBox8);
  869. this.Controls.Add(this.groupBox7);
  870. this.Controls.Add(this.groupBox3);
  871. this.Controls.Add(this.groupBox2);
  872. this.Controls.Add(this.groupBox1);
  873. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  874. this.Name = "GrainSizeMeasurementDialog";
  875. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeDialog_FormClosing);
  876. this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
  877. this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
  878. this.Controls.SetChildIndex(this.groupBox1, 0);
  879. this.Controls.SetChildIndex(this.groupBox2, 0);
  880. this.Controls.SetChildIndex(this.groupBox3, 0);
  881. this.Controls.SetChildIndex(this.groupBox7, 0);
  882. this.Controls.SetChildIndex(this.groupBox8, 0);
  883. this.Controls.SetChildIndex(this.groupBox9, 0);
  884. this.groupBox1.ResumeLayout(false);
  885. this.groupBox1.PerformLayout();
  886. this.groupBox2.ResumeLayout(false);
  887. this.groupBox7.ResumeLayout(false);
  888. this.groupBox7.PerformLayout();
  889. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
  890. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  891. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  892. this.groupBox8.ResumeLayout(false);
  893. this.groupBox8.PerformLayout();
  894. this.groupBox9.ResumeLayout(false);
  895. this.groupBox9.PerformLayout();
  896. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  897. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  898. this.ResumeLayout(false);
  899. }
  900. /// <summary>
  901. /// 初始化其他控件
  902. /// </summary>
  903. private void InitOtherTools()
  904. {
  905. //
  906. //初始化图像控件
  907. //
  908. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  909. this.documentWorkspace.Dock = DockStyle.Fill;
  910. this.documentWorkspace.HookMouseEvents();
  911. this.documentWorkspace.AuxiliaryLineEnabled = false;
  912. this.documentWorkspace.Visible = false;
  913. this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.NullTool;
  914. this.groupBox3.Controls.Add(documentWorkspace);
  915. //
  916. //初始化操作按钮
  917. //
  918. this.commonControlButtons = new CommonControlButtons();
  919. this.commonControlButtons.Dock = DockStyle.Top;
  920. this.commonControlButtons.Height = 30;
  921. this.commonControlButtons.HideZoomToWindowAndActualSize();
  922. this.commonControlButtons.Visible = false;
  923. this.groupBox3.Controls.Add(commonControlButtons);
  924. //{
  925. // //二值化相关
  926. // PhaseModel model = new PhaseModel();
  927. // model.choise = true;
  928. // model.mat = null;
  929. // model.color = panel2.BackColor.ToArgb();
  930. // model.position = this.documentWorkspace.PhaseModels.Count + 1;
  931. // model.name = PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text");
  932. // this.documentWorkspace.PhaseModels.Add(model);
  933. // //二值化end
  934. //}
  935. //{
  936. // //
  937. // //初始化相
  938. // //
  939. // PhaseModel model = new PhaseModel();
  940. // model.choise = true;
  941. // model.mat = null;
  942. // model.color = Color.Green/*panel2.BackColor*/.ToArgb();
  943. // model.position = this.documentWorkspace.PhaseModels.Count + 1;
  944. // model.name = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
  945. // this.documentWorkspace.PhaseModels.Add(model);
  946. //}
  947. //二值化集成2
  948. bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
  949. binaryClass.createDocumentItemsSmaller(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }
  950. , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
  951. binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
  952. //
  953. //调色板
  954. //
  955. this.colorsForm1 = new ColorsForm();
  956. this.colorsForm1.StartPosition = FormStartPosition.CenterScreen;
  957. this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);
  958. //
  959. //颜色panel给定初始值
  960. //
  961. this.panel1.BackColor = Color.Green;
  962. ////
  963. ////获取系统标尺-毫米
  964. ////
  965. //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Millimeter, out unitLength);
  966. ////double unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Millimeter);
  967. ////double physical_area_length_Micron = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
  968. //if (this.unitLength == 0)
  969. // this.unitLength = 1;
  970. ////
  971. ////获取当前系统放大倍数
  972. ////
  973. //this.gainNumber = this.appWorkspace.GetGainMultiple();
  974. //if (this.gainNumber == 0)
  975. // this.gainNumber = 1;
  976. }
  977. /// <summary>
  978. /// 初始化图片列表数据
  979. /// </summary>
  980. public void InitPicList()
  981. {
  982. //初始化图片列表
  983. for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
  984. {
  985. this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
  986. this.listView1.Items.Add("", i);
  987. this.listView1.Items[i].ImageIndex = i;
  988. this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  989. this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
  990. }
  991. }
  992. /// <summary>
  993. /// 初始化表头
  994. /// </summary>
  995. private void InitGridHeader()
  996. {
  997. //
  998. //分析结果表
  999. //
  1000. this.dataGridView2.ColumnHeadersHeight = 30;
  1001. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  1002. h1.Width = 174;
  1003. DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
  1004. h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1005. h2.Width = 172;
  1006. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  1007. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1008. h3.Width = 172;
  1009. DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
  1010. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  1011. h4.Width = 172;
  1012. this.dataGridView2.Columns.Add(h1);
  1013. this.dataGridView2.Columns.Add(h2);
  1014. this.dataGridView2.Columns.Add(h3);
  1015. this.dataGridView2.Columns.Add(h4);
  1016. DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
  1017. helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text")));
  1018. helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)"));
  1019. helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Actualarea.text")+"(μm)"));
  1020. helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.ALAgrainlevel.text")));
  1021. this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  1022. this.dataGridView2.Columns[0].ReadOnly = true;
  1023. this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  1024. this.dataGridView2.Columns[1].ReadOnly = true;
  1025. this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  1026. this.dataGridView2.Columns[2].ReadOnly = true;
  1027. this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  1028. this.dataGridView2.Columns[3].ReadOnly = true;
  1029. this.dataGridView2.AllowUserToResizeRows = false;
  1030. this.dataGridView2.AllowUserToResizeColumns = false;
  1031. //
  1032. //左下表
  1033. //
  1034. this.listView2.View = View.Details;
  1035. ColumnHeader header0 = new ColumnHeader();
  1036. header0.Text = PdnResources.GetString("Menu.Resultlist.Text");
  1037. header0.Width = 175;
  1038. this.listView2.Columns.Add(header0);
  1039. }
  1040. /// <summary>
  1041. /// 初始化画布按键功能
  1042. /// </summary>
  1043. private void InitCommonButtonEvent()
  1044. {
  1045. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  1046. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  1047. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  1048. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  1049. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  1050. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  1051. }
  1052. private void zoomInButton_Click(object sender, EventArgs e)
  1053. {
  1054. this.documentWorkspace.ZoomIn();
  1055. }
  1056. private void zoomOutButton_Click(object sender, EventArgs e)
  1057. {
  1058. this.documentWorkspace.ZoomOut();
  1059. }
  1060. private void zoomToWindowButton_Click(object sender, EventArgs e)
  1061. {
  1062. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  1063. }
  1064. private void actualSizeButton_Click(object sender, EventArgs e)
  1065. {
  1066. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  1067. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  1068. }
  1069. private void pointerButton_Click(object sender, EventArgs e)
  1070. {
  1071. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  1072. }
  1073. private void mobileModeButton_Click(object sender, EventArgs e)
  1074. {
  1075. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  1076. }
  1077. /// <summary>
  1078. /// 添加画布绑定事件
  1079. /// </summary>
  1080. private void AddPictureBoxEvent()
  1081. {
  1082. this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.BoxMouseDownHandler);
  1083. this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.BoxMouseMoveHandler);
  1084. this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.BoxMouseUpHandler);
  1085. this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);
  1086. }
  1087. /// <summary>
  1088. /// 调色板回调函数
  1089. /// </summary>
  1090. /// <param name="sender"></param>
  1091. /// <param name="ce"></param>
  1092. private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)
  1093. {
  1094. }
  1095. /// <summary>
  1096. /// 添加内容单元格
  1097. /// </summary>
  1098. /// <param name="text"></param>
  1099. /// <param name="tag"></param>
  1100. /// <returns></returns>
  1101. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  1102. {
  1103. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1104. textboxcell.Value = text;
  1105. textboxcell.Tag = tag;
  1106. return textboxcell;
  1107. }
  1108. /// <summary>
  1109. /// 设置按钮
  1110. /// </summary>
  1111. /// <param name="sender"></param>
  1112. /// <param name="e"></param>
  1113. private void button1_Click(object sender, EventArgs e)
  1114. {
  1115. AnalyzeSettingDialog grainSizeMeasurementSetDialog = new AnalyzeSettingDialog(this, getModelName());
  1116. if (grainSizeMeasurementSetDialog.hasModule)
  1117. {
  1118. grainSizeMeasurementSetDialog.StartPosition = FormStartPosition.CenterScreen;
  1119. grainSizeMeasurementSetDialog.ShowDialog();
  1120. }
  1121. else
  1122. {
  1123. grainSizeMeasurementSetDialog = null;
  1124. }
  1125. }
  1126. protected Color PhaseModels1Color;
  1127. /// <summary>
  1128. /// 晶界编辑按钮
  1129. /// </summary>
  1130. /// <param name="sender"></param>
  1131. /// <param name="e"></param>
  1132. private void button32_Click(object sender, EventArgs e)
  1133. {
  1134. if (this.bitmap == null)
  1135. {
  1136. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
  1137. return;
  1138. }
  1139. GrainSizeStandard.IntegrationClass.GrainBoundaryEditingDialog boundaryEditingDialog = new GrainSizeStandard.IntegrationClass.GrainBoundaryEditingDialog(this.appWorkspace, this.menuId, this.listView1.FocusedItem.Index, this.documentWorkspace.PhaseModels[1].mat == null ? Color.Red : PhaseModels1Color/*this.panel1.BackColor*/
  1140. , this.documentWorkspace.PhaseModels[1].mat == null ? null : this.documentWorkspace.PhaseModels[1].mat.Clone());
  1141. if (boundaryEditingDialog.ShowDialog() == DialogResult.OK && boundaryEditingDialog.PhaseMat != null)
  1142. {
  1143. PhaseModels1Color = boundaryEditingDialog.PhaseColor;
  1144. this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
  1145. this.documentWorkspace.Refresh();
  1146. }
  1147. }
  1148. /// <summary>
  1149. /// 保存结果按钮
  1150. /// </summary>
  1151. /// <param name="sender"></param>
  1152. /// <param name="e"></param>
  1153. private void button2_Click(object sender, EventArgs e)
  1154. {
  1155. if (this.listView1.SelectedItems.Count > 0)
  1156. {
  1157. string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
  1158. string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
  1159. bool replace = false;
  1160. int rowIndex = 0;
  1161. if (!string.IsNullOrEmpty(this.textBox1.Text) && !string.IsNullOrEmpty(this.textBox2.Text) && !string.IsNullOrEmpty(this.textBox3.Text))
  1162. {
  1163. if (this.listView2.Items.Count > 0)
  1164. {
  1165. foreach (ListViewItem item in this.listView2.Items)
  1166. {
  1167. if (item.Name.Equals(tag))
  1168. {
  1169. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1170. if (dr == DialogResult.OK)
  1171. {
  1172. replace = true;
  1173. }
  1174. else
  1175. {
  1176. return;
  1177. }
  1178. break;
  1179. }
  1180. }
  1181. }
  1182. double unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Millimeter);
  1183. decimal rulerWidth = decimal.Parse((BasicCalculationHelper.GetDistance(this.nowLine[0], this.nowLine[1], 10) * unitLength).ToString());
  1184. decimal rulerheight = decimal.Parse((BasicCalculationHelper.GetDistance(this.nowLine[2], this.nowLine[3], 10) * unitLength).ToString());
  1185. decimal area = 0.785m * rulerWidth * rulerheight;
  1186. decimal realArea = area / (this.gainNumber * this.gainNumber);
  1187. //有重名需要替换
  1188. if (replace)
  1189. {
  1190. for (int i = 0; i < this.resultTableList.Count; i++)
  1191. {
  1192. if (this.resultTableList[i].TableName.Equals(tag))
  1193. {
  1194. rowIndex = i;
  1195. this.resultTableList.Remove(this.resultTableList[i]);
  1196. if (this.nowLine[0] != PointF.Empty && this.nowLine[1] != PointF.Empty && this.nowLine[2] != PointF.Empty && this.nowLine[3] != PointF.Empty)
  1197. {
  1198. DataTable dt = new DataTable(tag);
  1199. dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1200. dt.Columns.Add(PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)");
  1201. dt.Columns.Add(PdnResources.GetString("Menu.Actualarea.text")+"(μm)");
  1202. dt.Columns.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  1203. DataRow dataRow = dt.NewRow();
  1204. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1205. dataRow[PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)"] = area * 1000000;
  1206. dataRow[PdnResources.GetString("Menu.Actualarea.text")+"(μm)"] = realArea * 1000000;
  1207. dataRow[PdnResources.GetString("Menu.ALAgrainlevel.text")] = this.textBox3.Text;
  1208. dt.Rows.Add(dataRow);
  1209. resultTableList.Insert(rowIndex, dt);
  1210. }
  1211. }
  1212. }
  1213. }
  1214. //新增
  1215. else
  1216. {
  1217. if (this.nowLine[0] != PointF.Empty && this.nowLine[1] != PointF.Empty && this.nowLine[2] != PointF.Empty && this.nowLine[3] != PointF.Empty)
  1218. {
  1219. ListViewItem listViewItem = new ListViewItem();
  1220. listViewItem.Name = tag;
  1221. listViewItem.SubItems[0].Text = imgName;
  1222. this.listView2.Items.Add(listViewItem);
  1223. this.listView2.SelectedItems.Clear();
  1224. this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
  1225. DataTable dt = new DataTable(tag);
  1226. dt.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1227. dt.Columns.Add(PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)");
  1228. dt.Columns.Add(PdnResources.GetString("Menu.Actualarea.text")+"(μm)");
  1229. dt.Columns.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  1230. DataRow dataRow = dt.NewRow();
  1231. dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName;
  1232. dataRow[PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)"] = area * 1000000;
  1233. dataRow[PdnResources.GetString("Menu.Actualarea.text")+"(μm)"] = realArea * 1000000;
  1234. dataRow[PdnResources.GetString("Menu.ALAgrainlevel.text")] = this.textBox3.Text;
  1235. dt.Rows.Add(dataRow);
  1236. resultTableList.Add(dt);
  1237. }
  1238. }
  1239. RefreshDataGridView2();
  1240. //保存处理后的图片
  1241. double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  1242. List<Bitmap> tempBit = new List<Bitmap>();
  1243. Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1244. originalBit.Tag = pantographRatio;
  1245. tempBit.Add(originalBit);
  1246. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  1247. Graphics graphics = Graphics.FromImage(newBit);
  1248. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  1249. {
  1250. Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
  1251. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1252. }
  1253. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  1254. {
  1255. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  1256. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  1257. }
  1258. Draw(graphics);
  1259. newBit.Tag = pantographRatio;
  1260. tempBit.Add(newBit);
  1261. if (bitDic.ContainsKey(tag))
  1262. bitDic[tag] = tempBit;
  1263. else
  1264. bitDic.Add(tag, tempBit);
  1265. //拼接中间数据
  1266. List<List<string>> dataList = new List<List<string>>();
  1267. List<string> columnName = new List<string>();
  1268. columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
  1269. columnName.Add(PdnResources.GetString("Menu.Maximumcalipddderdiameter.Text"));
  1270. columnName.Add(PdnResources.GetString("Menu.Verticalcaliperdiameter.Text"));
  1271. columnName.Add(PdnResources.GetString("Menu.Ellipsearea.text"));
  1272. columnName.Add(PdnResources.GetString("Menu.Actualarea.text"));
  1273. columnName.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  1274. dataList.Add(columnName);
  1275. List<string> strList = new List<string>();
  1276. strList.Add("1");
  1277. strList.Add((1000*rulerWidth).ToString());
  1278. strList.Add((1000*rulerheight).ToString());
  1279. strList.Add((area * 1000000).ToString());
  1280. strList.Add((realArea * 1000000).ToString());
  1281. strList.Add(this.textBox3.Text);
  1282. dataList.Add(strList);
  1283. bool isExist = false;//是否已存在进行替换
  1284. int modelIndex = -1;//要替换的下标
  1285. for (int j = 0; j < tempDataModel.Count; j++)
  1286. {
  1287. if (tempDataModel[j].tagName.Equals(tag))
  1288. {
  1289. isExist = true;
  1290. modelIndex = j;
  1291. break;
  1292. }
  1293. }
  1294. if (isExist && modelIndex > -1)
  1295. tempDataModel[modelIndex].dataList = dataList;
  1296. else
  1297. {
  1298. ExportProjectModel newModel = new ExportProjectModel();
  1299. newModel.tagName = tag;
  1300. newModel.picName = imgName;
  1301. newModel.dataList = dataList;
  1302. tempDataModel.Add(newModel);
  1303. }
  1304. }
  1305. else
  1306. {
  1307. MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawthecaliperfirst.text"));
  1308. }
  1309. }
  1310. else
  1311. {
  1312. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
  1313. }
  1314. }
  1315. /// <summary>
  1316. /// 刷新分析结果表
  1317. /// </summary>
  1318. private void RefreshDataGridView2()
  1319. {
  1320. this.dataGridView2.Rows.Clear();
  1321. if (this.showAll)
  1322. {
  1323. if (this.resultTableList.Count > 0)
  1324. {
  1325. foreach (DataTable dt in resultTableList)
  1326. {
  1327. for(int i = 0; i < dt.Rows.Count; i++)
  1328. {
  1329. DataGridViewRow row = new DataGridViewRow();
  1330. row.Height = 30;
  1331. row.Cells.Add(CreateTextBoxCell(dt.Rows[i][0].ToString(), ""));
  1332. row.Cells.Add(CreateTextBoxCell(Math.Round(Convert.ToDecimal(string.IsNullOrEmpty(dt.Rows[i][1].ToString()) ? "0" :
  1333. dt.Rows[i][1].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1334. row.Cells.Add(CreateTextBoxCell(Math.Round(Convert.ToDecimal(string.IsNullOrEmpty(dt.Rows[i][2].ToString()) ? "0" :
  1335. dt.Rows[i][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1336. row.Cells.Add(CreateTextBoxCell(dt.Rows[i][3].ToString(), ""));
  1337. this.dataGridView2.Rows.Add(row);
  1338. }
  1339. }
  1340. }
  1341. }
  1342. else
  1343. {
  1344. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1345. {
  1346. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1347. {
  1348. string tableName = this.listView2.SelectedItems[i].Name;
  1349. foreach (DataTable dt in resultTableList)
  1350. {
  1351. if (dt.TableName.Equals(tableName))
  1352. {
  1353. for (int j = 0; j < dt.Rows.Count; j++)
  1354. {
  1355. DataGridViewRow row = new DataGridViewRow();
  1356. row.Height = 30;
  1357. row.Cells.Add(CreateTextBoxCell(dt.Rows[j][0].ToString(), ""));
  1358. row.Cells.Add(CreateTextBoxCell(Math.Round(Convert.ToDecimal(string.IsNullOrEmpty(dt.Rows[j][1].ToString()) ? "0" :
  1359. dt.Rows[j][1].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1360. row.Cells.Add(CreateTextBoxCell(Math.Round(Convert.ToDecimal(string.IsNullOrEmpty(dt.Rows[j][2].ToString()) ? "0" :
  1361. dt.Rows[j][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", ""));
  1362. row.Cells.Add(CreateTextBoxCell(dt.Rows[j][3].ToString(), ""));
  1363. this.dataGridView2.Rows.Add(row);
  1364. }
  1365. }
  1366. }
  1367. }
  1368. }
  1369. }
  1370. }
  1371. /// <summary>
  1372. /// 全部显示按钮
  1373. /// </summary>
  1374. /// <param name="sender"></param>
  1375. /// <param name="e"></param>
  1376. private void button6_Click(object sender, EventArgs e)
  1377. {
  1378. if(this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
  1379. {
  1380. this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
  1381. this.showAll = true;
  1382. RefreshDataGridView2();
  1383. }
  1384. else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
  1385. {
  1386. this.button6.Text = PdnResources.GetString("Menu.Showall.text");
  1387. this.showAll = false;
  1388. RefreshDataGridView2();
  1389. }
  1390. }
  1391. /// <summary>
  1392. /// 删除按钮
  1393. /// </summary>
  1394. /// <param name="sender"></param>
  1395. /// <param name="e"></param>
  1396. private void button7_Click(object sender, EventArgs e)
  1397. {
  1398. if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1399. {
  1400. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1401. if (dr == DialogResult.OK)
  1402. {
  1403. for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
  1404. {
  1405. string tableName = this.listView2.SelectedItems[i].Name;
  1406. foreach (DataTable dt in resultTableList)
  1407. {
  1408. if (dt.TableName.Equals(tableName))
  1409. {
  1410. resultTableList.Remove(dt);
  1411. break;
  1412. }
  1413. }
  1414. if (bitDic.ContainsKey(tableName))
  1415. bitDic.Remove(tableName);
  1416. foreach (ExportProjectModel model in this.tempDataModel)
  1417. {
  1418. if (model.tagName.Equals(tableName))
  1419. {
  1420. this.tempDataModel.Remove(model);
  1421. break;
  1422. }
  1423. }
  1424. }
  1425. foreach (ListViewItem item in this.listView2.Items)
  1426. {
  1427. if (item.Selected)
  1428. this.listView2.Items.Remove(item);
  1429. }
  1430. RefreshDataGridView2();
  1431. }
  1432. }
  1433. }
  1434. /// <summary>
  1435. /// 生成报告按钮
  1436. /// </summary>
  1437. /// <param name="sender"></param>
  1438. /// <param name="e"></param>
  1439. private void button8_Click(object sender, EventArgs e)
  1440. {
  1441. if (this.checkBox1.Checked)
  1442. this.button1.PerformClick();
  1443. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  1444. {
  1445. //获取word书签与excel单元格的关系,以字典方式存储
  1446. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  1447. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  1448. if (mic_module_infos != null && mic_module_infos.Count > 0)
  1449. {
  1450. foreach (mic_module_infos info in mic_module_infos)
  1451. {
  1452. tagInfos.Add(info.tag_name, info.cell_position);
  1453. }
  1454. }
  1455. //分析结果
  1456. List<List<string>> analysisContent = new List<List<string>>();
  1457. List<string> contentHead = new List<string>();
  1458. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  1459. contentHead.Add(PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)");
  1460. contentHead.Add(PdnResources.GetString("Menu.Actualarea.text")+"(μm)");
  1461. contentHead.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  1462. analysisContent.Add(contentHead);
  1463. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  1464. {
  1465. List<string> content = new List<string>();
  1466. content.Add(item.Cells[0].Value.ToString());
  1467. content.Add(item.Cells[1].Value.ToString());
  1468. content.Add(item.Cells[2].Value.ToString());
  1469. content.Add(item.Cells[3].Value.ToString());
  1470. analysisContent.Add(content);
  1471. }
  1472. //图片
  1473. bitList = new List<Bitmap>();
  1474. if (this.showAll)
  1475. {
  1476. foreach(KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  1477. {
  1478. bitList.Add(kv.Value[0]);
  1479. bitList.Add(kv.Value[1]);
  1480. }
  1481. }
  1482. else
  1483. {
  1484. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  1485. {
  1486. foreach (ListViewItem item in this.listView2.SelectedItems)
  1487. {
  1488. if (bitDic.ContainsKey(item.Name))
  1489. {
  1490. bitList.Add(bitDic[item.Name][0]);
  1491. bitList.Add(bitDic[item.Name][1]);
  1492. }
  1493. }
  1494. }
  1495. }
  1496. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
  1497. }
  1498. else
  1499. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  1500. }
  1501. /// <summary>
  1502. /// 导出结果按钮
  1503. /// </summary>
  1504. /// <param name="sender"></param>
  1505. /// <param name="e"></param>
  1506. private void button9_Click(object sender, EventArgs e)
  1507. {
  1508. if (this.listView2.Items.Count > 0)
  1509. {
  1510. SaveFileDialog exe = new SaveFileDialog();
  1511. exe.Filter = "Execl files (*.xlsx)|*.xlsx";
  1512. exe.FilterIndex = 0;
  1513. exe.RestoreDirectory = true;
  1514. //exe.CreatePrompt = true;
  1515. exe.Title = "Export Excel File";
  1516. exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  1517. exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text")+ PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Measurementmethod.text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
  1518. DialogResult dr = exe.ShowDialog();
  1519. if (dr != DialogResult.OK)
  1520. return;
  1521. DataTable dtb = new DataTable();
  1522. dtb.Columns.Add(PdnResources.GetString("Menu.picture.Text"));
  1523. dtb.Columns.Add(PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)");
  1524. dtb.Columns.Add(PdnResources.GetString("Menu.Actualarea.text")+"(μm)");
  1525. dtb.Columns.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  1526. for(int i = 0; i < this.dataGridView2.Rows.Count; i++)
  1527. {
  1528. DataRow dataRow = dtb.NewRow();
  1529. dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView2.Rows[i].Cells[0].Value;
  1530. dataRow[PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)"] = this.dataGridView2.Rows[i].Cells[1].Value;
  1531. dataRow[PdnResources.GetString("Menu.Actualarea.text")+"(μm)"] = this.dataGridView2.Rows[i].Cells[2].Value;
  1532. dataRow[PdnResources.GetString("Menu.ALAgrainlevel.text")] = this.dataGridView2.Rows[i].Cells[3].Value;
  1533. dtb.Rows.Add(dataRow);
  1534. }
  1535. List<DataTable> list = new List<DataTable>();
  1536. list.Add(dtb);
  1537. this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
  1538. }
  1539. else
  1540. MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
  1541. }
  1542. /// <summary>
  1543. /// 图像索引切换选中事件
  1544. /// </summary>
  1545. /// <param name="sender"></param>
  1546. /// <param name="e"></param>
  1547. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  1548. {
  1549. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1550. {
  1551. existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
  1552. this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  1553. if (!existViewFlag)
  1554. mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
  1555. else
  1556. mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFullSizeWithRegion());
  1557. nowLine = new PointF[4];
  1558. rectangleFBorder = new RectangleF();
  1559. //二值化集成4
  1560. binaryClass.listView1_SelectedIndexChanged(this.bitmap, this.getCurrentWorkTag()/*.listView1.SelectedItems.Count == 0 ? null : this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index]*/);
  1561. if (binaryClass.getModelMat(getCurrentWorkTag()) != null)
  1562. this.documentWorkspace.PhaseModels[0].mat = binaryClass.getModelMat(getCurrentWorkTag()).Clone();
  1563. if (this.selectPicture >= 0)
  1564. {
  1565. this.saveDialogParamValues(this.imageList1.Images.Keys[this.selectPicture].ToString());
  1566. if (!this.analysisDict.ContainsKey(getCurrentWorkTag()))
  1567. this.analysisDict.Add(getCurrentWorkTag(), this.analysisDict[this.imageList1.Images.Keys[this.selectPicture]].cloneListParamModel(this.menuId));
  1568. }
  1569. this.showSaveParamToControl();
  1570. //if (this.checkBox1.Checked)
  1571. //{
  1572. // //this.documentWorkspace.PhaseModels[1].choise = true;//###
  1573. // this.applyDect();
  1574. //}
  1575. string toSelectImageKey = getCurrentWorkTag();
  1576. ////选择了应用晶界重现但是没有计算结果,则进行晶界重现的计算
  1577. //if (this.grainBoundaryDict.ContainsKey(toSelectImageKey) && this.grainBoundaryDict[toSelectImageKey].grainApplygrainboundaries == 1
  1578. // && !this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
  1579. //{
  1580. // procClass = new ProgressThreadProcClass();
  1581. // procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
  1582. //}
  1583. if (this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
  1584. {
  1585. this.documentWorkspace.PhaseModels[1].mat = this.grainBoundaryMatDict[toSelectImageKey].Clone();
  1586. this.documentWorkspace.PhaseModels[1].choise = !bcOriginChecked();
  1587. }
  1588. else
  1589. this.documentWorkspace.PhaseModels[1].mat = null;
  1590. this.commonControlButtons.Visible = true;
  1591. this.selectPicture = this.listView1.FocusedItem.Index;
  1592. ResetAllText();
  1593. this.button3.Text = PdnResources.GetString("Menu.measuring.text");
  1594. }
  1595. }
  1596. private string getCurrentWorkTag()
  1597. {
  1598. if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
  1599. return this.imageList1.Images.Keys[this.listView1.FocusedItem/*SelectedItems[0]*/.Index];
  1600. return null;
  1601. }
  1602. /// <summary>
  1603. /// 颜色panel被点击
  1604. /// </summary>
  1605. /// <param name="sender"></param>
  1606. /// <param name="e"></param>
  1607. private void panel1_Click(object sender, EventArgs e)
  1608. {
  1609. this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
  1610. this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed));
  1611. this.colorsForm1.ShowDialog();
  1612. }
  1613. private void colorsForm1Changed(object sender, EventArgs e)
  1614. {
  1615. this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor();
  1616. this.colorsForm1.Close();
  1617. this.documentWorkspace.Refresh();
  1618. }
  1619. /// <summary>
  1620. /// 小数数字框值改变
  1621. /// </summary>
  1622. /// <param name="sender"></param>
  1623. /// <param name="e"></param>
  1624. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  1625. {
  1626. if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
  1627. this.numericUpDown1.Value = this.numericUpDown1.Maximum;
  1628. if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
  1629. this.numericUpDown1.Value = this.numericUpDown1.Minimum;
  1630. CalcArea();
  1631. RefreshDataGridView2();
  1632. }
  1633. /// <summary>
  1634. /// 测量按钮被点击
  1635. /// </summary>
  1636. /// <param name="sender"></param>
  1637. /// <param name="e"></param>
  1638. private void button3_Click(object sender, EventArgs e)
  1639. {
  1640. if (this.button3.Text == PdnResources.GetString("Menu.measuring.text"))
  1641. canDraw = true;
  1642. else if (this.button3.Text == PdnResources.GetString("Menu.Edit.Delete.Text"))
  1643. {
  1644. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousucalipers.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1645. if (dr == DialogResult.OK)
  1646. {
  1647. this.nowLine = new PointF[4];
  1648. this.button3.Text = PdnResources.GetString("Menu.measuring.text");
  1649. ResetAllText();
  1650. this.documentWorkspace.Refresh();
  1651. }
  1652. }
  1653. }
  1654. /// <summary>
  1655. /// 鼠标按下
  1656. /// </summary>
  1657. /// <param name="sender"></param>
  1658. /// <param name="e"></param>
  1659. private void BoxMouseDownHandler(object sender, MouseEventArgs e)
  1660. {
  1661. if (e.Button == MouseButtons.Left)
  1662. {
  1663. PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
  1664. if (canDraw)
  1665. {
  1666. clickCount++;
  1667. if (clickCount == 1)
  1668. {
  1669. startPoint = endPoint = downPoint;
  1670. nowLine[0] = startPoint;
  1671. nowLine[1] = endPoint;
  1672. }
  1673. else if (clickCount == 2)
  1674. {
  1675. if (this.startPoint == this.endPoint)
  1676. {
  1677. canDraw = false;
  1678. clickCount = 0;
  1679. this.nowLine = new PointF[4];
  1680. }
  1681. }
  1682. else if (clickCount == 3)
  1683. {
  1684. nowLine[2] = downPoint;
  1685. tempPoint.X = downPoint.X;
  1686. tempPoint.Y = downPoint.Y;
  1687. }
  1688. else if (clickCount == 4)
  1689. {
  1690. if (this.nowLine[3] == PointF.Empty)
  1691. {
  1692. canDraw = false;
  1693. clickCount = 0;
  1694. this.nowLine = new PointF[4];
  1695. this.documentWorkspace.Refresh();
  1696. MessageBox.Show(PdnResources.GetString("Menu.Thetwopointsoftaintodraw.text"));
  1697. return;
  1698. }
  1699. CalcOtherRectangle();
  1700. CalcDiameter();
  1701. canDraw = false;
  1702. clickCount = 0;
  1703. if (this.nowLine[3] != PointF.Empty)
  1704. {
  1705. this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  1706. selected = true;
  1707. }
  1708. }
  1709. }
  1710. else
  1711. {
  1712. lastPoint.X = downPoint.X;
  1713. lastPoint.Y = downPoint.Y;
  1714. if (rectangleFBorder.Contains(downPoint))
  1715. {
  1716. selected = true;
  1717. canMove = true;
  1718. }
  1719. if (selected)
  1720. {
  1721. if (new RectangleF(this.nowLine[0].X - 3, this.nowLine[0].Y - 3, 7, 7).Contains(downPoint))
  1722. movePointIndex = 0;
  1723. else if (new RectangleF(this.nowLine[1].X - 3, this.nowLine[1].Y - 3, 7, 7).Contains(downPoint))
  1724. movePointIndex = 1;
  1725. else if (new RectangleF(this.nowLine[2].X - 3, this.nowLine[2].Y - 3, 7, 7).Contains(downPoint))
  1726. movePointIndex = 2;
  1727. else if (new RectangleF(this.nowLine[3].X - 3, this.nowLine[3].Y - 3, 7, 7).Contains(downPoint))
  1728. movePointIndex = 3;
  1729. else
  1730. movePointIndex = -1;
  1731. }
  1732. if (canMove)
  1733. return;
  1734. selected = false;
  1735. }
  1736. }
  1737. }
  1738. /// <summary>
  1739. /// 鼠标移动
  1740. /// </summary>
  1741. /// <param name="sender"></param>
  1742. /// <param name="e"></param>
  1743. private void BoxMouseMoveHandler(object sender, MouseEventArgs e)
  1744. {
  1745. this.documentWorkspace.panel.Cursor = Cursors.Default;
  1746. if(canDraw)
  1747. {
  1748. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  1749. if (clickCount == 1)
  1750. {
  1751. this.endPoint = movePoint;
  1752. this.nowLine[1] = this.endPoint;
  1753. }
  1754. else if (clickCount == 3 && this.nowLine[2] != PointF.Empty)
  1755. {
  1756. //第二条线是水平线
  1757. if(this.nowLine[0].X == this.nowLine[1].X)
  1758. {
  1759. this.nowLine[3].Y = this.nowLine[2].Y;
  1760. this.nowLine[3].X = movePoint.X;
  1761. }
  1762. //第二条线是垂线
  1763. else if (this.nowLine[0].Y == this.nowLine[1].Y)
  1764. {
  1765. this.nowLine[3].X = this.nowLine[2].X;
  1766. this.nowLine[3].Y = movePoint.Y;
  1767. }
  1768. //其他情况
  1769. else
  1770. {
  1771. float k = -1 / ((this.nowLine[1].Y - this.nowLine[0].Y) / (this.nowLine[1].X - this.nowLine[0].X));
  1772. float b = this.nowLine[2].Y - k * this.nowLine[2].X;
  1773. float dxTemp = movePoint.X - tempPoint.X;
  1774. float dyTemp = movePoint.Y - tempPoint.Y;
  1775. if (Math.Abs(dxTemp) >= Math.Abs(dyTemp))
  1776. {
  1777. this.nowLine[3].X = movePoint.X;
  1778. this.nowLine[3].Y = k * this.nowLine[3].X + b;
  1779. }
  1780. else
  1781. {
  1782. this.nowLine[3].Y = movePoint.Y;
  1783. this.nowLine[3].X = (this.nowLine[3].Y - b) / k;
  1784. }
  1785. }
  1786. }
  1787. this.documentWorkspace.Refresh();
  1788. }
  1789. else
  1790. {
  1791. if(selected && e.Button == MouseButtons.Left && canMove)
  1792. {
  1793. PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
  1794. float dx = movePoint.X - lastPoint.X;
  1795. float dy = movePoint.Y - lastPoint.Y;
  1796. lastPoint.X = movePoint.X;
  1797. lastPoint.Y = movePoint.Y;
  1798. if(movePointIndex == -1)
  1799. {
  1800. if (rectangleFBorder.Contains(movePoint))
  1801. this.documentWorkspace.panel.Cursor = Cursors.SizeAll;
  1802. rectangleFBorder.X += dx;
  1803. rectangleFBorder.Y += dy;
  1804. for (int i = 0; i < this.nowLine.Count(); i++)
  1805. {
  1806. this.nowLine[i].X += dx;
  1807. this.nowLine[i].Y += dy;
  1808. }
  1809. }
  1810. else if (movePointIndex == 0)
  1811. {
  1812. PointF oldPoint = new PointF(nowLine[0].X, nowLine[0].Y);
  1813. this.nowLine[0].X += dx;
  1814. this.nowLine[0].Y += dy;
  1815. double angle = BasicCalculationHelper.CalculateAngle(nowLine[1].X, nowLine[1].Y, oldPoint.X, oldPoint.Y ,nowLine[0].X, nowLine[0].Y);
  1816. this.nowLine[3] = BasicCalculationHelper.GetAnglePoint(this.nowLine[3], this.nowLine[2], angle);
  1817. CalcDiameter();
  1818. }
  1819. else if (movePointIndex == 1)
  1820. {
  1821. PointF oldPoint = new PointF(nowLine[1].X, nowLine[1].Y);
  1822. this.nowLine[1].X += dx;
  1823. this.nowLine[1].Y += dy;
  1824. double angle = BasicCalculationHelper.CalculateAngle(nowLine[0].X, nowLine[0].Y, oldPoint.X, oldPoint.Y, nowLine[1].X, nowLine[1].Y);
  1825. this.nowLine[3] = BasicCalculationHelper.GetAnglePoint(this.nowLine[3], this.nowLine[2], angle);
  1826. CalcDiameter();
  1827. }
  1828. else if (movePointIndex == 2)
  1829. {
  1830. PointF oldPoint = new PointF(nowLine[2].X, nowLine[2].Y);
  1831. this.nowLine[2].X += dx;
  1832. this.nowLine[2].Y += dy;
  1833. double angle = BasicCalculationHelper.CalculateAngle(nowLine[3].X, nowLine[3].Y, oldPoint.X, oldPoint.Y, nowLine[2].X, nowLine[2].Y);
  1834. this.nowLine[1] = BasicCalculationHelper.GetAnglePoint(this.nowLine[1], this.nowLine[0], angle);
  1835. CalcDiameter();
  1836. }
  1837. else if (movePointIndex == 3)
  1838. {
  1839. PointF oldPoint = new PointF(nowLine[3].X, nowLine[3].Y);
  1840. this.nowLine[3].X += dx;
  1841. this.nowLine[3].Y += dy;
  1842. double angle = BasicCalculationHelper.CalculateAngle(nowLine[2].X, nowLine[2].Y, oldPoint.X, oldPoint.Y, nowLine[3].X, nowLine[3].Y);
  1843. this.nowLine[1] = BasicCalculationHelper.GetAnglePoint(this.nowLine[1], this.nowLine[0], angle);
  1844. CalcDiameter();
  1845. }
  1846. CalcOtherRectangle();
  1847. this.documentWorkspace.Refresh();
  1848. }
  1849. }
  1850. }
  1851. /// <summary>
  1852. /// 鼠标抬起
  1853. /// </summary>
  1854. /// <param name="sender"></param>
  1855. /// <param name="e"></param>
  1856. private void BoxMouseUpHandler(object sender, MouseEventArgs e)
  1857. {
  1858. if (e.Button == MouseButtons.Left && canMove)
  1859. {
  1860. canMove = false;
  1861. movePointIndex = -1;
  1862. }
  1863. }
  1864. /// <summary>
  1865. /// 绘制事件
  1866. /// </summary>
  1867. /// <param name="sender"></param>
  1868. /// <param name="e"></param>
  1869. private void BoxPaintHandler(object sender, PaintEventArgs e)
  1870. {
  1871. if (this.documentWorkspace.CompositionSurface != null)
  1872. {
  1873. Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  1874. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  1875. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  1876. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  1877. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  1878. e.Graphics.TranslateTransform(x, y);
  1879. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  1880. Draw(e.Graphics);
  1881. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  1882. e.Graphics.TranslateTransform(-x, -y);
  1883. }
  1884. }
  1885. /// <summary>
  1886. /// 绘制
  1887. /// </summary>
  1888. private void Draw(Graphics graphics)
  1889. {
  1890. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  1891. Pen measurePen = new Pen(this.panel1.BackColor, Convert.ToInt32(this.numericUpDown2.Value));//基准线画笔
  1892. Pen borderPen = new Pen(Color.Black);//填充点外圈
  1893. SolidBrush insideBrush = new SolidBrush(Color.White);//填充点内圈
  1894. Pen rectPen = new Pen(Color.Black);
  1895. rectPen.DashStyle = DashStyle.Custom;
  1896. float[] dashArray = { 2.0f, 3.0f };
  1897. rectPen.DashPattern = dashArray;
  1898. if (this.nowLine[0] != this.nowLine[1])
  1899. {
  1900. graphics.DrawLine(measurePen, nowLine[0], nowLine[1]);
  1901. if (this.nowLine[2] != PointF.Empty && this.nowLine[3] != PointF.Empty)
  1902. {
  1903. graphics.DrawLine(measurePen, nowLine[2], nowLine[3]);
  1904. }
  1905. }
  1906. if (selected && !canDraw)
  1907. {
  1908. if(this.nowLine[0] != PointF.Empty)
  1909. {
  1910. graphics.DrawRectangle(borderPen, new Rectangle((int)(this.nowLine[0].X - 3), (int)(this.nowLine[0].Y - 3), 7, 7));
  1911. graphics.FillRectangle(insideBrush, new RectangleF(this.nowLine[0].X - 3, this.nowLine[0].Y - 3, 7, 7));
  1912. }
  1913. if (this.nowLine[1] != PointF.Empty)
  1914. {
  1915. graphics.DrawRectangle(borderPen, new Rectangle((int)(this.nowLine[1].X - 3), (int)(this.nowLine[1].Y - 3), 7, 7));
  1916. graphics.FillRectangle(insideBrush, new RectangleF(this.nowLine[1].X - 3, this.nowLine[1].Y - 3, 7, 7));
  1917. }
  1918. if (this.nowLine[2] != PointF.Empty)
  1919. {
  1920. graphics.DrawRectangle(borderPen, new Rectangle((int)(this.nowLine[2].X - 3), (int)(this.nowLine[2].Y - 3), 7, 7));
  1921. graphics.FillRectangle(insideBrush, new RectangleF(this.nowLine[2].X - 3, this.nowLine[2].Y - 3, 7, 7));
  1922. }
  1923. if (this.nowLine[3] != PointF.Empty)
  1924. {
  1925. graphics.DrawRectangle(borderPen, new Rectangle((int)(this.nowLine[3].X - 3), (int)(this.nowLine[3].Y - 3), 7, 7));
  1926. graphics.FillRectangle(insideBrush, new RectangleF(this.nowLine[3].X - 3, this.nowLine[3].Y - 3, 7, 7));
  1927. }
  1928. graphics.DrawRectangle(rectPen, rectangleFBorder.X, rectangleFBorder.Y, rectangleFBorder.Width, rectangleFBorder.Height);
  1929. }
  1930. measurePen.Dispose();
  1931. borderPen.Dispose();
  1932. insideBrush.Dispose();
  1933. rectPen.Dispose();
  1934. }
  1935. /// <summary>
  1936. /// 分析结果列表选择切换
  1937. /// </summary>
  1938. /// <param name="sender"></param>
  1939. /// <param name="e"></param>
  1940. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  1941. {
  1942. if (this.showAll)
  1943. return;
  1944. RefreshDataGridView2();
  1945. }
  1946. /// <summary>
  1947. /// 修改线宽
  1948. /// </summary>
  1949. /// <param name="sender"></param>
  1950. /// <param name="e"></param>
  1951. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  1952. {
  1953. this.documentWorkspace.Refresh();
  1954. }
  1955. /// <summary>
  1956. /// 计算外接矩形
  1957. /// </summary>
  1958. private void CalcOtherRectangle()
  1959. {
  1960. RectangleF rectangleF = new RectangleF();
  1961. float[] pointX = new float[] { this.nowLine[0].X, this.nowLine[1].X, this.nowLine[2].X, this.nowLine[3].X };
  1962. rectangleF.X = (int)pointX.Min();
  1963. float[] pointY = new float[] { this.nowLine[0].Y, this.nowLine[1].Y, this.nowLine[2].Y, this.nowLine[3].Y };
  1964. rectangleF.Y = (int)pointY.Min();
  1965. rectangleF.Width = (int)Math.Abs(pointX.Max() - pointX.Min());
  1966. rectangleF.Height = (int)Math.Abs(pointY.Max() - pointY.Min());
  1967. rectangleFBorder = new RectangleF(rectangleF.X - 3, rectangleF.Y - 3, rectangleF.Width + 7, rectangleF.Height + 7);
  1968. }
  1969. /// <summary>
  1970. /// 计算面积及其他数值
  1971. /// </summary>
  1972. private void CalcArea()
  1973. {
  1974. if(this.numericUpDown3.Value != 0 && this.numericUpDown4.Value != 0)
  1975. {
  1976. double unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Millimeter);
  1977. double widthLine = BasicCalculationHelper.GetDistance(this.nowLine[0], this.nowLine[1], 10) * unitLength;
  1978. double heightLine = BasicCalculationHelper.GetDistance(this.nowLine[2], this.nowLine[3], 10) * unitLength;
  1979. decimal area = 0.785m * (decimal)widthLine * (decimal)heightLine;
  1980. decimal realArea = (area / (this.gainNumber * this.gainNumber));// * (area / this.gainNumber);
  1981. //椭圆面积
  1982. this.textBox1.Text = Math.Round(area * 1000000, Convert.ToInt32(this.numericUpDown1.Value)) + "";
  1983. //实际面积
  1984. this.textBox2.Text = Math.Round(realArea * 1000000, Convert.ToInt32(this.numericUpDown1.Value)) + "";
  1985. //ALA晶粒级别
  1986. string level = "";
  1987. realArea = realArea;
  1988. if (realArea <= levelArr[0])
  1989. level = "7.0";
  1990. else if (realArea > levelArr[0] && realArea <= levelArr[1])
  1991. level = "6.5";
  1992. else if (realArea > levelArr[1] && realArea <= levelArr[2])
  1993. level = "6.0";
  1994. else if (realArea > levelArr[2] && realArea <= levelArr[3])
  1995. level = "5.5";
  1996. else if (realArea > levelArr[3] && realArea <= levelArr[4])
  1997. level = "5.0";
  1998. else if (realArea > levelArr[4] && realArea <= levelArr[5])
  1999. level = "4.5";
  2000. else if (realArea > levelArr[5] && realArea <= levelArr[6])
  2001. level = "4.0";
  2002. else if (realArea > levelArr[6] && realArea <= levelArr[7])
  2003. level = "3.5";
  2004. else if (realArea > levelArr[7] && realArea <= levelArr[8])
  2005. level = "3.0";
  2006. else if (realArea > levelArr[8] && realArea <= levelArr[9])
  2007. level = "2.5";
  2008. else if (realArea > levelArr[9] && realArea <= levelArr[10])
  2009. level = "2.0";
  2010. else if (realArea > levelArr[10] && realArea <= levelArr[11])
  2011. level = "1.5";
  2012. else if (realArea > levelArr[11] && realArea <= levelArr[12])
  2013. level = "1.0";
  2014. else if (realArea > levelArr[12] && realArea <= levelArr[13])
  2015. level = "0.5";
  2016. else if (realArea > levelArr[13] && realArea <= levelArr[14])
  2017. level = "0";
  2018. else if (realArea > levelArr[14] && realArea <= levelArr[15])
  2019. level = "-0.5";
  2020. else if (realArea > levelArr[15] && realArea <= levelArr[16])
  2021. level = "00"+ PdnResources.GetString("Menu.or.Text")+ "-1.0";
  2022. else if (realArea > levelArr[16] && realArea <= levelArr[17])
  2023. level = "-1.5";
  2024. else if (realArea > levelArr[17] && realArea <= levelArr[18])
  2025. level = "000"+ PdnResources.GetString("Menu.or.Text")+ "-2.0";
  2026. else if (realArea > levelArr[18] && realArea <= levelArr[19])
  2027. level = "-2.5";
  2028. else if (realArea > levelArr[19] && realArea <= levelArr[20])
  2029. level = "0000"+ PdnResources.GetString("Menu.or.Text")+ "-3.0";
  2030. else if (realArea > levelArr[20] && realArea <= levelArr[21])
  2031. level = "-3.5";
  2032. else if (realArea > levelArr[21] && realArea <= levelArr[22])
  2033. level = "00000"+ PdnResources.GetString("Menu.or.Text")+ "-4.0";
  2034. else
  2035. level = PdnResources.GetString("Menu.Theunknown.Text");
  2036. this.textBox3.Text = level;
  2037. }
  2038. }
  2039. /// <summary>
  2040. /// 重置所有文本状态
  2041. /// </summary>
  2042. private void ResetAllText()
  2043. {
  2044. selected = false;
  2045. this.numericUpDown3.ValueChanged -= numericUpDown3_ValueChanged;
  2046. this.numericUpDown4.ValueChanged -= numericUpDown4_ValueChanged;
  2047. this.numericUpDown3.ReadOnly = true;
  2048. this.numericUpDown3.Value = 0;
  2049. this.numericUpDown4.ReadOnly = true;
  2050. this.numericUpDown4.Value = 0;
  2051. this.numericUpDown3.ValueChanged += new EventHandler(numericUpDown3_ValueChanged);
  2052. this.numericUpDown4.ValueChanged += new EventHandler(numericUpDown4_ValueChanged);
  2053. this.textBox1.Text = "";
  2054. this.textBox2.Text = "";
  2055. this.textBox3.Text = "";
  2056. }
  2057. /// <summary>
  2058. /// 修改最大卡尺直径
  2059. /// </summary>
  2060. /// <param name="sender"></param>
  2061. /// <param name="e"></param>
  2062. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  2063. {
  2064. if(this.numericUpDown3.Value > 0 && this.numericUpDown4.Value > 0 && this.nowLine != null && this.nowLine[0] != PointF.Empty && this.nowLine[1] != PointF.Empty)
  2065. {
  2066. PointF newPointF = GetRotationPoint(this.nowLine[0], this.nowLine[1], this.numericUpDown3.Value);
  2067. if(newPointF != PointF.Empty)
  2068. {
  2069. this.nowLine[1] = newPointF;
  2070. CalcOtherRectangle();
  2071. CalcArea();
  2072. this.documentWorkspace.Refresh();
  2073. }
  2074. else
  2075. {
  2076. MessageBox.Show(PdnResources.GetString("Menu.Thevalueistoolarecalculated.text"));
  2077. }
  2078. }
  2079. }
  2080. /// <summary>
  2081. /// 修改垂直卡尺直径
  2082. /// </summary>
  2083. /// <param name="sender"></param>
  2084. /// <param name="e"></param>
  2085. private void numericUpDown4_ValueChanged(object sender, EventArgs e)
  2086. {
  2087. if (this.numericUpDown3.Value > 0 && this.numericUpDown4.Value > 0 && this.nowLine != null && this.nowLine[2] != PointF.Empty && this.nowLine[3] != PointF.Empty)
  2088. {
  2089. PointF newPointF = GetRotationPoint(this.nowLine[2], this.nowLine[3], this.numericUpDown4.Value);
  2090. if (newPointF != PointF.Empty)
  2091. {
  2092. this.nowLine[3] = newPointF;
  2093. CalcOtherRectangle();
  2094. CalcArea();
  2095. this.documentWorkspace.Refresh();
  2096. }
  2097. else
  2098. {
  2099. MessageBox.Show(PdnResources.GetString("Menu.Thevalueistoolargetocalculate.text"));
  2100. }
  2101. }
  2102. }
  2103. /// <summary>
  2104. /// 重新计算改变长度后的点
  2105. /// </summary>
  2106. /// <param name="cen"></param>
  2107. /// <param name="rotation"></param>
  2108. /// <param name="newLineLength"></param>
  2109. /// <returns></returns>
  2110. private PointF GetRotationPoint(PointF cen, PointF rotation, decimal newLength)
  2111. {
  2112. decimal maxValue = Convert.ToDecimal(Math.Sqrt(int.MaxValue));
  2113. decimal minValue = Convert.ToDecimal(Math.Sqrt(4.9E-324));
  2114. double lineLength = BasicCalculationHelper.GetDistance(cen, rotation, 10);
  2115. double unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Millimeter);
  2116. decimal newLineLength = newLength / (decimal)(unitLength * 1000);
  2117. if (newLineLength >= maxValue)
  2118. return PointF.Empty;
  2119. if (newLineLength <= minValue)
  2120. return PointF.Empty;
  2121. PointF rotationPoint = new PointF(cen.X + (float)newLineLength, cen.Y);
  2122. double angle = BasicCalculationHelper.Angle(cen, new PointF(cen.X + (float)lineLength, cen.Y), rotation);
  2123. if (rotation.Y < cen.Y)
  2124. {
  2125. angle = 360 - angle;
  2126. }
  2127. Matrix matrix = new Matrix();
  2128. matrix.RotateAt((float)angle, cen);
  2129. PointF[] ff = new PointF[1];
  2130. ff[0] = rotationPoint;
  2131. matrix.TransformPoints(ff);
  2132. matrix.Dispose();
  2133. matrix = null;
  2134. return ff[0];
  2135. }
  2136. /// <summary>
  2137. /// 计算直径
  2138. /// </summary>
  2139. private void CalcDiameter()
  2140. {
  2141. this.numericUpDown3.ValueChanged -= numericUpDown3_ValueChanged;
  2142. this.numericUpDown4.ValueChanged -= numericUpDown4_ValueChanged;
  2143. double unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Millimeter);
  2144. this.numericUpDown3.ReadOnly = false;
  2145. this.numericUpDown3.Value = decimal.Parse(Math.Round((BasicCalculationHelper.GetDistance(this.nowLine[0], this.nowLine[1], 10) * 1000 * unitLength), 5).ToString());
  2146. this.numericUpDown4.ReadOnly = false;
  2147. this.numericUpDown4.Value = decimal.Parse(Math.Round((BasicCalculationHelper.GetDistance(this.nowLine[2], this.nowLine[3], 10) * 1000 * unitLength), 5).ToString());
  2148. this.numericUpDown3.ValueChanged += new EventHandler(numericUpDown3_ValueChanged);
  2149. this.numericUpDown4.ValueChanged += new EventHandler(numericUpDown4_ValueChanged);
  2150. CalcArea();
  2151. }
  2152. /// <summary>
  2153. /// 导出项目
  2154. /// </summary>
  2155. /// <param name="sender"></param>
  2156. /// <param name="e"></param>
  2157. private void button10_Click(object sender, EventArgs e)
  2158. {
  2159. if (this.checkBox1.Checked)
  2160. this.button1.PerformClick();
  2161. if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
  2162. {
  2163. Instrument.ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text", this.analyzeSettingModel.savePath);
  2164. if (nodeItem == null) return;
  2165. //获取word书签与excel单元格的关系,以字典方式存储
  2166. List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
  2167. Dictionary<string, string> tagInfos = new Dictionary<string, string>();
  2168. if (mic_module_infos != null && mic_module_infos.Count > 0)
  2169. {
  2170. foreach (mic_module_infos info in mic_module_infos)
  2171. {
  2172. tagInfos.Add(info.tag_name, info.cell_position);
  2173. }
  2174. }
  2175. //分析结果
  2176. List<List<string>> analysisContent = new List<List<string>>();
  2177. List<string> contentHead = new List<string>();
  2178. contentHead.Add(PdnResources.GetString("Menu.picture.Text"));
  2179. contentHead.Add(PdnResources.GetString("Menu.Ellipsearea.text")+"(μm)");
  2180. contentHead.Add(PdnResources.GetString("Menu.Actualarea.text")+"(μm)");
  2181. contentHead.Add(PdnResources.GetString("Menu.ALAgrainlevel.text"));
  2182. analysisContent.Add(contentHead);
  2183. foreach (DataGridViewRow item in this.dataGridView2.Rows)
  2184. {
  2185. List<string> content = new List<string>();
  2186. content.Add(item.Cells[0].Value.ToString());
  2187. content.Add(item.Cells[1].Value.ToString());
  2188. content.Add(item.Cells[2].Value.ToString());
  2189. content.Add(item.Cells[3].Value.ToString());
  2190. analysisContent.Add(content);
  2191. }
  2192. //图片
  2193. bitList = new List<Bitmap>();
  2194. if (this.showAll)
  2195. {
  2196. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
  2197. {
  2198. bitList.Add(kv.Value[0]);
  2199. bitList.Add(kv.Value[1]);
  2200. }
  2201. }
  2202. else
  2203. {
  2204. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2205. {
  2206. foreach (ListViewItem item in this.listView2.SelectedItems)
  2207. {
  2208. if (bitDic.ContainsKey(item.Name))
  2209. {
  2210. bitList.Add(bitDic[item.Name][0]);
  2211. bitList.Add(bitDic[item.Name][1]);
  2212. }
  2213. }
  2214. }
  2215. }
  2216. //中间数据
  2217. if (!this.showAll)
  2218. {
  2219. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
  2220. {
  2221. List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
  2222. foreach (ListViewItem rowItem in this.listView2.SelectedItems)
  2223. {
  2224. foreach (ExportProjectModel model in this.tempDataModel)
  2225. {
  2226. if (model.tagName.Equals(rowItem.Name))
  2227. {
  2228. ExportProjectModel tempModel = new ExportProjectModel();
  2229. tempModel.tagName = model.tagName;
  2230. tempModel.picName = model.picName;
  2231. tempModel.dataList = model.dataList;
  2232. exportModel.Add(tempModel);
  2233. break;
  2234. }
  2235. }
  2236. }
  2237. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
  2238. }
  2239. }
  2240. else
  2241. this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, nodeItem.path, nodeItem.code);
  2242. //保存项目信息到数据库
  2243. this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
  2244. }
  2245. else
  2246. MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
  2247. }
  2248. //二值化集成3
  2249. #region 二值化相关方法
  2250. private void GrainSizeDialog_FormClosing(object sender, FormClosingEventArgs e)
  2251. {
  2252. if (getCurrentWorkTag() == null)
  2253. {
  2254. return;
  2255. }
  2256. #region [开启脚本录制]
  2257. if (appWorkspace.startScriptRecording)
  2258. {
  2259. getScriptRecording();
  2260. }
  2261. #endregion
  2262. binaryClass.saveParams();
  2263. this.saveDialogParamValues(getCurrentWorkTag());
  2264. GrainSizeAnalysisModel analysisModel = this.analysisDict[getCurrentWorkTag()];
  2265. //xml保存路径
  2266. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  2267. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  2268. foreach (var analysisItem in analysisModel.ListParam)
  2269. {
  2270. bool foundItem = false;
  2271. foreach (var item in analysisModelXml.ListParam)
  2272. {
  2273. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  2274. {
  2275. item.param_value = analysisItem.param_value;
  2276. foundItem = true;
  2277. break;
  2278. }
  2279. }
  2280. if (!foundItem)
  2281. {
  2282. GrainSizeAnalysisModel newMod = analysisItem.cloneModel();
  2283. newMod.value = null;//避免value为集合导致保存出错
  2284. analysisModelXml.ListParam.Add(newMod);
  2285. }
  2286. //analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  2287. }
  2288. //按路径和名称保存xml文件
  2289. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  2290. //保存xml
  2291. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  2292. this.documentWorkspace.Refresh();
  2293. }
  2294. /// <summary>
  2295. /// 读取保存的参数给窗口显示
  2296. /// </summary>
  2297. private void showSaveParamToControl()
  2298. {
  2299. //读取上次关闭窗口时保存的参数
  2300. if (this.analysisDict.Count == 0)
  2301. {
  2302. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  2303. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  2304. GrainSizeAnalysisModel grainSizeAnalysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  2305. foreach (var item in grainSizeAnalysisModel.ListParam)
  2306. item.setValue();
  2307. this.analysisDict.Add(getCurrentWorkTag(), grainSizeAnalysisModel);
  2308. }
  2309. GrainSizeAnalysisModel analysisModel = this.analysisDict[getCurrentWorkTag()];
  2310. object ShowGrainBoundry;
  2311. if (analysisModel.GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry, this.menuId))//小数点位数
  2312. this.numericUpDown1.Value = (int)ShowGrainBoundry;
  2313. if (analysisModel.GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry, this.menuId))//生成报告时打开设置
  2314. this.checkBox1.Checked = (bool)ShowGrainBoundry;
  2315. if (analysisModel.GetParamValue1(ParamKey_lineWidth, out ShowGrainBoundry, this.menuId))//线宽
  2316. this.numericUpDown2.Value = (int)ShowGrainBoundry;
  2317. if (analysisModel.GetParamValue1(ParamKey_lineColor, out ShowGrainBoundry, this.menuId))//颜色
  2318. this.panel1.BackColor = Color.FromArgb((int)ShowGrainBoundry);
  2319. if (analysisModel.GetParamValue1(ParamKey_maxDiameter, out ShowGrainBoundry, this.menuId))//最大卡尺直径
  2320. this.numericUpDown3.Value = decimal.Parse(ShowGrainBoundry.ToString());
  2321. if (analysisModel.GetParamValue1(ParamKey_minDiameter, out ShowGrainBoundry, this.menuId))//最小卡尺直径
  2322. this.numericUpDown4.Value = decimal.Parse(ShowGrainBoundry.ToString());
  2323. }
  2324. /// <summary>
  2325. /// 保存界面中的参数到model
  2326. /// </summary>
  2327. private void saveDialogParamValues(string imageKey)
  2328. {
  2329. GrainSizeAnalysisModel analysisModel = this.analysisDict[imageKey];
  2330. analysisModel.saveParamValue(ParamKey_lineWidth, Convert.ToInt32(this.numericUpDown2.Value).ToString(), (int)Base.Dtryt.Interger, this.menuId);//线宽
  2331. analysisModel.saveParamValue(ParamKey_lineColor, this.panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Interger, this.menuId);//颜色
  2332. analysisModel.saveParamValue(ParamKey_maxDiameter, numericUpDown3.Value.ToString(), (int)Base.Dtryt.ItemString, this.menuId);//最大卡尺直径
  2333. analysisModel.saveParamValue(ParamKey_minDiameter, numericUpDown4.Value.ToString(), (int)Base.Dtryt.ItemString, this.menuId);//最小卡尺直径
  2334. analysisModel.saveParamValue(ParamKey_CalculatorDecimalDigits, Convert.ToInt32(this.numericUpDown1.Value).ToString(), (int)Base.Dtryt.Interger, this.menuId);
  2335. analysisModel.saveParamValue(ParamKey_OpenWhileExportReport, this.checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean, this.menuId);//生成报告时打开设置
  2336. }
  2337. /// <summary>
  2338. /// 添加参数改变的监听
  2339. /// </summary>
  2340. /// <param name="sender"></param>
  2341. /// <param name="e"></param>
  2342. private void GrainSizeDialog_Load(object sender, EventArgs e)
  2343. {
  2344. this.binaryClass.loadParams();
  2345. }
  2346. private bool bcBinaryChecked()
  2347. {
  2348. return bc != null && bc.BinaryChecked;
  2349. }
  2350. private bool bcOriginChecked()
  2351. {
  2352. return bc != null && bc.OriginChecked;
  2353. }
  2354. /// <summary>
  2355. /// 参数改变时,重新处理图像
  2356. /// </summary>
  2357. /// <param name="sender"></param>
  2358. /// <param name="e"></param>
  2359. private void bClassBinaryImplFinishAction(object sender, EventArgs e)
  2360. {
  2361. this.documentWorkspace.Refresh();
  2362. }
  2363. ///// <summary>
  2364. ///// 参数改变时,重新处理图像
  2365. ///// </summary>
  2366. ///// <param name="sender"></param>
  2367. ///// <param name="e"></param>
  2368. //private void applyButtonImpl(object sender, EventArgs e)
  2369. //{
  2370. // if (!this.needChange)
  2371. // {
  2372. // this.needChange = true;
  2373. // return;
  2374. // }
  2375. // long start = Cv2.GetTickCount();
  2376. // if (this.listView1.FocusedItem != null && checkBox10.Checked)
  2377. // {
  2378. // //判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
  2379. // if (this.documentWorkspace.GraphicsList.IsExsitView())
  2380. // {
  2381. // this.documentWorkspace.PhaseModels[0].mat = action.PerformProcess(
  2382. // OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
  2383. // OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  2384. // this.documentWorkspace.PhaseModels[0].color = this.panel2.BackColor.ToArgb();
  2385. // this.documentWorkspace.Refresh();
  2386. // }
  2387. // else
  2388. // {
  2389. // this.documentWorkspace.PhaseModels[0].mat = action.PerformProcess(OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  2390. // this.documentWorkspace.PhaseModels[0].color = this.panel2.BackColor.ToArgb();
  2391. // this.documentWorkspace.Refresh();
  2392. // }
  2393. // }
  2394. // double time = (Cv2.GetTickCount() - start) / Cv2.GetTickFrequency();
  2395. // System.Console.WriteLine("执行时间:" + time);
  2396. //}
  2397. /// <summary>
  2398. /// 显示原图/原图+二值图
  2399. /// </summary>
  2400. /// <param name="sender"></param>
  2401. /// <param name="e"></param>
  2402. private void bcOriginCheckedChanged(object sender, EventArgs e)
  2403. {
  2404. if (!bcOriginChecked())
  2405. {
  2406. if (bcBinaryChecked())
  2407. this.documentWorkspace.PhaseModels[0].choise = true;
  2408. }
  2409. else
  2410. {
  2411. this.documentWorkspace.PhaseModels[0].choise = false;
  2412. this.documentWorkspace.PhaseModels[1].choise = false;
  2413. }
  2414. this.documentWorkspace.Refresh();
  2415. }
  2416. ///// <summary>
  2417. ///// 显示原图/原图+二值图
  2418. ///// </summary>
  2419. ///// <param name="sender"></param>
  2420. ///// <param name="e"></param>
  2421. //private void ShowOrHideOriginPic(object sender, EventArgs e)
  2422. //{
  2423. // if (!checkBox5.Checked)
  2424. // {
  2425. // if (checkBox10.Checked)
  2426. // this.documentWorkspace.PhaseModels[0].choise = true;
  2427. // }
  2428. // else
  2429. // {
  2430. // this.documentWorkspace.PhaseModels[0].choise = false;
  2431. // this.documentWorkspace.PhaseModels[1].choise = false;
  2432. // }
  2433. // this.documentWorkspace.Refresh();
  2434. //}
  2435. #endregion
  2436. private void button_ApplyToAll_Click(object sender, EventArgs e)
  2437. {
  2438. if (this.selectPicture < 0)
  2439. return;
  2440. this.saveDialogParamValues(this.imageList1.Images.Keys[this.selectPicture].ToString());
  2441. binaryClass.saveParams();
  2442. binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]);
  2443. //var firstIndex = this.listView1.FocusedItem.Index;
  2444. for (int i = 0; i < listView1.Items.Count; i++)
  2445. {
  2446. if (!this.analysisDict.ContainsKey(this.imageList1.Images.Keys[i]))
  2447. this.analysisDict.Add(this.imageList1.Images.Keys[i], this.analysisDict[getCurrentWorkTag()].cloneListParamModel(this.menuId));
  2448. else
  2449. this.analysisDict[this.imageList1.Images.Keys[i]] = this.analysisDict[getCurrentWorkTag()].cloneListParamModel(this.menuId);
  2450. this.listView1.EnsureVisible(i);
  2451. this.listView1.Items[i].Focused = true;
  2452. this.listView1.Items[i].Selected = true;
  2453. //if (i != firstIndex)
  2454. //{
  2455. // //更新二值图片
  2456. // binaryClass.updateAnalysisData(this.imageList1.Images.Keys[i], i);
  2457. // //...
  2458. // this.startStatistics();
  2459. //}
  2460. }
  2461. }
  2462. /// <summary>
  2463. /// 应用全部时刷新界面数据
  2464. /// </summary>
  2465. private void startStatistics()
  2466. {
  2467. }
  2468. private Mat runDect(Mat OrgImg0, int dark, int smooth_type, double sigma, int enhance, double[] cell_size)
  2469. {
  2470. Mat GryImg = new Mat();
  2471. Mat OrgImg = new Mat();
  2472. /////
  2473. if (4 == OrgImg0.Channels())
  2474. {
  2475. Cv2.CvtColor(OrgImg0, OrgImg, ColorConversionCodes.BGRA2BGR);
  2476. }
  2477. else
  2478. {
  2479. OrgImg = OrgImg0.Clone();
  2480. }
  2481. GrainSizeStandard.IntegrationClass.In5segmsurf prm = new GrainSizeStandard.IntegrationClass.In5segmsurf();
  2482. prm.OrgImg = OrgImg;
  2483. /////
  2484. //Cv2.ImShow("src", OrgImg);//kkkkk
  2485. //Cv2.WaitKey(0);//kkkkk
  2486. //转为为灰度?
  2487. if (3 == OrgImg.Channels() || 4 == OrgImg.Channels())
  2488. {
  2489. Cv2.CvtColor(OrgImg, GryImg, ColorConversionCodes.RGB2GRAY);
  2490. }
  2491. else
  2492. {
  2493. if (1 == OrgImg.Channels())
  2494. {
  2495. GryImg = OrgImg.Clone();
  2496. }
  2497. else
  2498. {
  2499. return null;
  2500. }
  2501. }
  2502. if (1 == dark)
  2503. {//采用新的算法不需要这里的处理了
  2504. // int Rows = GryImg.Rows;
  2505. // int Cols = GryImg.Cols;
  2506. // int[] point = new int[2];
  2507. // //单通道图像的反色
  2508. // for (point[0] = 0; point[0] < Rows; point[0]++)
  2509. // {
  2510. // for (point[1] = 0; point[1] < Cols; point[1]++)
  2511. // {
  2512. // byte bTemp = (byte)(255 - GryImg.At<byte>(point[0], point[1]));
  2513. // GryImg.Set<byte>(point, bTemp);//mmmmm
  2514. // }
  2515. // }
  2516. //}
  2517. //if (2 == dark)
  2518. //{
  2519. // Mat TempImg = GryImg.Clone();
  2520. // Cv2.Sobel(TempImg, GryImg, -1, 2, 2, 3);//mmmmm
  2521. }
  2522. //Cv2.ImShow("src", GryImg);//kkkkk
  2523. //Cv2.WaitKey(0);//kkkkk
  2524. //去噪
  2525. if (0 == smooth_type)
  2526. {
  2527. prm.smoothim_method = "gaussian";
  2528. }
  2529. else
  2530. {
  2531. if (1 == smooth_type)
  2532. {
  2533. prm.smoothim_method = "dirced";
  2534. }
  2535. else
  2536. {
  2537. return null;
  2538. }
  2539. }
  2540. //晶界增强
  2541. if (1 == enhance)
  2542. {
  2543. prm.filterridges = 1;
  2544. }
  2545. else
  2546. {
  2547. prm.filterridges = 0;
  2548. }
  2549. //调用算法
  2550. prm.gaussian_stdev = sigma;
  2551. prm.LEVEL = ".3";
  2552. prm.classifycells_convexarea = 0.50;
  2553. prm.classifycells_convexperim = 0.45;
  2554. GrainSizeStandard.IntegrationClass.OLDcellsegm cellsegm = new GrainSizeStandard.IntegrationClass.OLDcellsegm();
  2555. string[] namehere = new string[1] { "prm" };
  2556. GrainSizeStandard.IntegrationClass.In6segmsurf IN6BNImgs = new GrainSizeStandard.IntegrationClass.In6segmsurf();
  2557. GrainSizeStandard.IntegrationClass.OUTsegmsurf RSTss = cellsegm.mf_segmsurf_progress_auto(GryImg, cell_size[0], cell_size[1], namehere, prm, IN6BNImgs, Color.Red);
  2558. //cell_size = null;
  2559. //cellsegm = null;
  2560. //namehere = null;
  2561. Cv2.CvtColor(RSTss.wat, OrgImg0, ColorConversionCodes.BGR2BGRA);
  2562. //this.documentWorkspace.PhaseModels[1].mat = OrgImg0;// RSTss.wat;// action.PerformProcess(
  2563. //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
  2564. //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
  2565. //////this.documentWorkspace.PhaseModels[1].color = this.panel2.BackColor.ToArgb();
  2566. //this.documentWorkspace.Refresh();
  2567. //return RSTss.wat;
  2568. //string filename = "D:\\result11.jpg";
  2569. //Cv2.ImWrite(filename, RSTss.wat);
  2570. return OrgImg0;
  2571. }
  2572. #region [脚本录制]
  2573. private void getScriptRecording()
  2574. {
  2575. string className = InvariantData.path_Action + ".Action" + menuId;
  2576. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  2577. List<Args> args = param.Lists;
  2578. foreach (var item in args)
  2579. {
  2580. item.value = setScriptRecording(item.key);
  2581. }
  2582. //找出二值相关参数 进行赋值
  2583. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  2584. foreach (var item in isNullList)
  2585. {
  2586. item.value = binaryClass.setScriptRecording(item.key);
  2587. }
  2588. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  2589. }
  2590. private object setScriptRecording(string key)
  2591. {
  2592. object value = null;
  2593. switch (key)
  2594. {
  2595. case "lineWidth":
  2596. value = this.numericUpDown2.Value;
  2597. break;
  2598. case "lineColor":
  2599. value = this.panel1.BackColor.ToArgb();
  2600. break;
  2601. case "maxDiameter":
  2602. value = this.numericUpDown3.Value;
  2603. break;
  2604. case "minDiameter":
  2605. value = this.numericUpDown4.Value;
  2606. break;
  2607. case "CalculatorDecimalDigits":
  2608. value = this.numericUpDown1.Value;
  2609. break;
  2610. case "OpenWhileExportReport":
  2611. value = this.checkBox1.Checked;
  2612. break;
  2613. case "ExportResults":
  2614. value = false;
  2615. break;
  2616. case "ExportReports":
  2617. value = false;
  2618. break;
  2619. case "ExportProjects":
  2620. value = false;
  2621. break;
  2622. }
  2623. return value;
  2624. }
  2625. #endregion
  2626. }
  2627. }