123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195 |
- using Metis.ParameterSet;
- using OpenCvSharp;
- using OpenCvSharp.Extensions;
- using PaintDotNet.Base;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.Data.Param;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.DedicatedAnalysis.DuctileIron.Common;
- using PaintDotNet.Instrument;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace PaintDotNet.DedicatedAnalysis.BearingSteelStripRating.GB18254
- {
- /// <summary>
- /// 轴承钢碳化物带状
- /// </summary>
- internal class BearingSteelStripRatingDialog : PdnBaseForm
- {
- #region 基础控件
- private Button button1;
- private CheckBox checkBox1;
- private Button button2;
- private GroupBox groupBox2;
- private ListView listView1;
- private GroupBox groupBox3;
- private GroupBox groupBox5;
- private Panel panel2;
- private GroupBox groupBox8;
- private DataGridView dataGridView1;
- private GroupBox groupBox9;
- private Button button6;
- private Button button7;
- private ListView listView2;
- private DataGridView dataGridView2;
- private Button button9;
- private Button button8;
- private NumericUpDown numericUpDown1;
- private Label label8;
- private Label label9;
- private Label label10;
- private ImageList imageList1;
- private IContainer components;
- private GroupBox groupBox1;
- private CheckBox checkBox3;
- private Panel panel4;
- private Panel panel3;
- private CheckBox checkBox4;
- private Label label1;
- private NumericUpDown numericUpDown2;
- private Button button4;
- private Button button5;
- private Button button3;
- #endregion
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 选中图片的mat
- /// </summary>
- private Mat imageMat;
- /// <summary>
- /// 选中图片的结果图
- /// </summary>
- private Mat resultMat;
- /// <summary>
- /// 计算结果的表格集合
- /// </summary>
- private List<DataTable> resultTableList = new List<DataTable>();
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- private List<Bitmap> bitList;
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- /// <summary>
- /// 是否显示全部
- /// </summary>
- private bool showAll = false;
- /// <summary>
- /// 当前图片是否有视场
- /// </summary>
- //private bool isHadView = false;
- /// <summary>
- /// 原图mat-包括视场
- /// </summary>
- private Mat mat;
- /// <summary>
- /// 单位标尺
- /// </summary>
- private double unitLength = 1;
- /// <summary>
- /// 是否仅修改相的颜色
- /// </summary>
- private bool changeColor = false;
- /// <summary>
- /// 是否未对图片做其他操作
- /// </summary>
- private bool isFirstSwitch = false;
- /// <summary>
- /// 中间数据
- /// </summary>
- private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
- /// <summary>
- /// 面积
- /// </summary>
- //private List<string> tempArea;
- private BinaryControl bc;
- //二值化集成1
- BinaryClass binaryClass;
- private int menuId;
- private string menuName;
- private int defaultIndex = -1;
- /// <summary>
- /// 保存窗口参数
- /// </summary>
- /// <summary>
- /// 各个图片对应数据
- /// </summary>
- private Dictionary<string, GrainSizeAnalysisModel> eachData = new Dictionary<string, GrainSizeAnalysisModel>();
- 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_MaxColour = "maxColour";//最大色
- private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
- private decimal areaMin = 5;//宽
- private decimal areaMax = 5;//长
- private double rate = 0.3;//有效颗粒筛选占比
- private int binaryValue = -1;//二值方法选择
- private bool isExportResults = false;
- private bool isExportReports = false;
- private bool isExportProjects = false;
- private Button button10;
- private Button button11;
- private GroupBox groupBox4;
- private CheckBox checkBox2;
- private Button button13;
- private Button button12;
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- #region 0811新增变量
- //绘制状态:0,无操作;1,新增;2,删除;3,区域删除
- int DrawType = 0;
- //添加颗粒轮廓临时一个
- List<PointF> addPoints = new List<PointF>();
- //所有添加的颗粒轮廓
- List<List<PointF>> addPointsList = new List<List<PointF>>();
- //所有删除的颗粒轮廓
- List<List<PointF>> delPointsList = new List<List<PointF>>();
- //区域删除起始点与结束点
- PointF star = new PointF();
- PointF end = new PointF();
- //所有删除的区域起始点
- List<List<PointF>> delRegionList = new List<List<PointF>>();
- //所有删除的区域的颗粒轮廓
- List<List<List<PointF>>> delRegionPointsList = new List<List<List<PointF>>>();
- //操作记录
- List<int> HisOperate = new List<int>();
- //寻找连通分量
- Mat labelMat = new Mat();
- Mat stats = new Mat();
- Mat centroids = new Mat();
- int nonenum = 0;
- //连通域集合
- OpenCvSharp.Point[][] AllFields;
- //连通域集合
- List<IEnumerable<OpenCvSharp.Point>> AllFieldsTemp = new List<IEnumerable<OpenCvSharp.Point>>();
- private CheckBox checkBox5;
- private Button btnDelRegion;
- private GroupBox groupBox6;
- private Label label2;
- private NumericUpDown numericUpDown3;
- private CheckBox checkBox6;
- private CheckBox checkBox7;
- //当前二值化图
- Mat currentMat = new Mat();
- #endregion
- public BearingSteelStripRatingDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
- {
- this.appWorkspace = appWorkspace;
- NullKey();
- InitializeComponent();
- InitializeLanguageText();
- InitializeCustomControl();
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- this.binaryClass = new BinaryClass(menuId);
- InitGridHeader();
- InitOtherTools();
- InitPicList();
- InitCommonButtonEvent();
- SetAnalyzeModelFromXml("Template.Manager.item3.BearingSteelGBT18254");
- }
- private void ShowImgEvent(object sender, EventArgs e)
- {
- listView1.Focus();
- if (this.defaultIndex != -1)
- {
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
- {
- this.initScriptValues = true;//ScriptAutomatic
- //Boolean initScriptValues = true;
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- getValue(arg.key, arg.Value);
- }
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- }
- else
- {//读取上次关闭窗口时保存的参数
- GetXmlParameter();
- GetListParamModel();
- }
- this.listView1.Items[defaultIndex].Focused = true;
- this.listView1.Items[defaultIndex].Selected = true;
- if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
- this.startScriptAutomaticAction();
- }
- }
- private void InitializeCustomControl()
- {
- //
- // bc
- //
- this.bc = new PaintDotNet.CustomControl.BinaryControl();
- this.bc.BinaryBackColor = System.Drawing.Color.Black;
- this.bc.BinaryChecked = false;
- this.bc.BinaryStyle = 1;
- this.bc.Location = new System.Drawing.Point(150, 59);
- 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.bc.button4.Visible = false;
- //相颜色设定隐藏
- this.bc.button4.Visible = false;
- //this.bc.radioButton1.Enabled = false;
- //this.bc.label2.Visible = false;
- //this.Controls.Add(this.bc);
- //this.Controls.SetChildIndex(this.bc, 0);
- }
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = "操作";
- this.checkBox1.Text = "生成报告时打开设置";
- this.button1.Text = "设置";
- this.groupBox2.Text = "图像索引";
- this.groupBox3.Text = "预览";
- this.groupBox5.Text = "颗粒筛选";
- this.checkBox3.Text = "有效颗粒筛选";
- this.checkBox4.Text = "无筛选";
- this.groupBox8.Text = "结果展示";
- this.groupBox9.Text = "分析结果";
- this.button3.Text = "导出项目";
- this.label8.Text = "小数:";
- this.button9.Text = "导出结果";
- this.button8.Text = "生成报告";
- this.button7.Text = "删除";
- this.button6.Text = "全部显示";
- this.Text = "高碳铬轴承钢带状GB/T 18254-2002";
- this.button4.Text = "保存全部";
- this.button5.Text = "应用全部";
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.button11 = new System.Windows.Forms.Button();
- this.button10 = 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.groupBox3 = new System.Windows.Forms.GroupBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.label1 = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.checkBox4 = new System.Windows.Forms.CheckBox();
- this.checkBox3 = new System.Windows.Forms.CheckBox();
- this.panel4 = new System.Windows.Forms.Panel();
- this.panel3 = new System.Windows.Forms.Panel();
- this.panel2 = new System.Windows.Forms.Panel();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.groupBox9 = new System.Windows.Forms.GroupBox();
- this.button3 = new System.Windows.Forms.Button();
- this.label10 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label8 = new System.Windows.Forms.Label();
- this.button9 = new System.Windows.Forms.Button();
- this.button8 = new System.Windows.Forms.Button();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.listView2 = new System.Windows.Forms.ListView();
- this.button7 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.btnDelRegion = new System.Windows.Forms.Button();
- this.button13 = new System.Windows.Forms.Button();
- this.button12 = new System.Windows.Forms.Button();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.label2 = new System.Windows.Forms.Label();
- this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
- this.checkBox6 = new System.Windows.Forms.CheckBox();
- this.checkBox7 = new System.Windows.Forms.CheckBox();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox5.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- this.groupBox8.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.groupBox9.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox4.SuspendLayout();
- this.groupBox6.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).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.checkBox5);
- this.groupBox1.Controls.Add(this.button4);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.checkBox1);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(14, 3);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1107, 50);
- this.groupBox1.TabIndex = 1;
- this.groupBox1.TabStop = false;
- //
- // checkBox5
- //
- this.checkBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.checkBox5.Location = new System.Drawing.Point(753, 23);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(72, 16);
- this.checkBox5.TabIndex = 20;
- this.checkBox5.Text = "显示原图";
- this.checkBox5.UseVisualStyleBackColor = true;
- this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
- //
- // 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(1019, 14);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(84, 30);
- this.button4.TabIndex = 19;
- this.button4.Text = "保存全部";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // 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(929, 14);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(84, 30);
- this.button2.TabIndex = 2;
- this.button2.Text = "保存结果";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(839, 14);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(84, 30);
- this.button5.TabIndex = 18;
- this.button5.Text = "应用全部";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // 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.Checked = true;
- this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox1.Location = new System.Drawing.Point(141, 21);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(15, 14);
- this.checkBox1.TabIndex = 1;
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // 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(15, 14);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(84, 30);
- this.button1.TabIndex = 0;
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // button11
- //
- this.button11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button11.Location = new System.Drawing.Point(145, 32);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(84, 30);
- this.button11.TabIndex = 21;
- this.button11.Text = "删除";
- this.button11.UseVisualStyleBackColor = true;
- this.button11.Click += new System.EventHandler(this.DelClick);
- //
- // 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(41, 32);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(84, 30);
- this.button10.TabIndex = 20;
- this.button10.Text = "添加";
- this.button10.UseVisualStyleBackColor = true;
- this.button10.Click += new System.EventHandler(this.AddClick);
- //
- // 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(14, 60);
- 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(5, 17);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(124, 584);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown);
- //
- // 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;
- //
- // groupBox3
- //
- this.groupBox3.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.groupBox3.Location = new System.Drawing.Point(515, 60);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(606, 605);
- this.groupBox3.TabIndex = 3;
- this.groupBox3.TabStop = false;
- //
- // groupBox5
- //
- this.groupBox5.Controls.Add(this.label1);
- this.groupBox5.Controls.Add(this.numericUpDown2);
- this.groupBox5.Controls.Add(this.checkBox4);
- this.groupBox5.Controls.Add(this.checkBox3);
- this.groupBox5.Location = new System.Drawing.Point(155, 59);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(353, 94);
- this.groupBox5.TabIndex = 5;
- this.groupBox5.TabStop = false;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(167, 27);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 3;
- this.label1.Text = "有效占比:";
- //
- // numericUpDown2
- //
- this.numericUpDown2.DecimalPlaces = 1;
- this.numericUpDown2.Increment = new decimal(new int[] {
- 1,
- 0,
- 0,
- 65536});
- this.numericUpDown2.Location = new System.Drawing.Point(238, 23);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 1,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(52, 21);
- this.numericUpDown2.TabIndex = 2;
- this.numericUpDown2.Value = new decimal(new int[] {
- 3,
- 0,
- 0,
- 65536});
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
- //
- // checkBox4
- //
- this.checkBox4.AutoSize = true;
- this.checkBox4.Location = new System.Drawing.Point(41, 61);
- this.checkBox4.Name = "checkBox4";
- this.checkBox4.Size = new System.Drawing.Size(15, 14);
- this.checkBox4.TabIndex = 1;
- this.checkBox4.UseVisualStyleBackColor = true;
- this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
- //
- // checkBox3
- //
- this.checkBox3.AutoSize = true;
- this.checkBox3.Checked = true;
- this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox3.Location = new System.Drawing.Point(41, 25);
- this.checkBox3.Name = "checkBox3";
- this.checkBox3.Size = new System.Drawing.Size(15, 14);
- this.checkBox3.TabIndex = 0;
- this.checkBox3.UseVisualStyleBackColor = true;
- this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
- //
- // panel4
- //
- this.panel4.Location = new System.Drawing.Point(0, 0);
- this.panel4.Name = "panel4";
- this.panel4.Size = new System.Drawing.Size(200, 100);
- this.panel4.TabIndex = 0;
- //
- // panel3
- //
- this.panel3.Location = new System.Drawing.Point(0, 0);
- this.panel3.Name = "panel3";
- this.panel3.Size = new System.Drawing.Size(200, 100);
- this.panel3.TabIndex = 0;
- //
- // panel2
- //
- this.panel2.Location = new System.Drawing.Point(0, 0);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(200, 100);
- this.panel2.TabIndex = 0;
- //
- // groupBox8
- //
- this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox8.Controls.Add(this.dataGridView1);
- this.groupBox8.Location = new System.Drawing.Point(155, 408);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(353, 258);
- this.groupBox8.TabIndex = 8;
- this.groupBox8.TabStop = false;
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.AllowUserToDeleteRows = false;
- this.dataGridView1.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.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
- this.dataGridView1.Location = new System.Drawing.Point(7, 20);
- this.dataGridView1.MultiSelect = false;
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView1.Size = new System.Drawing.Size(340, 232);
- this.dataGridView1.TabIndex = 0;
- //
- // 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.button3);
- this.groupBox9.Controls.Add(this.label10);
- this.groupBox9.Controls.Add(this.label9);
- this.groupBox9.Controls.Add(this.numericUpDown1);
- this.groupBox9.Controls.Add(this.label8);
- this.groupBox9.Controls.Add(this.button9);
- this.groupBox9.Controls.Add(this.button8);
- this.groupBox9.Controls.Add(this.dataGridView2);
- this.groupBox9.Controls.Add(this.listView2);
- this.groupBox9.Controls.Add(this.button7);
- this.groupBox9.Controls.Add(this.button6);
- this.groupBox9.Location = new System.Drawing.Point(14, 672);
- this.groupBox9.Name = "groupBox9";
- this.groupBox9.Size = new System.Drawing.Size(1107, 204);
- this.groupBox9.TabIndex = 9;
- this.groupBox9.TabStop = false;
- //
- // button3
- //
- this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button3.Enabled = false;
- this.button3.Location = new System.Drawing.Point(967, 102);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(128, 26);
- this.button3.TabIndex = 10;
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Visible = false;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // label10
- //
- this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.label10.AutoSize = true;
- this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar;
- this.label10.Location = new System.Drawing.Point(953, 9);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(11, 192);
- this.label10.TabIndex = 9;
- this.label10.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
- //
- // label9
- //
- this.label9.AutoSize = true;
- this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar;
- this.label9.Location = new System.Drawing.Point(210, 9);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(11, 192);
- this.label9.TabIndex = 8;
- this.label9.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|";
- //
- // numericUpDown1
- //
- this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.numericUpDown1.Location = new System.Drawing.Point(1019, 162);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(70, 21);
- this.numericUpDown1.TabIndex = 7;
- this.numericUpDown1.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // label8
- //
- this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(983, 167);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(0, 12);
- this.label8.TabIndex = 6;
- //
- // button9
- //
- this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button9.Location = new System.Drawing.Point(967, 68);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(128, 26);
- this.button9.TabIndex = 5;
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // 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(967, 34);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(128, 26);
- this.button8.TabIndex = 4;
- this.button8.UseVisualStyleBackColor = true;
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.AllowUserToDeleteRows = false;
- this.dataGridView2.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.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.Color.White;
- this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
- this.dataGridView2.Location = new System.Drawing.Point(228, 13);
- this.dataGridView2.MultiSelect = false;
- this.dataGridView2.Name = "dataGridView2";
- this.dataGridView2.RowHeadersVisible = false;
- this.dataGridView2.RowTemplate.Height = 23;
- this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView2.Size = new System.Drawing.Size(719, 183);
- this.dataGridView2.TabIndex = 3;
- //
- // listView2
- //
- this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.listView2.HideSelection = false;
- this.listView2.Location = new System.Drawing.Point(16, 56);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(181, 140);
- this.listView2.TabIndex = 2;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
- //
- // button7
- //
- this.button7.Location = new System.Drawing.Point(145, 20);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(52, 26);
- this.button7.TabIndex = 1;
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(16, 20);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(93, 26);
- this.button6.TabIndex = 0;
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.btnDelRegion);
- this.groupBox4.Controls.Add(this.button13);
- this.groupBox4.Controls.Add(this.button12);
- this.groupBox4.Controls.Add(this.checkBox2);
- this.groupBox4.Controls.Add(this.button10);
- this.groupBox4.Controls.Add(this.button11);
- this.groupBox4.Location = new System.Drawing.Point(155, 159);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(353, 143);
- this.groupBox4.TabIndex = 10;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "颗粒编辑";
- //
- // btnDelRegion
- //
- this.btnDelRegion.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btnDelRegion.Location = new System.Drawing.Point(249, 32);
- this.btnDelRegion.Name = "btnDelRegion";
- this.btnDelRegion.Size = new System.Drawing.Size(84, 30);
- this.btnDelRegion.TabIndex = 25;
- this.btnDelRegion.Text = "区域删除";
- this.btnDelRegion.UseVisualStyleBackColor = true;
- this.btnDelRegion.Click += new System.EventHandler(this.DelRegionClick);
- //
- // button13
- //
- this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button13.Location = new System.Drawing.Point(145, 85);
- this.button13.Name = "button13";
- this.button13.Size = new System.Drawing.Size(84, 30);
- this.button13.TabIndex = 24;
- this.button13.Text = "应用";
- this.button13.UseVisualStyleBackColor = true;
- this.button13.Click += new System.EventHandler(this.ApplyClick);
- //
- // button12
- //
- this.button12.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button12.Location = new System.Drawing.Point(41, 85);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(84, 30);
- this.button12.TabIndex = 23;
- this.button12.Text = "撤销";
- this.button12.UseVisualStyleBackColor = true;
- this.button12.Click += new System.EventHandler(this.RedoClick);
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.Checked = true;
- this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox2.Location = new System.Drawing.Point(249, 93);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(48, 16);
- this.checkBox2.TabIndex = 22;
- this.checkBox2.Text = "连续";
- this.checkBox2.UseVisualStyleBackColor = true;
- //
- // groupBox6
- //
- this.groupBox6.Controls.Add(this.label2);
- this.groupBox6.Controls.Add(this.numericUpDown3);
- this.groupBox6.Controls.Add(this.checkBox6);
- this.groupBox6.Controls.Add(this.checkBox7);
- this.groupBox6.Location = new System.Drawing.Point(155, 308);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(353, 94);
- this.groupBox6.TabIndex = 11;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "阈值调整";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(188, 61);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(41, 12);
- this.label2.TabIndex = 3;
- this.label2.Text = "阈值:";
- //
- // numericUpDown3
- //
- this.numericUpDown3.Location = new System.Drawing.Point(238, 56);
- this.numericUpDown3.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.numericUpDown3.Name = "numericUpDown3";
- this.numericUpDown3.Size = new System.Drawing.Size(52, 21);
- this.numericUpDown3.TabIndex = 2;
- this.numericUpDown3.Value = new decimal(new int[] {
- 60,
- 0,
- 0,
- 0});
- this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
- //
- // checkBox6
- //
- this.checkBox6.AutoSize = true;
- this.checkBox6.Location = new System.Drawing.Point(41, 61);
- this.checkBox6.Name = "checkBox6";
- this.checkBox6.Size = new System.Drawing.Size(72, 16);
- this.checkBox6.TabIndex = 1;
- this.checkBox6.Text = "固定阈值";
- this.checkBox6.UseVisualStyleBackColor = true;
- this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
- //
- // checkBox7
- //
- this.checkBox7.AutoSize = true;
- this.checkBox7.Checked = true;
- this.checkBox7.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox7.Location = new System.Drawing.Point(41, 25);
- this.checkBox7.Name = "checkBox7";
- this.checkBox7.Size = new System.Drawing.Size(60, 16);
- this.checkBox7.TabIndex = 0;
- this.checkBox7.Text = "大津法";
- this.checkBox7.UseVisualStyleBackColor = true;
- this.checkBox7.CheckedChanged += new System.EventHandler(this.checkBox7_CheckedChanged);
- //
- // BearingSteelStripRatingDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1133, 881);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox9);
- this.Controls.Add(this.groupBox8);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Location = new System.Drawing.Point(0, 0);
- this.Name = "BearingSteelStripRatingDialog";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Dialog_FormClosing);
- this.Load += new System.EventHandler(this.MicrostructureBandDialog_Load);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox8, 0);
- this.Controls.SetChildIndex(this.groupBox9, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox5.ResumeLayout(false);
- this.groupBox5.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- this.groupBox8.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.groupBox9.ResumeLayout(false);
- this.groupBox9.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
- this.ResumeLayout(false);
- }
- private void BearingSteelStripRatingDialog_Load(object sender, EventArgs e)
- {
- this.binaryClass.loadParams();
- if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
- this.startScriptAutomaticAction();
- }
- /// <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;
- #region 0811新增
- this.documentWorkspace.panel.Paint += Panel_Paint;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.MouseUp += OnMouseUp;
- this.documentWorkspace.panel.MouseMove += onMouseMove;
- #endregion
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.NullTool;
- this.groupBox3.Controls.Add(documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.commonControlButtons.Visible = false;
- this.groupBox3.Controls.Add(commonControlButtons);
- //
- //颜色pane2给定初始值
- //
- this.panel2.BackColor = Color.Red;
- //
- //获取系统标尺-微米
- //
- this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Particlescreening.text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
- //binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- }
- /// <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;
- }
- /// <summary>
- /// 初始化表头
- /// </summary>
- private void InitGridHeader()
- {
- //
- //结果展示表
- //
- this.dataGridView1.ColumnHeadersHeight = 30;
- DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
- h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h1.Width = 60;
- DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn();
- h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h2.Width = 60;
- DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
- h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h3.Width = 60;
- DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn();
- h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h4.Width = 60;
- DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn();
- h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h5.Width = 60;
- DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn();
- h6.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h6.Width = 36;
- this.dataGridView1.Columns.Add(h1);
- this.dataGridView1.Columns.Add(h2);
- this.dataGridView1.Columns.Add(h3);
- this.dataGridView1.Columns.Add(h4);
- this.dataGridView1.Columns.Add(h5);
- this.dataGridView1.Columns.Add(h6);
- DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
- helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, "平均直径"));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, "最大直径"));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, "平均面积"));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, "最大面积"));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, "平均距离"));
- helper.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, "级别"));
- this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[0].ReadOnly = true;
- //this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
- this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[1].ReadOnly = true;
- //this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[2].ReadOnly = true;
- //this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[3].ReadOnly = true;
- //this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[4].ReadOnly = true;
- //this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView1.Columns[5].ReadOnly = false;
- //this.dataGridView1.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.AllowUserToResizeRows = false;
- this.dataGridView1.AllowUserToResizeColumns = false;
- //
- //分析结果表
- //
- this.dataGridView2.ColumnHeadersHeight = 30;
- DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn();
- //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h7.Width = 70;
- DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn();
- h8.Width = 90;
- DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn();
- //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h9.Width = 90;
- DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn();
- //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h10.Width = 90;
- DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn();
- //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h11.Width = 90;
- DataGridViewTextBoxColumn h12 = new DataGridViewTextBoxColumn();
- //h12.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h12.Width = 190;
- DataGridViewTextBoxColumn h13 = new DataGridViewTextBoxColumn();
- //h13.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
- h13.Width = 70;
- this.dataGridView2.Columns.Add(h7);
- this.dataGridView2.Columns.Add(h8);
- this.dataGridView2.Columns.Add(h9);
- this.dataGridView2.Columns.Add(h10);
- this.dataGridView2.Columns.Add(h11);
- this.dataGridView2.Columns.Add(h12);
- this.dataGridView2.Columns.Add(h13);
- DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2);
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, "图片"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, "平均直径/um"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, "最大直径/um"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, "平均面积/um²"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, "最大面积/um²"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, "颗粒间平均距离/um"));
- helper2.Headers.Add(new DataGridViewHelper.TopHeader(6, 1, "级别"));
- this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[0].ReadOnly = true;
- this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[1].ReadOnly = true;
- this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[2].ReadOnly = true;
- this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[3].ReadOnly = true;
- this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[4].ReadOnly = true;
- this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[5].ReadOnly = true;
- this.dataGridView2.Columns[6].SortMode = DataGridViewColumnSortMode.NotSortable;
- this.dataGridView2.Columns[6].ReadOnly = false;
- this.dataGridView2.AllowUserToResizeRows = false;
- this.dataGridView2.AllowUserToResizeColumns = false;
- //
- //左下表
- //
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.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);
- }
- //二值化集成3
- #region 二值化相关方法
- private void Dialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- binaryClass.saveParams();
- this.saveDialogParamValues();
- //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.eachData[GetImgKey()].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 MicrostructureBandDialog_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>
- //AppCommon appCommonDisplay = new AppCommon();
- //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 = false;
- // }
- // //ResetAreaAndContent();
- // ReloadDebrisSelection();
- // changeColor = false;
- // this.documentWorkspace.PhaseModels[0].choise = false;
- // }
- // else
- // {
- // this.documentWorkspace.PhaseModels[0].choise = false;
- // this.documentWorkspace.PhaseModels[1].choise = false;
- // appCommon.DisplayData(this.dataGridView1, 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;
- appCommon.DisplayData(this.dataGridView1, true);
- }
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.PhaseModels[1].choise = false;
- appCommon.DisplayData(this.dataGridView1, false);
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomOut();
- }
- private void zoomToWindowButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
- }
- private void actualSizeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
- this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
- }
- private void pointerButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- /// <summary>
- /// 设置按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.BearingSteelGBT18254");
- if (metallographicMethodSetDialog.hasModule)
- {
- metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
- metallographicMethodSetDialog.ShowDialog();
- }
- else
- {
- metallographicMethodSetDialog = null;
- }
- }
- DialogResult dr;
- /// <summary>
- /// 保存结果按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, 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 (!blSaveAll && item.Name.Equals(tag))
- {
- dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- break;
- }
- }
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Name.Equals(tag))
- {
- if (dr == DialogResult.OK || blSaveAll)
- {
- 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]);
- resultTableList.Insert(rowIndex, dtResult);
- }
- }
- }
- //新增
- 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;
- resultTableList.Insert(rowIndex, dtResult);
- }
- 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 processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- graphics.DrawImage(processedBit, new PointF(0, 0));
- 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.area.text"));
- columnName.Add(PdnResources.GetString("Menu.Maximumcaliperdiameter.text"));
- dataList.Add(columnName);
- 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.Nocarbidtosave.text"));
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text"));
- }
- }
- /// <summary>
- /// 刷新分析结果表
- /// </summary>
- private void RefreshDataGridView2()
- {
- dataGridView2.Rows.Clear();
- if (resultTableList.Count > 0)
- {
- if (this.showAll)
- {
- //dataGridView2.Rows.Clear();
- int i = 0;
- for (int k = 0; k < resultTableList.Count; k++)
- {
- dataGridView2.Rows.Add(resultTableList[k].Rows.Count);//增加同等数量的行数
- foreach (DataRow row in resultTableList[k].Rows)//逐个读取单元格的内容;
- {
- DataGridViewRow r1 = dataGridView2.Rows[i];
- r1.Cells[0].Value = row.RowState.ToString();
- for (int j = 0; j < resultTableList[k].Columns.Count; j++)
- {
- r1.Cells[j].Value = row[j].ToString();
- //r1.Cells[j].Value = row[j];
- }
- i++;
- }
- }
- }
- else
- {
- //dataGridView2.Rows.Clear();
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- int h = 0;
- 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))
- {
- dataGridView2.Rows.Add(dt.Rows.Count);//增加同等数量的行数
- foreach (DataRow row in dt.Rows)//逐个读取单元格的内容;
- {
- DataGridViewRow r1 = dataGridView2.Rows[h];
- r1.Cells[0].Value = row.RowState.ToString();
- for (int j = 0; j < dt.Columns.Count; j++)
- {
- r1.Cells[j].Value = row[j].ToString();
- }
- h++;
- }
- }
- }
- }
- }
- }
- //this.dataGridView3.Rows.Add(PdnResources.GetString("Menu.comprehensive.text"), PdnResources.GetString("Menu.Comprehensivaverage.text"), series, Math.Round(double.Parse(string.IsNullOrEmpty(avglstSize.ToString()) ? "0" : avglstSize.ToString()), Convert.ToInt32(this.numericUpDown1.Value)), avgLevel);
- }
- }
- /// <summary>
- /// 全部显示按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_Click(object sender, EventArgs e)
- {
- if (this.button6.Text == PdnResources.GetString("Menu.Showall.text"))
- {
- this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.showAll = true;
- RefreshDataGridView2();
- }
- else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
- {
- this.button6.Text = PdnResources.GetString("Menu.Showall.text");
- this.showAll = false;
- RefreshDataGridView2();
- }
- }
- /// <summary>
- /// 删除结果图片按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_Click(object sender, 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 (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals(tableName))
- {
- this.tempDataModel.Remove(model);
- break;
- }
- }
- }
- 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 button8_Click(object sender, EventArgs e)
- {
- if (dataGridView2.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
- return;
- }
- if (this.checkBox1.Checked)
- this.button1.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.savePath))
- //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("图片");
- contentHead.Add("平均直径/um");
- contentHead.Add("最大直径/um");
- contentHead.Add("平均面积/um²");
- contentHead.Add("最大面积/um²");
- contentHead.Add("颗粒间平均距离/um");
- contentHead.Add("级别");
- 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());
- content.Add(item.Cells[2].Value.ToString());
- content.Add(item.Cells[3].Value.ToString());
- content.Add(item.Cells[4].Value.ToString());
- content.Add(item.Cells[5].Value.ToString());
- content.Add(item.Cells[6].Value.ToString());
- analysisContent.Add(content);
- }
- analysisContent.Add(new List<string>() { "\r" });
- //图片
- 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.CreateAnalysisReportBearingSteal(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 button9_Click(object sender, EventArgs e)
- {
- if (this.dataGridView2.Rows.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 = "高碳铬轴承钢带状500倍" + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
- DialogResult dr = exe.ShowDialog();
- if (dr != DialogResult.OK)
- return;
- DataTable dtb = new DataTable();
- dtb.Columns.Add("图片");
- dtb.Columns.Add("平均直径/um");
- dtb.Columns.Add("最大直径/um");
- dtb.Columns.Add("平均面积/um²");
- dtb.Columns.Add("最大面积/um²");
- dtb.Columns.Add("颗粒间平均距离/um");
- dtb.Columns.Add("级别");
- for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
- {
- DataRow dataRow = dtb.NewRow();
- dataRow["图片"] = this.dataGridView2.Rows[i].Cells[0].Value;
- dataRow["平均直径/um"] = this.dataGridView2.Rows[i].Cells[1].Value;
- dataRow["最大直径/um"] = this.dataGridView2.Rows[i].Cells[2].Value;
- dataRow["平均面积/um²"] = this.dataGridView2.Rows[i].Cells[3].Value;
- dataRow["最大面积/um²"] = this.dataGridView2.Rows[i].Cells[4].Value;
- dataRow["颗粒间平均距离/um"] = this.dataGridView2.Rows[i].Cells[5].Value;
- dataRow["级别"] = this.dataGridView2.Rows[i].Cells[6].Value;
- dtb.Rows.Add(dataRow);
- }
- DataTable dtb1 = new DataTable();
- dtb1.Columns.Add("图片");
- dtb1.Columns.Add("平均直径/um");
- dtb1.Columns.Add("最大直径/um");
- dtb1.Columns.Add("平均面积/um²");
- dtb1.Columns.Add("最大面积/um²");
- dtb1.Columns.Add("颗粒间平均距离/um");
- dtb1.Columns.Add("级别");
- List<DataTable> list = new List<DataTable>();
- list.Add(dtb);
- list.Add(dtb1);
- this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
- }
- /// <summary>
- /// 图像索引切换选中事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //int sum;//判断是否二值过
- 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);
- GetListParamModel();
- //sum = 0;
- this.dataGridView1.Rows.Clear();
- if (this.documentWorkspace.PhaseModels.Count > 1)
- this.documentWorkspace.PhaseModels.Remove(this.documentWorkspace.PhaseModels[1]);
- this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- //二值化集成5
- binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.imageMat.Clone(), this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]);
- //Document document = Document.FromImageMat(imageMat/* //待测试.Clone()*/);
- //this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- this.commonControlButtons.Visible = true;
- changeColor = false;
- isFirstSwitch = false;
- #region 0811修改
- GetPoints(imageMat);
- #endregion
- ReloadDebrisSelection();
- }
- }
- /// <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 numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- if (this.numericUpDown1.Value > this.numericUpDown1.Maximum)
- this.numericUpDown1.Value = this.numericUpDown1.Maximum;
- if (this.numericUpDown1.Value < this.numericUpDown1.Minimum)
- this.numericUpDown1.Value = this.numericUpDown1.Minimum;
- RefreshDataGridView1();
- RefreshDataGridView2();
- }
- private void checkBox4_CheckedChanged(object sender, EventArgs e)
- {
- if (this.checkBox4.Checked == true)
- {
- this.checkBox3.Checked = false;
- this.label1.Visible = false;
- this.numericUpDown2.Visible = false;
- rate = 0.0;
- }
- if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
- return;
- ReloadDebrisSelection();
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 是否筛选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox3_CheckedChanged(object sender, EventArgs e)
- {
- if (this.checkBox3.Checked == true)
- {
- this.checkBox4.Checked = false;
- this.label1.Visible = true;
- this.numericUpDown2.Visible = true;
- rate = (double)numericUpDown2.Value;
- }
- if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
- return;
- ReloadDebrisSelection();
- this.documentWorkspace.Refresh();
- }
- /// <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)
- {
- 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())
- // {
- // ReloadDebrisSelection();
- // }
- // else
- // {
- // this.documentWorkspace.PhaseModels[0].mat = null;
- // //phaseModel.choise = false;
- // isFirstSwitch = false;
- // this.dataGridView1.Rows.Clear();
- // }
- // this.documentWorkspace.Refresh();
- //}
- DataTable dtDataGridView1 = null;
- DataTable dtResult = null;
- AppCommon appCommon = new AppCommon();
- /// <summary>
- /// 刷新颗粒筛选效果
- /// </summary>
- private void ReloadDebrisSelection()
- {
- if (this.documentWorkspace != null || this.documentWorkspace.PhaseModels[0].mat != null)
- {
- this.dataGridView1.Rows.Clear();
- dtDataGridView1 = new DataTable();
- Mat temp = new Mat();//中间变量
- Mat resultImg = imageMat.Clone();//DLL处理后得结果
- //DLL部分处理
- BearingSteelProcessor CP = new BearingSteelProcessor();
- #region 0811修改
- if (AllFields.Length < 1)
- {
- return;
- }
- CP.clear();
- foreach (var cnt in AllFields)
- {
- CP.addParticle(cnt);
- }
- #endregion
- CP.draw(rate,unitLength);
- double distance = (double)Math.Round(CP.getAllDistance() * 100) / 100;
- double avgarea = (double)Math.Round(CP.getAvgArea() * 100) / 100;
- double maxarea = (double)Math.Round(CP.getMaxArea() * 100) / 100;
- double avgdim = (double)Math.Round(CP.getAvgDim() * 100) / 100;
- double maxdim = (double)Math.Round(CP.getMaxDim() * 100) / 100;
- double level = (double)Math.Round(CP.getLevel() * 100) / 100;
- this.dataGridView1.Rows.Add(avgdim, maxdim, avgarea, maxarea, distance, level);
- List<IEnumerable<OpenCvSharp.Point>> particles = new List<IEnumerable<OpenCvSharp.Point>>();
- IEnumerable<OpenCvSharp.Point> Contour;
- for (int i = 0; i < CP.getParticleCount(); i++)
- {
- Contour = CP.getParticleContour(i);
- particles.Add(Contour);
- }
- AllFieldsTemp.Clear();
- AllFieldsTemp.AddRange(particles);
- Cv2.DrawContours(resultImg, particles, -1, new Scalar(0, 0, 255, 255), -1);
- //防止结果图为RGB,进行转换,转换成RGBA
- Mat resultImg_a = new Mat();
- Cv2.CvtColor(resultImg, resultImg_a, ColorConversionCodes.BGR2BGRA);
- this.documentWorkspace.PhaseModels[0].mat = resultImg;
- this.documentWorkspace.PhaseModels[0].choise = true;
- resultMat = resultImg_a;
- this.documentWorkspace.Refresh();
- //数据结果保存
- dtDataGridView1 = appCommon.ResultDataSaving(dataGridView1);
- string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
- string tag = this.imageList1.Images.Keys[this.listView1.FocusedItem.Index];
- //分析数据保存
- dtResult = appCommon.AnalysisDataSaving(dataGridView1, imgName, tag);
- if (dtDataGridView1.Rows.Count > 0)
- {
- RefreshDataGridView1();
- }
- if (bcOriginChecked())
- {
- appCommon.DisplayData(this.dataGridView1, false);
- }
- }
- }
- /// <summary>
- /// 有效颗粒筛选-默认是碳化物面积占外接圆得30%
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown2_ValueChanged(object sender, EventArgs e)
- {
- rate = (double)this.numericUpDown2.Value;
- if (this.checkBox3.Checked )
- ReloadDebrisSelection();
- }
- /// <summary>
- /// 导出项目到项目工程
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- try
- {
- if (dataGridView2.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!");
- return;
- }
- if (this.analyzeSettingModel == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- return;
- }
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.HighSpeedSteelCarbonBlock.Text", this.analyzeSettingModel.savePath);
- if (item != null)
- {
- //向文件夹内保存图片和报告
- if (!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.picture.Text"));
- contentHead.Add(PdnResources.GetString("Menu.view.text"));
- contentHead.Add(PdnResources.GetString("Menu.Highspeedtoolsteelcategory.text"));
- contentHead.Add(PdnResources.GetString("Menu.sizeed.text"));
- contentHead.Add(PdnResources.GetString("Menu.levdel.Text"));
- analysisContent.Add(contentHead);
- foreach (DataGridViewRow rowItem in this.dataGridView2.Rows)
- {
- List<string> content = new List<string>();
- content.Add(rowItem.Cells[0].Value.ToString());
- content.Add(rowItem.Cells[1].Value.ToString());
- content.Add(rowItem.Cells[2].Value.ToString());
- content.Add(rowItem.Cells[3].Value.ToString());
- content.Add(rowItem.Cells[4].Value.ToString());
- analysisContent.Add(content);
- }
- analysisContent.Add(new List<string>() { "\r" });
- //图片
- 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 rowItem in this.listView2.SelectedItems)
- {
- if (bitDic.ContainsKey(rowItem.Name))
- {
- bitList.Add(bitDic[rowItem.Name][0]);
- bitList.Add(bitDic[rowItem.Name][1]);
- }
- }
- }
- }
- //中间数据
- if (!this.showAll)
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- foreach (ListViewItem rowItem in this.listView2.SelectedItems)
- {
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals(rowItem.Name))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code);
- }
- }
- else
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code);
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
- return;
- }
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
- }
- }
- catch (Exception)
- {
- }
- }
- #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;
- if (!this.eachData.ContainsKey(GetImgKey()))
- {
- 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();
- analysisItem.ListParam = new List<GrainSizeAnalysisModel>();
- analysisItem.ListParam.Add(analysisItem);
- this.eachData.Add(GetImgKey(), analysisItem);
- }
- foreach (var item in this.eachData[GetImgKey()].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.eachData[GetImgKey()].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)PaintDotNet.Base.Dtryt.Boolean);//筛选
- //saveParamValue(ParamKey_ScreenMin, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最小值
- //saveParamValue(ParamKey_ScreenMax, numericUpDown5 != null ? numericUpDown5.Value.ToString() : "", (int)PaintDotNet.Base.Dtryt.Decimal);//面积最大值
- saveParamValue(ParamKey_MaxColour, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//最大色
- saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数
- }
- /// <summary>
- /// 获取保存的参数
- /// </summary>
- private void GetListParamModel()
- {
- if (this.eachData.ContainsKey(GetImgKey()) && this.eachData[GetImgKey()] != null)
- {
- for (int i = 0; i < this.eachData[GetImgKey()].ListParam.Count; i++)
- {
- switch (this.eachData[GetImgKey()].ListParam[i].param_key)
- {
- case ParamKey_Report:
- checkBox1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
- break;
- case ParamKey_Screen:
- checkBox3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value;
- break;
- case ParamKey_ScreenMin:
- areaMin = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
- break;
- case ParamKey_ScreenMax:
- areaMax = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
- break;
- case ParamKey_MaxColour:
- panel2.BackColor = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value);
- break;
- case ParamKey_DecimalPlace:
- numericUpDown1.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value);
- break;
- }
- }
- }
- }
- /// <summary>
- /// 获取XML保存的参数
- /// </summary>
- private void GetXmlParameter()
- {
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
- GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- if (this.eachData.ContainsKey(listView1.Items[i].Index.ToString()))
- {
- this.eachData[listView1.Items[i].Index.ToString()] = analysisModelXml.cloneListParamModel(this.menuId);
- }
- else
- {
- this.eachData.Add(listView1.Items[i].Index.ToString(), analysisModelXml.cloneListParamModel(this.menuId));
- }
- }
- foreach (var item in this.eachData[GetImgKey()].ListParam)
- item.setValue();
- }
- /// <summary>
- /// 保存参数,防止没有图片
- /// </summary>
- private void NullKey()
- {
- GrainSizeAnalysisModel grainsizeanalysismodel = new GrainSizeAnalysisModel();
- grainsizeanalysismodel.ListParam = new List<GrainSizeAnalysisModel>();
- this.eachData.Add("null", grainsizeanalysismodel);
- }
- private string GetImgKey()
- {
- string key = this.listView1.FocusedItem != null ? this.listView1.FocusedItem.Index.ToString() : "null";
- return key;
- }
- #endregion
- //按钮-应用全部
- private void button5_Click(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null)
- {
- return;
- }
- binaryClass.saveParams();
- binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[int.Parse(GetImgKey())]);
- saveDialogParamValues();
- GrainSizeAnalysisModel data = new GrainSizeAnalysisModel();
- if (eachData.ContainsKey(GetImgKey()))
- {
- data = eachData[GetImgKey()];
- }
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- eachData[i.ToString()] = data.cloneListParamModel(this.menuId);
- this.listView1.EnsureVisible(i);
- this.listView1.Items[i].Focused = true;
- this.listView1.Items[i].Selected = true;
- }
- }
- private bool blSaveAll = false;
- //按钮-保存全部
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem == null)
- {
- return;
- }
- if (eachData.Count - 1 != listView1.Items.Count)
- {
- MessageBox.Show("请先点击应用全部!");
- return;
- }
- saveDialogParamValues();
- int current = int.Parse(GetImgKey());
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- this.listView1.EnsureVisible(i);
- this.listView1.Items[i].Focused = true;
- this.listView1.Items[i].Selected = true;
- this.button2.PerformClick();
- blSaveAll = true;
- }
- this.listView1.EnsureVisible(current);
- this.listView1.Items[current].Focused = true;
- this.listView1.Items[current].Selected = true;
- blSaveAll = false;
- }
- private void listView1_MouseDown(object sender, MouseEventArgs e)
- {
- if (this.listView1.FocusedItem != null)
- saveDialogParamValues();
- }
- #region [脚本相关]
- private void getValue(string key, object value)
- {
- switch (key)
- {
- //是否筛选
- case "parameter1":
- checkBox3.Checked = Convert.ToBoolean(value);
- break;
- case "parameter5":
- int val1 = (int)value;
- break;
- case "parameter6":
- int val2 = (int)value;
- panel2.BackColor = Color.FromArgb(val2);
- break;
- case "OpenWhileExportReport":
- checkBox1.Checked = Convert.ToBoolean(value);
- break;
- case "CalculatorDecimalDigits":
- numericUpDown1.Value = Convert.ToDecimal(value);
- break;
- case "ExportResults":
- isExportResults = Convert.ToBoolean(value);
- break;
- case "ExportReports":
- isExportReports = Convert.ToBoolean(value);
- break;
- case "ExportProjects":
- isExportProjects = Convert.ToBoolean(value);
- break;
- }
- }
- private void startScriptAutomaticAction()
- {
- this.button5.PerformClick();
- this.button4.PerformClick();
- this.button6.Text = "全部显示";
- this.showAll = true;
- RefreshDataGridView2();
- if (isExportResults)//导出结果
- this.button8.PerformClick();
- if (isExportReports)//生成报告
- this.button9.PerformClick();
- if (isExportProjects)//导出项目
- this.button3.PerformClick();
- this.appWorkspace.ScriptAutomatic = false;
- this.Close();
- }
- #endregion
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- //找出二值相关参数 进行赋值
- List<Args> isNullList = args.Where(m => m.value == null).ToList();
- foreach (var item in isNullList)
- {
- item.value = binaryClass.setScriptRecording(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "parameter1":
- value = checkBox3.Checked;
- break;
- //case "parameter2":
- // value = trackBar2.Value;
- // break;
- //case "parameter3":
- // value = trackBar4.Value;
- // break;
- case "parameter6":
- value = panel2.BackColor.ToArgb();
- break;
- case "OpenWhileExportReport":
- value = checkBox1.Checked;
- break;
- case "CalculatorDecimalDigits":
- value = numericUpDown1.Value;
- break;
- case "ExportResults":
- value = isExportResults;
- break;
- case "ExportReports":
- value = isExportReports;
- break;
- case "ExportProjects":
- value = isExportProjects;
- break;
- }
- return value;
- }
- #endregion
- /// <summary>
- /// 刷新数据展示表
- /// </summary>
- private void RefreshDataGridView1()
- {
- this.dataGridView1.Rows.Clear();
- if (dtDataGridView1 != null && dtDataGridView1.Rows.Count > 0)
- {
- dataGridView1.Rows.Add(dtDataGridView1.Rows.Count);//增加同等数量的行数
- int i = 0;
- foreach (DataRow row in dtDataGridView1.Rows)//逐个读取单元格的内容;
- {
- DataGridViewRow r1 = dataGridView1.Rows[i];
- r1.Cells[0].Value = row.RowState.ToString();
- for (int j = 0; j < dtDataGridView1.Columns.Count; j++)
- {
- r1.Cells[j].Value = row[j].ToString();
- }
- i++;
- }
- }
- }
- #region 颗粒编辑0811新增,1021新增区域删除
- #region 图像绘制与刷新
- /// <summary>
- /// 预览刷新
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Panel_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
- {
- //
- // 以下是计算绘制图片的位置和大小并绘制图片
- //
- 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.DrawLines(new Pen(this.panel1.BackColor, Convert.ToInt32(this.txt_LeftLineWeight.Text)), list.ToArray());
- 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 addPen = new Pen(Color.FromArgb(0, 0, 255), 2);//添加颗粒画笔
- Pen delPen = new Pen(Color.FromArgb(0, 255, 0), 2);//删除颗粒画笔
- //画已经添加颗粒
- if (addPointsList.Count > 0)
- {
- for (int i = 0; i < addPointsList.Count; i++)
- {
- graphics.DrawLines(addPen, addPointsList[i].ToArray());
- }
- }
- if (delPointsList.Count > 0)
- {
- for (int i = 0; i < delPointsList.Count; i++)
- {
- graphics.DrawLines(delPen, delPointsList[i].ToArray());
- }
- }
- if (star != null && end != null && star != end)
- {
- Rectangle rectangle = CreatRectangle(star, end);
- graphics.DrawRectangle(delPen, rectangle);
- }
- if (delRegionPointsList.Count > 0)
- {
- foreach (var item in delRegionPointsList)
- {
- if (item.Count > 0)
- {
- for (int i = 0; i < item.Count; i++)
- {
- if (item[i].Count > 2)
- graphics.DrawLines(delPen, item[i].ToArray());
- }
- }
- }
- }
- //画正在添加颗粒
- if (addPoints.Count > 0)
- {
- graphics.DrawLines(addPen, addPoints.ToArray());
- }
- addPen.Dispose();
- delPen.Dispose();
- }
- //获取矩形
- private Rectangle CreatRectangle(PointF p1, PointF p2)
- {
- Rectangle rectangleF = new Rectangle();
- if (p1.X > p2.X)
- rectangleF.X = (int)p2.X;
- else
- rectangleF.X = (int)p1.X;
- if (p1.Y > p2.Y)
- rectangleF.Y = (int)p2.Y;
- else
- rectangleF.Y = (int)p1.Y;
- rectangleF.Width = (int)Math.Abs(p2.X - p1.X);
- rectangleF.Height = (int)Math.Abs(p2.Y - p1.Y);
- return new Rectangle(rectangleF.X, rectangleF.Y, rectangleF.Width, rectangleF.Height);
- }
- #endregion
- #region 鼠标事件
- /// <summary>
- /// 移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void onMouseMove(object sender, MouseEventArgs e)
- {
- PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location);
- if (e.Button == MouseButtons.Left)
- {
- switch (DrawType)
- {
- case 1:
- addPoints.Add(movePoint);
- break;
- case 2:
- break;
- case 3:
- end = movePoint;
- break;
- }
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void OnMouseUp(object sender, MouseEventArgs e)
- {
- PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
- if (e.Button == MouseButtons.Left)
- {
- switch (DrawType)
- {
- case 1:
- if (addPoints.Count > 3)
- {
- List<PointF> points = new List<PointF>();
- points.AddRange(addPoints);
- addPointsList.Add(points);
- HisOperate.Add(1);
- }
- addPoints.Clear();
- if (!checkBox2.Checked)
- DrawType = 0;
- break;
- case 3:
- if (star != end)
- {
- DelRegionPoints();
- HisOperate.Add(3);
- star = new PointF();
- end = new PointF();
- }
- if (!checkBox2.Checked)
- DrawType = 0;
- break;
- }
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- private void OnMouseDown(object sender, MouseEventArgs e)
- {
- //禁止画黑色矩形
- this.documentWorkspace.DrawRectangleFlag = false;
- PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location);
- if (e.Button == MouseButtons.Left)
- {
- switch (DrawType)
- {
- case 1:
- addPoints.Add(downPoint);
- break;
- case 2:
- DelPoints(downPoint);
- if (!checkBox2.Checked)
- DrawType = 0;
- break;
- case 3:
- star = end = downPoint;
- break;
- }
- }
- }
- #endregion
- #region 按钮事件
- /// <summary>
- /// 添加按钮
- /// </summary>
- private void AddClick(object sender, EventArgs e)
- {
- DrawType = 1;
- }
- /// <summary>
- /// 删除按钮
- /// </summary>
- private void DelClick(object sender, EventArgs e)
- {
- DrawType = 2;
- }
- /// <summary>
- /// 撤销按钮
- /// </summary>
- private void RedoClick(object sender, EventArgs e)
- {
- if (HisOperate.Count > 0)
- {
- int op = HisOperate.Last();
- switch (op)
- {
- case 1:
- addPointsList.RemoveAt(addPointsList.Count - 1);
- break;
- case 2:
- delPointsList.RemoveAt(delPointsList.Count - 1);
- break;
- case 3:
- delRegionPointsList.RemoveAt(delRegionPointsList.Count - 1);
- break;
- }
- HisOperate.RemoveAt(HisOperate.Count - 1);
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 应用按钮
- /// </summary>
- private void ApplyClick(object sender, EventArgs e)
- {
- if (addPointsList.Count > 0)
- {
- List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
- foreach (var item in addPointsList)
- {
- List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
- item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
- points.Add(plistAdd);
- }
- currentMat.DrawContours(points, -1, new Scalar(255), -1);
- addPointsList.Clear();
- }
- if (delPointsList.Count > 0)
- {
- List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
- foreach (var item in delPointsList)
- {
- List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
- item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
- points.Add(plistAdd);
- }
- currentMat.DrawContours(points, -1, new Scalar(0), -1);
- delPointsList.Clear();
- }
- if (delRegionPointsList.Count > 0)
- {
- List<List<OpenCvSharp.Point>> points = new List<List<OpenCvSharp.Point>>();
- for (int i = 0; i < delRegionPointsList.Count; i++)
- {
- foreach (var item in delRegionPointsList[i])
- {
- List<OpenCvSharp.Point> plistAdd = new List<OpenCvSharp.Point>();
- item.ForEach(p => plistAdd.Add(new OpenCvSharp.Point((int)p.X, (int)p.Y)));
- points.Add(plistAdd);
- }
- }
- currentMat.DrawContours(points, -1, new Scalar(0), -1);
- delRegionPointsList.Clear();
- }
- HisOperate.Clear();
- DrawType = 0;
- GetPoints(currentMat);
- ReloadDebrisSelection();
- }
- /// <summary>
- /// 区域删除按钮
- /// </summary>
- private void DelRegionClick(object sender, EventArgs e)
- {
- DrawType = 3;
- }
- #endregion
- #region 图形处理
- /// <summary>
- /// 获取图像所有轮廓
- /// </summary>
- /// <param name="source"></param>
- private unsafe void GetPoints(Mat source)
- {
- Mat srcGray;
- if (source.Type() == MatType.CV_8UC1)
- {
- srcGray = source;
- }
- else
- {
- srcGray = source.CvtColor(ColorConversionCodes.BGR2GRAY);
- //修改-20221114
- if (binaryValue == -1)
- {
- Cv2.Threshold(srcGray, srcGray, 0, 255, ThresholdTypes.Otsu);
- }
- else
- {
- Cv2.Threshold(srcGray, srcGray, binaryValue, 255, ThresholdTypes.Binary);
- }
- }
- currentMat = srcGray.Clone();
- OpenCvSharp.Point[][] contours = new OpenCvSharp.Point[][] { };
- HierarchyIndex[] hierarchyIndex = new HierarchyIndex[] { };
- //轮廓
- Cv2.FindContours(srcGray, out contours, out hierarchyIndex, RetrievalModes.External, ContourApproximationModes.ApproxNone);
- AllFields = contours;
- }
- private void DelPoints(PointF pointF)
- {
- OpenCvSharp.Point2f p1 = new OpenCvSharp.Point2f(pointF.X, pointF.Y);
- bool del = false;
- for (int i = 0; i < AllFields.Count(); i++)
- {
- double d = Cv2.PointPolygonTest(AllFields[i], p1, false);
- if (d >= 0)
- {
- List<PointF> pointFs = new List<PointF>();
- AllFields[i].ToList().ForEach(p => pointFs.Add(new PointF(p.X, p.Y)));
- delPointsList.Add(pointFs);
- del = true;
- break;
- }
- }
- if (del)
- {
- HisOperate.Add(2);
- this.documentWorkspace.Refresh();
- }
- }
- private void DelRegionPoints()
- {
- List<List<PointF>> delList = new List<List<PointF>>();
- for (int i = 0; i < AllFieldsTemp.Count(); i++)
- {
- for (int j = 0; j < AllFieldsTemp[i].Count(); j++)
- {
- OpenCvSharp.Point point = AllFieldsTemp[i].ElementAt(j);
- if (point.X >= star.X && point.X <= end.X && point.Y >= star.Y && point.Y <= end.Y)
- {
- List<PointF> pointFs = new List<PointF>();
- AllFieldsTemp[i].ToList().ForEach(p => pointFs.Add(new PointF(p.X, p.Y)));
- delList.Add(pointFs);
- break;
- }
- }
- }
- delRegionPointsList.Add(delList);
- this.documentWorkspace.Refresh();
- }
- #endregion
- #endregion
- private void checkBox5_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBox5.Checked == true)
- {
- this.documentWorkspace.PhaseModels[0].mat = imageMat;
- this.documentWorkspace.PhaseModels[0].choise = true;
- this.documentWorkspace.Refresh();
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].mat = resultMat;
- this.documentWorkspace.PhaseModels[0].choise = true;
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 20221114-添加二值阈值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox7_CheckedChanged(object sender, EventArgs e)
- {
- if (this.checkBox7.Checked == true)
- {
- this.checkBox7.Checked = true;
- this.checkBox6.Checked = false;
- this.label2.Visible = false;
- this.numericUpDown3.Visible = false;
- binaryValue = -1;
- }
- if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
- return;
- GetPoints(imageMat);
- ReloadDebrisSelection();
- this.documentWorkspace.Refresh();
- }
- private void checkBox6_CheckedChanged(object sender, EventArgs e)
- {
- if (this.checkBox6.Checked == true)
- {
- this.checkBox6.Checked = true;
- this.label2.Visible = true;
- this.numericUpDown3.Visible = true;
- binaryValue = (int)numericUpDown3.Value;
- this.checkBox7.Checked = false;
- }
- if (this.documentWorkspace == null || this.documentWorkspace.CompositionSurface == null)
- return;
- GetPoints(imageMat);
- ReloadDebrisSelection();
- this.documentWorkspace.Refresh();
- }
- private void numericUpDown3_ValueChanged(object sender, EventArgs e)
- {
- binaryValue = (int)numericUpDown3.Value;
- if (this.checkBox6.Checked )
- {
- GetPoints(imageMat);
- ReloadDebrisSelection();
- }
-
- }
- }
- public class BearingSteelProcessor
- {
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern IntPtr createBearingSteelProcessor();
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void run(IntPtr pClassObject, IntPtr img, double rate, bool isFillHole,double unitlength);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void draw(IntPtr pClassObject, double rate,double unitlength);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern int getParticleCount(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern int getParticleId(IntPtr pClassObject, int idx);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getParticleArea(IntPtr pClassObject, int idx);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getParticleFeretmax(IntPtr pClassObject, int idx);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getParticleFeretmin(IntPtr pClassObject, int idx);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void getParticleContour(IntPtr pClassObject, IntPtr Contour, int idx);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void addParticle(IntPtr pClassObject, IntPtr Contour);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getAllDistance(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getAvgArea(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getMaxArea(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getAvgDim(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getMaxDim(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern double getLevel(IntPtr pClassObject);
- [DllImport("BearingSteelDLL.dll", CallingConvention = CallingConvention.Cdecl)]
- private static extern void clear(IntPtr pClassObject);
- private IntPtr p_Object;
- public BearingSteelProcessor()
- {
- this.p_Object = createBearingSteelProcessor();
- }
- /// <summary>
- /// 颗粒检测
- /// </summary>
- public void run(Mat img, double rate, bool isFillHole,double unitlength)
- {
- run(this.p_Object, img.CvPtr, rate, isFillHole, unitlength);
- }
- public void draw(double rate, double unitlength)
- {
- draw(this.p_Object, rate, unitlength);
- }
- public int getParticleCount()
- {
- return getParticleCount(this.p_Object);
- }
- public int getParticleId(int idx)
- {
- return getParticleId(this.p_Object, idx);
- }
- public double getParticleArea(int idx)
- {
- return getParticleArea(this.p_Object, idx);
- }
- public double getParticleFeretmax(int idx)
- {
- return getParticleFeretmax(this.p_Object, idx);
- }
- public double getParticleFeretmin(int idx)
- {
- return getParticleFeretmin(this.p_Object, idx);
- }
- public double getAllDistance()
- {
- return getAllDistance(this.p_Object);
- }
- public double getAvgArea()
- {
- return getAvgArea(this.p_Object);
- }
- public double getMaxArea()
- {
- return getMaxArea(this.p_Object);
- }
- public double getAvgDim()
- {
- return getAvgDim(this.p_Object);
- }
- public double getMaxDim()
- {
- return getMaxDim(this.p_Object);
- }
- public double getLevel()
- {
- return getLevel(this.p_Object);
- }
- public void clear()
- {
- clear(this.p_Object);
- }
- public IEnumerable<OpenCvSharp.Point> getParticleContour(int idx)
- {
- var Contour = new VectorOfPoint();
- getParticleContour(this.p_Object, Contour.CvPtr, idx);
- return Contour.ToArray().AsEnumerable();
- }
- public IEnumerable<IEnumerable<OpenCvSharp.Point>> getParticles()
- {
- IEnumerable<IEnumerable<OpenCvSharp.Point>> particles = new List<IEnumerable<OpenCvSharp.Point>>();
- for (int i = 0; i < getParticleCount(); i++)
- {
- IEnumerable<OpenCvSharp.Point> Contour;
- Contour = getParticleContour(i);
- particles.Append(Contour);
- }
- return particles;
- }
- public void addParticle(IEnumerable<OpenCvSharp.Point> cnts)
- {
- var contour = new VectorOfPoint(cnts);
- addParticle(this.p_Object, contour.CvPtr);
- }
- public void addParticle(OpenCvSharp.Point[] cnts)
- {
- var contour = new VectorOfPoint(cnts);
- addParticle(this.p_Object, contour.CvPtr);
- }
- }
- }
|