| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652 | using Metis.ParameterSet;using OpenCvSharp;using OpenCvSharp.Extensions;using PaintDotNet.Base.CommTool;using PaintDotNet.Base.Functionodel;using PaintDotNet.CustomControl;using PaintDotNet.DbOpreate.DbBll;using PaintDotNet.DbOpreate.DbModel;using System;using System.Collections.Generic;using System.Data;using System.Drawing;using System.Drawing.Drawing2D;using System.Linq;using System.Windows.Forms;namespace PaintDotNet.DedicatedAnalysis.NonferrousMetals.GBT23603_2009{    internal partial class SurfacePollutionDetection : PdnBaseForm    {        private System.Windows.Forms.GroupBox groupBox1;        private System.Windows.Forms.GroupBox groupBox2;        private System.Windows.Forms.GroupBox groupBox4;        private System.Windows.Forms.GroupBox groupBox5;        private System.Windows.Forms.GroupBox groupBox6;        private System.Windows.Forms.GroupBox groupBox7;        private System.Windows.Forms.GroupBox groupBox8;        private System.Windows.Forms.GroupBox groupBox9;        private System.Windows.Forms.Button button2;        private System.Windows.Forms.Button button1;        private System.Windows.Forms.Button button4;        private System.Windows.Forms.Button button3;        private System.Windows.Forms.Button button8;        private System.Windows.Forms.Button button7;        private System.Windows.Forms.Button button6;        private System.Windows.Forms.Button button5;        private System.Windows.Forms.DataGridView dataGridView1;        private System.Windows.Forms.DataGridView dataGridView2;        private System.Windows.Forms.ListView listView1;        private System.Windows.Forms.ListView listView2;        private System.Windows.Forms.CheckBox checkBox1;        private System.Windows.Forms.Label label2;        private System.Windows.Forms.CheckBox checkBox3;        private System.Windows.Forms.Label label4;        private System.Windows.Forms.Label label3;        private System.Windows.Forms.Label label5;        private System.Windows.Forms.Panel panel2;        private System.Windows.Forms.NumericUpDown numericUpDown4;        private System.Windows.Forms.NumericUpDown numericUpDown3;        private System.Windows.Forms.NumericUpDown numericUpDown5;        private System.Windows.Forms.NumericUpDown numericUpDown6;        private System.Windows.Forms.TrackBar trackBar4;        private System.Windows.Forms.TrackBar trackBar3;        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;        private System.Windows.Forms.ImageList imageList1;        private System.Windows.Forms.Button button9;        private Button button10;        /// <summary>        /// 图像面板        /// </summary>        private DocumentWorkspaceWindow documentWorkspace;        /// <summary>        /// 调色板        /// </summary>        PaintDotNet.ColorsForm colorsForm2;        /// <summary>        /// 公共按钮        /// </summary>        private CommonControlButtons commonControlButtons;        /// <summary>        /// 单位标尺        /// </summary>        private double unitLength = 1;        /// <summary>        /// 是否仅修改相的颜色        /// </summary>        private bool changeColor = false;        /// <summary>        /// 选中图片的bitmap        /// </summary>        private Bitmap bitmap;        /// <summary>        /// 当前图片是否有视场        /// </summary>        private bool isHadView = false;        /// <summary>        /// 原图mat-包括视场        /// </summary>        private Mat mat;        /// <summary>        /// 筛选小于5后的集合        /// </summary>        private List<List<OpenCvSharp.Point>> pointNext;        /// <summary>        /// 0:添加 1:选择 2:删除        /// </summary>        private int operationK = -1;        /// <summary>        /// 被选择的线        /// </summary>        private int selected = -1;        /// <summary>        /// 起止点        /// </summary>        private System.Drawing.PointF startPoint, endPoint;        /// <summary>        /// 存储所有线的点集合        /// </summary>        private List<PointF[]> pointList = new List<PointF[]>();        /// <summary>        /// 线的总数        /// </summary>        private int lineCount = 0;        /// <summary>        /// 测量点        /// </summary>        public List<RectangleF> rectangleFList = new List<RectangleF>();        /// <summary>        /// 判断图形是否可移动        /// </summary>        private bool canMove = false;        /// <summary>        /// 移动线上的哪一个点        /// </summary>        private int movePointIndex = -1;        /// <summary>        /// 辅助计算偏移量-移动线两端的点        /// </summary>        private PointF lastPoint = new PointF(0, 0);        /// <summary>        /// 辅助计算偏移量-移动线中间的点        /// </summary>        private PointF tempPoint = new PointF(0, 0);        /// <summary>        /// 存储当前线的点集合        /// </summary>        private PointF[] nowLine;        /// <summary>        /// 计算结果的表格集合        /// </summary>        private List<DataTable> resultTableList = new List<DataTable>();        /// <summary>        /// 储存点击保存结果后的所有原图与分析图        /// </summary>        private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();        /// <summary>        /// 是否显示全部        /// </summary>        private bool showAll = false;        /// <summary>        /// 保存用于生成报告的图片        /// </summary>        private List<Bitmap> bitList;        /// <summary>        /// 主控件        /// </summary>        private AppWorkspace appWorkspace;        /// <summary>        /// 中间数据        /// </summary>        private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();        /// <summary>        /// 储存长度        /// </summary>        private List<double> length = new List<double>();        private BinaryControl bc;        //二值化集成1        BinaryClass binaryClass;        private int menuId;        private DataGridViewTextBoxColumn Column3;        private DataGridViewTextBoxColumn Column4;        private int defaultIndex = -1;        private NumericUpDown numericUpDown1;        private Label label1;        /// <summary>        /// 保存窗口参数        /// </summary>        private GrainSizeAnalysisModel analysisModel;        private const string ParamKey_Report = "report";//报告设置        private const string ParamKey_Screen = "screen";//筛选        private const string ParamKey_ScreenMin = "screenMin";//面积最小值        private const string ParamKey_ScreenMax = "screenMax";//面积最大值        private const string ParamKey_LineWidth = "lineWidth";//测量线线宽        private const string ParamKey_FontSize = "fontSize";//字体大小        private const string ParamKey_FontColour = "fontColour";//字体颜色        private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数        private decimal areaMin = -1;        private decimal areaMax = -1;        /// <summary>        /// 必需的设计器变量。        /// </summary>        private System.ComponentModel.IContainer components = null;        public SurfacePollutionDetection()        {            InitializeComponent();        }        public SurfacePollutionDetection(AppWorkspace appWorkspace, int menuId)        {            this.appWorkspace = appWorkspace;            InitializeComponent();            InitializeCustomControl();            this.menuId = menuId;            this.binaryClass = new BinaryClass(menuId);            string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";            GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));            this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);            foreach (var item in this.analysisModel.ListParam)                item.setValue();            InitializeLanguageText();            InitOtherTools();            InitGridHeader();            InitCommonButtonEvent();            AddPictureBoxEvent();            GetListParamModel();            InitPicList();            SetAnalyzeModelFromXml("Template.Manager.item3.SurfacePollutionDetection");        }        private void ShowImgEvent(object sender, EventArgs e)        {            listView1.Focus();            if (this.defaultIndex != -1)            {                this.listView1.Items[defaultIndex].Focused = true;                this.listView1.Items[defaultIndex].Selected = true;            }        }        //<summary>        //初始化其他控件        //</summary>        private void InitOtherTools()        {            //            //初始化图像控件            //            this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);            this.documentWorkspace.Dock = DockStyle.Fill;            this.documentWorkspace.HookMouseEvents();            this.documentWorkspace.AuxiliaryLineEnabled = false;            this.documentWorkspace.Visible = false;            this.documentWorkspace.activeTool = Annotation.Enum.DrawToolType.NullTool;            this.groupBox8.Controls.Add(documentWorkspace);            //            //初始化操作按钮            //            this.commonControlButtons = new CommonControlButtons();            this.commonControlButtons.Dock = DockStyle.Top;            this.commonControlButtons.Height = 30;            this.commonControlButtons.HideZoomToWindowAndActualSize();            this.commonControlButtons.Visible = false;            this.groupBox8.Controls.Add(commonControlButtons);            //            //调色板            //            this.colorsForm2 = new ColorsForm();            this.colorsForm2.StartPosition = FormStartPosition.CenterScreen;            this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged);            //            //颜色panel给定初始值            //            this.panel2.BackColor = Color.Green;            //            //获取系统标尺-微米            //            //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);            //            //获取放大倍数            //            decimal magnification = this.appWorkspace.GetGainMultiple();            //            //按钮绑定事件            //            this.button3.LostFocus += new System.EventHandler(this.button3_LostFocus);            //二值化集成2            bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件            binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }            , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构            binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件        }        #region Windows 窗体设计器生成的代码        private void InitializeLanguageText()        {            this.label1.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";            this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");            this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");            this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");            this.button1.Text = PdnResources.GetString("Menu.Setting.Text");            this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");            this.groupBox4.Text = PdnResources.GetString("Menu.Particlescreening.text");            this.label2.Text = PdnResources.GetString("Menu.range.text") + ":";            this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");            this.groupBox5.Text = PdnResources.GetString("Menu.Measuringlinesetting.text");            this.label4.Text = PdnResources.GetString("Menu.color.text") + ":";            this.label3.Text = PdnResources.GetString("Menu.width.text") + ":";            this.groupBox6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Measuringeration.text");            this.button9.Text = PdnResources.GetString("Menu.MeasureAction.MeasureSelect.Text");            this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");            this.button3.Text = PdnResources.GetString("Menu.Addto.text");            this.groupBox7.Text = PdnResources.GetString("Menu.datapresentation.text");            this.Column1.HeaderText = PdnResources.GetString("Menu.Measuringline.text");            this.Column2.HeaderText = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)";            this.groupBox8.Text = PdnResources.GetString("Menu.Preview.text");            this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text");            this.button10.Text = PdnResources.GetString("Menu.Exportproject.text");            this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":";            this.Column3.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text");            this.Column4.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxdepth.text") + "(um)";            this.button8.Text = PdnResources.GetString("Menu.Exportresults.text");            this.button7.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");            this.button6.Text = PdnResources.GetString("Menu.Edit.Delete.Text");            this.button5.Text = PdnResources.GetString("Menu.Showall.text");            this.Text = PdnResources.GetString("Menu.Surfacecontaminationlayerdetection.Text");        }        private void InitializeCustomControl()        {            this.bc = new PaintDotNet.CustomControl.BinaryControl();            //             // bc            //             this.bc.BinaryBackColor = System.Drawing.Color.Red;            this.bc.BinaryChecked = false;            this.bc.BinaryStyle = 1;            this.bc.Location = new System.Drawing.Point(145, 68);            this.bc.Name = "bc";            this.bc.OriginChecked = false;            this.bc.scope1End = 0D;            this.bc.scope1Start = 0D;            this.bc.scope2End = 0D;            this.bc.scope2Start = 0D;            this.bc.scope3End = 0D;            this.bc.scope3Start = 0D;            this.bc.Size = new System.Drawing.Size(360, 292);            this.bc.TabIndex = 19;            this.Controls.Add(this.bc);            this.Controls.SetChildIndex(this.bc, 0);        }        /// <summary>        /// 设计器支持所需的方法 - 不要修改        /// 使用代码编辑器修改此方法的内容。        /// </summary>        private void InitializeComponent()        {            this.components = new System.ComponentModel.Container();            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();            this.groupBox1 = new System.Windows.Forms.GroupBox();            this.checkBox1 = new System.Windows.Forms.CheckBox();            this.button2 = new System.Windows.Forms.Button();            this.button1 = new System.Windows.Forms.Button();            this.groupBox2 = new System.Windows.Forms.GroupBox();            this.listView1 = new System.Windows.Forms.ListView();            this.imageList1 = new System.Windows.Forms.ImageList(this.components);            this.groupBox4 = new System.Windows.Forms.GroupBox();            this.trackBar4 = new System.Windows.Forms.TrackBar();            this.trackBar3 = new System.Windows.Forms.TrackBar();            this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();            this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();            this.label2 = new System.Windows.Forms.Label();            this.checkBox3 = new System.Windows.Forms.CheckBox();            this.groupBox5 = new System.Windows.Forms.GroupBox();            this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();            this.label1 = new System.Windows.Forms.Label();            this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();            this.panel2 = new System.Windows.Forms.Panel();            this.label4 = new System.Windows.Forms.Label();            this.label3 = new System.Windows.Forms.Label();            this.groupBox6 = new System.Windows.Forms.GroupBox();            this.button9 = new System.Windows.Forms.Button();            this.button4 = new System.Windows.Forms.Button();            this.button3 = new System.Windows.Forms.Button();            this.groupBox7 = new System.Windows.Forms.GroupBox();            this.dataGridView1 = new System.Windows.Forms.DataGridView();            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();            this.groupBox8 = new System.Windows.Forms.GroupBox();            this.groupBox9 = new System.Windows.Forms.GroupBox();            this.button10 = new System.Windows.Forms.Button();            this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();            this.label5 = new System.Windows.Forms.Label();            this.listView2 = new System.Windows.Forms.ListView();            this.dataGridView2 = new System.Windows.Forms.DataGridView();            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();            this.button8 = new System.Windows.Forms.Button();            this.button7 = new System.Windows.Forms.Button();            this.button6 = new System.Windows.Forms.Button();            this.button5 = new System.Windows.Forms.Button();            this.groupBox1.SuspendLayout();            this.groupBox2.SuspendLayout();            this.groupBox4.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();            this.groupBox5.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();            this.groupBox6.SuspendLayout();            this.groupBox7.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();            this.groupBox9.SuspendLayout();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();            this.SuspendLayout();            //             // groupBox1            //             this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox1.Controls.Add(this.checkBox1);            this.groupBox1.Controls.Add(this.button2);            this.groupBox1.Controls.Add(this.button1);            this.groupBox1.Location = new System.Drawing.Point(12, 12);            this.groupBox1.Name = "groupBox1";            this.groupBox1.Size = new System.Drawing.Size(1081, 50);            this.groupBox1.TabIndex = 1;            this.groupBox1.TabStop = false;            //             // checkBox1            //             this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.checkBox1.AutoSize = true;            this.checkBox1.Location = new System.Drawing.Point(123, 22);            this.checkBox1.Name = "checkBox1";            this.checkBox1.Size = new System.Drawing.Size(15, 14);            this.checkBox1.TabIndex = 2;            this.checkBox1.UseVisualStyleBackColor = true;            //             // button2            //             this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Right)));            this.button2.Location = new System.Drawing.Point(987, 16);            this.button2.Name = "button2";            this.button2.Size = new System.Drawing.Size(75, 27);            this.button2.TabIndex = 1;            this.button2.UseVisualStyleBackColor = true;            this.button2.Click += new System.EventHandler(this.button2_Click);            //             // button1            //             this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.button1.Location = new System.Drawing.Point(27, 20);            this.button1.Name = "button1";            this.button1.Size = new System.Drawing.Size(75, 23);            this.button1.TabIndex = 0;            this.button1.UseVisualStyleBackColor = true;            this.button1.Click += new System.EventHandler(this.button1_Click);            //             // groupBox2            //             this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.groupBox2.Controls.Add(this.listView1);            this.groupBox2.Location = new System.Drawing.Point(12, 68);            this.groupBox2.Name = "groupBox2";            this.groupBox2.Size = new System.Drawing.Size(135, 607);            this.groupBox2.TabIndex = 2;            this.groupBox2.TabStop = false;            //             // listView1            //             this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.listView1.HideSelection = false;            this.listView1.LargeImageList = this.imageList1;            this.listView1.Location = new System.Drawing.Point(0, 20);            this.listView1.MultiSelect = false;            this.listView1.Name = "listView1";            this.listView1.Size = new System.Drawing.Size(121, 580);            this.listView1.TabIndex = 0;            this.listView1.UseCompatibleStateImageBehavior = false;            this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);            //             // imageList1            //             this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;            this.imageList1.ImageSize = new System.Drawing.Size(64, 64);            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;            //             // groupBox4            //             this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.groupBox4.Controls.Add(this.trackBar4);            this.groupBox4.Controls.Add(this.trackBar3);            this.groupBox4.Controls.Add(this.numericUpDown4);            this.groupBox4.Controls.Add(this.numericUpDown3);            this.groupBox4.Controls.Add(this.label2);            this.groupBox4.Controls.Add(this.checkBox3);            this.groupBox4.Location = new System.Drawing.Point(153, 366);            this.groupBox4.Name = "groupBox4";            this.groupBox4.Size = new System.Drawing.Size(352, 74);            this.groupBox4.TabIndex = 2;            this.groupBox4.TabStop = false;            //             // trackBar4            //             this.trackBar4.AutoSize = false;            this.trackBar4.Location = new System.Drawing.Point(231, 32);            this.trackBar4.Maximum = 0;            this.trackBar4.Name = "trackBar4";            this.trackBar4.Size = new System.Drawing.Size(60, 19);            this.trackBar4.TabIndex = 11;            this.trackBar4.TickStyle = System.Windows.Forms.TickStyle.None;            this.trackBar4.Scroll += new System.EventHandler(this.trackBar4_Scroll);            //             // trackBar3            //             this.trackBar3.AutoSize = false;            this.trackBar3.Location = new System.Drawing.Point(162, 31);            this.trackBar3.Maximum = 0;            this.trackBar3.Name = "trackBar3";            this.trackBar3.Size = new System.Drawing.Size(60, 21);            this.trackBar3.TabIndex = 10;            this.trackBar3.TickStyle = System.Windows.Forms.TickStyle.None;            this.trackBar3.Scroll += new System.EventHandler(this.trackBar3_Scroll);            //             // numericUpDown4            //             this.numericUpDown4.Location = new System.Drawing.Point(297, 31);            this.numericUpDown4.Maximum = new decimal(new int[] {            0,            0,            0,            0});            this.numericUpDown4.Name = "numericUpDown4";            this.numericUpDown4.Size = new System.Drawing.Size(49, 21);            this.numericUpDown4.TabIndex = 9;            this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);            //             // numericUpDown3            //             this.numericUpDown3.Location = new System.Drawing.Point(107, 31);            this.numericUpDown3.Maximum = new decimal(new int[] {            0,            0,            0,            0});            this.numericUpDown3.Name = "numericUpDown3";            this.numericUpDown3.Size = new System.Drawing.Size(49, 21);            this.numericUpDown3.TabIndex = 8;            this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);            //             // label2            //             this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left;            this.label2.AutoSize = true;            this.label2.Location = new System.Drawing.Point(62, 35);            this.label2.Name = "label2";            this.label2.Size = new System.Drawing.Size(41, 12);            this.label2.TabIndex = 5;            this.label2.Text = "范围:";            //             // checkBox3            //             this.checkBox3.AutoSize = true;            this.checkBox3.Location = new System.Drawing.Point(15, 34);            this.checkBox3.Name = "checkBox3";            this.checkBox3.Size = new System.Drawing.Size(15, 14);            this.checkBox3.TabIndex = 3;            this.checkBox3.UseVisualStyleBackColor = true;            this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);            //             // groupBox5            //             this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.groupBox5.Controls.Add(this.numericUpDown1);            this.groupBox5.Controls.Add(this.label1);            this.groupBox5.Controls.Add(this.numericUpDown5);            this.groupBox5.Controls.Add(this.panel2);            this.groupBox5.Controls.Add(this.label4);            this.groupBox5.Controls.Add(this.label3);            this.groupBox5.Location = new System.Drawing.Point(153, 446);            this.groupBox5.Name = "groupBox5";            this.groupBox5.Size = new System.Drawing.Size(352, 63);            this.groupBox5.TabIndex = 2;            this.groupBox5.TabStop = false;            //             // numericUpDown1            //             this.numericUpDown1.Location = new System.Drawing.Point(172, 25);            this.numericUpDown1.Maximum = new decimal(new int[] {            99999,            0,            0,            0});            this.numericUpDown1.Minimum = new decimal(new int[] {            1,            0,            0,            0});            this.numericUpDown1.Name = "numericUpDown1";            this.numericUpDown1.Size = new System.Drawing.Size(50, 21);            this.numericUpDown1.TabIndex = 22;            this.numericUpDown1.Value = new decimal(new int[] {            13,            0,            0,            0});            this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);            //             // label1            //             this.label1.AutoSize = true;            this.label1.Location = new System.Drawing.Point(133, 31);            this.label1.Name = "label1";            this.label1.Size = new System.Drawing.Size(0, 12);            this.label1.TabIndex = 21;            //             // numericUpDown5            //             this.numericUpDown5.Location = new System.Drawing.Point(58, 25);            this.numericUpDown5.Maximum = new decimal(new int[] {            8,            0,            0,            0});            this.numericUpDown5.Minimum = new decimal(new int[] {            3,            0,            0,            0});            this.numericUpDown5.Name = "numericUpDown5";            this.numericUpDown5.Size = new System.Drawing.Size(50, 21);            this.numericUpDown5.TabIndex = 9;            this.numericUpDown5.Value = new decimal(new int[] {            3,            0,            0,            0});            this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);            //             // panel2            //             this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));            this.panel2.BackColor = System.Drawing.Color.Green;            this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;            this.panel2.Location = new System.Drawing.Point(296, 24);            this.panel2.Name = "panel2";            this.panel2.Size = new System.Drawing.Size(50, 21);            this.panel2.TabIndex = 8;            this.panel2.Click += new System.EventHandler(this.panel2_Click);            //             // label4            //             this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));            this.label4.AutoSize = true;            this.label4.Location = new System.Drawing.Point(249, 31);            this.label4.Name = "label4";            this.label4.Size = new System.Drawing.Size(0, 12);            this.label4.TabIndex = 7;            //             // label3            //             this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.label3.AutoSize = true;            this.label3.Location = new System.Drawing.Point(17, 32);            this.label3.Name = "label3";            this.label3.Size = new System.Drawing.Size(0, 12);            this.label3.TabIndex = 6;            //             // groupBox6            //             this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.groupBox6.Controls.Add(this.button9);            this.groupBox6.Controls.Add(this.button4);            this.groupBox6.Controls.Add(this.button3);            this.groupBox6.Location = new System.Drawing.Point(153, 515);            this.groupBox6.Name = "groupBox6";            this.groupBox6.Size = new System.Drawing.Size(352, 44);            this.groupBox6.TabIndex = 2;            this.groupBox6.TabStop = false;            //             // button9            //             this.button9.Location = new System.Drawing.Point(177, 15);            this.button9.Name = "button9";            this.button9.Size = new System.Drawing.Size(75, 23);            this.button9.TabIndex = 4;            this.button9.UseVisualStyleBackColor = true;            this.button9.Click += new System.EventHandler(this.button9_Click);            //             // button4            //             this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));            this.button4.Location = new System.Drawing.Point(271, 15);            this.button4.Name = "button4";            this.button4.Size = new System.Drawing.Size(75, 23);            this.button4.TabIndex = 3;            this.button4.UseVisualStyleBackColor = true;            this.button4.Click += new System.EventHandler(this.button4_Click);            //             // button3            //             this.button3.Anchor = System.Windows.Forms.AnchorStyles.Top;            this.button3.Location = new System.Drawing.Point(76, 15);            this.button3.Name = "button3";            this.button3.Size = new System.Drawing.Size(75, 23);            this.button3.TabIndex = 2;            this.button3.UseVisualStyleBackColor = true;            this.button3.Click += new System.EventHandler(this.button3_Click);            //             // groupBox7            //             this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)));            this.groupBox7.Controls.Add(this.dataGridView1);            this.groupBox7.Location = new System.Drawing.Point(153, 565);            this.groupBox7.Name = "groupBox7";            this.groupBox7.Size = new System.Drawing.Size(352, 110);            this.groupBox7.TabIndex = 2;            this.groupBox7.TabStop = false;            //             // dataGridView1            //             this.dataGridView1.AllowUserToAddRows = false;            this.dataGridView1.AllowUserToResizeColumns = false;            this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {            this.Column1,            this.Column2});            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;            this.dataGridView1.Location = new System.Drawing.Point(3, 17);            this.dataGridView1.MultiSelect = false;            this.dataGridView1.Name = "dataGridView1";            this.dataGridView1.ReadOnly = true;            this.dataGridView1.RowHeadersVisible = false;            this.dataGridView1.RowTemplate.Height = 23;            this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;            this.dataGridView1.Size = new System.Drawing.Size(346, 90);            this.dataGridView1.TabIndex = 0;            //             // Column1            //             this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;            this.Column1.DefaultCellStyle = dataGridViewCellStyle1;            this.Column1.Name = "Column1";            this.Column1.ReadOnly = true;            this.Column1.Width = 170;            //             // Column2            //             dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;            this.Column2.DefaultCellStyle = dataGridViewCellStyle2;            this.Column2.Name = "Column2";            this.Column2.ReadOnly = true;            this.Column2.Width = 170;            //             // groupBox8            //             this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox8.Location = new System.Drawing.Point(511, 68);            this.groupBox8.Name = "groupBox8";            this.groupBox8.Size = new System.Drawing.Size(584, 607);            this.groupBox8.TabIndex = 2;            this.groupBox8.TabStop = false;            //             // groupBox9            //             this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.groupBox9.Controls.Add(this.button10);            this.groupBox9.Controls.Add(this.numericUpDown6);            this.groupBox9.Controls.Add(this.label5);            this.groupBox9.Controls.Add(this.listView2);            this.groupBox9.Controls.Add(this.dataGridView2);            this.groupBox9.Controls.Add(this.button8);            this.groupBox9.Controls.Add(this.button7);            this.groupBox9.Controls.Add(this.button6);            this.groupBox9.Controls.Add(this.button5);            this.groupBox9.Location = new System.Drawing.Point(12, 681);            this.groupBox9.Name = "groupBox9";            this.groupBox9.Size = new System.Drawing.Size(1083, 188);            this.groupBox9.TabIndex = 2;            this.groupBox9.TabStop = false;            //             // button10            //             this.button10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));            this.button10.Location = new System.Drawing.Point(987, 104);            this.button10.Name = "button10";            this.button10.Size = new System.Drawing.Size(75, 23);            this.button10.TabIndex = 10;            this.button10.UseVisualStyleBackColor = true;            this.button10.Click += new System.EventHandler(this.button10_Click);            //             // numericUpDown6            //             this.numericUpDown6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));            this.numericUpDown6.Location = new System.Drawing.Point(1013, 158);            this.numericUpDown6.Maximum = new decimal(new int[] {            10,            0,            0,            0});            this.numericUpDown6.Name = "numericUpDown6";            this.numericUpDown6.Size = new System.Drawing.Size(49, 21);            this.numericUpDown6.TabIndex = 9;            this.numericUpDown6.ValueChanged += new System.EventHandler(this.numericUpDown6_ValueChanged);            //             // label5            //             this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)             | System.Windows.Forms.AnchorStyles.Right)));            this.label5.AutoSize = true;            this.label5.Location = new System.Drawing.Point(976, 160);            this.label5.Name = "label5";            this.label5.Size = new System.Drawing.Size(0, 12);            this.label5.TabIndex = 8;            //             // listView2            //             this.listView2.HideSelection = false;            this.listView2.Location = new System.Drawing.Point(14, 60);            this.listView2.Name = "listView2";            this.listView2.Size = new System.Drawing.Size(158, 122);            this.listView2.TabIndex = 1;            this.listView2.UseCompatibleStateImageBehavior = false;            this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);            //             // dataGridView2            //             this.dataGridView2.AllowUserToAddRows = false;            this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)             | System.Windows.Forms.AnchorStyles.Right)));            this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.Control;            this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;            this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {            this.Column3,            this.Column4});            this.dataGridView2.Location = new System.Drawing.Point(216, 32);            this.dataGridView2.MultiSelect = false;            this.dataGridView2.Name = "dataGridView2";            this.dataGridView2.ReadOnly = true;            this.dataGridView2.RowHeadersVisible = false;            this.dataGridView2.RowTemplate.Height = 23;            this.dataGridView2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;            this.dataGridView2.Size = new System.Drawing.Size(740, 150);            this.dataGridView2.TabIndex = 1;            //             // Column3            //             this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;            this.Column3.HeaderText = "Column3";            this.Column3.Name = "Column3";            this.Column3.ReadOnly = true;            //             // Column4            //             this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;            this.Column4.HeaderText = "Column4";            this.Column4.Name = "Column4";            this.Column4.ReadOnly = true;            //             // button8            //             this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));            this.button8.Location = new System.Drawing.Point(987, 74);            this.button8.Name = "button8";            this.button8.Size = new System.Drawing.Size(75, 23);            this.button8.TabIndex = 7;            this.button8.UseVisualStyleBackColor = true;            this.button8.Click += new System.EventHandler(this.button8_Click);            //             // button7            //             this.button7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));            this.button7.Location = new System.Drawing.Point(987, 45);            this.button7.Name = "button7";            this.button7.Size = new System.Drawing.Size(75, 23);            this.button7.TabIndex = 6;            this.button7.UseVisualStyleBackColor = true;            this.button7.Click += new System.EventHandler(this.button7_Click);            //             // button6            //             this.button6.Location = new System.Drawing.Point(110, 31);            this.button6.Name = "button6";            this.button6.Size = new System.Drawing.Size(75, 23);            this.button6.TabIndex = 5;            this.button6.UseVisualStyleBackColor = true;            this.button6.Click += new System.EventHandler(this.button6_Click);            //             // button5            //             this.button5.Location = new System.Drawing.Point(6, 31);            this.button5.Name = "button5";            this.button5.Size = new System.Drawing.Size(75, 23);            this.button5.TabIndex = 4;            this.button5.UseVisualStyleBackColor = true;            this.button5.Click += new System.EventHandler(this.button5_Click);            //             // SurfacePollutionDetection            //             this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);            this.ClientSize = new System.Drawing.Size(1107, 881);            this.Controls.Add(this.groupBox9);            this.Controls.Add(this.groupBox8);            this.Controls.Add(this.groupBox7);            this.Controls.Add(this.groupBox6);            this.Controls.Add(this.groupBox5);            this.Controls.Add(this.groupBox4);            this.Controls.Add(this.groupBox2);            this.Controls.Add(this.groupBox1);            this.Name = "SurfacePollutionDetection";            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Dialog_FormClosing);            this.Load += new System.EventHandler(this.GrainSizeDialog_Load);            this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);            this.Controls.SetChildIndex(this.groupBox1, 0);            this.Controls.SetChildIndex(this.groupBox2, 0);            this.Controls.SetChildIndex(this.groupBox4, 0);            this.Controls.SetChildIndex(this.groupBox5, 0);            this.Controls.SetChildIndex(this.groupBox6, 0);            this.Controls.SetChildIndex(this.groupBox7, 0);            this.Controls.SetChildIndex(this.groupBox8, 0);            this.Controls.SetChildIndex(this.groupBox9, 0);            this.groupBox1.ResumeLayout(false);            this.groupBox1.PerformLayout();            this.groupBox2.ResumeLayout(false);            this.groupBox4.ResumeLayout(false);            this.groupBox4.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();            this.groupBox5.ResumeLayout(false);            this.groupBox5.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();            this.groupBox6.ResumeLayout(false);            this.groupBox7.ResumeLayout(false);            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();            this.groupBox9.ResumeLayout(false);            this.groupBox9.PerformLayout();            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();            ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();            this.ResumeLayout(false);        }        #endregion        //二值化集成3        #region 二值化相关方法        private void Dialog_FormClosing(object sender, FormClosingEventArgs e)        {            this.saveDialogParamValues();            binaryClass.saveParams();            //xml保存路径            string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";            GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));            foreach (var analysisItem in this.analysisModel.ListParam)            {                bool foundItem = false;                foreach (var item in analysisModelXml.ListParam)                {                    if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)                    {                        item.param_value = analysisItem.param_value;                        foundItem = true;                        break;                    }                }                if (!foundItem)                    analysisModelXml.ListParam.Add(analysisItem.cloneModel());            }            //按路径和名称保存xml文件            string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);            //保存xml            FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);        }        private void ShownChoiseItemAndInitData(object sender, EventArgs e)        {            binaryClass.RefreshHistogramControl1Values();        }        /// <summary>        /// 添加参数改变的监听        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void GrainSizeDialog_Load(object sender, EventArgs e)        {            this.binaryClass.loadParams();        }        private bool bcBinaryChecked()        {            return bc != null && bc.BinaryChecked;        }        private bool bcOriginChecked()        {            return bc != null && bc.OriginChecked;        }        /// <summary>        /// 参数改变时,重新处理图像        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void bClassBinaryImplFinishAction(object sender, EventArgs e)        {            if (this.documentWorkspace.CompositionSurface == null)                return;            sum++;            if (bcBinaryChecked())            {                if (bcOriginChecked())                {                    this.documentWorkspace.PhaseModels[1].choise = false;                }                else                {                    this.documentWorkspace.PhaseModels[1].choise = true;                }                ResetAreaAndContent();                ReloadDebrisSelection();                changeColor = false;                this.documentWorkspace.PhaseModels[0].choise = false;                this.documentWorkspace.PhaseModels[1].choise = true;            }            else            {                this.documentWorkspace.PhaseModels[0].choise = false;                this.documentWorkspace.PhaseModels[1].choise = false;            }            this.documentWorkspace.Refresh();        }        /// <summary>        /// 显示原图/原图+二值图        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void bcOriginCheckedChanged(object sender, EventArgs e)        {            if (!bcOriginChecked())            {                if (bcBinaryChecked())                {                    this.documentWorkspace.PhaseModels[0].choise = false;                    this.documentWorkspace.PhaseModels[1].choise = true;                }            }            else            {                this.documentWorkspace.PhaseModels[0].choise = false;                this.documentWorkspace.PhaseModels[1].choise = false;            }            this.documentWorkspace.Refresh();        }        #endregion        /// <summary>        /// 添加测量线按钮失去焦点        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button3_LostFocus(object sender, EventArgs e)        {            operationK = -1;            selected = -1;            this.documentWorkspace.Refresh();        }        /// <summary>        /// 初始化表头        /// </summary>        private void InitGridHeader()        {            //            //结果展示表            //            this.dataGridView1.ColumnHeadersHeight = 50;            DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();            h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h1.Width = 66;            DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();            h2.Width = 138;            DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();            h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h3.Width = 66;            DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();            h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h4.Width = 66;            //            //分析结果表            //            this.dataGridView2.ColumnHeadersHeight = 30;            DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();            h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h5.Width = 115;            DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();            h6.Width = 155;            DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();            h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h7.Width = 190;            DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();            h8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h8.Width = 115;            DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();            h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;            h9.Width = 115;            //            //左下表            //            this.listView2.View = View.Details;            ColumnHeader header0 = new ColumnHeader();            header0.Text = PdnResources.GetString("Menu.Imagelist.Text");            header0.Width = 175;            this.listView2.Columns.Add(header0);        }        /// <summary>        /// 初始化画布按键功能        /// </summary>        private void InitCommonButtonEvent()        {            this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);            this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);            this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);            this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);            this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);            this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);        }        /// <summary>        /// 添加画布绑定事件        /// </summary>        private void AddPictureBoxEvent()        {            this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.BoxMouseDownHandler);            this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.BoxMouseMoveHandler);            this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.BoxMouseUpHandler);            this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler);        }        /// <summary>        /// 鼠标抬起        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void BoxMouseUpHandler(object sender, MouseEventArgs e)        {            if (e.Button == MouseButtons.Left)            {                if (operationK == 0)                {                    if (startPoint != null && endPoint != null && startPoint != endPoint)                    {                        RectangleF rectangleF = CalcOtherRectangle(pointList[lineCount][0], pointList[lineCount][1]);                        rectangleFList.Add(rectangleF);                        double result = calculationLength(pointList[lineCount][0], pointList[lineCount][1]);                        length.Add(result);                        lineCount++;                    }                    else                    {                        pointList.RemoveAt(pointList.Count - 1);                    }                    RefreshDataGridView1();                }                else if (operationK == 1)                {                    canMove = false;                    movePointIndex = -1;                    //RefreshDataGridView1();                }            }            //operationK = -1;            this.documentWorkspace.Refresh();        }        /// <summary>        /// 刷新数据展示表        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void RefreshDataGridView1()        {            this.dataGridView1.Rows.Clear();            int number = 1;            double maxLength = 0;            foreach (PointF[] points in pointList)            {                DataGridViewRow row = new DataGridViewRow();                row.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Measuringline.text") + number, ""));                number++;                double length = calculationLength(points[0], points[1]);                double lengthEnd = Math.Round(length, int.Parse(this.numericUpDown6.Value.ToString()));                if (maxLength < lengthEnd)                {                    maxLength = lengthEnd;                }                row.Cells.Add(CreateTextBoxCell(lengthEnd.ToString(), ""));                this.dataGridView1.Rows.Add(row);            }            if (maxLength != 0)            {                DataGridViewRow row1 = new DataGridViewRow();                row1.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxdepth.text"), ""));                row1.Cells.Add(CreateTextBoxCell(maxLength.ToString(), ""));                this.dataGridView1.Rows.Add(row1);            }            this.dataGridView1.ClearSelection();        }        /// <summary>        /// 添加内容单元格        /// </summary>        /// <param name="text"></param>        /// <param name="tag"></param>        /// <returns></returns>        private DataGridViewCell CreateTextBoxCell(string text, object tag)        {            DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();            textboxcell.Value = text;            textboxcell.Tag = tag;            return textboxcell;        }        /// <summary>        /// 计算外接矩形        /// </summary>        private RectangleF CalcOtherRectangle(PointF p1, PointF p2)        {            RectangleF rectangleF = new RectangleF();            if (p1.X > p2.X)                rectangleF.X = p2.X;            else                rectangleF.X = p1.X;            if (p1.Y > p2.Y)                rectangleF.Y = p2.Y;            else                rectangleF.Y = p1.Y;            rectangleF.Width = Math.Abs(p2.X - p1.X);            rectangleF.Height = Math.Abs(p2.Y - p1.Y);            return new RectangleF(rectangleF.X - 3, rectangleF.Y - 3, rectangleF.Width + 7, rectangleF.Height + 7);        }        /// <summary>        /// 鼠标移动        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void BoxMouseMoveHandler(object sender, MouseEventArgs e)        {            this.documentWorkspace.panel.Cursor = Cursors.Default;            if (operationK >= 0 && e.Button == MouseButtons.Left)            {                PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);                if (operationK == 0)                {                    this.endPoint = movePoint;                    if (this.startPoint != this.endPoint)                    {                        pointList[lineCount][1] = endPoint;                    }                }                else if (operationK == 1 && selected > -1 && canMove)                {                    float dx = movePoint.X - lastPoint.X;                    float dy = movePoint.Y - lastPoint.Y;                    float dxTemp = movePoint.X - tempPoint.X;                    float dyTemp = movePoint.Y - tempPoint.Y;                    lastPoint.X = movePoint.X;                    lastPoint.Y = movePoint.Y;                    if (movePointIndex == -1)                    {                        RectangleF rectangleF = new RectangleF();                        rectangleF = rectangleFList[selected];                        if (rectangleF.Contains(movePoint))                            this.documentWorkspace.panel.Cursor = Cursors.SizeAll;                        rectangleF.X += dx;                        rectangleF.Y += dy;                        rectangleFList[selected] = rectangleF;                        for (int i = 0; i < pointList[selected].Count(); i++)                        {                            if (pointList[selected][i] == PointF.Empty)                                continue;                            pointList[selected][i].X += dx;                            pointList[selected][i].Y += dy;                        }                    }                    else if (movePointIndex == 0)                    {                        pointList[selected][0].X += dx;                        pointList[selected][0].Y += dy;                        rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]);                    }                    else if (movePointIndex == 1)                    {                        pointList[selected][1].X += dx;                        pointList[selected][1].Y += dy;                        rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]);                    }                }                this.documentWorkspace.Refresh();            }        }        /// <summary>        /// 格式化坐标点        /// </summary>        /// <param name="coordinateA">参考点1</param>        /// <param name="coordinateB">参考点2</param>        /// <param name="basicCoordinate">需比对的点</param>        /// <returns></returns>        private float FormatCoordinate(float coordinateA, float coordinateB, float basicCoordinate)        {            float coordinate = basicCoordinate;            float[] pointArr = new float[] { coordinateA, coordinateB };            if (coordinate > pointArr.Max() - 3)                coordinate = pointArr.Max() - 3;            if (coordinate < pointArr.Min() + 3)                coordinate = pointArr.Min() + 3;            return coordinate;        }        /// <summary>        /// 鼠标按下        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void BoxMouseDownHandler(object sender, MouseEventArgs e)        {            if (operationK >= 0 && e.Button == MouseButtons.Left)            {                PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);                if (operationK == 0)                {                    startPoint = endPoint = downPoint;                    nowLine = new PointF[4];                    nowLine[0] = startPoint;                    nowLine[1] = endPoint;                    pointList.Add(nowLine);                }                else if (operationK == 1)                {                    lastPoint.X = downPoint.X;                    lastPoint.Y = downPoint.Y;                    tempPoint.X = downPoint.X;                    tempPoint.Y = downPoint.Y;                    for (int i = rectangleFList.Count - 1; i >= 0; i--)                    {                        if (rectangleFList[i].Contains(downPoint))                        {                            selected = i;                            canMove = true;                        }                    }                    if (selected > -1)                    {                        if (new RectangleF(pointList[selected][0].X - 3, pointList[selected][0].Y - 3, 7, 7).Contains(downPoint))                            movePointIndex = 0;                        else if (new RectangleF(pointList[selected][1].X - 3, pointList[selected][1].Y - 3, 7, 7).Contains(downPoint))                            movePointIndex = 1;                        else                            movePointIndex = -1;                    }                    if (canMove)                        return;                    selected = -1;                }            }        }        //<summary>        //初始化图片列表数据        //</summary>        public void InitPicList()        {            //初始化图片列表            for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)            {                this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);                this.listView1.Items.Add("", i);                this.listView1.Items[i].ImageIndex = i;                this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();                this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();                if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))                {                    defaultIndex = i;                }            }            this.Shown += ShowImgEvent;        }        int sum;        /// <summary>        /// 图像索引切换选中事件        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void listView1_SelectedIndexChanged(object sender, EventArgs e)        {            if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)            {                unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);                sum = 0;                this.dataGridView1.Rows.Clear();                this.documentWorkspace.PhaseModels.Clear();                this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;                this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();                //二值化集成5                binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.bitmap);                this.documentWorkspace.Visible = true;                this.commonControlButtons.Visible = true;                length.Clear();                rectangleFList.Clear();                selected = -1;                nowLine = null;                pointList.Clear();                lineCount = 0;                changeColor = false;                if (sum == 0)                {                    if (bcOriginChecked() || !bcBinaryChecked())                    {                        this.documentWorkspace.PhaseModels[1].choise = false;                    }                    else                    {                        this.documentWorkspace.PhaseModels[1].choise = true;                    }                    ResetAreaAndContent();                    ReloadDebrisSelection();                }                else                {                    if (bcOriginChecked() || !bcBinaryChecked())                    {                        this.documentWorkspace.PhaseModels[1].choise = false;                    }                    else                    {                        this.documentWorkspace.PhaseModels[1].choise = true;                    }                    this.documentWorkspace.Refresh();                }                sum = 0;            }        }        /// <summary>        /// 是否筛选        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void checkBox3_CheckedChanged(object sender, System.EventArgs e)        {            if (this.documentWorkspace.CompositionSurface == null)                return;            if (bcBinaryChecked())            {                ReloadDebrisSelection();                changeColor = false;            }            //if (this.documentWorkspace.CompositionSurface == null)            //    return;            //if (bcBinaryChecked() && this.checkBox3.Checked)             //{            //    ReloadDebrisSelection();            //    this.documentWorkspace.PhaseModels[1].choise = true;            //}                           //else if (bcBinaryChecked() && !this.checkBox3.Checked)            //{            //    changeColor = false;            //    ReLoadBinarization();            //}        }        /// <summary>        /// 刷新颗粒筛选效果        /// </summary>        private void ReloadDebrisSelection()        {            if (this.documentWorkspace.PhaseModels[0].mat != null /*&& checkBox3.Checked*/)            {                OpenCvSharp.Point[][] contours;//原始轮廓信息                HierarchyIndex[] hierachy;                List<List<OpenCvSharp.Point>> ps = new List<List<OpenCvSharp.Point>>();//轮廓的拓扑信息                Mat temp = new Mat();//中间变量                this.documentWorkspace.PhaseModels[0].mat.CopyTo(temp);                Cv2.FindContours(BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);                pointNext = new List<List<OpenCvSharp.Point>>();                for (int i = 0; i < hierachy.Length; i++)                {                    if (hierachy[i].Parent == -1)                    {                        double area = Math.Abs(Cv2.ContourArea(contours[i])) * unitLength * unitLength;                        if (checkBox3.Checked)                        {                            if (area >= (this.trackBar3.Value) && area <= (this.trackBar4.Value))                            {                                ps.Add(contours[i].ToList());                            }                            else                            {                                if (contours[i].Length < 5)                                    continue;                                else                                {                                    pointNext.Add(contours[i].ToList());                                }                            }                        }                        else                        {                            if (contours[i].Length < 5)                                continue;                            else                            {                                pointNext.Add(contours[i].ToList());                            }                        }                    }                }                Cv2.FillPoly(temp, ps, new Scalar(0, 0, 0, 0));                //Cv2.FillPoly(temp, pointNext, new Scalar(bc.BinaryBackColor.B, bc.BinaryBackColor.G, bc.BinaryBackColor.R, 255));                this.documentWorkspace.PhaseModels[0].choise = false;                this.documentWorkspace.PhaseModels[1].mat = temp;                RefreshDataGridView1();                this.documentWorkspace.Refresh();            }        }        private void numericUpDown5_ValueChanged(object sender, System.EventArgs e)        {            this.documentWorkspace.Refresh();        }        /// <summary>        /// 修改数据小数点后位数        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void numericUpDown6_ValueChanged(object sender, System.EventArgs e)        {            RefreshDataGridView1();            RefreshDataGridView2();            this.documentWorkspace.Refresh();        }        /// <summary>        /// 设置按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button1_Click(object sender, System.EventArgs e)        {            AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.SurfacePollutionDetection");            if (metallographicMethodSetDialog.hasModule)            {                metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;                metallographicMethodSetDialog.ShowDialog();            }            else            {                metallographicMethodSetDialog = null;            }        }        /// <summary>        /// 保存结果按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button2_Click(object sender, System.EventArgs e)        {            if (this.listView1.SelectedItems.Count > 0)            {                string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();                string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];                bool replace = false;                int rowIndex = 0;                if (this.dataGridView1.Rows.Count > 0)                {                    if (this.listView2.Items.Count > 0)                    {                        foreach (ListViewItem item in this.listView2.Items)                        {                            if (item.Name.Equals(tag))                            {                                DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);                                if (dr == DialogResult.OK)                                {                                    replace = true;                                }                                else                                {                                    return;                                }                                break;                            }                        }                    }                    //有重名需要替换                    if (replace)                    {                        for (int i = 0; i < this.resultTableList.Count; i++)                        {                            if (this.resultTableList[i].TableName.Equals(tag))                            {                                rowIndex = i;                                this.resultTableList.Remove(this.resultTableList[i]);                                if (this.pointList.Count > 0)                                {                                    DataTable dt = new DataTable(tag);                                    dt.Columns.Add(PdnResources.GetString("Menu.Measuringline.text"));                                    dt.Columns.Add(PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)");                                    int number = 0;                                    foreach (PointF[] points in pointList)                                    {                                        DataGridViewRow row = new DataGridViewRow();                                        row.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Measuringline.text") + number, ""));                                        number++;                                        double length = calculationLength(points[0], points[1]);                                        DataRow avgRow = dt.NewRow();                                        avgRow[PdnResources.GetString("Menu.Measuringline.text")] = PdnResources.GetString("Menu.Measuringline.text") + number;                                        avgRow[PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)"] = length;                                        dt.Rows.Add(avgRow);                                    }                                    resultTableList.Add(dt);                                }                            }                        }                    }                    //新增                    else                    {                        ListViewItem listViewItem = new ListViewItem();                        listViewItem.Name = tag;                        listViewItem.SubItems[0].Text = imgName;                        this.listView2.Items.Add(listViewItem);                        this.listView2.SelectedItems.Clear();                        this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;                        if (this.pointList.Count > 0)                        {                            DataTable dt = new DataTable(tag);                            dt.Columns.Add(PdnResources.GetString("Menu.Measuringline.text"));                            dt.Columns.Add(PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)");                            int number = 0;                            foreach (PointF[] points in pointList)                            {                                number++;                                double length = calculationLength(points[0], points[1]);                                DataRow avgRow = dt.NewRow();                                avgRow[PdnResources.GetString("Menu.Measuringline.text")] = PdnResources.GetString("Menu.Measuringline.text") + number;                                avgRow[PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)"] = length;                                dt.Rows.Add(avgRow);                            }                            resultTableList.Add(dt);                        }                    }                    RefreshDataGridView2();                    //保存处理后的图片                    double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数                    List<Bitmap> tempBit = new List<Bitmap>();                    Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();                    originalBit.Tag = pantographRatio;                    tempBit.Add(originalBit);                    Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);                    Graphics graphics = Graphics.FromImage(newBit);                    if (this.documentWorkspace.phaseModels != null && this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null)                    {                        Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.phaseModels[0].mat);                        graphics.DrawImage(processedBit, new PointF(0, 0));                    }                    Draw(graphics);                    newBit.Tag = pantographRatio;                    tempBit.Add(newBit);                    if (bitDic.ContainsKey(tag))                        bitDic[tag] = tempBit;                    else                        bitDic.Add(tag, tempBit);                    //拼接中间数据                    List<List<string>> dataList = new List<List<string>>();                    List<string> columnName = new List<string>();                    columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));                    columnName.Add(PdnResources.GetString("Menu.Measuringline.text"));                    columnName.Add(PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "/um");                    dataList.Add(columnName);                    if (length.Count > 0)                    {                        for (int i = 0; i < length.Count; i++)                        {                            List<string> strList = new List<string>();                            strList.Add((i + 1).ToString());                            strList.Add("mm");                            strList.Add((length[i] * unitLength).ToString());                            dataList.Add(strList);                        }                    }                    bool isExist = false;//是否已存在进行替换                    int modelIndex = -1;//要替换的下标                    for (int j = 0; j < tempDataModel.Count; j++)                    {                        if (tempDataModel[j].tagName.Equals(tag))                        {                            isExist = true;                            modelIndex = j;                            break;                        }                    }                    if (isExist && modelIndex > -1)                        tempDataModel[modelIndex].dataList = dataList;                    else                    {                        ExportProjectModel newModel = new ExportProjectModel();                        newModel.tagName = tag;                        newModel.picName = imgName;                        newModel.dataList = dataList;                        tempDataModel.Add(newModel);                    }                }                else                {                    MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawthemeasuringlinefirst.text"));                }            }            else            {                MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));            }        }        /// <summary>        /// 刷新分析结果表        /// </summary>        private void RefreshDataGridView2()        {            this.dataGridView2.Rows.Clear();            double maxLength = 0;            if (this.showAll)            {                if (this.resultTableList.Count > 0)                {                    DataGridViewRow row1 = new DataGridViewRow();                    row1.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxdepth.text"), ""));                    foreach (DataTable dt in resultTableList)                    {                        for (int i = 0; i < dt.Rows.Count; i++)                        {                            DataGridViewRow row = new DataGridViewRow();                            row.Height = 30;                            row.Cells.Add(CreateTextBoxCell(dt.Rows[i][0].ToString(), ""));                            double lengthEnd = Math.Round(double.Parse(dt.Rows[i][1].ToString()), int.Parse(this.numericUpDown6.Value.ToString()));                            if (maxLength < lengthEnd)                            {                                maxLength = lengthEnd;                            }                            row.Cells.Add(CreateTextBoxCell(lengthEnd.ToString(), ""));                            this.dataGridView2.Rows.Add(row);                        }                    }                    row1.Cells.Add(CreateTextBoxCell(maxLength + "", ""));                    this.dataGridView2.Rows.Add(row1);                }            }            else            {                if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)                {                    for (int i = 0; i < this.listView2.SelectedItems.Count; i++)                    {                        string tableName = this.listView2.SelectedItems[i].Name;                        DataGridViewRow row1 = new DataGridViewRow();                        row1.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxdepth.text"), ""));                        foreach (DataTable dt in resultTableList)                        {                            if (dt.TableName.Equals(tableName))                            {                                for (int j = 0; j < dt.Rows.Count; j++)                                {                                    DataGridViewRow row = new DataGridViewRow();                                    row.Height = 30;                                    row.Cells.Add(CreateTextBoxCell(dt.Rows[j][0].ToString(), ""));                                    double lengthEnd = Math.Round(double.Parse(dt.Rows[j][1].ToString()), int.Parse(this.numericUpDown6.Value.ToString()));                                    if (maxLength < lengthEnd)                                    {                                        maxLength = lengthEnd;                                    }                                    row.Cells.Add(CreateTextBoxCell(lengthEnd.ToString(), ""));                                    this.dataGridView2.Rows.Add(row);                                }                            }                        }                        row1.Cells.Add(CreateTextBoxCell(maxLength + "", ""));                        this.dataGridView2.Rows.Add(row1);                    }                }            }        }        /// <summary>        /// 添加测量线按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button3_Click(object sender, System.EventArgs e)        {            operationK = 0;            selected = -1;            this.documentWorkspace.Refresh();        }        /// <summary>        /// 删除测量线按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button4_Click(object sender, System.EventArgs e)        {            if (selected > -1)            {                DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);                if (dr == DialogResult.OK)                {                    this.pointList.Remove(this.pointList[selected]);                    this.rectangleFList.Remove(this.rectangleFList[selected]);                    length.Remove(this.length[selected]);                    lineCount--;                    selected = -1;                    RefreshDataGridView1();                    this.documentWorkspace.Refresh();                }            }            else                MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text"));        }        /// <summary>        /// 按键DELETE删除测量线        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)        {            if (keyData == Keys.Delete)            {                if (selected > -1)                {                    DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);                    if (dr == DialogResult.OK)                    {                        this.pointList.Remove(this.pointList[selected]);                        this.rectangleFList.Remove(this.rectangleFList[selected]);                        length.Remove(this.length[selected]);                        lineCount--;                        selected = -1;                        RefreshDataGridView1();                        this.documentWorkspace.Refresh();                    }                }                else                    MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text"));            }            //return true;            return base.ProcessCmdKey(ref msg, keyData);        }        /// <summary>        /// 全部显示按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button5_Click(object sender, System.EventArgs e)        {            if (this.button5.Text == PdnResources.GetString("Menu.Showall.text"))            {                this.button5.Text = PdnResources.GetString("Menu.Cancelshowall.text");                this.showAll = true;                RefreshDataGridView2();            }            else if (this.button5.Text == PdnResources.GetString("Menu.Cancelshowall.text"))            {                this.button5.Text = PdnResources.GetString("Menu.Showall.text");                this.showAll = false;                RefreshDataGridView2();            }        }        /// <summary>        /// 删除按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button6_Click(object sender, System.EventArgs e)        {            if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)            {                DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text") + "?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);                if (dr == DialogResult.OK)                {                    for (int i = 0; i < this.listView2.SelectedItems.Count; i++)                    {                        string tableName = this.listView2.SelectedItems[i].Name;                        foreach (DataTable dt in resultTableList)                        {                            if (dt.TableName.Equals(tableName))                            {                                resultTableList.Remove(dt);                                break;                            }                        }                        if (bitDic.ContainsKey(tableName))                            bitDic.Remove(tableName);                    }                    foreach (ListViewItem item in this.listView2.Items)                    {                        if (item.Selected)                            this.listView2.Items.Remove(item);                    }                    RefreshDataGridView2();                }            }        }               /// <summary>        /// 生成报告按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button7_Click(object sender, System.EventArgs e)        {            if (this.checkBox1.Checked)                this.button1.PerformClick();            if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))            {                //获取word书签与excel单元格的关系,以字典方式存储                List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);                Dictionary<string, string> tagInfos = new Dictionary<string, string>();                if (mic_module_infos != null && mic_module_infos.Count > 0)                {                    foreach (mic_module_infos info in mic_module_infos)                    {                        tagInfos.Add(info.tag_name, info.cell_position);                    }                }                //分析结果                List<List<string>> analysisContent = new List<List<string>>();                List<string> contentHead = new List<string>();                contentHead.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text"));                contentHead.Add(PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text") + "(um)");                analysisContent.Add(contentHead);                foreach (DataGridViewRow item in this.dataGridView2.Rows)                {                    List<string> content = new List<string>();                    content.Add(item.Cells[0].Value.ToString());                    content.Add(item.Cells[1].Value.ToString());                    analysisContent.Add(content);                }                //图片                bitList = new List<Bitmap>();                if (this.showAll)                {                    foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)                    {                        bitList.Add(kv.Value[0]);                        bitList.Add(kv.Value[1]);                    }                }                else                {                    if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)                    {                        foreach (ListViewItem item in this.listView2.SelectedItems)                        {                            if (bitDic.ContainsKey(item.Name))                            {                                bitList.Add(bitDic[item.Name][0]);                                bitList.Add(bitDic[item.Name][1]);                            }                        }                    }                }                this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);            }            else                MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");        }        /// <summary>        /// 导出结果按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button8_Click(object sender, System.EventArgs e)        {            if (this.listView2.Items.Count > 0)            {                SaveFileDialog exe = new SaveFileDialog();                exe.Filter = "Execl files (*.xlsx)|*.xlsx";                exe.FilterIndex = 0;                exe.RestoreDirectory = true;                //exe.CreatePrompt = true;                exe.Title = "Export Excel File";                exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);                exe.FileName = PdnResources.GetString("Menu.Surfacecontaminationlayerdetection.Text") + DateTime.Now.ToString("yyyyMMddHHmmss");                DialogResult dr = exe.ShowDialog();                if (dr != DialogResult.OK)                    return;                DataTable dtb = new DataTable();                dtb.Columns.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text"));                dtb.Columns.Add(PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"));                for (int i = 0; i < this.dataGridView2.Rows.Count; i++)                {                    DataRow dataRow = dtb.NewRow();                    dataRow[PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text")] = this.dataGridView2.Rows[i].Cells[0].Value;                    dataRow[PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text")] = this.dataGridView2.Rows[i].Cells[1].Value;                    dtb.Rows.Add(dataRow);                }                List<DataTable> list = new List<DataTable>();                list.Add(dtb);                this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, false, false, true);            }            else                MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");        }        /// <summary>        /// 刷新其他信息        /// </summary>        private void ResetAreaAndContent()        {            if (this.documentWorkspace.PhaseModels[0].mat != null && bcBinaryChecked())            {                OpenCvSharp.Point[][] contours;//原始轮廓信息                HierarchyIndex[] hierachy;                Mat temp = new Mat();                this.documentWorkspace.PhaseModels[0].mat.CopyTo(temp);                Cv2.FindContours(BinaryClass.BGRA2GRAY(this.documentWorkspace.PhaseModels[0].mat), out contours, out hierachy, RetrievalModes.CComp, ContourApproximationModes.ApproxNone);                if (hierachy.Length > 0)                {                    double maxArea = 0;//面积最大值                    double minArea = 9999999999;//面积最小值                    //maxSize = 0;                    pointNext = new List<List<OpenCvSharp.Point>>();                    for (int i = 0; i < hierachy.Length; i++)                    {                        double area = Math.Abs(Cv2.ContourArea(contours[i]));                        if (maxArea < area)                            maxArea = area;                        if (minArea > area)                            minArea = area;                        if (contours[i].Length < 5)                            continue;                        else                        {                            pointNext.Add(contours[i].ToList());                        }                    }                    //填充最大碳化物                    //Cv2.FillPoly(temp, pointNext, new Scalar(bc.BinaryBackColor.B, bc.BinaryBackColor.G, bc.BinaryBackColor.R, 255));                    this.documentWorkspace.PhaseModels[1].mat = temp;                    if (!changeColor)                    {                        maxArea = maxArea * unitLength * unitLength;                        minArea = minArea * unitLength * unitLength;                        int maxNum = (int)Math.Ceiling(maxArea);//获取面积最大值                        int minNum = (int)Math.Floor(minArea);//获取面积最小值                        //先解绑事件以防数据赋值异常                        this.numericUpDown3.ValueChanged -= numericUpDown3_ValueChanged;                        this.numericUpDown4.ValueChanged -= numericUpDown4_ValueChanged;                        this.trackBar3.Scroll -= trackBar3_Scroll;                        this.trackBar4.Scroll -= trackBar4_Scroll;                        this.numericUpDown3.Maximum = maxNum;                        this.numericUpDown3.Minimum = minNum;                        this.trackBar3.Maximum = maxNum;                        this.trackBar3.Minimum = minNum;                        this.numericUpDown4.Maximum = maxNum;                        this.numericUpDown4.Minimum = minNum;                        this.trackBar4.Maximum = maxNum;                        this.trackBar4.Minimum = minNum;                        this.numericUpDown3.Value = minNum;                        this.trackBar3.Value = minNum;                        this.numericUpDown4.Value = maxNum;                        this.trackBar4.Value = maxNum;                        if (areaMin != -1 && areaMin >= this.numericUpDown3.Minimum && areaMin <= this.numericUpDown4.Maximum)                        {                            trackBar3.Value = (int)areaMin;                            this.numericUpDown3.Value = areaMin;                        }                        if (areaMax != -1 && areaMax >= this.numericUpDown3.Value && areaMax <= this.numericUpDown4.Maximum)                        {                            trackBar4.Value = (int)areaMax;                            this.numericUpDown4.Value = areaMax;                        }                        this.numericUpDown3.ValueChanged += new EventHandler(numericUpDown3_ValueChanged);                        this.numericUpDown4.ValueChanged += new EventHandler(numericUpDown4_ValueChanged);                        this.trackBar3.Scroll += new EventHandler(trackBar3_Scroll);                        this.trackBar4.Scroll += new EventHandler(trackBar4_Scroll);                        RefreshDataGridView1();                    }                }            }        }        private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce)        {        }        private void mobileModeButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;        }        private void pointerButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;        }        private void actualSizeButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;            this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;        }        private void zoomToWindowButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;        }        private void zoomOutButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ZoomOut();        }        private void zoomInButton_Click(object sender, EventArgs e)        {            this.documentWorkspace.ZoomIn();        }        /// <summary>        /// 绘制事件        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void BoxPaintHandler(object sender, PaintEventArgs e)        {            if (this.documentWorkspace.CompositionSurface != null)            {                Rectangle rc = this.documentWorkspace.panel.ClientRectangle;                int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);                int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);                int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;                int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;                e.Graphics.TranslateTransform(x, y);                e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);                Draw(e.Graphics);                e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);                e.Graphics.TranslateTransform(-x, -y);            }        }        /// <summary>        /// 绘制        /// </summary>        private void Draw(Graphics graphics)        {            graphics.SmoothingMode = SmoothingMode.AntiAlias;            Pen rectPen = new Pen(this.panel2.BackColor, float.Parse(this.numericUpDown5.Value.ToString()));            rectPen.DashStyle = DashStyle.Solid;            Pen borderPen = new Pen(Color.Black);            borderPen.DashStyle = DashStyle.Custom;            float[] dashArray = { 2.0f, 3.0f };            borderPen.DashPattern = dashArray;            if (pointList.Count > 0)            {                foreach (PointF[] pointFs in pointList)                {                    if (pointFs.Count() > 1 && pointFs[0] != pointFs[1])                    {                        //注释                        //float lineLength = 0;//this.trackBar1.Value / 2f;                        //double angle = Math.Round(BasicCalculationHelper.AngleText(pointFs[0], pointFs[1], new PointF(pointFs[0].X + lineLength, pointFs[0].Y)), 10);                        graphics.DrawLine(rectPen, pointFs[0], pointFs[1]);                        if (pointFs[0] != pointFs[1])                        {                            double result = calculationLength(pointFs[0], pointFs[1]);                            double resultEnd = Math.Round(result, int.Parse(numericUpDown6.Value.ToString()));                            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);                        }                    }                }                if (selected > -1)                {                    graphics.DrawRectangle(borderPen, rectangleFList[selected].X, rectangleFList[selected].Y, rectangleFList[selected].Width, rectangleFList[selected].Height);                    graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][0].X - 3), (int)(pointList[selected][0].Y - 3), 7, 7));                    graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][1].X - 3), (int)(pointList[selected][1].Y - 3), 7, 7));                }            }            rectPen.Dispose();        }        /// <summary>        /// 计算画线长度        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private double calculationLength(PointF p1, PointF p2)        {            double num = p1.X - p2.X;            double num1 = p1.Y - p2.Y;            double num2 = num * num + num1 * num1;            return Math.Sqrt(num2) * unitLength;        }        /// <summary>        /// 颗粒筛选范围最小值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void trackBar3_Scroll(object sender, System.EventArgs e)        {            this.numericUpDown3.Value = this.trackBar3.Value;        }        /// <summary>        /// 颗粒筛选范围最大值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void trackBar4_Scroll(object sender, System.EventArgs e)        {            this.numericUpDown4.Value = this.trackBar4.Value;        }        /// <summary>        /// 二值处理        /// </summary>        /// <param name="colorOneStart"></param>        /// <param name="colorOneEnd"></param>        /// <param name="phaseColor"></param>        /// <returns></returns>        private unsafe Mat Binarization(int colorOneStart, int colorOneEnd, Color phaseColor)        {            Mat srcGray;            if (mat.Type() == MatType.CV_8UC1)                srcGray = mat;            else                srcGray = mat.CvtColor(ColorConversionCodes.BGR2GRAY);            Mat src = new Mat(mat.Rows, mat.Cols, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));            int index0 = 0;            byte* ptr0 = (byte*)mat.Data;            int index1 = 0;            byte* ptr1 = (byte*)srcGray.Data;            int index2 = 0;            byte* ptr2 = (byte*)src.Data;            for (int o = 0; o < srcGray.Height; o++)            {                for (int p = 0; p < srcGray.Width; p++)                {                    index0 = (int)((mat.Step() * o) + (p * 4));                    index1 = (int)((srcGray.Step() * o) + (p * 1));                    index2 = (int)((src.Step() * o) + (p * 4));                    if (ptr1[index1] >= colorOneStart && ptr1[index1] <= colorOneEnd)                    {                        if (isHadView)                        {                            if (ptr0[index0 + 3] != 0)                            {                                ptr2[index2] = phaseColor.B;                                ptr2[index2 + 1] = phaseColor.G;                                ptr2[index2 + 2] = phaseColor.R;                                ptr2[index2 + 3] = 255;                            }                        }                        else                        {                            ptr2[index2] = phaseColor.B;                            ptr2[index2 + 1] = phaseColor.G;                            ptr2[index2 + 2] = phaseColor.R;                            ptr2[index2 + 3] = 255;                        }                    }                }            }            return src;        }        /// <summary>        /// 刷新二值效果        /// </summary>        private void ReLoadBinarization()        {            if (this.documentWorkspace.CompositionSurface == null)                return;            if (bcBinaryChecked())            {                ResetAreaAndContent();                //if (this.checkBox3.Checked)                ReloadDebrisSelection();            }            else            {                //this.documentWorkspace.PhaseModels[0].mat = null;                this.dataGridView1.Rows.Clear();            }            this.documentWorkspace.Refresh();        }        /// <summary>        /// 测量线被点击        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void panel2_Click(object sender, System.EventArgs e)        {            this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);            this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed));            this.colorsForm2.ShowDialog();            this.documentWorkspace.Refresh();        }        private void colorsForm2Changed(object sender, EventArgs e)        {            this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor();            this.colorsForm2.Close();            changeColor = true;            this.documentWorkspace.Refresh();        }        /// <summary>        /// 颗粒筛选范围最小值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void numericUpDown3_ValueChanged(object sender, System.EventArgs e)        {            if (this.numericUpDown3.Value > this.numericUpDown4.Value)                this.numericUpDown3.Value = this.numericUpDown4.Value;            this.trackBar3.Value = Convert.ToInt32(this.numericUpDown3.Value);            areaMin = this.numericUpDown3.Value;            areaMax = this.numericUpDown4.Value;            if (this.checkBox3.Checked && bcBinaryChecked())                ReloadDebrisSelection();        }        /// <summary>        /// 选择测量线按钮        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button9_Click(object sender, EventArgs e)        {            operationK = 1;        }        /// <summary>        /// 分析结果列表选择切换        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void listView2_SelectedIndexChanged(object sender, EventArgs e)        {            if (this.showAll)                return;            RefreshDataGridView2();        }        /// <summary>        /// 导出项目        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void button10_Click(object sender, EventArgs e)        {            if (this.checkBox1.Checked)                this.button1.PerformClick();            if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))            {                Instrument.ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.NonferrousMetal.TitaniumAlloyBiomaterial.Text", this.analyzeSettingModel.savePath);                if (nodeItem == null) return;                //获取word书签与excel单元格的关系,以字典方式存储                List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);                Dictionary<string, string> tagInfos = new Dictionary<string, string>();                if (mic_module_infos != null && mic_module_infos.Count > 0)                {                    foreach (mic_module_infos info in mic_module_infos)                    {                        tagInfos.Add(info.tag_name, info.cell_position);                    }                }                //分析结果                List<List<string>> analysisContent = new List<List<string>>();                List<string> contentHead = new List<string>();                contentHead.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.image.text"));                contentHead.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxdepth.text") + "/um");                analysisContent.Add(contentHead);                foreach (DataGridViewRow item in this.dataGridView2.Rows)                {                    List<string> content = new List<string>();                    content.Add(item.Cells[0].Value.ToString());                    content.Add(item.Cells[1].Value.ToString());                    analysisContent.Add(content);                }                //图片                bitList = new List<Bitmap>();                if (this.showAll)                {                    foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)                    {                        bitList.Add(kv.Value[0]);                        bitList.Add(kv.Value[1]);                    }                }                else                {                    if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)                    {                        foreach (ListViewItem item in this.listView2.SelectedItems)                        {                            if (bitDic.ContainsKey(item.Name))                            {                                bitList.Add(bitDic[item.Name][0]);                                bitList.Add(bitDic[item.Name][1]);                            }                        }                    }                }                this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, nodeItem.path, nodeItem.code);                //保存项目信息到数据库                this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);            }            else                MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");        }        private void numericUpDown1_ValueChanged(object sender, EventArgs e)        {            this.documentWorkspace.Refresh();        }        /// <summary>        /// 颗粒筛选范围最大值        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void numericUpDown4_ValueChanged(object sender, System.EventArgs e)        {            if (this.numericUpDown4.Value < this.numericUpDown3.Value)                this.numericUpDown4.Value = this.numericUpDown3.Value;            this.trackBar4.Value = Convert.ToInt32(this.numericUpDown4.Value);            areaMin = this.numericUpDown3.Value;            areaMax = this.numericUpDown4.Value;            if (this.checkBox3.Checked && bcBinaryChecked())                ReloadDebrisSelection();        }        #region 参数保存及提取        /// <summary>        /// 保存参数的key,value和type        /// </summary>        /// <param name="param_key"></param>        /// <param name="param_value"></param>        /// <param name="param_type"></param>        private void saveParamValue(string param_key, string param_value, int param_type)        {            bool foundItem = false;            foreach (var item in this.analysisModel.ListParam)            {                if (item.param_key.Equals(param_key) && item.menuId == this.menuId)                {                    item.param_value = param_value;                    item.setValue();                    foundItem = true;                    break;                }            }            if (!foundItem)            {                GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();                analysisItem.menuId = this.menuId;                analysisItem.param_key = param_key;                analysisItem.param_type = param_type;                analysisItem.param_value = param_value;                analysisItem.setValue();                this.analysisModel.ListParam.Add(analysisItem);            }        }        /// <summary>        /// 保存界面中的参数到model        /// </summary>        private void saveDialogParamValues()        {            saveParamValue(ParamKey_Report, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置            saveParamValue(ParamKey_Screen, checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//筛选            saveParamValue(ParamKey_ScreenMin, numericUpDown3.Value.ToString(), (int)Base.Dtryt.Decimal);//面积最小值            saveParamValue(ParamKey_ScreenMax, numericUpDown4.Value.ToString(), (int)Base.Dtryt.Decimal);//面积最大值            saveParamValue(ParamKey_LineWidth, numericUpDown5.Value.ToString(), (int)Base.Dtryt.Decimal);//测量线线宽            saveParamValue(ParamKey_FontSize, numericUpDown1.Value.ToString(), (int)Base.Dtryt.Decimal);//字号            saveParamValue(ParamKey_FontColour, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//字体颜色            saveParamValue(ParamKey_DecimalPlace, numericUpDown6 != null ? numericUpDown6.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数        }        /// <summary>        /// 获取保存的参数        /// </summary>        private void GetListParamModel()        {            if (this.analysisModel != null)            {                for (int i = 0; i < this.analysisModel.ListParam.Count; i++)                {                    switch (this.analysisModel.ListParam[i].param_key)                    {                        case ParamKey_Report:                            checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;                            break;                        case ParamKey_Screen:                            checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;                            break;                        case ParamKey_ScreenMin:                            areaMin = decimal.Parse(this.analysisModel.ListParam[i].param_value);                            break;                        case ParamKey_ScreenMax:                            areaMax = decimal.Parse(this.analysisModel.ListParam[i].param_value);                            break;                        case ParamKey_LineWidth:                            numericUpDown5.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);                            break;                        case ParamKey_FontSize:                            numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);                            break;                        case ParamKey_FontColour:                            panel2.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);                            break;                        case ParamKey_DecimalPlace:                            numericUpDown6.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);                            break;                    }                }            }        }        #endregion    }}
 |