123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725 |
- using OpenCvSharp;
- using OpenCvSharp.Extensions;
- using PaintDotNet.Base.Functionodel;
- using PaintDotNet.CustomControl;
- using PaintDotNet.Data.Param;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using PaintDotNet.DbOpreate.DbBll;
- using PaintDotNet.DbOpreate.DbModel;
- using PaintDotNet.Base.CommTool;
- using System.Data;
- using System.IO;
- using PaintDotNet.Instrument;
- using Metis.ParameterSet;
- using PaintDotNet.Base;
- namespace PaintDotNet.GeneralAnalysis
- {
- /// <summary>
- /// 两相面积含量
- /// </summary>
- internal class PolyphaseContentDialog : PdnBaseForm
- {
- /// <summary>
- /// 主空间
- /// </summary>
- private AppWorkspace appWorkspace;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- private DocumentWorkspaceWindow tmpDocumentWorkspace;
- /// <summary>
- /// 选中图片的mat
- /// </summary>
- private Mat imageMat;
- private List<PolyphaseAnalysisResult> polyphaseAnalysisResults = new List<PolyphaseAnalysisResult>();
- private List<PolyphaseAnalysisResult> viewPolyphaseAnalysisResults = new List<PolyphaseAnalysisResult>();
- private List<PolyphaseAnalysisResult> mainPolyphaseAnalysisResults = new List<PolyphaseAnalysisResult>();
- /// <summary>
- /// 处理程序
- /// </summary>
- private ParamObject action = new Data.Action.Action901();
- /// <summary>
- /// 当前选择的图片index
- /// </summary>
- int selectIndex = 0;
- int decnum = 2;
- private CommonControlButtons commonControlButtons;
- private int is_all = 0;
- private List<Bitmap> bitList = new List<Bitmap>();
- private Dictionary<string, List<Bitmap>> bitDic = new Dictionary<string, List<Bitmap>>();
- private int imgIndex = -1;
- private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
- private bool isExportResults = false;
- private bool isExportReports = false;
- private bool isExportProjects = false;
- /// <summary>
- /// 是否脚本运行
- /// </summary>
- private Boolean initScriptValues = false;
- private int menuId;
- private string menuName;
- #region 控件
- private System.Windows.Forms.GroupBox groupBox4;
- private System.Windows.Forms.ListView listView1;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.Button button1;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox_review;
- private System.Windows.Forms.GroupBox groupBox5;
- private System.Windows.Forms.GroupBox groupBox6;
- private System.Windows.Forms.GroupBox groupBox7;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.DataGridView dataGridView1;
- private System.Windows.Forms.ImageList imageList1;
- private GroupBox groupBox3;
- private Label label5;
- private Label label4;
- private Label label3;
- private DataGridView dataGridView_results;
- private Label lbl_content;
- private Label lbl_area;
- private Label lbl_rate;
- private Button button_remove;
- private Button button_all;
- private Button button5;
- private NumericUpDown numericUpDown1;
- private DataGridViewTextBoxColumn Column1;
- private DataGridViewTextBoxColumn Column2;
- private DataGridViewTextBoxColumn Column3;
- private DataGridViewTextBoxColumn Column4;
- private Button button9;
- private CheckedListBox listBox_analysisResult;
- private DataGridViewTextBoxColumn Column5;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
- private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
- private IContainer components;
- #endregion
- public PolyphaseContentDialog()
- {
- InitializeComponent();
- }
- public PolyphaseContentDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
- {
- InitializeComponent();
- InitializeLanguageText();
- this.appWorkspace = appWorkspace;
- this.menuId = menuItem.MenuId;
- this.menuName = menuItem.Text;
- this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.AuxiliaryLineEnabled = false;
- this.documentWorkspace.Visible = false;
- tmpDocumentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
- this.groupBox_review.Controls.Add(documentWorkspace);
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox_review.Controls.Add(commonControlButtons);
- InitPicList();
- CalcProcess();
- this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
- SetAnalyzeModelFromXml("Template.Manager.item2.PolyphaseContent");
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
- SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
- InitCommonButtonEvent();
-
- this.Shown += showImg;
- this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
- }
- private void showImg(object sender, EventArgs e)
- {
- listView1.Focus();
- if (this.imgIndex != -1)
- {
- //滚动到指定的行位置
- this.listView1.EnsureVisible(this.imgIndex);
- this.listView1.Items[imgIndex].Focused = true;
- this.listView1.Items[imgIndex].Selected = true;
- //如果是脚本执行,将参数带入
- if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
- {
- this.initScriptValues = true;//ScriptAutomatic
- //Boolean initScriptValues = true;
- ////在这里反射出对应功能的参数类
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- foreach (Args arg in param.Lists)
- {
- Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
- if (param1.value != null)
- arg.Value = param1.value;
- getValue(arg.key, arg.Value);
- }
- appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
- }
- else
- {//读取上次关闭窗口时保存的参数
- getLastData();
- }
- if (this.initScriptValues && this.appWorkspace.ScriptAutomatic)
- this.startScriptAutomaticAction();
- }
- }
- /// <summary>
- /// 获取上次操作参数
- /// </summary>
- private void getLastData()
- {
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- if (!System.IO.File.Exists(filePath))
- {
- generalAnalysisModel = new GeneralAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel();
- generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel();
- generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel();
- generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
- generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
- generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel();
- generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel();
- generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false;
- generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false;
- generalAnalysisModel.PolyphaseContentModels.hasUsed = false;
- generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false;
- generalAnalysisModel.DebrisSelectionModels.hasUsed = false;
- generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false;
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\");
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew);
- }
- else
- {
- generalAnalysisModel = XmlSerializeHelper.DESerializer<GeneralAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open));
- if (generalAnalysisModel.PolyphaseContentModels == null) {
- generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
- }
- if (generalAnalysisModel.PolyphaseContentModels.hasUsed)
- {
- numericUpDown1.Value = generalAnalysisModel.PolyphaseContentModels.parameter1;
- checkBox1.Checked = generalAnalysisModel.PolyphaseContentModels.parameter2;
- }
- }
- }
- /// <summary>
- /// 保存上次操作参数
- /// </summary>
- private void saveLastData(object sender, EventArgs e)
- {
- #region [开启脚本录制]
- if (appWorkspace.startScriptRecording)
- {
- getScriptRecording();
- }
- #endregion
- if (generalAnalysisModel.PolyphaseContentModels == null)
- {
- generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel();
- }
- generalAnalysisModel.PolyphaseContentModels.hasUsed = true;
- generalAnalysisModel.PolyphaseContentModels.parameter1 = (int)numericUpDown1.Value;
- generalAnalysisModel.PolyphaseContentModels.parameter2 = checkBox1.Checked;
- string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
- string porosityInfoXml = XmlSerializeHelper.XmlSerialize<GeneralAnalysisModel>(generalAnalysisModel);
- FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
- }
- private void PolyphaseContentDialog_Load(object sender, EventArgs e)
- {
- }
- #region 公共按钮
- 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)
- {
- if(this.imageMat != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.imageMat != null)
- 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;
- }
- #endregion
- /// <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();
- // }
- //}
- public void InitPicList()
- {
- //初始化图片列表
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
- {
- this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);
- this.listView1.Items.Add("", i);
- this.listView1.Items[i].ImageIndex = i;
- String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
- if (listView1.Items.Find(imageName, false).Count() > 0)
- {
- if (imageName.Split('.').Count() > 1)
- {
- imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
- }
- }
- this.listView1.Items[i].Text = imageName;
- this.listView1.Items[i].Name = imageName;
- if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
- {
- this.imgIndex = i;
- }
- }
- }
- /// <summary>
- /// ListView图片选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ListViewSelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
- {
- this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
- Document document = Document.FromImageMat(imageMat.Clone());
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
- this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels;
- //tmpDocumentWorkspace.Document = document;
- //tmpDocumentWorkspace.Visible = true;
- //tmpDocumentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList;
- //tmpDocumentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels;
- this.applyButtonImpl(sender, e);
- //获取显示直方图
- //pdnRegion = new PdnRegion(AppWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].Document.Bounds);
- //this.histogramControl1.Histogram.UpdateHistogram(AppWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].SurfaceBox.Surface, pdnRegion);
- }
- }
- private void CalcProcess()
- {
- //for (int selectIndex = 0; selectIndex < this.appWorkspace.DocumentWorkspaces.Count(); selectIndex++)
- //{
- //}
- }
- /// <summary>
- /// 参数改变时,重新处理图像
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void applyButtonImpl(object sender, EventArgs e)
- {
- //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
- double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
- if (this.listView1.FocusedItem != null)
- {
- dataGridView1.Rows.Clear();
- mainPolyphaseAnalysisResults.Clear();
- selectIndex = this.listView1.FocusedItem.Index;
- //判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
- if (this.appWorkspace.DocumentWorkspaces[selectIndex].GraphicsList.IsExsitView())
- {
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
- {
- PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
- if (pModel.choise)
- {
- Color pColor = new Color();
- pColor = Color.FromArgb(pModel.color);
- Mat front = pModel.mat;
- //相总面积
- int phaseAmount = AnalysisTools.GetPointsFromMat(front);
- //视图中相面积
- Bitmap frontTarget = this.documentWorkspace.GetFullSizeWithRegion(front.ToBitmap());
- //frontTarget.Save("D:\\1-1.bmp");
- //获取视图中相的点合计
- //int frontAmount = AnalysisTools.GetPointsFromMat(PaintDotNet.Camera.Tools.ToMat(frontTarget));
- Mat background = this.imageMat.Clone();
- Mat roi = new Mat(background, new Rect(0, 0, background.Width, background.Height));
- Mat mask = Mat.FromImageData(front.ToBytes(), ImreadModes.Grayscale);
- front.CopyTo(roi, mask);
- Bitmap target = this.documentWorkspace.GetFullSizeWithRegion(background.ToBitmap());
- Mat targetMat = PaintDotNet.Camera.Tools.ToMat(target);
- targetMat.SaveImage("D:\\2.bmp");
- //获取合并后视场内的点合计
- int allAmount = AnalysisTools.GetPointsFromMat(targetMat);
- int picAmount = AnalysisTools.GetPointsFromMat(background);
- double cRate = 0f;
- //计算比例
- //视场内部存在相
- //if (viewAmount > 0)
- //{
- //}
- //else
- //{
- // //视场内部不存在相
- // cRate = (double)phaseAmount / allAmount;
- //}
- cRate = (double)phaseAmount / allAmount;
- //计算面积
- double cArea = phaseAmount;
- //计算相含量
- double fRate = (double)phaseAmount / picAmount;
- //dataGridView1.Rows.Add(this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name, cArea, cRate, fRate);
- PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
- pResult.GraphName = this.listView1.FocusedItem.Text;
- pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
- pResult.PolyphaseArea = cArea * pxPerUnit * pxPerUnit;
- pResult.PolyphaseRate = cRate * 100;
- pResult.PolyphaseAllRate = fRate * 100;
- mainPolyphaseAnalysisResults.Add(pResult);
- dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum) , AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
- }
- }
- }
- else
- {
- for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
- {
- PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
- if (pModel.choise)
- {
- Color pColor = new Color();
- pColor = Color.FromArgb(pModel.color);
- int phaseArea = AnalysisTools.GetPointsFromMat(pModel.mat);
- Mat sourceMat = this.imageMat.Clone();
- int picAmount = AnalysisTools.GetPointsFromMat(sourceMat);
- //计算面积
- double cRate = (double)phaseArea / picAmount;
- PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
- pResult.GraphName = this.listView1.FocusedItem.Text;
- pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
- pResult.PolyphaseArea = phaseArea * pxPerUnit * pxPerUnit;
- pResult.PolyphaseRate = cRate * 100;
- pResult.PolyphaseAllRate = cRate * 100;
- mainPolyphaseAnalysisResults.Add(pResult);
- dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
- }
- }
- }
- show_avg();
- }
- }
- #region InitializeComponent
- private void InitializeLanguageText()
- {
- this.Column2.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
- this.Column3.HeaderText = PdnResources.GetString("Menu.proportion.text") + "%";
- this.Column4.HeaderText = PdnResources.GetString("Menu.Phasecontent.text") + "%";
- this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
- this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
- this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
- this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
- this.Column5.HeaderText = PdnResources.GetString("Menu.picture.Text");
- this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Phasename.text");
- this.label4.Text = PdnResources.GetString("Menu.Phasearea.text") + ":";
- this.label3.Text = PdnResources.GetString("Menu.proportion.text") + "% :";
- this.Text = PdnResources.GetString("Menu.GeneralAnalysis.TwoPhaseArea.Text");
- this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
- this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.proportion.text") + "%";
- this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Phasecontent.text") + "%";
- this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
- this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
- this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
- this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Averageresult.text");
- this.label5.Text = PdnResources.GetString("Menu.Phasecontent.text") + "% :";
- this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
- this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
- this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
- this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
- this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Resultspreview.text");
- this.Column1.HeaderText = PdnResources.GetString("Menu.Phasename.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.listView1 = new System.Windows.Forms.ListView();
- this.imageList1 = new System.Windows.Forms.ImageList(this.components);
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button5 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox_review = new System.Windows.Forms.GroupBox();
- this.groupBox5 = new System.Windows.Forms.GroupBox();
- this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
- this.button_remove = new System.Windows.Forms.Button();
- this.button_all = new System.Windows.Forms.Button();
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.dataGridView_results = new System.Windows.Forms.DataGridView();
- this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.groupBox7 = new System.Windows.Forms.GroupBox();
- this.button9 = new System.Windows.Forms.Button();
- this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.lbl_content = new System.Windows.Forms.Label();
- this.lbl_area = new System.Windows.Forms.Label();
- this.lbl_rate = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.groupBox4.SuspendLayout();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- this.groupBox5.SuspendLayout();
- this.groupBox6.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
- this.groupBox7.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
- this.groupBox3.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox4.Controls.Add(this.listView1);
- this.groupBox4.Location = new System.Drawing.Point(13, 72);
- this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox4.Size = new System.Drawing.Size(158, 483);
- this.groupBox4.TabIndex = 9;
- this.groupBox4.TabStop = false;
- this.groupBox4.Text = "图像索引";
- //
- // 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(8, 26);
- this.listView1.Margin = new System.Windows.Forms.Padding(4);
- this.listView1.MultiSelect = false;
- this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(140, 449);
- 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;
- //
- // groupBox1
- //
- this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox1.Controls.Add(this.button5);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.checkBox1);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(20, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(1145, 53);
- this.groupBox1.TabIndex = 10;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button5
- //
- this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.button5.Location = new System.Drawing.Point(956, 21);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(75, 23);
- this.button5.TabIndex = 3;
- this.button5.Text = "关闭";
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // 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(1053, 21);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(75, 23);
- this.button2.TabIndex = 2;
- this.button2.Text = "保存结果";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // checkBox1
- //
- this.checkBox1.AutoSize = true;
- this.checkBox1.Location = new System.Drawing.Point(98, 24);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.Size = new System.Drawing.Size(132, 16);
- this.checkBox1.TabIndex = 1;
- this.checkBox1.Text = "生成报告时打开设置";
- this.checkBox1.UseVisualStyleBackColor = true;
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(6, 24);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(75, 23);
- this.button1.TabIndex = 0;
- this.button1.Text = "设置";
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox2.Controls.Add(this.dataGridView1);
- this.groupBox2.Location = new System.Drawing.Point(178, 72);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(406, 347);
- this.groupBox2.TabIndex = 11;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "结果预览";
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column1,
- this.Column2,
- this.Column3,
- this.Column4});
- this.dataGridView1.Location = new System.Drawing.Point(6, 26);
- this.dataGridView1.Name = "dataGridView1";
- this.dataGridView1.RowHeadersVisible = false;
- this.dataGridView1.RowHeadersWidth = 51;
- this.dataGridView1.RowTemplate.Height = 27;
- this.dataGridView1.Size = new System.Drawing.Size(394, 444);
- this.dataGridView1.TabIndex = 0;
- //
- // Column1
- //
- this.Column1.MinimumWidth = 6;
- this.Column1.Name = "Column1";
- this.Column1.Width = 70;
- //
- // Column2
- //
- this.Column2.MinimumWidth = 6;
- this.Column2.Name = "Column2";
- this.Column2.Width = 90;
- //
- // Column3
- //
- this.Column3.MinimumWidth = 6;
- this.Column3.Name = "Column3";
- this.Column3.Width = 125;
- //
- // Column4
- //
- this.Column4.MinimumWidth = 6;
- this.Column4.Name = "Column4";
- this.Column4.Width = 125;
- //
- // 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(590, 72);
- this.groupBox_review.Name = "groupBox_review";
- this.groupBox_review.Size = new System.Drawing.Size(575, 483);
- this.groupBox_review.TabIndex = 12;
- this.groupBox_review.TabStop = false;
- this.groupBox_review.Text = "预览";
- //
- // groupBox5
- //
- this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox5.Controls.Add(this.listBox_analysisResult);
- this.groupBox5.Controls.Add(this.button_remove);
- this.groupBox5.Controls.Add(this.button_all);
- this.groupBox5.Location = new System.Drawing.Point(12, 562);
- this.groupBox5.Name = "groupBox5";
- this.groupBox5.Size = new System.Drawing.Size(224, 165);
- this.groupBox5.TabIndex = 13;
- this.groupBox5.TabStop = false;
- this.groupBox5.Text = "分析结果";
- //
- // listBox_analysisResult
- //
- this.listBox_analysisResult.CheckOnClick = true;
- this.listBox_analysisResult.FormattingEnabled = true;
- this.listBox_analysisResult.HorizontalScrollbar = true;
- this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
- this.listBox_analysisResult.Name = "listBox_analysisResult";
- this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
- this.listBox_analysisResult.TabIndex = 10;
- this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
- //
- // button_remove
- //
- this.button_remove.Location = new System.Drawing.Point(130, 24);
- this.button_remove.Name = "button_remove";
- this.button_remove.Size = new System.Drawing.Size(75, 23);
- this.button_remove.TabIndex = 8;
- this.button_remove.Text = "删除";
- this.button_remove.UseVisualStyleBackColor = true;
- this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
- //
- // button_all
- //
- this.button_all.Location = new System.Drawing.Point(14, 24);
- this.button_all.Name = "button_all";
- this.button_all.Size = new System.Drawing.Size(75, 23);
- this.button_all.TabIndex = 1;
- this.button_all.Text = "全部显示";
- this.button_all.UseVisualStyleBackColor = true;
- this.button_all.Click += new System.EventHandler(this.button_all_Click);
- //
- // groupBox6
- //
- this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6.Controls.Add(this.dataGridView_results);
- this.groupBox6.Location = new System.Drawing.Point(257, 562);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(678, 165);
- this.groupBox6.TabIndex = 14;
- this.groupBox6.TabStop = false;
- //
- // dataGridView_results
- //
- this.dataGridView_results.AllowUserToAddRows = false;
- this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.Column5,
- this.dataGridViewTextBoxColumn1,
- this.dataGridViewTextBoxColumn2,
- this.dataGridViewTextBoxColumn3,
- this.dataGridViewTextBoxColumn4});
- this.dataGridView_results.Location = new System.Drawing.Point(16, 29);
- this.dataGridView_results.Name = "dataGridView_results";
- this.dataGridView_results.RowHeadersVisible = false;
- this.dataGridView_results.RowHeadersWidth = 51;
- this.dataGridView_results.RowTemplate.Height = 27;
- this.dataGridView_results.Size = new System.Drawing.Size(645, 130);
- this.dataGridView_results.TabIndex = 1;
- //
- // Column5
- //
- this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.Column5.HeaderText = "Column5";
- this.Column5.MinimumWidth = 6;
- this.Column5.Name = "Column5";
- //
- // dataGridViewTextBoxColumn1
- //
- this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.dataGridViewTextBoxColumn1.HeaderText = "dataGridViewTextBoxColumn1";
- this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
- //
- // dataGridViewTextBoxColumn2
- //
- this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.dataGridViewTextBoxColumn2.HeaderText = "dataGridViewTextBoxColumn2";
- this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
- //
- // dataGridViewTextBoxColumn3
- //
- this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.dataGridViewTextBoxColumn3.HeaderText = "dataGridViewTextBoxColumn3";
- this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
- //
- // dataGridViewTextBoxColumn4
- //
- this.dataGridViewTextBoxColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
- this.dataGridViewTextBoxColumn4.HeaderText = "dataGridViewTextBoxColumn4";
- this.dataGridViewTextBoxColumn4.MinimumWidth = 6;
- this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
- //
- // groupBox7
- //
- this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox7.Controls.Add(this.button9);
- this.groupBox7.Controls.Add(this.numericUpDown1);
- this.groupBox7.Controls.Add(this.label1);
- this.groupBox7.Controls.Add(this.button4);
- this.groupBox7.Controls.Add(this.button3);
- this.groupBox7.Location = new System.Drawing.Point(941, 562);
- this.groupBox7.Name = "groupBox7";
- this.groupBox7.Size = new System.Drawing.Size(224, 165);
- this.groupBox7.TabIndex = 15;
- this.groupBox7.TabStop = false;
- this.groupBox7.Enter += new System.EventHandler(this.groupBox7_Enter);
- //
- // button9
- //
- this.button9.Location = new System.Drawing.Point(19, 88);
- this.button9.Name = "button9";
- this.button9.Size = new System.Drawing.Size(141, 23);
- this.button9.TabIndex = 9;
- this.button9.Text = "项目工程";
- this.button9.UseVisualStyleBackColor = true;
- this.button9.Click += new System.EventHandler(this.button9_Click);
- //
- // numericUpDown1
- //
- this.numericUpDown1.Location = new System.Drawing.Point(66, 122);
- this.numericUpDown1.Maximum = new decimal(new int[] {
- 10,
- 0,
- 0,
- 0});
- this.numericUpDown1.Name = "numericUpDown1";
- this.numericUpDown1.Size = new System.Drawing.Size(94, 21);
- this.numericUpDown1.TabIndex = 4;
- this.numericUpDown1.Value = new decimal(new int[] {
- 2,
- 0,
- 0,
- 0});
- this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(17, 126);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(41, 12);
- this.label1.TabIndex = 3;
- this.label1.Text = "小数:";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(19, 54);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(141, 23);
- this.button4.TabIndex = 1;
- this.button4.Text = "导出结果";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(19, 20);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(141, 23);
- this.button3.TabIndex = 0;
- this.button3.Text = "生成报告";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox3.Controls.Add(this.lbl_content);
- this.groupBox3.Controls.Add(this.lbl_area);
- this.groupBox3.Controls.Add(this.lbl_rate);
- this.groupBox3.Controls.Add(this.label5);
- this.groupBox3.Controls.Add(this.label4);
- this.groupBox3.Controls.Add(this.label3);
- this.groupBox3.Location = new System.Drawing.Point(184, 439);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(394, 116);
- this.groupBox3.TabIndex = 16;
- this.groupBox3.TabStop = false;
- //
- // lbl_content
- //
- this.lbl_content.AutoSize = true;
- this.lbl_content.Location = new System.Drawing.Point(239, 60);
- this.lbl_content.Name = "lbl_content";
- this.lbl_content.Size = new System.Drawing.Size(0, 12);
- this.lbl_content.TabIndex = 7;
- //
- // lbl_area
- //
- this.lbl_area.AutoSize = true;
- this.lbl_area.Location = new System.Drawing.Point(76, 26);
- this.lbl_area.Name = "lbl_area";
- this.lbl_area.Size = new System.Drawing.Size(0, 12);
- this.lbl_area.TabIndex = 6;
- //
- // lbl_rate
- //
- this.lbl_rate.AutoSize = true;
- this.lbl_rate.Location = new System.Drawing.Point(73, 60);
- this.lbl_rate.Name = "lbl_rate";
- this.lbl_rate.Size = new System.Drawing.Size(0, 12);
- this.lbl_rate.TabIndex = 5;
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(179, 61);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(0, 12);
- this.label5.TabIndex = 3;
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(16, 26);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(0, 12);
- this.label4.TabIndex = 2;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(16, 61);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(0, 12);
- this.label3.TabIndex = 1;
- //
- // PolyphaseContentDialog
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1177, 744);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox7);
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox5);
- this.Controls.Add(this.groupBox_review);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.groupBox4);
- this.Name = "PolyphaseContentDialog";
- this.Text = "两相面积含量";
- this.Load += new System.EventHandler(this.PolyphaseContentDialog_Load);
- this.Controls.SetChildIndex(this.groupBox4, 0);
- this.Controls.SetChildIndex(this.groupBox1, 0);
- this.Controls.SetChildIndex(this.groupBox2, 0);
- this.Controls.SetChildIndex(this.groupBox_review, 0);
- this.Controls.SetChildIndex(this.groupBox5, 0);
- this.Controls.SetChildIndex(this.groupBox6, 0);
- this.Controls.SetChildIndex(this.groupBox7, 0);
- this.Controls.SetChildIndex(this.groupBox3, 0);
- this.groupBox4.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- this.groupBox1.PerformLayout();
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- this.groupBox5.ResumeLayout(false);
- this.groupBox6.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
- this.groupBox7.ResumeLayout(false);
- this.groupBox7.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- this.ResumeLayout(false);
- }
- #endregion
- private void show_avg()
- {
- if (listView1.FocusedItem != null)
- {
- var results = mainPolyphaseAnalysisResults.Where(p => p.GraphName.Equals(listView1.FocusedItem.Text));
- if (results.Count() > 0)
- {
- lbl_area.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseArea), decnum);
- lbl_rate.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseRate), decnum);
- lbl_content.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseAllRate), decnum);
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- if (listView1.SelectedItems.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.seselecttheimagethatyouwanttoan.Text")+"!");
- return;
- }
- if (dataGridView1.Rows.Count == 0)
- {
- MessageBox.Show("结果为空!");
- return;
- }
- String tag = listView1.FocusedItem.Text;
- List<Bitmap> tempBit = new List<Bitmap>();
- if (listView1.FocusedItem != null)
- {
- if (polyphaseAnalysisResults.FindAll(item => item.GraphName.Equals(listView1.FocusedItem.Text)).Count == 0)
- {
- listBox_analysisResult.Items.Add(this.listView1.FocusedItem.Text);
- listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
- for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult aResult = mainPolyphaseAnalysisResults[i];
- polyphaseAnalysisResults.Add(aResult);
- viewPolyphaseAnalysisResults.Add(aResult);
- dataGridView_results.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum));
- }
- }
- else
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
- if (dr != DialogResult.OK)
- {
- return;
- }
- viewPolyphaseAnalysisResults.RemoveAll(u => u.GraphName == listView1.FocusedItem.Text);
- polyphaseAnalysisResults.RemoveAll(u => u.GraphName == listView1.FocusedItem.Text);
- polyphaseAnalysisResults.AddRange(mainPolyphaseAnalysisResults);
- viewPolyphaseAnalysisResults.AddRange(mainPolyphaseAnalysisResults);
- List<string> list = new List<string>();
- foreach (var s in this.listBox_analysisResult.Items)
- {
- list.Add(s.ToString());
- }
- this.listBox_analysisResult.Items.Clear();
- foreach (var s in list)
- {
- this.listBox_analysisResult.Items.Add(s);
- }
- var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
- this.dataGridView_results.Rows.Clear();
- listBox_analysisResult.SetItemChecked(thisindex, true);
- for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult aResult = mainPolyphaseAnalysisResults[i];
- dataGridView_results.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum));
- }
- }
- double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
- Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
- originalBit.Tag = pantographRatio;
- tempBit.Add(originalBit);
- Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
- Graphics graphics = Graphics.FromImage(newBit);
- Draw(graphics);
- newBit.Tag = pantographRatio;
- tempBit.Add(newBit);
- if (bitDic.ContainsKey(tag))
- {
- bitDic[tag].Clear();
- bitDic[tag] = tempBit;
- }
- else
- {
- bitDic.Add(tag, tempBit);
- }
- }
- }
- private void Draw(Graphics graphics)
- {
- if (this.documentWorkspace.phaseModels.Count > 0)
- {
- foreach (PhaseModel model in this.documentWorkspace.phaseModels)
- {
- if (model.choise && model.mat != null)
- {
- Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
- graphics.DrawImage(map, 0, 0, map.Width, map.Height);
- }
- }
- }
- }
- private void button_all_Click(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (this.is_all % 2 == 0)
- {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, false);
- }
- }
- else {
- for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
- {
- listBox_analysisResult.SetItemChecked(i, true);
- }
- viewPolyphaseAnalysisResults.Clear();
- viewPolyphaseAnalysisResults.AddRange(polyphaseAnalysisResults);
- for (int i = 0; i < viewPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult aResult = viewPolyphaseAnalysisResults[i];
- dataGridView_results.Rows.Add(aResult.GraphName, aResult.PolyphaseName, aResult.PolyphaseArea, AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum));
- }
- }
- this.is_all += 1;
- }
- private void button_remove_Click(object sender, EventArgs e)
- {
- var removeList = new List<string>();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text")+"?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- dataGridView_results.Rows.Clear();
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- polyphaseAnalysisResults.RemoveAll(u => u.GraphName == s.ToString());
- viewPolyphaseAnalysisResults.RemoveAll(u => u.GraphName == s.ToString());
- removeList.Add(s.ToString());
- }
- for (int i = 0; i < viewPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult aResult = viewPolyphaseAnalysisResults[i];
- dataGridView_results.Rows.Add(aResult.GraphName, aResult.PolyphaseName, aResult.PolyphaseArea, AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum));
- }
- foreach (var m in removeList)
- {
- listBox_analysisResult.Items.Remove(m);
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheimagetodelete.Text")+"!");
- }
- }
- private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
- {
- dataGridView_results.Rows.Clear();
- if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
- {
- foreach (var s in listBox_analysisResult.CheckedItems)
- {
- List<PolyphaseAnalysisResult> findResults = polyphaseAnalysisResults.FindAll(item => item.GraphName.Equals(s.ToString()));
- viewPolyphaseAnalysisResults.Clear();
- viewPolyphaseAnalysisResults.AddRange(findResults);
- for (int i = 0; i < viewPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult aResult = viewPolyphaseAnalysisResults[i];
- dataGridView_results.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum));
- }
- }
- }
- }
- private void domainUpDown1_SelectedItemChanged(object sender, EventArgs e)
- {
- }
- private void button5_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void listView1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- decnum = (int)numericUpDown1.Value;
- refeshGrids();
- }
- private void refeshGrids()
- {
- dataGridView1.Rows.Clear();
- for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult pResult = mainPolyphaseAnalysisResults[i];
- dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
- }
- dataGridView_results.Rows.Clear();
- for (int i = 0; i < polyphaseAnalysisResults.Count; i++)
- {
- PolyphaseAnalysisResult pResult = polyphaseAnalysisResults[i];
- dataGridView_results.Rows.Add(pResult.GraphName, pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
- }
- show_avg();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseContent");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (checkBox1.Checked)
- {
- AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseContent");
- if (recombinationRateSetDialog.hasModule)
- {
- recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
- recombinationRateSetDialog.ShowDialog();
- }
- else
- {
- recombinationRateSetDialog = null;
- }
- }
- bitList.Clear();
- if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- content1.Add(this.dataGridView_results.Columns[4].HeaderText);
- analysisContent.Add(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- if (bitDic.ContainsKey(tag))
- {
- bitList.Add(bitDic[tag][0]);
- bitList.Add(bitDic[tag][1]);
- }
- }
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
- }
- else
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- }
- private void groupBox7_Enter(object sender, EventArgs e)
- {
- }
- private void button4_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.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.GeneralAnalysis.TwoPhaseArea.Text")+ PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss");
- DialogResult dr = exe.ShowDialog();
- if (dr == DialogResult.OK)
- {
- DataTable dtb = new DataTable();
- foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
- {
- dtb.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
- {
- DataRow dataRow = dtb.NewRow();
- for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
- }
- dtb.Rows.Add(dataRow);
- }
- List<DataTable> list = new List<DataTable>();
- list.Add(dtb);
- this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
- }
- }
- private void button9_Click(object sender, EventArgs e)
- {
- if (this.dataGridView_results.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
- return;
- }
- if (this.analyzeSettingModel == null)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
- return;
- }
- //获取项目工程内的文件夹路径
- ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.TwoPhaseArea.Text", this.analyzeSettingModel.savePath);
- if (item != null)
- {
- //向文件夹内保存图片和报告
- if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
- {
- //获取word书签与excel单元格的关系,以字典方式存储
- List<mic_module_infos> mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
- Dictionary<string, string> tagInfos = new Dictionary<string, string>();
- if (mic_module_infos != null && mic_module_infos.Count > 0)
- {
- foreach (mic_module_infos info in mic_module_infos)
- {
- tagInfos.Add(info.tag_name, info.cell_position);
- }
- }
- List<List<string>> analysisContent = new List<List<string>>();
- List<List<string>> inclusionList = new List<List<string>>();
- List<ExportProjectModel> exportModel = new List<ExportProjectModel>();
- List<Bitmap> bitImgList = new List<Bitmap>();
- List<string> titleContent = new List<string>();
- for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
- {
- List<string> content1 = new List<string>();
- if (i == 0)
- {
- content1.Add(this.dataGridView_results.Columns[0].HeaderText);
- content1.Add(this.dataGridView_results.Columns[1].HeaderText);
- content1.Add(this.dataGridView_results.Columns[2].HeaderText);
- content1.Add(this.dataGridView_results.Columns[3].HeaderText);
- content1.Add(this.dataGridView_results.Columns[4].HeaderText);
- analysisContent.Add(content1);
- titleContent.AddRange(content1);
- }
- content1 = new List<string>();
- content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
- content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString());
- analysisContent.Add(content1);
- string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
- var export = exportModel.Where(m => m.picName == tag).FirstOrDefault();
- if (export == null)
- {
- ExportProjectModel exportProjectModel = new ExportProjectModel();
- exportProjectModel.dataList = new List<List<string>>();
- exportProjectModel.dataList.Add(titleContent);
- exportProjectModel.dataList.Add(content1);
- exportProjectModel.picName = tag;
- exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.TwoPhaseArea.Text");
- exportModel.Add(exportProjectModel);
- }
- else
- {
- exportModel[exportModel.IndexOf(export)].dataList.Add(content1);
- }
- if (bitDic.ContainsKey(tag))
- {
- bitImgList.Add(bitDic[tag][0]);
- bitImgList.Add(bitDic[tag][1]);
- }
- }
- try
- {
- this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
- return;
- }
- //保存项目信息到数据库
- this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
- }
- }
- private void getValue(string key, Object value)
- {
- switch (key)
- {
- case "OpenWhileExportReport":
- checkBox1.Checked = Convert.ToBoolean(value);
- break;
- case "CalculatorDecimalDigits":
- numericUpDown1.Value = Convert.ToDecimal(value);
- break;
- case "ExportResults":
- isExportResults = Convert.ToBoolean(value);
- break;
- case "ExportReports":
- isExportReports = Convert.ToBoolean(value);
- break;
- case "ExportProjects":
- isExportProjects = Convert.ToBoolean(value);
- break;
- }
- }
- #region [应用全部保存全部-私有方法]
- /// <summary>
- /// 应用全部私有方法
- /// </summary>
- private void applyAll()
- {
- }
- /// <summary>
- /// 保存全部私有方法
- /// </summary>
- private void saveAll()
- {
- for (int i = 0; i < listView1.Items.Count; i++)
- {
- this.listView1.EnsureVisible(i);
- this.listView1.Items[i].Focused = true;
- this.listView1.Items[i].Selected = true;
- this.button2.PerformClick();
- }
- }
- /// <summary>
- /// 执行脚本自动化的步骤
- /// </summary>
- private void startScriptAutomaticAction()
- {
- saveAll();
- if (isExportResults)//导出结果
- this.button4.PerformClick();
- if (isExportReports)//生成报告
- this.button3.PerformClick();
- if (isExportProjects)//导出项目
- this.button9.PerformClick();
- this.appWorkspace.ScriptAutomatic = false;
- this.Close();
- }
- #endregion
- #region [脚本录制]
- private void getScriptRecording()
- {
- string className = InvariantData.path_Action + ".Action" + menuId;
- ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
- List<Args> args = param.Lists;
- foreach (var item in args)
- {
- item.value = setScriptRecording(item.key);
- }
- appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
- }
- private object setScriptRecording(string key)
- {
- object value = null;
- switch (key)
- {
- case "OpenWhileExportReport":
- value = checkBox1.Checked;
- break;
- case "CalculatorDecimalDigits":
- value = numericUpDown1.Value;
- break;
- case "ExportResults":
- value = isExportResults;
- break;
- case "ExportReports":
- value = isExportReports;
- break;
- case "ExportProjects":
- value = isExportProjects;
- break;
- }
- return value;
- }
- #endregion
- }
- }
|