GrainSizeMeasurementDialog.cs 125 KB

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