12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297 |
- using OpenCvSharp;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Instrument;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Windows.Forms;
- namespace PaintDotNet.DedicatedAnalysis.NonferrousMetals
- {
- internal class NonFMetalsStandardDialog : PdnBaseForm
- {
- #region 属性
- //是否进行了结果(厚度)计算
- protected bool calculate1d = false;
- /// <summary>
- /// 计算结果的表格集合
- /// </summary>
- private List<DataTable> resultTableList = new List<DataTable>();
- protected Panel panelC;
- /// <summary>
- /// 调色板
- /// </summary>
- private ColorsForm colorsFormGrid;
- /// <summary>
- /// 主控件
- /// </summary>
- protected AppWorkspace appWorkspace;
- //二值化集成1
- protected BinaryClass binaryClass;
- protected int menuId;
- /// <summary>
- /// 公共按钮
- /// </summary>
- private CommonControlButtons commonControlButtons;
- /// <summary>
- /// 图像面板
- /// </summary>
- protected DocumentWorkspaceWindow documentWorkspace;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- protected Mat imageMat;
- /// <summary>
- /// 当前选择的图片
- /// </summary>
- protected Mat matOrg;
- ///// <summary>
- ///// 当前选择的图片
- ///// </summary>
- //private Mat mat;
- protected string oldSelectItem;
- public bool comboboxChange = true;
- /// <summary>
- /// 图形上所有的点
- /// </summary>
- protected List<PointF> linePointList = new List<PointF>();
- /// <summary>
- /// 直线图形上所有的点
- /// </summary>
- protected List<List<PointF>> straightLinePointList = new List<List<PointF>>();
- /// <summary>
- /// 圆圈图形上所有的点,其中第一个点为圆心坐标
- /// </summary>
- protected List<List<PointF>> roundLinePointList = new List<List<PointF>>();
- /// <summary>
- /// 是否选择了图片
- /// </summary>
- protected int selectPicture = -1;
- /// <summary>
- /// 用于编号的坐标点集合,value为: Nx5 matrix (CV_32S) of statistics: x0, y0, width0, height0, area0 + [1内部 0外部] + [label]
- /// </summary>
- protected Dictionary<Point2d, List<int>> massLabelPoints = new Dictionary<Point2d, List<int>>();
- /// <summary>
- /// 矩形内的连通域
- /// </summary>
- protected int within = 0;
- /// <summary>
- /// 保存用于生成报告的图片
- /// </summary>
- protected List<Bitmap> bitList;
- /// <summary>
- /// 储存点击保存结果后的所有原图与分析图
- /// </summary>
- protected Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- /// <summary>
- /// 中间数据
- /// </summary>
- protected List<ExportProjectModel> tempDataModel = new List<ExportProjectModel>();
- /// <summary>
- /// 分析结果暂存
- /// </summary>
- protected List<System.Data.DataTable> dataTable_Totals = new List<System.Data.DataTable>();
- /// <summary>
- /// 详细分析结果暂存
- /// </summary>
- protected List<System.Data.DataTable> dataTables = new List<System.Data.DataTable>();
- /// <summary>
- /// 全部显示
- /// </summary>
- protected bool allShow = false;
- /// <summary>
- /// 详细列表需要求和的index集合
- /// </summary>
- protected List<int> IndexChangedFromIndex = new List<int>();
- /// <summary>
- /// 列表需要求和的index集合,value值为:1 求和 2:平均 3:级别计算 + [输入数据index位置,-1则需要调用自定义方法进行计算]
- /// </summary>
- protected Dictionary<int, int[]> IndexChangedToIndex = new Dictionary<int, int[]>();
- #endregion
- #region 组件
- private GroupBox groupBox_operating;
- protected GroupBox groupBox_img;
- protected ListView lstView_img;
- private ImageList imageList_img;
- private IContainer components;
- protected GroupBox groupBox_review;
- protected GroupBox groupBox_report;
- private Label label_resultPrecision;
- private Button button_exportResults;
- private Button button_generateReport;
- protected GroupBox groupBox6groupBox_analysisResult2;
- protected GroupBox groupBox_analysisResult1;
- private Button button_setting;
- protected CheckBox checkBox_generateReport_opensetting;
- protected DataGridView dataGridView2;
- protected ListView listView2;
- private Button button16;
- private Button button12;
- private Button button11;
- protected NumericUpDown numericUpDown1_0;
- private Button button1;
- private BinaryControlSmaller bc;
- protected DataGridView dataGridView_Total;
- private Button button2;
- private Button btn_saveresult;
- #endregion
- #region 构造函数
- public NonFMetalsStandardDialog(AppWorkspace appWorkspace, int menuId)
- {
- this.appWorkspace = appWorkspace;
- this.Icon = PdnInfo.AppIcon;
- this.Load += new System.EventHandler(this.NonFMetalsStandardDialog_Load);
- InitializeComponent();
- InitializeCustomControl();
- InitializeLanguageText();
- this.menuId = menuId;
- this.binaryClass = new BinaryClass(menuId);
- Initialize();
- SubclassInitialize();
- //初始化头
- this.listView2.View = View.Details;
- ColumnHeader header0 = new ColumnHeader();
- header0.Text = "";
- header0.Width = 180;
- this.listView2.Columns.Add(header0);
- //二值化集成2
- bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
- binaryClass.createDocumentItemsSmaller(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"), PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text") }
- , this.bc, this.appWorkspace, this.documentWorkspace, this.lstView_img);//初始化相的工作结构
- //##############################################
- binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
- 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));
- SetAnalyzeModelFromXml(getTemplateName());
- this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
- }
- private void Dialog_FormClosing(object sender, FormClosingEventArgs e)
- {
- binaryClass.saveParams();
- }
- private void ShownChoiseItemAndInitData(object sender, EventArgs e)
- {
- if (index > -1)
- {
- //滚动到指定的行位置
- this.lstView_img.EnsureVisible(index);
- if (this.lstView_img.SelectedItems != null && this.lstView_img.SelectedItems.Count > 0)
- {
- if (this.selectPicture == this.lstView_img.SelectedItems[0].Index)
- return;
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.SelectedItems[0].Index].CompositionSurface.CreatedAliasedMat();
- if (this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count)
- binaryClass.saveMat(this.imageList_img.Images.Keys[this.selectPicture]);
- //二值化集成4
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), getCurrentWorkTag());
- binaryClass.RefreshHistogramControl1Values();
- bool existViewFlag = this.appWorkspace.DocumentWorkspaces[this.lstView_img.SelectedItems[0].Index].GraphicsList.IsExsitView();
- if (!existViewFlag)
- matOrg = imageMat.Clone();
- else
- matOrg = PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.lstView_img.SelectedItems[0].Index].GetFullSizeWithRegion());
-
- this.selectPicture = this.lstView_img.SelectedItems[0].Index;
- //this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- //AddRectangleToRectangleFCaps(); this.documentWorkspace.Refresh();
- calculate1d = false;
- refreshWhileImgChanged();
- //this.commonControlButtons.Visible = true;//0914###18449
- this.documentWorkspace.Refresh();
- }
- }
- //// 初始化数据
- //this.bitmap = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreateAliasedBitmap();
- //Document document = Document.FromImage(bitmap);
- //this.documentWorkspace.Document = document;
- //this.documentWorkspace.Visible = true;
- //this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
- //this.applyButtonImpl(null, null);
- ////显示直方图
- //this.histogramControl1.CreateHistogram(this.bitmap, true, 339, 130, 0);
- }
- public NonFMetalsStandardDialog()
- {
- InitializeComponent();
- }
- #endregion
- #region 初始化组件
- private void InitializeLanguageText()
- {
- this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
- this.button2.Text = PdnResources.GetString("Menu.reckoning.text");
- this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
- this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
- this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text");
- this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.button11.Text = PdnResources.GetString("Menu.Showall.text");
- this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- }
- private void InitializeCustomControl()
- {
- //
- // bc
- //
- this.bc = new PaintDotNet.CustomControl.BinaryControlSmaller();
- this.bc.BinaryBackColor = System.Drawing.Color.Red;
- this.bc.BinaryChecked = false;
- this.bc.BinaryStyle = 1;
- this.bc.Location = new System.Drawing.Point(176, 70);
- 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, 247);
- this.bc.TabIndex = 38;
- 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();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox_operating = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox_generateReport_opensetting = new System.Windows.Forms.CheckBox();
- this.button_setting = new System.Windows.Forms.Button();
- this.btn_saveresult = new System.Windows.Forms.Button();
- this.groupBox_img = new System.Windows.Forms.GroupBox();
- this.lstView_img = new System.Windows.Forms.ListView();
- this.imageList_img = new System.Windows.Forms.ImageList(this.components);
- this.groupBox_review = new System.Windows.Forms.GroupBox();
- this.groupBox_report = new System.Windows.Forms.GroupBox();
- this.button1 = new System.Windows.Forms.Button();
- this.numericUpDown1_0 = new System.Windows.Forms.NumericUpDown();
- this.label_resultPrecision = new System.Windows.Forms.Label();
- this.button_exportResults = new System.Windows.Forms.Button();
- this.button_generateReport = new System.Windows.Forms.Button();
- this.groupBox6groupBox_analysisResult2 = new System.Windows.Forms.GroupBox();
- this.dataGridView_Total = new System.Windows.Forms.DataGridView();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.groupBox_analysisResult1 = new System.Windows.Forms.GroupBox();
- this.button11 = new System.Windows.Forms.Button();
- this.listView2 = new System.Windows.Forms.ListView();
- this.button16 = new System.Windows.Forms.Button();
- this.button12 = new System.Windows.Forms.Button();
- this.groupBox_operating.SuspendLayout();
- this.groupBox_img.SuspendLayout();
- this.groupBox_report.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
- this.groupBox6groupBox_analysisResult2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Total)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox_analysisResult1.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox_operating
- //
- this.groupBox_operating.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_operating.Controls.Add(this.button2);
- this.groupBox_operating.Controls.Add(this.checkBox_generateReport_opensetting);
- this.groupBox_operating.Controls.Add(this.button_setting);
- this.groupBox_operating.Controls.Add(this.btn_saveresult);
- this.groupBox_operating.Location = new System.Drawing.Point(13, 12);
- this.groupBox_operating.Name = "groupBox_operating";
- this.groupBox_operating.Size = new System.Drawing.Size(1102, 53);
- this.groupBox_operating.TabIndex = 12;
- this.groupBox_operating.TabStop = false;
- //
- // button2
- //
- this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button2.Location = new System.Drawing.Point(911, 20);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 7;
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.buttonCalculate_Click);
- //
- // checkBox_generateReport_opensetting
- //
- this.checkBox_generateReport_opensetting.AutoSize = true;
- this.checkBox_generateReport_opensetting.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
- this.checkBox_generateReport_opensetting.Location = new System.Drawing.Point(91, 24);
- this.checkBox_generateReport_opensetting.Name = "checkBox_generateReport_opensetting";
- this.checkBox_generateReport_opensetting.Size = new System.Drawing.Size(132, 16);
- this.checkBox_generateReport_opensetting.TabIndex = 6;
- this.checkBox_generateReport_opensetting.UseVisualStyleBackColor = true;
- //
- // button_setting
- //
- this.button_setting.Location = new System.Drawing.Point(6, 20);
- this.button_setting.Name = "button_setting";
- this.button_setting.Size = new System.Drawing.Size(75, 23);
- this.button_setting.TabIndex = 4;
- this.button_setting.UseVisualStyleBackColor = true;
- this.button_setting.Click += new System.EventHandler(this.button_setting_Click);
- //
- // btn_saveresult
- //
- this.btn_saveresult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.btn_saveresult.Location = new System.Drawing.Point(998, 20);
- this.btn_saveresult.Name = "btn_saveresult";
- this.btn_saveresult.Size = new System.Drawing.Size(75, 23);
- this.btn_saveresult.TabIndex = 2;
- this.btn_saveresult.UseVisualStyleBackColor = true;
- this.btn_saveresult.Click += new System.EventHandler(this.btn_saveresult_Click);
- //
- // groupBox_img
- //
- this.groupBox_img.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox_img.Controls.Add(this.lstView_img);
- this.groupBox_img.Location = new System.Drawing.Point(13, 72);
- this.groupBox_img.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox_img.Name = "groupBox_img";
- this.groupBox_img.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox_img.Size = new System.Drawing.Size(158, 514);
- this.groupBox_img.TabIndex = 13;
- this.groupBox_img.TabStop = false;
- //
- // lstView_img
- //
- this.lstView_img.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.lstView_img.HideSelection = false;
- this.lstView_img.LargeImageList = this.imageList_img;
- this.lstView_img.Location = new System.Drawing.Point(8, 26);
- this.lstView_img.Margin = new System.Windows.Forms.Padding(4);
- this.lstView_img.MultiSelect = false;
- this.lstView_img.Name = "lstView_img";
- this.lstView_img.Size = new System.Drawing.Size(140, 480);
- this.lstView_img.TabIndex = 0;
- this.lstView_img.UseCompatibleStateImageBehavior = false;
- this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
- //
- // imageList_img
- //
- this.imageList_img.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
- this.imageList_img.ImageSize = new System.Drawing.Size(64, 64);
- this.imageList_img.TransparentColor = System.Drawing.Color.Transparent;
- //
- // groupBox_review
- //
- this.groupBox_review.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.groupBox_review.Location = new System.Drawing.Point(541, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(575, 514);
- this.groupBox_review.TabIndex = 30;
- this.groupBox_review.TabStop = false;
- //
- // groupBox_report
- //
- this.groupBox_report.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox_report.Controls.Add(this.button1);
- this.groupBox_report.Controls.Add(this.numericUpDown1_0);
- this.groupBox_report.Controls.Add(this.label_resultPrecision);
- this.groupBox_report.Controls.Add(this.button_exportResults);
- this.groupBox_report.Controls.Add(this.button_generateReport);
- this.groupBox_report.Location = new System.Drawing.Point(974, 592);
- this.groupBox_report.Name = "groupBox_report";
- this.groupBox_report.Size = new System.Drawing.Size(142, 218);
- this.groupBox_report.TabIndex = 33;
- this.groupBox_report.TabStop = false;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(29, 112);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 23;
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // numericUpDown1_0
- //
- this.numericUpDown1_0.Location = new System.Drawing.Point(63, 165);
- 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 = 22;
- this.numericUpDown1_0.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1_0.ValueChanged += new System.EventHandler(this.numericUpDown1_0_ValueChanged);
- //
- // label_resultPrecision
- //
- this.label_resultPrecision.AutoSize = true;
- this.label_resultPrecision.Location = new System.Drawing.Point(26, 169);
- this.label_resultPrecision.Name = "label_resultPrecision";
- this.label_resultPrecision.Size = new System.Drawing.Size(29, 12);
- this.label_resultPrecision.TabIndex = 3;
- //
- // button_exportResults
- //
- this.button_exportResults.Location = new System.Drawing.Point(29, 73);
- this.button_exportResults.Name = "button_exportResults";
- this.button_exportResults.Size = new System.Drawing.Size(75, 23);
- this.button_exportResults.TabIndex = 1;
- this.button_exportResults.UseVisualStyleBackColor = true;
- this.button_exportResults.Click += new System.EventHandler(this.button_exportResults_Click);
- //
- // button_generateReport
- //
- this.button_generateReport.Location = new System.Drawing.Point(29, 34);
- this.button_generateReport.Name = "button_generateReport";
- this.button_generateReport.Size = new System.Drawing.Size(75, 23);
- this.button_generateReport.TabIndex = 0;
- this.button_generateReport.UseVisualStyleBackColor = true;
- this.button_generateReport.Click += new System.EventHandler(this.button_generateReport_Click);
- //
- // groupBox6groupBox_analysisResult2
- //
- this.groupBox6groupBox_analysisResult2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView_Total);
- this.groupBox6groupBox_analysisResult2.Controls.Add(this.dataGridView2);
- this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 592);
- this.groupBox6groupBox_analysisResult2.Name = "groupBox6groupBox_analysisResult2";
- this.groupBox6groupBox_analysisResult2.Size = new System.Drawing.Size(719, 218);
- this.groupBox6groupBox_analysisResult2.TabIndex = 32;
- this.groupBox6groupBox_analysisResult2.TabStop = false;
- //
- // dataGridView_Total
- //
- this.dataGridView_Total.AllowUserToAddRows = false;
- this.dataGridView_Total.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView_Total.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView_Total.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.dataGridView_Total.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
- this.dataGridView_Total.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_Total.Location = new System.Drawing.Point(13, 144);
- this.dataGridView_Total.Name = "dataGridView_Total";
- this.dataGridView_Total.ReadOnly = true;
- this.dataGridView_Total.RowHeadersVisible = false;
- this.dataGridView_Total.RowTemplate.Height = 23;
- this.dataGridView_Total.Size = new System.Drawing.Size(693, 68);
- this.dataGridView_Total.TabIndex = 17;
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
- dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F);
- dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Location = new System.Drawing.Point(13, 12);
- 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, 128);
- this.dataGridView2.TabIndex = 16;
- //
- // groupBox_analysisResult1
- //
- this.groupBox_analysisResult1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox_analysisResult1.Controls.Add(this.button11);
- this.groupBox_analysisResult1.Controls.Add(this.listView2);
- this.groupBox_analysisResult1.Controls.Add(this.button16);
- this.groupBox_analysisResult1.Controls.Add(this.button12);
- this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 592);
- this.groupBox_analysisResult1.Name = "groupBox_analysisResult1";
- this.groupBox_analysisResult1.Size = new System.Drawing.Size(224, 218);
- this.groupBox_analysisResult1.TabIndex = 31;
- this.groupBox_analysisResult1.TabStop = false;
- //
- // button11
- //
- this.button11.BackColor = System.Drawing.SystemColors.Control;
- this.button11.Location = new System.Drawing.Point(19, 22);
- this.button11.Name = "button11";
- this.button11.Size = new System.Drawing.Size(63, 26);
- this.button11.TabIndex = 27;
- this.button11.UseVisualStyleBackColor = false;
- this.button11.Click += new System.EventHandler(this.button11_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(19, 58);
- this.listView2.Name = "listView2";
- this.listView2.Size = new System.Drawing.Size(182, 149);
- this.listView2.TabIndex = 26;
- this.listView2.UseCompatibleStateImageBehavior = false;
- this.listView2.SelectedIndexChanged += new System.EventHandler(this.listview2_SelectedIndexChanged);
- //
- // button16
- //
- this.button16.BackColor = System.Drawing.SystemColors.Control;
- this.button16.Location = new System.Drawing.Point(19, 21);
- this.button16.Name = "button16";
- this.button16.Size = new System.Drawing.Size(93, 26);
- this.button16.TabIndex = 25;
- this.button16.UseVisualStyleBackColor = false;
- this.button16.Click += new System.EventHandler(this.button16_Click);
- //
- // button12
- //
- this.button12.BackColor = System.Drawing.SystemColors.Control;
- this.button12.Location = new System.Drawing.Point(149, 21);
- this.button12.Name = "button12";
- this.button12.Size = new System.Drawing.Size(52, 26);
- this.button12.TabIndex = 24;
- this.button12.UseVisualStyleBackColor = false;
- this.button12.Click += new System.EventHandler(this.button12_Click);
-
- //
- // NonFMetalsStandardDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
- this.ClientSize = new System.Drawing.Size(1127, 822);
-
- this.Controls.Add(this.groupBox_report);
- this.Controls.Add(this.groupBox6groupBox_analysisResult2);
- this.Controls.Add(this.groupBox_analysisResult1);
- this.Controls.Add(this.groupBox_review);
- this.Controls.Add(this.groupBox_img);
- this.Controls.Add(this.groupBox_operating);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Name = "NonFMetalsStandardDialog";
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Dialog_FormClosing);
- this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData);
- this.Controls.SetChildIndex(this.groupBox_operating, 0);
- this.Controls.SetChildIndex(this.groupBox_img, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
- this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
- this.Controls.SetChildIndex(this.groupBox_report, 0);
-
- this.groupBox_operating.ResumeLayout(false);
- this.groupBox_operating.PerformLayout();
- this.groupBox_img.ResumeLayout(false);
- this.groupBox_report.ResumeLayout(false);
- this.groupBox_report.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
- this.groupBox6groupBox_analysisResult2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Total)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox_analysisResult1.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- int index = -1;
- public void Initialize()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);//.CreateAliasedBitmap()
- this.lstView_img.Items.Add("", i);
- this.lstView_img.Items[i].ImageIndex = i;
- this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- index = i;
- }
- }
- //
- // 初始化选中的数据
- //
- if (index > -1 && index < this.lstView_img.Items.Count)
- this.lstView_img.Items[index].Selected = true; //选中行
- ////初始化图片列表
- //for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- //{
- // this.imageList_img.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
- // this.lstView_img.Items.Add("", i);
- // this.lstView_img.Items[i].ImageIndex = i;
- // this.lstView_img.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- // this.lstView_img.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- //}
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
- this.documentWorkspace.Cursor = Cursors.Default;
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.Paint += Panel_Paint;
- this.documentWorkspace.panel.MouseMove += onMouseMove;
- this.documentWorkspace.panel.MouseUp += onMouseUp;
- this.groupBox_review.Controls.Add(this.documentWorkspace);
- //
- //初始化操作按钮
- //
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- 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);
- groupBox_review.Controls.Add(this.commonControlButtons);
- }
- #endregion
- #region 二值化相关方法
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bClassBinaryImplFinishAction(object sender, EventArgs e)
- {
- this.documentWorkspace.Refresh();
- }
- //二值化集成3
- /// <summary>
- /// 添加参数改变的监听
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void NonFMetalsStandardDialog_Load(object sender, EventArgs e)
- {
- this.binaryClass.loadParams();
- //this.lstView_img.Select();
- }
- private bool bcBinaryChecked()
- {
- return bc != null && bc.BinaryChecked;
- }
- protected bool bcOriginChecked()
- {
- return bc != null && bc.OriginChecked;
- }
- /// <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;
- }
- else
- {
- this.documentWorkspace.PhaseModels[0].choise = false;
- }
- this.documentWorkspace.Refresh();
- }
- #endregion
- #region 内部方法
- /// <summary>
- /// PanelC的调色板颜色改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void gridColorChanged(object sender, EventArgs e)
- {
- Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
- //更改背景色,触发事件
- this.panelC.BackColor = color;
- this.documentWorkspace.Refresh();
- //关闭色板
- this.colorsFormGrid.Close();
- }
- /// <summary>
- /// 设置按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_setting_Click(object sender, EventArgs e)
- {
- string templateName = getTemplateName();
- AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, templateName);
- if (metallographicMethodSetDialog.hasModule)
- {
- metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen;
- metallographicMethodSetDialog.ShowDialog();
- }
- else
- {
- metallographicMethodSetDialog = null;
- }
- }
- private void btn_saveresult_Click(object sender, EventArgs e)
- {
- buildListBox_analysisResult();
- }
- private void lstView_img_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected)
- {
- if (this.selectPicture == this.lstView_img.FocusedItem.Index)
- return;
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- if (this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count)
- binaryClass.saveMat(this.imageList_img.Images.Keys[this.selectPicture]);
- //二值化集成4
- binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), getCurrentWorkTag());
- bool existViewFlag = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GraphicsList.IsExsitView();
- if (!existViewFlag)
- matOrg = imageMat.Clone();
- else
- matOrg = PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].GetFullSizeWithRegion());
-
- this.selectPicture = this.lstView_img.FocusedItem.Index;
- //this.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
- //AddRectangleToRectangleFCaps(); this.documentWorkspace.Refresh();
- calculate1d = false;
- refreshWhileImgChanged();
- bool BinaryChecked = false;
- if (getCurrentWorkTag() != null)
- BinaryChecked = (binaryClass.getModelMat(getCurrentWorkTag()) != null);
- //this.commonControlButtons.Visible = true;//0914###18449
- this.documentWorkspace.Refresh();
- }
- }
- /// <summary>
- /// 导出项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.checkBox_generateReport_opensetting.Checked)
- this.button_setting.PerformClick();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem nodeItem = this.appWorkspace.GetInsertProjectPath(2, getProjectEngineeringName(), 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>>();
- {
- List<string> contentHeaderText = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- contentHeaderText.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)//################################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- }
- {
- List<string> contentHeaderText = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- contentHeaderText.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText);
- foreach (DataGridViewRow item in this.dataGridView_Total.Rows)
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText.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 button_exportResults_Click(object sender, EventArgs e)
- {
- if (this.listView2.Items.Count > 0)
- {
- //for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- //{
- // System.Data.DataRow dataRow = table1.NewRow();
- // if (r == 0)
- // {
- // for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- // {
- // dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Columns[c].HeaderText;
- // }
- // table1.Rows.Add(dataRow);
- // }
- // dataRow = table1.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;
- // }
- // table1.Rows.Add(dataRow);
- //}
- //System.Data.DataTable table2 = new System.Data.DataTable();
- //table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
- //foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- //{
- // table2.Columns.Add(c.HeaderText);
- //}
- //for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
- //{
- // System.Data.DataRow dataRow = table2.NewRow();
- // if (r == 0)
- // {
- // for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- // {
- // dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Columns[c].HeaderText;
- // }
- // table2.Rows.Add(dataRow);
- // }
- // dataRow = table2.NewRow();
- // for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- // {
- // dataRow[this.dataGridView_Total.Columns[c].HeaderText] = this.dataGridView_Total.Rows[r].Cells[c].Value;
- // }
- // table2.Rows.Add(dataRow);
- //}
- //if (table1.Rows.Count > 0) ds.Tables.Add(table1);
- //if (table2.Rows.Count > 0) ds.Tables.Add(table2);
- //if (ds.Tables.Count > 0)
- // DataToExcle(ds);
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
- return;
- }
- if (this.listView2.Items.Count > 0)
- {
- List<System.Data.DataTable> list = new List<System.Data.DataTable>();
- System.Data.DataTable table1 = new System.Data.DataTable();
- table1.TableName = PdnResources.GetString("Menu.breakdown.text");
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- table1.Columns.Add(/*HeaderTextUsable ? */c.HeaderText/* : c.Name*/);
- }
- for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = table1.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[/*HeaderTextUsable ? */this.dataGridView2.Columns[c].HeaderText/* : this.dataGridView2.Columns[c].Name*/] = this.dataGridView2.Columns[c].HeaderText;
- }
- table1.Rows.Add(dataRow);
- }
- dataRow = table1.NewRow();
- for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
- {
- dataRow[/*HeaderTextUsable ? */this.dataGridView2.Columns[c].HeaderText/* : this.dataGridView2.Columns[c].Name*/] = this.dataGridView2.Rows[r].Cells[c].Value;
- }
- table1.Rows.Add(dataRow);
- }
- System.Data.DataTable table2 = new System.Data.DataTable();
- table2.TableName = PdnResources.GetString("Menu.statisaatics.text");
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- table2.Columns.Add(/*HeaderTextUsable ? */c.HeaderText/* : c.Name*/);
- }
- for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
- {
- System.Data.DataRow dataRow = table2.NewRow();
- if (r == 0)
- {
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- {
- dataRow[/*HeaderTextUsable ? */this.dataGridView_Total.Columns[c].HeaderText/* : this.dataGridView_Total.Columns[c].Name*/] = this.dataGridView_Total.Columns[c].HeaderText;
- }
- table2.Rows.Add(dataRow);
- }
- dataRow = table2.NewRow();
- for (int c = 0; c < this.dataGridView_Total.Rows[r].Cells.Count; c++)
- {
- dataRow[/*HeaderTextUsable ? */this.dataGridView_Total.Columns[c].HeaderText/* : this.dataGridView_Total.Columns[c].Name*/] = this.dataGridView_Total.Rows[r].Cells[c].Value;
- }
- table2.Rows.Add(dataRow);
- }
- if (table1.Rows.Count > 0) list.Add(table1);
- if (table2.Rows.Count > 0) list/*ds.Tables*/.Add(table2);
- //if (table1.Rows.Count > 0) ds.Tables.Add(table1);
- //if (table2.Rows.Count > 0) ds.Tables.Add(table2);
- //if (ds.Tables.Count > 0)
- // DataToExcle(ds);
- if (list.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text") + "!");
- return;
- }
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.DefaultExt = "xlsx";
- saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
- saveFileDialog.FileName = this.Text + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
- saveFileDialog.RestoreDirectory = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true/*HeaderTextUsable*/, false, true);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
- }
- /// <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);
- 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;
- drawSubclass(graphics);
- }
- /// <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.Items.Count <= 0 && this.listView2.SelectedItems.Count <= 0)
- return;
- RefreshDataGridView2();
- //double value_1 = 0;
- //double small_l = 0;
- //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;
- // 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();
- // small_l += double.Parse(dataTable1.Rows[0][c].ToString());
- // }
- // this.dataGridView2.Rows.Add(dgvr);
- // }
- // }
- // 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();
- // small_l += double.Parse(dataTable1.Rows[0][c].ToString());
- // }
- // this.dataGridView2.Rows.Add(dgvr);
- // }
- // }
- // }
- //}
- //double grainNumber = 0;
- //this.dataGridView_Total.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.dataTable_Totals)
- // {
- // 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;
- // }
- // }
- // grainNumber += double.Parse(dataTable1.Rows[0][0].ToString());
- //}
- //{
- // DataGridViewRow dgvr = new DataGridViewRow();
- // foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- // {
- // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- // }
- // dgvr.Cells[0].Value = (grainNumber).ToString();
- // dgvr.Cells[1].Value = (small_l).ToString();
- // small_l = small_l / value_1;
- // dgvr.Cells[2].Value = small_l.ToString();
- // dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- // this.dataGridView_Total.Rows.Add(dgvr);
- //}
- ////##
- //this.RefreshDataGridView4();
- }
- /// <summary>
- /// 切换分析结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void listview2_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (!this.allShow)
- {
- RefreshDataGridView2();
- //if (this.listView2.SelectedItems.Count <= 0)
- // return;
- //double value_1 = 0;
- //double small_l = 0;
- //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();
- // small_l += double.Parse(dataTable1.Rows[0][c].ToString());
- // }
- // this.dataGridView2.Rows.Add(dgvr);
- // }
- // }
- //}
- //double grainNumber = 0;
- //this.dataGridView_Total.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.dataTable_Totals)
- // {
- // if (this.listView2.SelectedItems[i].Tag.Equals(dataTable.TableName))
- // dataTable1 = dataTable;
- // }
- // grainNumber += double.Parse(dataTable1.Rows[0][0].ToString());
- //}
- //{
- // DataGridViewRow dgvr = new DataGridViewRow();
- // foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- // {
- // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- // }
- // dgvr.Cells[0].Value = (grainNumber).ToString();
- // dgvr.Cells[1].Value = (small_l).ToString();
- // small_l = small_l / value_1;
- // dgvr.Cells[2].Value = small_l.ToString();
- // dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- // this.dataGridView_Total.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.button6.Text == PdnResources.GetString("Menu.Showall.text"))
- //{
- // this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text");
- // this.showAll = true;
- // RefreshDataGridView2();
- //}
- //else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text"))
- //{
- // this.button6.Text = PdnResources.GetString("Menu.Showall.text");
- // this.showAll = false;
- // RefreshDataGridView2();
- //}
- if (this.listView2.Items.Count > 0)
- {
- this.button11.Visible = false;
- this.button16.Visible = true;
- this.button16.Focus();
- this.allShow = true;
- RefreshDataGridView2();
- //double value_1 = 0;
- //double small_l = 0;
- //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();
- // small_l += double.Parse(this.dataTables[i].Rows[0][c].ToString());
- // }
- // this.dataGridView2.Rows.Add(dgvr);
- //}
- //double grainNumber = 0;
- //this.dataGridView_Total.Rows.Clear();
- //for (int i = 0; i < this.dataTable_Totals.Count; i++)
- //{
- // grainNumber += double.Parse(this.dataTable_Totals[i].Rows[0][0].ToString());
- //}
- //{
- // DataGridViewRow dgvr = new DataGridViewRow();
- // foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
- // {
- // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- // }
- // dgvr.Cells[0].Value = (grainNumber).ToString();
- // dgvr.Cells[1].Value = (small_l).ToString();
- // small_l = small_l / value_1;
- // dgvr.Cells[2].Value = small_l.ToString();
- // dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
- // this.dataGridView_Total.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 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.dataTable_Totals)
- {
- if (dataTable.TableName.Equals(this.listView2.SelectedItems[i].Tag))
- {
- this.dataTable_Totals.Remove(dataTable);
- break;
- }
- }
- foreach (DataTable dt in resultTableList)
- {
- if (dt.TableName.Equals(this.listView2.SelectedItems[i].Tag))
- {
- resultTableList.Remove(dt);
- break;
- }
- }
- for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
- {
- System.Data.DataTable dataTable1 = dataTables[dataTableI];
- if (dataTable1.TableName.Equals(this.listView2.SelectedItems[i].Tag/*tag*/))
- dataTables.RemoveAt(dataTableI);
- }
- 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.dataGridView_Total.Rows.Clear();
- this.dataGridView2.Rows.Clear();
- }
- else
- RefreshDataGridView2();
- //RefreshDataGridView4();
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
- }
- }
- /// <summary>
- /// 小数位数
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
- {
- if (this.numericUpDown1_0.Value > this.numericUpDown1_0.Maximum)
- this.numericUpDown1_0.Value = this.numericUpDown1_0.Maximum;
- if (this.numericUpDown1_0.Value < this.numericUpDown1_0.Minimum)
- this.numericUpDown1_0.Value = this.numericUpDown1_0.Minimum;
- RefreshDataGridView1();
- RefreshDataGridView2();
- }
- /// <summary>
- /// 生成报告
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button_generateReport_Click(object sender, EventArgs e)
- {
- //if (this.listView2.Items.Count == 0)
- //{
- // MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- // return;
- //}
- //if (this.checkBox_generateReport_opensetting.Checked)
- // this.button_setting.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>>();
- //List<string> contentHeaderText = new List<string>();
- //foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- //{
- // contentHeaderText.Add(c.HeaderText);
- //}
- //analysisContent.Add(contentHeaderText);
- //foreach (DataGridViewRow item in this.dataGridView2.Rows)//##########################
- //{
- // List<string> content = new List<string>();
- // for (int i = 0; i < contentHeaderText.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")+"!");
- if (this.listView2.Items.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.checkBox_generateReport_opensetting.Checked)
- this.button_setting.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>>();
- List<string> contentHeaderText = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView2.Columns)
- {
- contentHeaderText.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText);
- foreach (DataGridViewRow item in this.dataGridView2.Rows)//##########################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText.Count; i++)
- {
- content.Add(item.Cells[i].Value.ToString());
- }
- analysisContent.Add(content);
- }
- List<string> contentHeaderText2 = new List<string>();
- foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
- {
- contentHeaderText2.Add(c.HeaderText);
- }
- analysisContent.Add(contentHeaderText2);
- foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
- {
- List<string> content = new List<string>();
- for (int i = 0; i < contentHeaderText2.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>
- /// 导出多 Sheet 报表
- /// </summary>
- /// <param name="ds">要导出的数据</param>
- public void DataToExcle(System.Data.DataSet ds)
- {
- try
- {
- if (ds.Tables == null || ds.Tables.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text")+"!");
- return;
- }
- SaveFileDialog saveFileDialog = new SaveFileDialog();
- saveFileDialog.DefaultExt = "xlsx";
- saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text");
- saveFileDialog.FileName = this.Text + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx";
- saveFileDialog.RestoreDirectory = true;
- if (saveFileDialog.ShowDialog() == DialogResult.OK)
- {
- List<System.Data.DataTable> list = new List<System.Data.DataTable>();
- foreach (System.Data.DataTable itemTable in ds.Tables)
- list.Add(itemTable);
- this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true, false, true);
- }
- }
- catch (Exception e)
- {
- throw e;
- }
- }
- /// <summary>
- /// 刷新分析结果表
- /// </summary>
- private void RefreshDataGridView2()
- {
- this.dataGridView2.Rows.Clear();
- double dValue;
- List<double> totalValueList = new List<double>();
- for (int i = 0; i < this.dataGridView_Total.Columns.Count; i++)
- {
- totalValueList.Add(0.0);
- }
- int startFromIndex = 1;
- if (IndexChangedFromIndex.Count > 0)
- startFromIndex = IndexChangedFromIndex[0];
- if (this.allShow)
- {
- foreach (DataTable dt in resultTableList)
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 30;
- for (int rowJ = 0; rowJ < startFromIndex; rowJ++)
- row.Cells.Add(CreateTextBoxCell(dt.Rows[i][rowJ].ToString(), ""));
- for (int rowJ = startFromIndex; rowJ < dt.Rows[i].ItemArray.Length; rowJ++)
- {
- row.Cells.Add(CreateTextBoxCell(this.resShow(dt.Rows[i][rowJ].ToString()), ""));
- if (double.TryParse(dt.Rows[i][rowJ].ToString(), out dValue))
- totalValueList[rowJ - startFromIndex] = totalValueList[rowJ - startFromIndex] + dValue;
- }
- this.dataGridView2.Rows.Add(row);
- }
- }
- else
- {
- if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0)
- {
- for (int i = 0; i < this.listView2.SelectedItems.Count; i++)
- foreach (DataTable dt in resultTableList)
- if (dt.TableName.Equals((string)this.listView2.SelectedItems[i].Tag))
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 30;
- for (int rowJ = 0; rowJ < startFromIndex; rowJ++)
- row.Cells.Add(CreateTextBoxCell(dt.Rows[i][rowJ].ToString(), ""));
- for (int rowJ = startFromIndex; rowJ < dt.Rows[j].ItemArray.Length; rowJ++)
- {
- row.Cells.Add(CreateTextBoxCell(this.resShow(dt.Rows[j][rowJ].ToString()), ""));
- if (double.TryParse(dt.Rows[j][rowJ].ToString(), out dValue))
- totalValueList[rowJ - startFromIndex] = totalValueList[rowJ - startFromIndex] + dValue;
- }
- this.dataGridView2.Rows.Add(row);
- }
- }
- else if (this.listView2.Items.Count > 0)
- {
- string tableName = (string)this.listView2.Items[0].Tag;
- foreach (DataTable dt in resultTableList)
- if (dt.TableName.Equals(tableName))
- for (int j = 0; j < dt.Rows.Count; j++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 30;
- for (int rowJ = 0; rowJ < startFromIndex; rowJ++)
- row.Cells.Add(CreateTextBoxCell(dt.Rows[j][rowJ].ToString(), ""));
- for (int rowJ = startFromIndex; rowJ < dt.Rows[j].ItemArray.Length; rowJ++)
- {
- row.Cells.Add(CreateTextBoxCell(this.resShow(dt.Rows[j][rowJ].ToString()), ""));
- if (double.TryParse(dt.Rows[j][rowJ].ToString(), out dValue))
- totalValueList[rowJ - startFromIndex] = totalValueList[rowJ - startFromIndex] + dValue;
- }
- this.dataGridView2.Rows.Add(row);
- }
- }
- }
- this.dataGridView_Total.Rows.Clear();
- if (this.dataGridView2.Rows.Count > 0 && this.dataGridView_Total.Columns.Count == totalValueList.Count)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.Height = 30;
- for (int i = 0; i < this.dataGridView_Total.Columns.Count; i++)
- {
- row.Cells.Add(CreateTextBoxCell(this.resShow((totalValueList[i] / this.dataGridView2.Rows.Count).ToString()), ""));
- }
- this.dataGridView_Total.Rows.Add(row);
- }
- }
- #region 公共按钮
- 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.InclusionNoEffect;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
- }
- #endregion
- #region 矩形拖动
- /// <summary>
- /// 防止拖动鼠标与小手动作的冲突
- /// </summary>
- /// <returns></returns>
- protected bool CanUseMouseFunctions()
- {//#22071
- return this.documentWorkspace.ActiveTool != Annotation.Enum.DrawToolType.MoveMode;
- }
- /// <summary>
- /// 鼠标按下
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- protected virtual void OnMouseDown(object sender, MouseEventArgs e)
- {
- //// 换算后的点
- //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- }
- /// <summary>
- /// 移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void onMouseMove(object sender, MouseEventArgs e)
- {
- this.documentWorkspace.Refresh();
- //// 换算后的点
- //PointF point1 = documentWorkspace.GetScalePoint(e.Location);
- }
- /// <summary>
- /// 鼠标抬起
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void onMouseUp(object sender, MouseEventArgs e)
- {
- //m_canMove = false;
- }
- #endregion
- #endregion
- #region 可调用方法
- /// <summary>
- /// 颜色点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void panel1_Click(object sender, EventArgs e)
- {
- this.panelC = (Panel)sender;
- this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panelC.BackColor);
- this.colorsFormGrid.ShowDialog();
- }
- ///// <summary>
- ///// 是否能取到二值的结果
- ///// </summary>
- ///// <returns></returns>
- //protected Boolean getBinaryChecked()
- //{
- // return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
- //}
- /// <summary>
- /// 返回当前选择的图片内容
- /// </summary>
- /// <returns></returns>
- protected DocumentWorkspace getCurrentWorkspace()
- {
- return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
- }
- /// <summary>
- /// 返回当前选择的图片tag
- /// </summary>
- /// <returns></returns>
- protected string getCurrentWorkTag()
- {
- return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : lstView_img.SelectedItems[0].Index/*lstView_img.SelectedItems[0].Index*/];
- }
- #endregion
- #region 需继承方法
- /// <summary>
- /// 小数点位数变化时刷新界面的数据
- /// </summary>
- protected virtual void RefreshDataGridView1()
- {
- }
- /// <summary>
- /// 图片索引改变后调用的事件
- /// </summary>
- protected virtual void refreshWhileImgChanged()
- {
- }
- /// <summary>
- /// 计算结果是否存在
- /// </summary>
- /// <returns>返回是否可以计算和保存结果</returns>
- protected virtual bool resultCalculateExist()
- {
- return false;
- }
- /// <summary>
- /// 计算结果
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected virtual void buttonCalculate_Click(object sender, EventArgs e)
- {
- }
- /// <summary>
- /// 点击保存结果按钮,用来返回需要新增的一行数据
- /// </summary>
- /// <param name="tag"></param>
- /// <param name="imgName"></param>
- /// <returns></returns>
- protected virtual DataTable toInsertTableRow(string tag, string imgName)
- {
- DataTable dt = new DataTable(tag);
- return dt;
- }
- /// <summary>
- /// 保存结果
- /// </summary>
- protected virtual void buildListBox_analysisResult()
- {
- if (this.matOrg == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
- return;
- }
- string imgName = getCurrentWorkspace().GetFriendlyName();
- string tag = getCurrentWorkTag();
- bool replace = false;
- int rowIndex = 0;
- if (!resultCalculateExist())
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawauxiliarylinesfirst.text"));
- return;
- }
- if (!calculate1d)
- {
- MessageBox.Show("请先计算结果"/*PdnResources.GetString("Menu.Pleasedrawthemeasuringlinefirst.text")*/);
- return;
- }
- if (this.listView2.Items.Count > 0)
- {
- foreach (ListViewItem item in this.listView2.Items)
- {
- if (item.Tag.Equals(tag))
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- replace = true;
- }
- else
- {
- return;
- }
- break;
- }
- }
- }
- if (!replace)
- {
- 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);
- }
- //有重名需要替换
- if (replace)
- {
- for (int i = 0; i < this.resultTableList.Count; i++)
- {
- if (this.resultTableList[i].TableName.Equals(tag))
- {
- rowIndex = i;
- this.resultTableList.Remove(this.resultTableList[i]);
- resultTableList.Insert(rowIndex, toInsertTableRow(tag, imgName));
- }
- }
- }
- //新增
- else
- resultTableList.Add(toInsertTableRow(tag, imgName));
- RefreshDataGridView2();
- //保存处理后的图片
- double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.selectPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- List<Bitmap> tempBit = new List<Bitmap>();
- Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);// this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- if (this.documentWorkspace.PhaseModels[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);
- }
- graphics.SmoothingMode = SmoothingMode.AntiAlias;
- drawSubclass/*Draw*/(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- bitDic[tag] = tempBit;
- else
- bitDic.Add(tag, tempBit);
- //拼接中间数据
- //-->
- 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)
- {
- List<List<string>> tempDataList = buildTempDataList();
- if (tempDataList != null)
- tempDataModel[modelIndex].dataList = tempDataList;
- }
- else
- {
- ExportProjectModel newModel = new ExportProjectModel();
- newModel.tagName = tag;
- newModel.picName = getCurrentWorkspace().GetFriendlyName();
- List<List<string>> tempDataList = buildTempDataList();
- newModel.dataList = tempDataList;
- if (tempDataList != null)
- tempDataModel.Add(newModel);
- }
- //buildListBoxArea_analysisResult();
- }
- /// <summary>
- /// 拼接中间数据
- /// </summary>
- /// <returns></returns>
- protected virtual List<List<string>> buildTempDataList()
- {
- return null;
- //List<List<string>> dataList = new List<List<string>>();
- //return dataList;
- }
- /// <summary>
- /// 添加内容单元格
- /// </summary>
- /// <param name="text"></param>
- /// <param name="tag"></param>
- /// <returns></returns>
- protected DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
- {
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = text;
- textboxcell.Tag = tag;
- return textboxcell;
- }
- /// <summary>
- /// 小数位数格式化 //0916###18530
- /// </summary>
- /// <param name="resValue"></param>
- /// <returns></returns>
- protected string resShow(string resValue)
- {
- if (string.IsNullOrEmpty(resValue))
- {
- return "0";
- }
- double dValue;
- if (!double.TryParse(resValue, out dValue))
- {
- return resValue;
- }
- return Math.Round(dValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
- }
- protected virtual void SubclassInitialize()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 报告模板命名
- /// </summary>
- /// <returns></returns>
- protected virtual string getTemplateName()
- {
- throw new NotImplementedException();
- }
- /// <summary>
- /// 项目工程内的文件夹路径名称
- /// </summary>
- /// <returns></returns>
- protected virtual string getProjectEngineeringName()
- {
- throw new NotImplementedException();
- }
- protected virtual void drawSubclass(Graphics graphics)
- {
- ////显示辅助线
- //if (showGridChecked())
- // if (isAreaType)
- // guideClass.DrawAreaGuide(graphics, this.comboBox1.SelectedItem);
- // else
- // guideClass.DrawGuideLines(graphics, this.comboBox1.SelectedItem);
- ////显示截点
- //if (drawGuidePoints())
- // styleClass.DrawGuidePoints(graphics);
- }
- ///// <summary>
- ///// 刷新图形边线点集合
- ///// </summary>
- //protected virtual void AddRectangleToRectangleFCaps()
- //{
- // this.documentWorkspace.Refresh();
- //}
- #endregion
- }
- }
|