SurfacePollutionDetection.cs 118 KB

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