| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868 |
- using OpenCvSharp;
- using PaintDotNet.Base.CommTool;
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.DedicatedAnalysis.GrainSize.GBT6394_2017;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Windows.Forms;
- using Point = System.Drawing.Point;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.Base.Enum;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.CustomControl;
- using Application = System.Windows.Forms.Application;
- using GroupBox = System.Windows.Forms.GroupBox;
- using CheckBox = System.Windows.Forms.CheckBox;
- using Button = System.Windows.Forms.Button;
- using Label = System.Windows.Forms.Label;
- using TextBox = System.Windows.Forms.TextBox;
- using System.Data;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Annotation;
- namespace PaintDotNet.DedicatedAnalysis.GrainSize
- {
- internal class GrainSizeCutOffPointMethodDialog : PdnBaseForm
- {
- /// <summary>
- /// 晶粒度(截点法)
- /// </summary>
- #region 控件
- private GroupBox groupBox1;
- private Button button2;
- private CheckBox checkBox2_0;
- private GroupBox groupBox2;
- private ListView listView1;
- private Button button10;
- private Button button9;
- private GroupBox groupBox8;
- private NumericUpDown numericUpDown1_0;
- private Button button16;
- private Label label5;
- private Button button14;
- private Button button13;
- private DataGridView dataGridView2;
- private Button button12;
- private Button button11;
- private Label label4;
- private Label label3;
- private GroupBox groupBox7;
- private GroupBox groupBox3;
- private GroupBox groupBox10;
- private GroupBox groupBox11;
- private ComboBox comboBox1;
- private Button button6_0;
- private Button button8;
- private Button button7_0;
- private CheckBox checkBox5_0;
- private CheckBox checkBox4_0;
- private CheckBox checkBox3_0;
- private ImageList imageList1;
- private IContainer components;
- private Button button1;
- #endregion
- /// <summary>
- /// 主控件
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 0,GBT6394; 1,GBT4335; 2,GBT24177; 3,E112; 4,ISO643
- /// </summary>
- int gbtType;
- #region 生成报告相关
- //1013###19377 刘虎--晶粒度--结果位置增加平均截距的显示,修改网格长度为实际长度
- //分析结果列表的头标题
- /// <summary>
- /// PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text")
- /// </summary>
- List<string> contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text") };
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- private List<Bitmap> bitList;
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- /// <summary>
- /// 中间数据
- /// </summary>
- private List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
- #endregion
- //截点样式集成
- GrainPointStyleClass styleClass = new GrainPointStyleClass();
- //辅助线集成
- GrainSizeGuideClass guideClass = new GrainSizeGuideClass();
- /// <summary>
- /// 图形位置
- /// </summary>
- private PointF loctation;
- //二值化集成1
- BinaryClass binaryClass;
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsFormGrid;
- /// <summary>
- /// 选中图片的bitmap
- /// </summary>
- private Bitmap bitmap;
- private DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 图形上所有的点
- /// </summary>
- private List<PointF> linePointList = new List<PointF>();
- /// <summary>
- /// 是否选择了图片
- /// </summary>
- private bool selectPicture = false;
- /// <summary>
- /// 存在视场标记
- /// </summary>
- private bool existViewFlag = false;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- private Mat matOrg;
- /// <summary>
- /// 分析结果暂存
- /// </summary>
- private List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 全部显示
- /// </summary>
- private bool allShow = false;
- private PointF m_StartPoint = Point.Empty;
- private bool m_canMove;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn Column6;
- private ListView listView2;
- private GroupBox groupBox4;
- private CheckBox grainBoundryCheckBox;
- private ComboBox comboBox2;
- private Label label1;
- private ComboBox comboBox3;
- private Label label6;
- private Label label7;
- private TextBox textBox6;
- private CheckBox checkBox2;
- private Label label8;
- private NumericUpDown numericUpDown2;
- private NumericUpDown numericUpDown1;
- private Button button3;
- private Panel panel1;
- private Button button5;
- private BinaryControl bc;
- public bool comboboxChange = true;
- /// <summary>
- ///
- /// </summary>
- /// <param name="appWorkspace"></param>
- /// <param name="gbtType">0,GBT6394; 1,GBT4335; 2,GBT24177; 3,E112; 4,ISO643;5,YST347(XX)</param>
- public GrainSizeCutOffPointMethodDialog(AppWorkspace appWorkspace, int gbtType)
- {
- this.gbtType = gbtType;
- if (gbtType == 3 || this.gbtType == 4)
- contentHead = new List<string>() { PdnResources.GetString("Menu.picture.Text"), PdnResources.GetString("Menu.Tools.GridLine.Text"), PdnResources.GetString("Menu.hectuallength.Text"), PdnResources.GetString("Menu.Thenumberofsections.text"), PdnResources.GetString("Menu.averageintercept.text"), PdnResources.GetString("Menu.Averagegrainsizegrade.text") };
- InitializeComponent();
- this.binaryClass = new BinaryClass();
- InitializeLanguageText();
- string dialogName = "GBT6394_2017";
- switch (this.gbtType)
- {
- case 1:
- dialogName = "GBT4335_2013";
- break;
- case 2:
- dialogName = "GBT24177_2009";
- break;
- case 3:
- dialogName = "ASTM_E112_2013";
- break;
- case 4:
- dialogName = "ISO643";
- break;
- default:
- break;
- }
- this.Text = dialogName + "("+ PdnResources.GetString("Menu.Areamethod.text")+ ")";
- if (this.gbtType == 3 || this.gbtType == 4)
- {
- this.Text = dialogName + "("+ PdnResources.GetString("Menu.Interceptmethod.text")+ ")";
- }
- else
- {
- if (this.gbtType == 1)
- this.Text = dialogName + "("+ PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Three-circleinterceptmethod.text")+ ")";
- else
- this.Text = dialogName + "("+ PdnResources.GetString("Menu.sectionmethod.text")+ ")";
- }
- this.appWorkspace = appWorkspace;
- this.button11.Visible = true;
- this.button16.Visible = false;
- //
- //初始化色板
- //
- this.colorsFormGrid = new ColorsForm();
- this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
- this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));//##############
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = false;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.Paint += Panel_Paint;
- this.documentWorkspace.panel.MouseMove += onMouseMove;
- this.documentWorkspace.panel.MouseUp += onMouseUp;
- this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
- this.groupBox7.Controls.Add(documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox7.Controls.Add(commonControlButtons);
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- //初始化头
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = "";
- header0.Width = 180;
- this.listView2.Columns.Add(header0);
- InitPicList();
- InitComboboxValue(null);
- styleClass.UpdateCupOffPointStyle();
- AddRectangleToRectangleFCaps();
- InitCommonButtonEvent();
- string templateName = "Template.Manager.item3.GrainSizeCutOff6394Method";
- switch (this.gbtType)
- {
- case 1:
- templateName = "Template.Manager.item3.GrainSizeCutOff4335Method";
- break;
- case 2:
- templateName = "Template.Manager.item3.GrainSizeCutOff24177Method";
- break;
- case 3:
- templateName = "Template.Manager.item3.GrainSizeCutOff112Method";
- break;
- case 4:
- templateName = "Template.Manager.item3.GrainSizeCutOff643Method";
- break;
- default:
- break;
- }
- SetAnalyzeModelFromXml(templateName);
- }
- //二值化集成3
- #region 二值化相关方法
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GrainSizeDialog_Load(object sender, EventArgs e)
- {
- this.comboBox3.Text = PdnResources.GetString("Menu.pdenoisingtype.Text");
- this.comboBox3.SelectedIndex = 1;
- this.comboBox2.Text = PdnResources.GetString("Menu.electthegrainboundarytype.Text");
- this.comboBox2.SelectedIndex = 1;
- this.binaryClass.loadParams();
- this.binaryClass.guideClass = this.guideClass;
- this.binaryClass.comboBox1 = this.comboBox1;
- }
- private bool bcBinaryChecked()
- {
- return bc != null && bc.BinaryChecked;
- }
- private bool bcOriginChecked()
- {
- return bc != null && bc.OriginChecked;
- }
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- AddRectangleToRectangleFCaps();
- }
- /// <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 = true;
- if (grainBoundryCheckBox.Checked && checkBox3_0.Checked)
- this.documentWorkspace.PhaseModels[1].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- this.documentWorkspace.PhaseModels[1].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- 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);
- }
- 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>
- 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();
- }
- }
- #region 初始化
- private void InitializeLanguageText()
- {
- this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.button14.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":";
- this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.button5.Text = PdnResources.GetString("Menu.Exportproject.text");
- this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.button9.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
- this.button10.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
- this.checkBox2_0.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.label7.Text = PdnResources.GetString("Menu.Image.Sigma.Text");
- this.checkBox2.Text = PdnResources.GetString("Menu.Grainboundaryenhancement.text");
- this.label8.Text = PdnResources.GetString("Menu.Grainboundarysize.text") + ":";
- this.button3.Text = PdnResources.GetString("Menu.Grainboundaryedit.text");
- this.groupBox4.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
- this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
- this.checkBox4_0.Text = PdnResources.GetString("Menu.displaygrid.text");
- this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
- this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
- this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
- this.button7_0.Text = PdnResources.GetString("Menu.1section.text");
- this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
- this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Tools.GridLine.Text");
- this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
- this.button11.Text = PdnResources.GetString("Menu.Showall.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.Column6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.averageintercept.text");
- this.Column4.HeaderText = PdnResources.GetString("Menu.Thenumberofsections.text");
- this.Column3.HeaderText = PdnResources.GetString("Menu.hectuallength.Text");
- this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
- this.grainBoundryCheckBox.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
- this.label1.Text = PdnResources.GetString("Menu.Grainboundarytype.text") + ":";
- this.label6.Text = PdnResources.GetString("Menu.Denoisingtype.text") + ":";
- this.comboBox3.Items.AddRange(new object[] {
- PdnResources.GetString("Menu.Gaussiansmoothing.text"),
- PdnResources.GetString("Menu.directionalsmoothing.text")});
- this.comboBox2.Items.AddRange(new object[] {
- PdnResources.GetString("Menu.Brightgrainboundary.text"),
- PdnResources.GetString("Menu.Darkgrainboundary.text"),
- PdnResources.GetString("Menu.gradient.text")});
- //
- // bc
- //
- this.bc = new PaintDotNet.CustomControl.BinaryControl();
- this.bc.BinaryChecked = false;
- this.bc.Location = new System.Drawing.Point(151, 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 = 18;
- this.Controls.Add(this.bc);
- this.Controls.SetChildIndex(this.bc, 0);
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox2_0 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.button10 = new System.Windows.Forms.Button();
- this.button9 = new System.Windows.Forms.Button();
- this.groupBox8 = new System.Windows.Forms.GroupBox();
- this.button5 = new System.Windows.Forms.Button();
- this.listView2 = new System.Windows.Forms.ListView();
- this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
- this.button16 = new System.Windows.Forms.Button();
- this.label5 = new System.Windows.Forms.Label();
- this.button14 = new System.Windows.Forms.Button();
- this.button13 = new System.Windows.Forms.Button();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button12 = new System.Windows.Forms.Button();
- this.button11 = new System.Windows.Forms.Button();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
-
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.groupBox10 = new System.Windows.Forms.GroupBox();
- this.button8 = new System.Windows.Forms.Button();
- this.button7_0 = new System.Windows.Forms.Button();
- this.button6_0 = new System.Windows.Forms.Button();
- this.groupBox11 = new System.Windows.Forms.GroupBox();
- this.checkBox5_0 = new System.Windows.Forms.CheckBox();
- this.checkBox4_0 = new System.Windows.Forms.CheckBox();
- this.checkBox3_0 = new System.Windows.Forms.CheckBox();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.panel1 = new System.Windows.Forms.Panel();
- this.button3 = new System.Windows.Forms.Button();
- this.label8 = new System.Windows.Forms.Label();
- this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.comboBox3 = new System.Windows.Forms.ComboBox();
- this.label6 = new System.Windows.Forms.Label();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.label1 = new System.Windows.Forms.Label();
- this.grainBoundryCheckBox = new System.Windows.Forms.CheckBox();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- this.groupBox8.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox3.SuspendLayout();
- this.groupBox10.SuspendLayout();
- this.groupBox11.SuspendLayout();
- this.groupBox4.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.checkBox2_0);
- 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(1081, 50);
- this.groupBox1.TabIndex = 2;
- this.groupBox1.TabStop = false;
-
- //
- // button2
- //
- this.button2.BackColor = System.Drawing.SystemColors.Control;
- this.button2.Location = new System.Drawing.Point(985, 14);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(84, 30);
- this.button2.TabIndex = 3;
-
- this.button2.UseVisualStyleBackColor = false;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // checkBox2_0
- //
- this.checkBox2_0.AutoSize = true;
- this.checkBox2_0.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
- this.checkBox2_0.Location = new System.Drawing.Point(139, 22);
- this.checkBox2_0.Name = "checkBox2_0";
- this.checkBox2_0.Size = new System.Drawing.Size(132, 16);
- this.checkBox2_0.TabIndex = 2;
-
- this.checkBox2_0.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.BackColor = System.Drawing.SystemColors.Control;
- 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 = false;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.listView1);
- this.groupBox2.Location = new System.Drawing.Point(14, 59);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(135, 592);
- this.groupBox2.TabIndex = 3;
- 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, 569);
- this.listView1.TabIndex = 0;
- this.listView1.UseCompatibleStateImageBehavior = false;
- this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
- //
- // imageList1
- //
- this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
- //
- // button10
- //
- this.button10.BackColor = System.Drawing.SystemColors.Control;
- this.button10.Location = new System.Drawing.Point(106, 57);
- this.button10.Name = "button10";
- this.button10.Size = new System.Drawing.Size(95, 26);
- this.button10.TabIndex = 11;
-
- this.button10.UseVisualStyleBackColor = false;
- this.button10.Click += new System.EventHandler(this.button10_Click);
- //
- // button9
- //
- this.button9.BackColor = System.Drawing.SystemColors.Control;
- this.button9.Location = new System.Drawing.Point(242, 18);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(92, 26);
- this.button9.TabIndex = 10;
-
- this.button9.UseVisualStyleBackColor = false;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // groupBox8
- //
- this.groupBox8.Controls.Add(this.button5);
- this.groupBox8.Controls.Add(this.listView2);
- this.groupBox8.Controls.Add(this.numericUpDown1_0);
- this.groupBox8.Controls.Add(this.button16);
- this.groupBox8.Controls.Add(this.label5);
- this.groupBox8.Controls.Add(this.button14);
- this.groupBox8.Controls.Add(this.button13);
- this.groupBox8.Controls.Add(this.dataGridView2);
- this.groupBox8.Controls.Add(this.button12);
- this.groupBox8.Controls.Add(this.button11);
- this.groupBox8.Controls.Add(this.label4);
- this.groupBox8.Controls.Add(this.label3);
- this.groupBox8.Location = new System.Drawing.Point(14, 657);
- this.groupBox8.Name = "groupBox8";
- this.groupBox8.Size = new System.Drawing.Size(1081, 204);
- this.groupBox8.TabIndex = 10;
- this.groupBox8.TabStop = false;
- //
- // button5
- //
- this.button5.BackColor = System.Drawing.SystemColors.Control;
- this.button5.Location = new System.Drawing.Point(941, 109);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(128, 26);
- this.button5.TabIndex = 24;
- this.button5.UseVisualStyleBackColor = false;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // listView2
- //
- this.listView2.FullRowSelect = true;
- this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
- this.listView2.HideSelection = false;
- this.listView2.Location = new System.Drawing.Point(15, 56);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(181, 140);
- this.listView2.TabIndex = 23;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
- //
- // numericUpDown1_0
- //
- this.numericUpDown1_0.Location = new System.Drawing.Point(997, 163);
- this.numericUpDown1_0.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown1_0.Name = "numericUpDown1_0";
- this.numericUpDown1_0.Size = new System.Drawing.Size(56, 21);
- this.numericUpDown1_0.TabIndex = 21;
- this.numericUpDown1_0.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
- //
- // button16
- //
- this.button16.BackColor = System.Drawing.SystemColors.Control;
- this.button16.Location = new System.Drawing.Point(15, 20);
- this.button16.Name = "button16";
- this.button16.Size = new System.Drawing.Size(93, 26);
- this.button16.TabIndex = 20;
- this.button16.UseVisualStyleBackColor = false;
- this.button16.Click += new System.EventHandler(this.button16_Click);
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(958, 169);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(41, 12);
- this.label5.TabIndex = 18;
- //
- // button14
- //
- this.button14.BackColor = System.Drawing.SystemColors.Control;
- this.button14.Location = new System.Drawing.Point(941, 71);
- this.button14.Name = "button14";
- this.button14.Size = new System.Drawing.Size(128, 26);
- this.button14.TabIndex = 16;
- this.button14.UseVisualStyleBackColor = false;
- this.button14.Click += new System.EventHandler(this.button14_Click);
- //
- // button13
- //
- this.button13.BackColor = System.Drawing.SystemColors.Control;
- this.button13.Location = new System.Drawing.Point(941, 34);
- this.button13.Name = "button13";
- this.button13.Size = new System.Drawing.Size(128, 26);
- this.button13.TabIndex = 12;
- this.button13.UseVisualStyleBackColor = false;
- this.button13.Click += new System.EventHandler(this.button13_Click);
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4,
- this.Column5,
- this.Column6});
- this.dataGridView2.Location = new System.Drawing.Point(228, 20);
- this.dataGridView2.Name = "dataGridView2";
- this.dataGridView2.ReadOnly = true;
- this.dataGridView2.RowHeadersVisible = false;
- this.dataGridView2.RowTemplate.Height = 23;
- this.dataGridView2.Size = new System.Drawing.Size(693, 176);
- this.dataGridView2.TabIndex = 15;
- //
- // Column1
- //
-
- this.Column1.Name = "Column1";
- this.Column1.ReadOnly = true;
- //
- // Column2
- //
- this.Column2.Name = "Column2";
- this.Column2.ReadOnly = true;
- //
- // Column3
- //
- this.Column3.Name = "Column3";
- this.Column3.ReadOnly = true;
- //
- // Column4
- //
- this.Column4.Name = "Column4";
- this.Column4.ReadOnly = true;
- //
- // Column5
- //
-
- this.Column5.Name = "Column5";
- this.Column5.ReadOnly = true;
- //
- // Column6
- //
-
- this.Column6.Name = "Column6";
- this.Column6.ReadOnly = true;
- //
- // button12
- //
- this.button12.BackColor = System.Drawing.SystemColors.Control;
- this.button12.Location = new System.Drawing.Point(145, 20);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(52, 26);
- this.button12.TabIndex = 13;
-
- this.button12.UseVisualStyleBackColor = false;
- this.button12.Click += new System.EventHandler(this.button12_Click);
- //
- // button11
- //
- this.button11.BackColor = System.Drawing.SystemColors.Control;
- this.button11.Location = new System.Drawing.Point(15, 20);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(63, 26);
- this.button11.TabIndex = 12;
-
- this.button11.UseVisualStyleBackColor = false;
- this.button11.Click += new System.EventHandler(this.button11_Click);
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.ForeColor = System.Drawing.SystemColors.ScrollBar;
- this.label4.Location = new System.Drawing.Point(924, 9);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(11, 192);
- this.label4.TabIndex = 1;
- this.label4.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|";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.ForeColor = System.Drawing.SystemColors.ScrollBar;
- this.label3.Location = new System.Drawing.Point(214, 9);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(11, 192);
- this.label3.TabIndex = 0;
- this.label3.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|";
- //
- // groupBox7
- //
- this.groupBox7.Location = new System.Drawing.Point(515, 59);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(580, 592);
- this.groupBox7.TabIndex = 11;
- this.groupBox7.TabStop = false;
-
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.comboBox1);
- this.groupBox3.Controls.Add(this.button9);
- this.groupBox3.Location = new System.Drawing.Point(153, 497);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(356, 57);
- this.groupBox3.TabIndex = 12;
- this.groupBox3.TabStop = false;
-
- //
- // comboBox1
- //
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox1.FormattingEnabled = true;
- this.comboBox1.Location = new System.Drawing.Point(15, 22);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(214, 20);
- this.comboBox1.TabIndex = 0;
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // groupBox10
- //
- this.groupBox10.Controls.Add(this.button10);
- this.groupBox10.Controls.Add(this.button8);
- this.groupBox10.Controls.Add(this.button7_0);
- this.groupBox10.Controls.Add(this.button6_0);
- this.groupBox10.Location = new System.Drawing.Point(153, 560);
- this.groupBox10.Name = "groupBox10";
- this.groupBox10.Size = new System.Drawing.Size(208, 91);
- this.groupBox10.TabIndex = 16;
- this.groupBox10.TabStop = false;
-
- //
- // button8
- //
- this.button8.BackColor = System.Drawing.SystemColors.Control;
- this.button8.Location = new System.Drawing.Point(106, 16);
- this.button8.Name = "button8";
- this.button8.Size = new System.Drawing.Size(95, 26);
- this.button8.TabIndex = 9;
-
- this.button8.UseVisualStyleBackColor = false;
- this.button8.Click += new System.EventHandler(this.button8_Click);
- //
- // button7_0
- //
- this.button7_0.BackColor = System.Drawing.SystemColors.Control;
- this.button7_0.Location = new System.Drawing.Point(5, 57);
- this.button7_0.Name = "button7_0";
- this.button7_0.Size = new System.Drawing.Size(95, 26);
- this.button7_0.TabIndex = 8;
-
- this.button7_0.UseVisualStyleBackColor = false;
- this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
- //
- // button6_0
- //
- this.button6_0.BackColor = System.Drawing.SystemColors.Control;
- this.button6_0.Location = new System.Drawing.Point(5, 17);
- this.button6_0.Name = "button6_0";
- this.button6_0.Size = new System.Drawing.Size(95, 26);
- this.button6_0.TabIndex = 7;
-
- this.button6_0.UseVisualStyleBackColor = false;
- this.button6_0.Click += new System.EventHandler(this.button6_0_Click);
- //
- // groupBox11
- //
- this.groupBox11.Controls.Add(this.checkBox5_0);
- this.groupBox11.Controls.Add(this.checkBox4_0);
- this.groupBox11.Controls.Add(this.checkBox3_0);
- this.groupBox11.Location = new System.Drawing.Point(367, 560);
- this.groupBox11.Name = "groupBox11";
- this.groupBox11.Size = new System.Drawing.Size(142, 91);
- this.groupBox11.TabIndex = 17;
- this.groupBox11.TabStop = false;
-
- //
- // checkBox5_0
- //
- this.checkBox5_0.AutoSize = true;
- this.checkBox5_0.Checked = true;
- this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox5_0.Location = new System.Drawing.Point(15, 64);
- this.checkBox5_0.Name = "checkBox5_0";
- this.checkBox5_0.Size = new System.Drawing.Size(72, 16);
- this.checkBox5_0.TabIndex = 2;
-
- this.checkBox5_0.UseVisualStyleBackColor = true;
- this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
- //
- // checkBox4_0
- //
- this.checkBox4_0.AutoSize = true;
- this.checkBox4_0.Checked = true;
- this.checkBox4_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox4_0.Location = new System.Drawing.Point(15, 45);
- this.checkBox4_0.Name = "checkBox4_0";
- this.checkBox4_0.Size = new System.Drawing.Size(72, 16);
- this.checkBox4_0.TabIndex = 1;
-
- this.checkBox4_0.UseVisualStyleBackColor = true;
- this.checkBox4_0.CheckedChanged += new System.EventHandler(this.checkBox4_0_CheckedChanged);
- //
- // checkBox3_0
- //
- this.checkBox3_0.AutoSize = true;
- this.checkBox3_0.Checked = true;
- this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox3_0.Location = new System.Drawing.Point(15, 23);
- this.checkBox3_0.Name = "checkBox3_0";
- this.checkBox3_0.Size = new System.Drawing.Size(72, 16);
- this.checkBox3_0.TabIndex = 0;
-
- this.checkBox3_0.UseVisualStyleBackColor = true;
- this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
- //
- // groupBox4
- //
- this.groupBox4.Controls.Add(this.panel1);
- this.groupBox4.Controls.Add(this.button3);
- this.groupBox4.Controls.Add(this.label8);
- this.groupBox4.Controls.Add(this.numericUpDown2);
- this.groupBox4.Controls.Add(this.numericUpDown1);
- this.groupBox4.Controls.Add(this.checkBox2);
- this.groupBox4.Controls.Add(this.textBox6);
- this.groupBox4.Controls.Add(this.label7);
- this.groupBox4.Controls.Add(this.comboBox3);
- this.groupBox4.Controls.Add(this.label6);
- this.groupBox4.Controls.Add(this.comboBox2);
- this.groupBox4.Controls.Add(this.label1);
- this.groupBox4.Controls.Add(this.grainBoundryCheckBox);
- this.groupBox4.Location = new System.Drawing.Point(153, 353);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(356, 138);
- this.groupBox4.TabIndex = 21;
- this.groupBox4.TabStop = false;
-
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.Color.Red;
- this.panel1.Location = new System.Drawing.Point(89, 16);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(72, 21);
- this.panel1.TabIndex = 31;
- this.panel1.Click += new System.EventHandler(this.panel1_Click);
- //
- // button3
- //
- this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.button3.Location = new System.Drawing.Point(260, 16);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(75, 23);
- this.button3.TabIndex = 18;
-
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(6, 108);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(65, 12);
- this.label8.TabIndex = 30;
-
- //
- // numericUpDown2
- //
- this.numericUpDown2.DecimalPlaces = 2;
- this.numericUpDown2.Location = new System.Drawing.Point(164, 104);
- this.numericUpDown2.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDown2.Name = "numericUpDown2";
- this.numericUpDown2.Size = new System.Drawing.Size(61, 21);
- this.numericUpDown2.TabIndex = 29;
- this.numericUpDown2.Tag = "max";
- this.numericUpDown2.Value = new decimal(new int[] {
- 500,
- 0,
- 0,
- 0});
- this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged_1);
- //
- // numericUpDown1
- //
- this.numericUpDown1.DecimalPlaces = 2;
- this.numericUpDown1.Location = new System.Drawing.Point(85, 104);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 1000,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(61, 21);
- this.numericUpDown1.TabIndex = 28;
- this.numericUpDown1.Tag = "min";
- this.numericUpDown1.Value = new decimal(new int[] {
- 1,
- 0,
- 0,
- 131072});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged_1);
- //
- // checkBox2
- //
- this.checkBox2.AutoSize = true;
- this.checkBox2.Checked = true;
- this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked;
- this.checkBox2.Location = new System.Drawing.Point(8, 50);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.Size = new System.Drawing.Size(72, 16);
- this.checkBox2.TabIndex = 26;
-
- this.checkBox2.UseVisualStyleBackColor = true;
- this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(65, 75);
- this.textBox6.Name = "textBox6";
- this.textBox6.Size = new System.Drawing.Size(45, 21);
- this.textBox6.TabIndex = 25;
- this.textBox6.Text = "0.5";
- this.textBox6.TextChanged += new System.EventHandler(this.textBox6_TextChanged);
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(6, 79);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(53, 12);
- this.label7.TabIndex = 24;
-
- //
- // comboBox3
- //
- this.comboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox3.FormattingEnabled = true;
-
- this.comboBox3.Location = new System.Drawing.Point(201, 76);
- this.comboBox3.Name = "comboBox3";
- this.comboBox3.Size = new System.Drawing.Size(133, 20);
- this.comboBox3.TabIndex = 23;
- this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(136, 79);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(65, 12);
- this.label6.TabIndex = 22;
-
- //
- // comboBox2
- //
- this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBox2.FormattingEnabled = true;
-
- this.comboBox2.Location = new System.Drawing.Point(201, 48);
- this.comboBox2.Name = "comboBox2";
- this.comboBox2.Size = new System.Drawing.Size(133, 20);
- this.comboBox2.TabIndex = 11;
- this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(136, 51);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 21;
-
- //
- // grainBoundryCheckBox
- //
- this.grainBoundryCheckBox.AutoSize = true;
- this.grainBoundryCheckBox.Location = new System.Drawing.Point(8, 20);
- this.grainBoundryCheckBox.Name = "grainBoundryCheckBox";
- this.grainBoundryCheckBox.Size = new System.Drawing.Size(72, 16);
- this.grainBoundryCheckBox.TabIndex = 7;
-
- this.grainBoundryCheckBox.UseVisualStyleBackColor = true;
- this.grainBoundryCheckBox.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
- //
- // GrainSizeCutOffPointMethodDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1100, 870);
-
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox10);
- this.Controls.Add(this.groupBox11);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox8);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.MaximumSize = new System.Drawing.Size(1116, 909);
- this.MinimumSize = new System.Drawing.Size(1116, 909);
- this.Name = "GrainSizeCutOffPointMethodDialog";
- this.Text = "";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeDialog_FormClosing);
- this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox8, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox11, 0);
- this.Controls.SetChildIndex(this.groupBox10, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.Controls.SetChildIndex(this.groupBox4, 0);
-
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- this.groupBox8.ResumeLayout(false);
- this.groupBox8.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox10.ResumeLayout(false);
- this.groupBox11.ResumeLayout(false);
- this.groupBox11.PerformLayout();
- this.groupBox4.ResumeLayout(false);
- this.groupBox4.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// 初始化矩形
- /// </summary>
- private void InitRectangleF(PointF pointF)
- {
- if (this.selectPicture)
- {
- bool foundItem;
- guideClass.RectangleFLine = guideClass.guideRectLine(pointF, this.comboBox1.SelectedItem, out foundItem);
- if (foundItem)
- this.AddRectangleToRectangleFCaps();
- }
- }
- //rundect
- /// <summary>
- /// 刷新截点集合
- /// </summary>
- private void AddRectangleToRectangleFCaps()
- {
- GrainSizeGuideStyleModel grainSizeGuideStyleModel = guideClass.GrainSizeGuideStyleModel;
- if (grainSizeGuideStyleModel == null)
- return;
- Mat mat;
- if (!grainBoundryCheckBox.Checked && !bcBinaryChecked())
- {
- mat = matOrg;
- }
- else
- {
- if (grainBoundryCheckBox.Checked)
- {
- if (this.documentWorkspace.PhaseModels[1].mat != null)
- mat = this.documentWorkspace.PhaseModels[1].mat;
- else
- return;
- }
- else if (this.documentWorkspace.PhaseModels[0].mat != null)
- {
- mat = this.documentWorkspace.PhaseModels[0].mat;
- }
- else
- return;
- }
- if (mat == null)
- return;
- this.linePointList.Clear();
- //获取图形上所有的点
- this.linePointList.AddRange(guideClass.getGuidePointList(mat, this.comboBox1.SelectedItem));
- //垂直辅助线 / 水平辅助线
- bool vGuideStylesOrHGuideStyles = guideClass.IsVGuideStylesOrHGuideStyles(this.comboBox1.SelectedItem);
- int matLevel = 0;
- if (grainBoundryCheckBox.Checked)
- matLevel = 2;
- else if (bcBinaryChecked())
- matLevel = 1;
- else if(!grainBoundryCheckBox.Checked && !bcBinaryChecked())
- matLevel = 0;
- //自动添加截点
- styleClass.AddRectangleToRectangleFCaps(mat, matLevel, this.linePointList, vGuideStylesOrHGuideStyles, this.documentWorkspace.CompositionSurface.Width
- , this.documentWorkspace.CompositionSurface.Height);
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 辅助线维护
- /// </summary>
- public void InitComboboxValue(ArrayList arrayList)
- {
- guideClass.createGuideClassModels(this.gbtType);
-
- this.comboBox1.DataSource = null;
- if (arrayList != null && arrayList.Count > 0)
- {
- this.comboboxChange = false;
- arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
- this.comboBox1.DataSource = arrayList;
- this.comboboxChange = false;
- int oldSelectIndex = -1;
- for (int i = 0; i < this.comboBox1.Items.Count; i++)
- {
- if (this.oldSelectItem.Equals(this.comboBox1.Items[i]))
- {
- oldSelectIndex = i;
- }
- }
- if (oldSelectIndex > -1)
- this.comboBox1.SelectedIndex = oldSelectIndex;
- else if (this.comboBox1.Items.Count > 0)
- this.comboBox1.SelectedIndex = 0;
- }
- else
- {
- ArrayList arrayList1 = guideClass.GetComboList();
- if (arrayList1.Count > 0)
- {
- this.comboBox1.DataSource = arrayList1;
- this.comboBox1.SelectedIndex = 0;
- }
- }
- // 更新辅助线及其样式
- guideClass.UpdateGuideStyle(matOrg, this.comboBox1.SelectedItem);
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// ListView图片选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
- {
- existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView();
- this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- if (!existViewFlag)
- {
- matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
- }
- else
- {
- matOrg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFullSizeWithRegion());
- }
- //二值化集成4
- binaryClass.listView1_SelectedIndexChanged(this.bitmap);
- if (this.grainBoundryCheckBox.Checked)
- {
- this.documentWorkspace.PhaseModels[1].choise = true;
- this.applyDect();
- }
- this.selectPicture = true;
- this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- InitRectangleF(new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2));
- AddRectangleToRectangleFCaps();
- }
- }
- /// <summary>
- /// 辅助线样式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.bitmap == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- return;
- }
- this.oldSelectItem = (string)this.comboBox1.SelectedItem;
- GrainGuideStyleSettingsDialog grainGuideStyleSettingsDialog = new GrainGuideStyleSettingsDialog(0, this.gbtType, this.bitmap);
- grainGuideStyleSettingsDialog.StartPosition = FormStartPosition.CenterScreen;
- grainGuideStyleSettingsDialog.ShowDialog(this);
- }
- /// <summary>
- /// 截点样式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button10_Click(object sender, EventArgs e)
- {
- GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSurveyPointStyleSettingDialog();
- grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
- grainSurveyPointStyleSettingDialog.ShowDialog(this);
- }
- /// <summary>
- /// 画布绘制
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Panel_Paint(object sender, PaintEventArgs e)
- {
- if (this.documentWorkspace.CompositionSurface != null)
- {
- //
- // 以下是计算绘制图片的位置和大小并绘制图片
- //
- System.Drawing.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);
- if (this.checkBox4_0.Checked || this.checkBox5_0.Checked)
- Draw(e.Graphics);
- e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
- e.Graphics.TranslateTransform(-x, -y);
- }
- }
- /// <summary>
- /// 绘制
- /// </summary>
- private void Draw(Graphics graphics)
- {
- // 抗锯齿
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- //显示辅助线
- if (checkBox4_0.Checked)
- guideClass.DrawGuideLines(graphics, this.comboBox1.SelectedItem);
- //显示截点
- if (matOrg != null && this.checkBox5_0.Checked)
- styleClass.DrawGuidePoints(graphics);
- }
- private string oldSelectItem = "";
- /// <summary>
- /// 切换辅助线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (!this.selectPicture)
- {
- int oldSelectIndex = -1;
- for (int i = 0; i < this.comboBox1.Items.Count; i++)
- {
- if (this.oldSelectItem.Equals(this.comboBox1.Items[i]))
- {
- oldSelectIndex = i;
- }
- }
- if (this.comboBox1.SelectedIndex > 0)
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- if (oldSelectIndex > -1)
- this.comboBox1.SelectedIndex = oldSelectIndex;
- else if (this.comboBox1.Items.Count > 0)
- this.comboBox1.SelectedIndex = 0;
- return;
- }
- if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
- {
- this.oldSelectItem = (string)this.comboBox1.SelectedItem;
- // 更新辅助线及其样式
- guideClass.UpdateGuideStyle(matOrg, this.comboBox1.SelectedItem);
- if (this.selectPicture)
- {
- PointF pointF;
- if (this.comboboxChange)
- {
- pointF = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- }
- else
- pointF = this.loctation;
- InitRectangleF(pointF);
- this.comboboxChange = true;
- }
- this.documentWorkspace.Refresh();
- }
- }
- #region 矩形拖动
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- private void OnMouseDown(object sender, MouseEventArgs e)
- {
- // 换算后的点
- PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- if (point1.X <= this.documentWorkspace.CompositionSurface.Width
- && point1.X >= 0
- && point1.Y >= 0
- && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
- {
- RectangleF rectangleF;
- // 复合辅助线
- int add = guideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
- if (add == 0 && styleClass.PointKb > 0)
- rectangleF = guideClass.RectangleFLine;
- //手动添加截点
- styleClass.OnMouseDownFirst(point1, rectangleF, this.linePointList, sender, e);
- }
- //辅助线缩放
- if (styleClass.PointKb == 0)
- guideClass.OnMouseDown(point1, sender, e);
- //辅助线移动
- if (e.Button == MouseButtons.Left && e.Clicks == 1 && styleClass.PointKb == 0)//##############
- {
- if (guideClass.RectangleFLine.Contains(point1))
- {
- m_canMove = true;
- this.m_StartPoint = point1;
- }
- }
- //手动删除截点或取消添加截点
- styleClass.OnMouseDownNext(point1, sender, e);
- }
- /// <summary>
- /// 移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void onMouseMove(object sender, MouseEventArgs e)
- {
- // 换算后的点
- PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- this.documentWorkspace.Refresh();//#########
- if (guideClass.onMouseMove(point1, this.comboBox1.SelectedItem, e))// 矩形缩放
- {
- this.loctation = new PointF(guideClass.RectangleFLine.X + guideClass.RectangleFLine.Width / 2, guideClass.RectangleFLine.Y + guideClass.RectangleFLine.Height / 2);
- this.AddRectangleToRectangleFCaps();
- this.documentWorkspace.Refresh();
- }
- else if (e.Button == MouseButtons.Left && m_canMove)
- {
- // 矩形偏移
- guideClass.rectangleFLine.Offset(point1.X - this.m_StartPoint.X, point1.Y - this.m_StartPoint.Y);
- this.loctation = new PointF(guideClass.RectangleFLine.X + guideClass.RectangleFLine.Width / 2, guideClass.RectangleFLine.Y + guideClass.RectangleFLine.Height / 2);
- this.m_StartPoint = point1;
- this.AddRectangleToRectangleFCaps();
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void onMouseUp(object sender, MouseEventArgs e)
- {
- m_canMove = false;
- guideClass.onMouseUp(sender, e);
- }
- #endregion
- /// <summary>
- /// surfaceBox双击事件
- /// 目前是参考AxioVision
- /// 应该是把每次选的点都取最高和最低的BGR
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private unsafe void pictureBox1_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 移除未完成的定义物体的轮廓的对象
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void GrainSizeDialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- this.documentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.PhaseExtraction);
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 0.5截点添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button6_0_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count > 0)
- styleClass.PointKb = 1;
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- }
- /// <summary>
- /// 1截点添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button7_0_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count > 0)
- styleClass.PointKb = 2;
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- }
- /// <summary>
- /// 2截点添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button8_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count > 0)
- {
- //垂直辅助线 / 水平辅助线
- bool vGuideStylesOrHGuideStyles = guideClass.IsVGuideStylesOrHGuideStyles(this.comboBox1.SelectedItem);
- if (vGuideStylesOrHGuideStyles)
- styleClass.PointKb = 3;
- else
- styleClass.PointKb = 4;
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- }
- /// <summary>
- /// 是否显示截点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
- {
- if (!this.checkBox4_0.Checked)
- MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 是否显示网格
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox4_0_CheckedChanged(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// Panel2的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void gridColorChanged(object sender, EventArgs e)
- {
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panel1.BackColor = color;
- this.documentWorkspace.PhaseModels[1].color = this.panel1.BackColor.ToArgb();
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- this.documentWorkspace.Refresh();
- }
- //关闭色板
- this.colorsFormGrid.Close();
- }
- /// <summary>
- /// 设置按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- string templateName = "Template.Manager.item3.GrainSizeCutOff6394Method";
- switch (this.gbtType)
- {
- case 1:
- templateName = "Template.Manager.item3.GrainSizeCutOff4335Method";
- break;
- case 2:
- templateName = "Template.Manager.item3.GrainSizeCutOff24177Method";
- break;
- case 3:
- templateName = "Template.Manager.item3.GrainSizeCutOff112Method";
- break;
- case 4:
- templateName = "Template.Manager.item3.GrainSizeCutOff643Method";
- break;
- default:
- break;
- }
- AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);//#############001
- if (metallographicMethodSetDialog.hasModule)
- {
- metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
- metallographicMethodSetDialog.ShowDialog();
- }
- else
- {
- metallographicMethodSetDialog = null;
- }
- }
- /// <summary>
- /// 生成报告按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button13_Click(object sender, EventArgs e)
- {
- if (this.checkBox2_0.Checked)
- this.button1.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.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>>();
- analysisContent.Add(contentHead);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHead.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- if (this.allShow)
- {
- 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]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- else if (this.listView2.Items.Count > 0)//###
- {
- ListViewItem item = this.listView2.Items[0];
- if (bitDic.ContainsKey(item.Name))
- {
- bitList.Add(bitDic[item.Name][0]);
- bitList.Add(bitDic[item.Name][1]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- /// <summary>
- /// 导出结果按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button14_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- SaveFileDialog exe = new SaveFileDialog();
- exe.Filter = "Execl files (*.xlsx)|*.xlsx";
- exe.FilterIndex = 0;
- exe.RestoreDirectory = true;
- exe.Title = "Export Excel File";
- exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- exe.FileName = PdnResources.GetString("Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text")+"("+ PdnResources.GetString("Menu.sectionmethod.text")+ ")"+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss");
- DialogResult dr = exe.ShowDialog();
- if (dr == DialogResult.OK)
- {
- DataTable dtb = new DataTable();
- foreach (var item in this.contentHead)
- {
- dtb.Columns.Add(item);
- }
- for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
- {
- DataRow dataRow = dtb.NewRow();
- for (int k = 0; k < this.contentHead.Count; k++)
- {
- dataRow[this.contentHead[k]] = this.dataGridView2.Rows[i].Cells[k].Value;
- }
- dtb.Rows.Add(dataRow);
- }
- List<DataTable> list = new List<DataTable>();
- list.Add(dtb);
- OfficeFileHandleHelper.ExportDataToExcel(exe.FileName, list);
- MessageBox.Show(PdnResources.GetString("Menu.ResultsExportedsuccessfully.Text"));
- }
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text")+"!");
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.listView1.SelectedItems.Count > 0)
- {
- if(this.comboBox1.SelectedItem != null && !PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
- {
- string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName();
- string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index];
- System.Data.DataTable dataTable = new System.Data.DataTable();
- bool replace = false;
- int add = 0;
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- add++;
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- break;
- }
- }
- if (replace || this.listView2.Items.Count == 0 || add == 0)
- {
- if(!replace)
- {
- ListViewItem listViewItem = new ListViewItem();
- listViewItem.SubItems[0].Text = imgName;
- listViewItem.Tag = "" + tag;
- if (this.listView2.Items.Count == 0)
- this.listView2.Items.Add(listViewItem);
- else
- this.listView2.Items.Insert(0, listViewItem);
- }
- this.dataGridView2.Rows.Clear();
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
- }
- dgvr.Cells[0].Value = imgName;
- dgvr.Cells[1].Value = this.comboBox1.SelectedItem;
- double length = guideClass.guideLength(this.comboBox1.SelectedItem);
- dgvr.Cells[2].Value = length;
- double countPoints = styleClass.getCountPoints();
- decimal M = 1;// this.appWorkspace.GetGainMultiple() ;
- double PL = (double)M * countPoints / length;
- dgvr.Cells[3].Value = countPoints;
- dgvr.Cells[4].Value = 1.0 / PL;
- if (this.gbtType == 4)
- {
- dgvr.Cells[5].Value = 6.6439 * Math.Log10(PL * 1000.0) - 3.2877;
- }
- else
- {
- dgvr.Cells[5].Value = 6.643856 * Math.Log10(PL * 1000.0) - 3.288;
- }
- this.dataGridView2.Rows.Add(dgvr);
- dataTable.TableName = tag;
- foreach (System.Data.DataTable dataTable1 in dataTables)
- {
- if (dataTable1.TableName.Equals(dataTable.TableName))
- {
- dataTables.Remove(dataTable1);
- break;
- }
- }
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- dataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- DataRow dataRow = dataTable.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- dataTable.Rows.Add(dataRow);
- }
- this.dataTables.Add(dataTable);
- }
- this.RefreshDataGridView4();
- //保存处理后的图片
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
- {
- Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
- graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
- }
- Draw(graphics);
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- //拼接中间数据
- List<List<string>> dataList = styleClass.getTableDataList();
- 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.Pleaseselectauxiliaryline.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
- }
-
- }
- /// <summary>
- /// 晶界重现
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked && !bcOriginChecked() && checkBox3_0.Checked)
- {
- this.documentWorkspace.PhaseModels[1].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[1].choise = false;
- this.documentWorkspace.Refresh();
- }
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- else
- AddRectangleToRectangleFCaps();//1009###18946
- }
- ProgressThreadProcClass procClass;
- double sigma = 0.5;
- Mat OrgImg;// = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);// OpenCvSharp.Cv2.ImRead(inputImageFile);
- int dark;// = this.comboBox2.SelectedIndex;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
- int smooth_type;// = this.comboBox3.SelectedIndex;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
- //double sigma = double.Parse(textBox6.Text);// 0.5;//如果是高斯平滑,则指定高斯sigma,如果是方向平滑 则忽略此参数
- int enhance;// = this.checkBox2.Checked ? 1 : 0;// 1;//是否增强晶界?不增强:enhance=0; 增强: enhance=1
- double[] cell_size;// = new double[2] { (double)numericUpDown1.Value, (double)numericUpDown2.Value }; ;// new double[2] { 0.01, 500 };//晶界大小
- Mat OrgImg0;
- private void applyDect()
- {
- if (this.bitmap == null)
- {
- return;
- }
- if (!double.TryParse(textBox6.Text, out sigma))
- {
- return;
- }
- /*Mat */OrgImg = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap);// OpenCvSharp.Cv2.ImRead(inputImageFile);
- /*int */dark = this.comboBox2.SelectedIndex;// 2;//指定晶界类型,暗晶界dark=1, 否则dark=0, dark=2梯度
- /*int */smooth_type = this.comboBox3.SelectedIndex;// 1;//去噪类型: 高斯平滑: smooth_type=0; 方向平滑: smooth_type=1
- /*int */enhance = this.checkBox2.Checked ? 1 : 0;// 1;//是否增强晶界?不增强:enhance=0; 增强: enhance=1
- /*double[] */cell_size = new double[2] { (double)numericUpDown1.Value, (double)numericUpDown2.Value }; ;// new double[2] { 0.01, 500 };//晶界大小
- procClass = new ProgressThreadProcClass();
- procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
- if (OrgImg0 != null)
- {
- this.documentWorkspace.PhaseModels[1].mat = OrgImg0.Clone();
- this.documentWorkspace.Refresh();
- OrgImg0 = null;
- }
- if (OrgImg != null)
- {
- OrgImg.Dispose();
- OrgImg = null;
- }
- //this.runDect(OrgImg, dark, smooth_type, sigma, enhance, cell_size);
- AddRectangleToRectangleFCaps();//0916###18747
- }
- private void applyDectAction()
- {
- OrgImg0 = this.runDect(OrgImg, dark, smooth_type, sigma, enhance, cell_size);
- if (procClass != null) procClass.DismissProgressAction(this);
- }
- private void checkBox2_CheckedChanged(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- private void textBox6_TextChanged(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- private void numericUpDown1_ValueChanged_1(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- private void numericUpDown2_ValueChanged_1(object sender, EventArgs e)
- {
- if (this.grainBoundryCheckBox.Checked)
- {
- this.applyDect();
- }
- }
- /// <summary>
- /// 显示晶界
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
- {
- if (!bcOriginChecked() && grainBoundryCheckBox.Checked && checkBox3_0.Checked)
- {
- this.documentWorkspace.PhaseModels[1].choise = true;
- }
- else
- {
- this.documentWorkspace.PhaseModels[1].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- /// <summary>
- /// 晶界编辑
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (this.documentWorkspace.PhaseModels[1].mat == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
- return;
- }
- GrainBoundaryEditingDialog boundaryEditingDialog = new GrainBoundaryEditingDialog(this.appWorkspace, this.listView1.FocusedItem.Index, this.panel1.BackColor
- , this.documentWorkspace.PhaseModels[1].mat.Clone());
- boundaryEditingDialog.GuideClass = this.guideClass;
- boundaryEditingDialog.SelectedItem = this.comboBox1.SelectedItem;
- if (boundaryEditingDialog.ShowDialog() == DialogResult.OK)
- {
- this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
- AddRectangleToRectangleFCaps();
- }
- }
- private void panel1_Click(object sender, EventArgs e)
- {
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor);
- this.colorsFormGrid.ShowDialog();
- }
- /// <summary>
- /// 导出项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if (this.checkBox2_0.Checked)
- this.button1.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- Instrument.ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text", this.analyzeSettingModel.savePath);
- if (nodeItem == null) return;
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = PaintDotNet.DbOpreate.DbBll.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>>();
- analysisContent.Add(contentHead);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHead.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- //图片
- bitList = new List<Bitmap>();
- //中间数据
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- if (this.allShow)
- {
- foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitDic)
- {
- bitList.Add(kv.Value[0]);
- bitList.Add(kv.Value[1]);
- }
- //中间数据
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- }
- }
- 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]);
- }
- else if (bitDic.ContainsKey(item.Tag.ToString()))
- {
- bitList.Add(bitDic[item.Tag.ToString()][0]);
- bitList.Add(bitDic[item.Tag.ToString()][1]);
- }
- }
- //中间数据
- 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;
- }
- else if (model.tagName.Equals(rowItem.Tag.ToString()))
- {
- ExportProjectModel tempModel = new ExportProjectModel();
- tempModel.tagName = model.tagName;
- tempModel.picName = model.picName;
- tempModel.dataList = model.dataList;
- exportModel.Add(tempModel);
- break;
- }
- }
- }
- }
- else if (this.listView2.Items.Count > 0)
- {
- ListViewItem rowItem = this.listView2.Items[0];
- if (bitDic.ContainsKey(rowItem.Name))
- {
- bitList.Add(bitDic[rowItem.Name][0]);
- bitList.Add(bitDic[rowItem.Name][1]);
- }
- else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
- {
- bitList.Add(bitDic[rowItem.Tag.ToString()][0]);
- bitList.Add(bitDic[rowItem.Tag.ToString()][1]);
- }
- //中间数据
- {
- 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;
- }
- else if (model.tagName.Equals(rowItem.Tag.ToString()))
- {
- 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, nodeItem.path, nodeItem.code);
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- /// <summary>
- /// 切换分析结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listview2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if(!this.allShow)
- {
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTables)
- {
- if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- }
- /// <summary>
- /// 全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button11_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- this.button11.Visible = false;
- this.button16.Visible = true;
- this.button16.Focus();
- this.allShow = true;
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
- {
- dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 取消全部显示
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button16_Click(object sender, EventArgs e)
- {
- this.button11.Visible = true;
- this.button16.Visible = false;
- this.button11.Focus();
- this.allShow = false;
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- {
- System.Data.DataTable dataTable1 = new System.Data.DataTable();
- foreach (var dataTable in this.dataTables)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- else
- {
- if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
- dataTable1 = dataTable;
- }
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable1.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = dataTable1.Rows[0][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- this.RefreshDataGridView4();
- }
- /// <summary>
- /// 分析结果删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button12_Click(object sender, EventArgs e)
- {
- if(this.listView2.Items.Count > 0)
- {
- if(this.listView2.SelectedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- if (this.listView2.SelectedItems.Count <= 0)
- return;
- for (int i = this.listView2.SelectedItems.Count - 1; i >= 0; i--)
- {
- int selectIndex = this.listView2.SelectedItems[i].Index;
- foreach (var dataTable in this.dataTables)
- {
- if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
- {
- this.dataTables.Remove(dataTable);
- break;
- }
- }
- if (bitDic.ContainsKey((string)this.listView2.SelectedItems[i].Tag))
- bitDic.Remove((string)this.listView2.SelectedItems[i].Tag);
- //中间数据
- foreach (ExportProjectModel model in this.tempDataModel)
- {
- if (model.tagName.Equals((string)this.listView2.SelectedItems[i].Tag))
- {
- this.tempDataModel.Remove(model);
- break;
- }
- }
- this.listView2.Items.RemoveAt(selectIndex);
- }
- if (this.listView2.Items.Count == 0)
- this.dataGridView2.Rows.Clear();
- else
- {
- //if (selectIndex == 0)
- // this.listView2.Items[0].Selected = true;
- //else
- // this.listView2.Items[selectIndex - 1].Selected = true;
- RefreshDataGridView4();
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 刷新分析结果数据
- /// </summary>
- private void RefreshDataGridView4()
- {
- if (!this.allShow)
- {
- if (this.listView2.SelectedItems.Count > 0)
- {
- this.dataGridView2.Rows.Clear();
- for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
- {
- int dataTableIndex = 0;
- if (this.listView2.SelectedItems.Count > 0)
- {
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
- dataTableIndex = i;
- }
- }
- if (this.gbtType == 3 || this.gbtType == 4)
- {
- if (this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- if (c == 2 || c == 3 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- else
- {
- if (this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- if (c == 2 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- else if (this.listView2.Items.Count > 0)
- {
- this.dataGridView2.Rows.Clear();
- var firstTag = this.listView2.Items[0].Tag;
- int dataTableIndex = 0;
- for (int i = 0; i < this.dataTables.Count; i++)
- {
- if (this.dataTables[i].TableName.Equals(firstTag))
- dataTableIndex = i;
- }
- if (this.gbtType == 3 || this.gbtType == 4)
- {
- if (this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- if (c == 2 || c == 3 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- else
- {
- if (this.dataTables[dataTableIndex].Rows.Count > 0)
- {
- for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
- {
- if (c == 2 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
- this.dataTables[dataTableIndex].Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- }
- else
- {
- this.dataGridView2.Rows.Clear();
- DataTable dataTable = new DataTable();
- if (this.gbtType == 3 || this.gbtType == 4)
- for (int i = this.dataTables.Count - 1; i >= 0; i--)
- {
- dataTable = this.dataTables[i];
- for (int r = 0; r < dataTable.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable.Columns.Count; c++)
- {
- if (c == 2|| c == 3 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
- dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- else
- for (int i = this.dataTables.Count - 1; i >= 0; i--)
- {
- dataTable = this.dataTables[i];
- for (int r = 0; r < dataTable.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < dataTable.Columns.Count; c++)
- {
- if (c == 2 || c == 4 || c == 5)
- dgvr.Cells[c].Value = Math.Round(double.Parse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
- dataTable.Rows[r][c].ToString()), Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- else
- dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
- }
- this.dataGridView2.Rows.Add(dgvr);
- }
- }
- }
- }
- private Mat runDect(Mat OrgImg0, int dark, int smooth_type, double sigma, int enhance, double[] cell_size)
- {
- Mat GryImg = new Mat();
- Mat OrgImg = new Mat();
- /////
- if (4 == OrgImg0.Channels())
- {
- Cv2.CvtColor(OrgImg0, OrgImg, ColorConversionCodes.BGRA2BGR);
- }
- else
- {
- OrgImg = OrgImg0.Clone();
- }
- In5segmsurf prm = new In5segmsurf();
- prm.OrgImg = OrgImg;
- /////
- //Cv2.ImShow("src", OrgImg);//kkkkk
- //Cv2.WaitKey(0);//kkkkk
- //转为为灰度?
- if (3 == OrgImg.Channels() || 4 == OrgImg.Channels())
- {
- Cv2.CvtColor(OrgImg, GryImg, ColorConversionCodes.RGB2GRAY);
- }
- else
- {
- if (1 == OrgImg.Channels())
- {
- GryImg = OrgImg.Clone();
- }
- else
- {
- return null;
- }
- }
- if (1 == dark)
- {
- int Rows = GryImg.Rows;
- int Cols = GryImg.Cols;
- int[] point = new int[2];
- //单通道图像的反色
- for (point[0] = 0; point[0] < Rows; point[0]++)
- {
- for (point[1] = 0; point[1] < Cols; point[1]++)
- {
- byte bTemp = (byte)(255 - GryImg.At<byte>(point[0], point[1]));
- GryImg.Set<byte>(point, bTemp);//mmmmm
- }
- }
- }
- if (2 == dark)
- {
- Mat TempImg = GryImg.Clone();
- Cv2.Sobel(TempImg, GryImg, -1, 2, 2, 3);//mmmmm
- }
- //Cv2.ImShow("src", GryImg);//kkkkk
- //Cv2.WaitKey(0);//kkkkk
- //去噪
- if (0 == smooth_type)
- {
- prm.smoothim_method = "gaussian";
- }
- else
- {
- if (1 == smooth_type)
- {
- prm.smoothim_method = "dirced";
- }
- else
- {
- return null;
- }
- }
- //晶界增强
- if (1 == enhance)
- {
- prm.filterridges = 1;
- }
- else
- {
- prm.filterridges = 0;
- }
- //调用算法
- prm.gaussian_stdev = sigma;
- prm.LEVEL = ".3";
- prm.classifycells_convexarea = 0.50;
- prm.classifycells_convexperim = 0.45;
- OLDcellsegm cellsegm = new OLDcellsegm();
- string[] namehere = new string[1] { "prm" };
- In6segmsurf IN6BNImgs = new In6segmsurf();
- OUTsegmsurf RSTss = cellsegm.mf_segmsurf_progress_auto(GryImg, cell_size[0], cell_size[1], namehere, prm, IN6BNImgs, this.panel1.BackColor, this);
- cell_size = null;
- cellsegm = null;
- namehere = null;
- Cv2.CvtColor(RSTss.wat, OrgImg0, ColorConversionCodes.BGR2BGRA);
- //this.documentWorkspace.PhaseModels[1].mat = OrgImg0;// RSTss.wat;// action.PerformProcess(
- //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
- //// OpenCvSharp.Extensions.BitmapConverter.ToMat(this.bitmap));
- //////this.documentWorkspace.PhaseModels[1].color = this.panel2.BackColor.ToArgb();
- //this.documentWorkspace.Refresh();
- //return RSTss.wat;
- //string filename = "D:\\result11.jpg";
- //Cv2.ImWrite(filename, RSTss.wat);
- return OrgImg0;
- }
- /// <summary>
- /// 小数位数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
- {
- this.RefreshDataGridView4();
- //this.dec = Convert.ToInt32(this.numericUpDown1_0.Value);
- //if(this.dataTables.Count > 0)
- //{
- // foreach (var dataTable in this.dataTables)
- // {
- // }
- //}
- }
- public void UpdateCupOffPointStyle()
- {
- styleClass.UpdateCupOffPointStyle();
- AddRectangleToRectangleFCaps();
- }
- #region 内部类
- internal class LocalListViewItem
- {
- public DocumentWorkspace Value { get; }
- public string Display { get; }
- public LocalListViewItem(DocumentWorkspace Value, string Display)
- {
- this.Value = Value;
- this.Display = Display;
- }
- }
- internal class DocumentItem
- {
- public Bitmap bitmap;
- public GraphicsList graphicsList;
- public List<PhaseModel> phaseModels;
- //public AnalysisResult analysisResult;
- public DocumentItem(Bitmap bitmap, GraphicsList graphicsList, List<PhaseModel> phaseModels)
- {
- this.bitmap = bitmap;
- this.graphicsList = graphicsList;
- this.phaseModels = phaseModels;
- }
- }
- #endregion
- }
- }
|