using OpenCvSharp;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.CustomControl;
using PaintDotNet.DbOpreate.DbModel;
using PaintDotNet.Instrument;
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
using PaintDotNet.Base.DedicatedAnalysis.GrainSize;
using Metis.ParameterSet;
using PaintDotNet.Data.Param;
using PaintDotNet.Base;
using System.IO;
using OpenCvSharp.Extensions;
using PaintDotNet.Base.SettingModel;
namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard
{
internal class GrainSizeStandardDialog : PdnBaseForm
{
///
/// 晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)
///
private int grainMethodType = -1;
///
/// 晶粒度标准集成
///
protected GrainSizeStandardClass GSSClass = new GrainSizeStandardClass();
#region 内部属性
///
/// 主控件
///
protected AppWorkspace appWorkspace;
///
/// 平均截距
///
private double value_111 = -1;
///
/// 二值化集成
///
protected BinaryClass binaryClass;
///
/// 公共按钮
///
private CommonControlButtons commonControlButtons;
///
/// 图像面板
///
protected DocumentWorkspaceWindow documentWorkspace;
///
/// 当前选择的图片
///
protected Mat imageMat;
///
/// 相0的图片,处理多视场使用
///
protected Mat PhaseModel0Mat
{
get
{
if (binaryClass.PhaseModels0Mat != null)
return binaryClass.PhaseModels0Mat;
return this.documentWorkspace.PhaseModels[0].mat;
}
}
///
/// 防止进入页面时错误提示辅助线选项信息
///
public bool comboboxChange = true;
///
/// 当前选择图片的Index
///
protected int selectPicture = -1;
///
/// 调色板
///
private ColorsForm colorsFormGrid;
private Panel panelC;
///
/// 保存用于生成报告的图片
///
private List bitList;
///
/// 储存点击保存结果后的所有原图与分析图
///
protected Dictionary> bitDic = new Dictionary>();
///
/// 中间数据
///
protected List tempDataModel = new List();
///
/// 分析结果暂存
///
protected List dataTable_Totals = new List();
///
/// GBT6394面积法 分析结果暂存 -视场面积(Dictionary的key为"RectArea")
///
private Dictionary> dict_Totals = new Dictionary>();
///
/// 详细分析结果暂存
///
protected List dataTables = new List();
///
/// 全部显示
///
protected bool allShow = false;
///
/// 详细列表需要求和的index集合
///
protected List IndexChangedFromIndex = new List();
///
/// 列表需要求和的index集合,value值为:1 求和 2:平均 3:级别计算 + [输入数据index位置,-1则需要调用自定义方法进行计算]
///
protected Dictionary IndexChangedToIndex = new Dictionary();
///
/// 详细列表不需要格式化的字符串数据
///
protected List DetailListStringIndex = new List();
///
/// 详细列表不需要按double排序的字符串数据
///
protected List DetailListNotDoubleIndex = new List();
///
/// 为了解决标题文字相同的标准,只能使用name赋值每列的数据
///
protected bool HeaderTextUsable = true;
///
/// 是否脚本运行
///
private Boolean initScriptValues = false;
///
/// 数值大于0,则窗口初始化数据完成
///
private int finishedLoadAction = -1;
///
/// 当前菜单的唯一id
///
private int menuId;
private string menuName;
///
/// 保存窗口参数
///
private GrainSizeAnalysisModel analysisModel;
///
/// 保存所有窗口的参数
///
private Dictionary analysisDict = new Dictionary();
///
/// 应用到全部之前,记住当前选择的窗口
///
private int currentOldSelectIndex = -1;
///
/// 晶界重现-保存所有窗口的参数 应用则计算,不应用则清空Mat。应用到全部则提前清空Mat和Model
///
private Dictionary grainBoundaryDict = new Dictionary();
///
/// 晶界重现-保存所有窗口的计算结果 应用则计算,不应用则清空
///
protected Dictionary grainBoundaryMatDict = new Dictionary();
protected Dictionary everyImgPhaseDict = new Dictionary();
///
/// 面积法晶界颜色-保存所有窗口的计算结果 保存结果时一起保存,重新保存则替换
///
protected Dictionary grainColorsMatDict = new Dictionary();
//private Dictionary grainBoundaryColorDict = new Dictionary();
//string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
//bool createNewFile = !System.IO.File.Exists(xmlFilePath);
// if (createNewFile)
// return;
// Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
//sigma = grainBoundryDectModel.sigma;
// textBox6.Text = sigma + "";
// grainApplygrainboundaries = grainBoundryDectModel.grainApplygrainboundaries;
// this.applyRadioButton1.Checked = (grainApplygrainboundaries == 1);
// m_iStandardImage = grainBoundryDectModel.m_iStandardImage;
protected static string ParamKey_displaygrainboundaries = "displaygrainboundaries";//显示晶界
protected static string ParamKey_displaygrid = "displaygrid";//显示网格
protected static string ParamKey_displaysections = "displaysections";//显示截点
protected static string ParamKey_comboBox1SelectedItem = "comboBox1SelectedItem";//选择的辅助线
protected static string ParamKey_ShowGrainNumber = "ShowGrainNumber";//显示晶粒编号
protected static string ParamKey_ShowGrainColor = "ShowGrainColor";//用不同颜色显示晶粒
protected static string ParamKey_CalculatorDecimalDigits = "CalculatorDecimalDigits";//小数点位数
protected static string ParamKey_OpenWhileExportReport = "OpenWhileExportReport";//生成报告时打开设置//#22009 22010
protected static string ParamKey_TargetSelection = "TargetSelection";//目标选择
#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;
private CheckBox checkBox_generateReport_opensetting;
protected GroupBox groupBox3;
private Button button9;
protected ComboBox comboBox1;
protected DataGridView dataGridView2;
protected ListView listView2;
private Button button16;
private Button button12;
private Button button11;
private NumericUpDown numericUpDown1_0;
private Button button1;
private BinaryControlSmaller bc;
protected DataGridView dataGridView_Total;
protected Button btn_saveresult;
protected Button button_ApplyToAll;
protected Button button_SaveAll;
private Button threeDButton;
protected Button btn_Grainboundarytoreproduce;
private Base.SettingModel.GrainBoundryDectModel GrainBoundryDectModel;
private Mat OrgImg0;
#endregion
#region 构造函数
///
/// 构造函数
///
///
/// 晶粒度标准的方法类型(0 截点法/截距法, 1 面积法)
public GrainSizeStandardDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem, MethodOfAssessment methodOfAssessment, int grainMethodType = 1)
{
this.menuId = menuItem.MenuId;
this.menuName = menuItem.Text;
this.appWorkspace = appWorkspace;
this.Icon = PdnInfo.AppIcon;
this.colorsFormGrid = new ColorsForm();
this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged));
if (GSSClass.InitDialogMethod(methodOfAssessment))
{
this.grainMethodType = grainMethodType;
SetAnalyzeModelFromXml(GSSClass.methodOfAssessment.resourcesName);
}
else
{
this.grainMethodType = grainMethodType;
if (!GSSClass.InitComboboxValue())
{
if (grainMethodType == 1)
GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
else if (grainMethodType == 0)
GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
}
SetAnalyzeModelFromXml(getTemplateName());
}
InitializeComponent();
this.binaryClass = new BinaryClass(menuId);
this.binaryClass.ShowDrawClassView = ShowDrawClassView();
InitializeLanguageText();
Initialize();
SubclassInitialize();
//如果是脚本执行,将参数带入
if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null && (int)appWorkspace.ScriptCurrentParam.MenuId == menuId)
{
this.initScriptValues = true;//ScriptAutomatic
////在这里反射出对应功能的参数类
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;
//获取晶界重现参数
getBinary(arg.Key, arg.Value);
}
this.analysisModel = GrainSizeAnalysisModel.cloneListParamScript(param);
foreach (var item in this.analysisModel.ListParam)
item.setValue();
getSonData();
if (this.GrainBoundryDectModel != null) {
string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
string userInfoXml = XmlSerializeHelper.XmlSerialize(this.GrainBoundryDectModel);
FileOperationHelper.WriteStringToFile(userInfoXml, xmlFilePath, FileMode.Create);
this.applyDect();
}
}
else
{//读取上次关闭窗口时保存的参数
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
foreach (var item in this.analysisModel.ListParam)
item.setValue();
}
//初始化头
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);//初始化相的工作结构
//如果是脚本执行,将参数带入二值化集成2 之后:
appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
//InitComboboxValue(null);
this.button11.Visible = true;
this.button16.Visible = false;
this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
}
#region [晶界重现-脚本相关]
///
/// 脚本获取晶界重现参数
///
private void getBinary(string key, Object value)
{
GrainBoundryDectModel = new Base.SettingModel.GrainBoundryDectModel();
switch (key)
{
case "GrainApplygrainboundaries":
GrainBoundryDectModel.grainApplygrainboundaries = Convert.ToInt32(value);
break;
case "lineColor":
GrainBoundryDectModel.grainColor = Convert.ToInt32(value);
break;
case "GrainAdOutParam_0":
GrainBoundryDectModel.m_AdOutParam_0 = Convert.ToInt32(value);
break;
case "GrainAdOutParam_1":
GrainBoundryDectModel.m_AdOutParam_1 = Convert.ToInt32(value);
break;
case "GrainAdOutParam_2":
GrainBoundryDectModel.m_AdOutParam_2 = Convert.ToInt32(value);
break;
case "GrainAdOutParam_3":
GrainBoundryDectModel.m_AdOutParam_3 = Convert.ToInt32(value);
break;
case "GrainAdOutParam_4":
GrainBoundryDectModel.m_AdOutParam_4 = Convert.ToInt32(value);
break;
case "GrainAdOutParam_5":
GrainBoundryDectModel.m_AdOutParam_5 = Convert.ToDouble(value);
break;
case "GrainAdOutParam_6":
GrainBoundryDectModel.m_AdOutParam_6 = Convert.ToInt32(value);
break;
}
}
private void applyDect()
{
if (this.documentWorkspace.PhaseModels.Count == 0) return;
Mat PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
double adOutParam_5 = this.GrainBoundryDectModel.m_AdOutParam_5;
int grainApplygrainboundaries = this.GrainBoundryDectModel.grainApplygrainboundaries;
int adOutParam_0 = this.GrainBoundryDectModel.m_AdOutParam_0;
int adOutParam_1 = this.GrainBoundryDectModel.m_AdOutParam_1;
double adOutParam_2 = this.GrainBoundryDectModel.m_AdOutParam_2;
double adOutParam_3 = this.GrainBoundryDectModel.m_AdOutParam_3;
int adOutParam_4 = this.GrainBoundryDectModel.m_AdOutParam_4;
int adOutParam_6 = this.GrainBoundryDectModel.m_AdOutParam_6;
procClass = new ProgressThreadProcClass();
procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
if (OrgImg0 != null)
{
if (this.documentWorkspace.GraphicsList.IsExsitView() && ShowDrawClassView())
{
Vec4b vec4 = new Vec4b(0, 0, 0, 0);
//视场图像
Mat exsitViewMatOrg = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion());
for (int y = 0; y < exsitViewMatOrg/*temp*/.Rows; y++)
{
for (int x = 0; x < exsitViewMatOrg/*temp*/.Cols; x++)
{
if (exsitViewMatOrg.At(y, x).Item3 == 0)
OrgImg0.Set(y, x, vec4);//不在视场图像范围内
}
}
}
this.documentWorkspace.PhaseModels[0].mat = OrgImg0.Clone();
this.documentWorkspace.Refresh();
if (PhaseModel0MatCopy != null)
{
PhaseModel0MatCopy.Dispose();
PhaseModel0MatCopy = null;
}
PhaseModel0MatCopy = this.documentWorkspace.PhaseModels[0].mat.Clone();
//this.resetOperationsAction();
OrgImg0.Dispose();/* //待测试是否有用 */ OrgImg0 = null;
}
}
#endregion
private void ShownChoiseItemAndInitData(object sender, EventArgs e)
{
//二值化集成3
this.binaryClass.loadParams();
this.binaryClass.guideClass = GSSClass.GuideClass;
this.binaryClass.comboBox1 = this.comboBox1;
if (index > -1)
{
//滚动到指定的行位置
if (index >= 0 && index < this.lstView_img.Items.Count)
this.lstView_img.EnsureVisible(index); //选中行 //##21319
if (this.lstView_img.FocusedItem != null && this.lstView_img.FocusedItem.Selected || this.lstView_img.SelectedItems != null && this.lstView_img.SelectedItems.Count > 0)
{
if (this.selectPicture == index/*this.lstView_img.FocusedItem.Index*/)
return;
this.imageMat = this.appWorkspace.DocumentWorkspaces[index/*this.lstView_img.FocusedItem.Index*/].CompositionSurface.CreatedAliasedMat();
//二值化集成4
//if (!is###OtherGrainSizeStandardDialog)
{
if (ShowDrawClassView())
binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
else
binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.imageMat.Clone(), getCurrentWorkTag());
this.bcOriginCheckedChanged(null, null);
}
if (!this.analysisDict.ContainsKey(getCurrentWorkTag()))
this.analysisDict.Add(getCurrentWorkTag(), this.analysisModel/*.cloneListParamModel(this.menuId)*/);
else
this.analysisDict[getCurrentWorkTag()] = this.analysisModel/*.cloneListParamModel(this.menuId)*/;
//this.analysisModel = this.analysisDict[getCurrentWorkTag()];
//if (GSSClass.massLabelPointsList != null && GSSClass.massLabelPointsList.Count > 0)
//{
// GSSClass.massLabelPointsList.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)}
// this.documentWorkspace.Refresh();//######
//}
////if (this.checkBox1.Checked)
////{
//// this.documentWorkspace.PhaseModels[1].choise = true;//#########################
//// this.applyDect();
////}
this.selectPicture = index;// this.lstView_img.FocusedItem.Index;
GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
//UpdateGuideStyle(true);//19845
InitRectangleF(false);
AddRectangleToRectangleFCaps();
refreshWhileImgChanged();
}
InitComboboxValue(null);
try
{
object ItemStringObject;
if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject)) {
try
{
this.comboBox1.SelectedIndex = Convert.ToInt32(ItemStringObject);
}
catch (Exception)
{
this.comboBox1.SelectedItem = (string)ItemStringObject;
}
}
}
catch (Exception exc)
{
System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
}
}
//// 初始化数据
//Bitmap 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);
object ShowGrainBoundry;//#21752
if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
////显示直方图
//this.histogramControl1.CreateHistogram(this.bitmap, true, 339, 130, 0);
this.finishedLoadAction++;
if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
this.startScriptAutomaticAction();
}
///
/// 执行脚本自动化的步骤
///
private void startScriptAutomaticAction()
{
this.button_ApplyToAll.PerformClick();
this.button_SaveAll.PerformClick();
for (int j = 0; j < this.listView2.Items.Count; j++)
this.listView2.Items[j].Selected = true;
object ItemStringObject;
if (GetParamValue1("ExportResults", out ItemStringObject)
&& (bool)ItemStringObject)//导出结果
this.button_exportResults.PerformClick();
if (GetParamValue1("ExportReports", out ItemStringObject)
&& (bool)ItemStringObject)//生成报告
this.button_generateReport.PerformClick();
if (GetParamValue1("ExportProjects", out ItemStringObject)
&& (bool)ItemStringObject)//导出项目
this.button1.PerformClick();
//List dedicatedLists = new List();
//IntegerNumber seven = new IntegerNumber(0, 10);
//seven.key = "CalculatorDecimalDigits";
//seven.name = "小数点位数";
//seven.initialValue = 2;
//seven.value = 2;
//dedicatedLists.Add(seven);
//dedicatedLists.Add(new BooleanObject("OpenWhileExportReport", "生成报告时打开设置", true, null));
//dedicatedLists.Add(new BooleanObject("ExportResults", "导出结果", true, null));
//dedicatedLists.Add(new BooleanObject("ExportReports", "生成报告", true, null));
//dedicatedLists.Add(new BooleanObject("ExportProjects", "导出项目", true, null));
this.appWorkspace.ScriptAutomatic = false;
this.Close();
}
public GrainSizeStandardDialog()
{
InitializeComponent();
}
#endregion
#region 初始化组件
private void InitializeLanguageText()
{
//
// 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);
this.button9.Text = PdnResources.GetString("Menu.Auxiliarylinesettings.text");
this.groupBox3.Text = PdnResources.GetString("Menu.Tools.GridLine.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");
this.groupBox_analysisResult1.Text = PdnResources.GetString("Menu.Analysisresult.text");
this.button_generateReport.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
this.button_exportResults.Text = PdnResources.GetString("Menu.Exportresults.text");
this.label_resultPrecision.Text = PdnResources.GetString("Menu.Decimal.text");
this.button1.Text = PdnResources.GetString("Menu.Exportproject.text");
this.threeDButton.Text = PdnResources.GetString("Menu.threeD.text");
this.groupBox_img.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
this.btn_saveresult.Text = PdnResources.GetString("Menu.Saveresult.text");
this.btn_Grainboundarytoreproduce.Text = PdnResources.GetString("Menu.Grainboundarytoreproduce.text");
this.button_ApplyToAll.Text = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Applytoall.text");
this.button_SaveAll.Text = PdnResources.GetString("Menu.File.SaveAll.Text");
this.button_setting.Text = PdnResources.GetString("Menu.Setting.Text");
this.groupBox_operating.Text = PdnResources.GetString("Menu.operation.text");
this.checkBox_generateReport_opensetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
}
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.button_SaveAll = new System.Windows.Forms.Button();
this.button_ApplyToAll = 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.btn_Grainboundarytoreproduce = 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.threeDButton = new System.Windows.Forms.Button();
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.groupBox3 = new System.Windows.Forms.GroupBox();
this.button9 = new System.Windows.Forms.Button();
this.comboBox1 = new System.Windows.Forms.ComboBox();
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.groupBox3.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.button_SaveAll);
this.groupBox_operating.Controls.Add(this.button_ApplyToAll);
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.Controls.Add(this.btn_Grainboundarytoreproduce);
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;
//
// button_SaveAll
//
this.button_SaveAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button_SaveAll.Location = new System.Drawing.Point(993, 20);
this.button_SaveAll.Name = "button_SaveAll";
this.button_SaveAll.Size = new System.Drawing.Size(75, 23);
this.button_SaveAll.TabIndex = 8;
this.button_SaveAll.UseVisualStyleBackColor = true;
this.button_SaveAll.Click += new System.EventHandler(this.button_SaveAll_Click);
//
// button_ApplyToAll
//
this.button_ApplyToAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button_ApplyToAll.Location = new System.Drawing.Point(751, 20);
this.button_ApplyToAll.Name = "button_ApplyToAll";
this.button_ApplyToAll.Size = new System.Drawing.Size(75, 23);
this.button_ApplyToAll.TabIndex = 7;
this.button_ApplyToAll.UseVisualStyleBackColor = true;
this.button_ApplyToAll.Click += new System.EventHandler(this.button_ApplyToAll_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(15, 14);
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(912, 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);
//
// btn_Grainboundarytoreproduce
//
this.btn_Grainboundarytoreproduce.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(832, 20);
this.btn_Grainboundarytoreproduce.Name = "btn_Grainboundarytoreproduce";
this.btn_Grainboundarytoreproduce.Size = new System.Drawing.Size(75, 23);
this.btn_Grainboundarytoreproduce.TabIndex = 2;
this.btn_Grainboundarytoreproduce.UseVisualStyleBackColor = true;
this.btn_Grainboundarytoreproduce.Click += new System.EventHandler(this.btn_Grainboundarytoreproduce_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, 502);
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, 468);
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, 502);
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.threeDButton);
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, 580);
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;
//
// threeDButton
//
this.threeDButton.Location = new System.Drawing.Point(28, 149);
this.threeDButton.Name = "threeDButton";
this.threeDButton.Size = new System.Drawing.Size(75, 23);
this.threeDButton.TabIndex = 24;
this.threeDButton.UseVisualStyleBackColor = true;
this.threeDButton.Click += new System.EventHandler(this.threeDButton_Click);
//
// 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, 184);
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, 188);
this.label_resultPrecision.Name = "label_resultPrecision";
this.label_resultPrecision.Size = new System.Drawing.Size(0, 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, 580);
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, 580);
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);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button9);
this.groupBox3.Controls.Add(this.comboBox1);
this.groupBox3.Location = new System.Drawing.Point(179, 320);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(355, 48);
this.groupBox3.TabIndex = 34;
this.groupBox3.TabStop = false;
//
// button9
//
this.button9.BackColor = System.Drawing.SystemColors.Control;
this.button9.Location = new System.Drawing.Point(241, 15);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(92, 26);
this.button9.TabIndex = 10;
this.button9.UseVisualStyleBackColor = false;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(15, 18);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(220, 20);
this.comboBox1.TabIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// GrainSizeStandardDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(1127, 810);
this.Controls.Add(this.groupBox3);
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 = "GrainSizeStandardDialog";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.GrainSizeStandardDialog_FormClosing);
this.Load += new System.EventHandler(this.GrainSizeStandardDialog_Load);
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.Controls.SetChildIndex(this.groupBox3, 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.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
private void DataGridView2_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
//DetailListNotDoubleIndex.Add(0); //DetailListNotDoubleIndex.Add(1);
// 如果是学号或成绩列,则按浮点数处理
if (DetailListNotDoubleIndex.Count > 0 && !DetailListNotDoubleIndex.Contains(e.Column.Index))
{
e.SortResult = (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) > 0) ? 1 : (Convert.ToDouble(e.CellValue1) - Convert.ToDouble(e.CellValue2) < 0) ? -1 : 0;
}
//否则,按字符串比较
else
{
e.SortResult = System.String.Compare(Convert.ToString(e.CellValue1), Convert.ToString(e.CellValue2));
}
e.Handled = true;//不能省掉,不然没效果
}
///
/// 选中的左侧list的下标
///
protected int index = 0;
public void Initialize()
{
//初始化图片列表
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();
if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
{
index = i;
}
}
//
// 初始化选中的数据
//
if (index >= 0 && index < this.lstView_img.Items.Count)
this.lstView_img.Items[index].Selected = true; //选中行 //##21319
//
//初始化图像控件
//
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.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;//禁止视场移动
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);
////
//// 初始化选中的数据
////
//this.lstView_img.Items[index].Selected = true; //选中行
}
#endregion
#region 二值化相关方法
///
/// 添加参数改变的监听
///
///
///
private void GrainSizeStandardDialog_Load(object sender, EventArgs e)
{
this.threeDButton.Enabled = false;
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
this.dataGridView2.SortCompare += DataGridView2_SortCompare;
if (grainMethodType == 0)
{
GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
AddRectangleToRectangleFCaps();
}
////二值化集成3
//this.binaryClass.loadParams();
//this.binaryClass.guideClass = GSSClass.GuideClass;
//this.binaryClass.comboBox1 = this.comboBox1;
//object ShowGrainBoundry;//#21752
//if (GetParamValue1(ParamKey_CalculatorDecimalDigits, out ShowGrainBoundry))//小数点位数
// this.numericUpDown1_0.Value = (int)ShowGrainBoundry;
//if (GetParamValue1(ParamKey_OpenWhileExportReport, out ShowGrainBoundry))//生成报告时打开设置
// this.checkBox_generateReport_opensetting.Checked = (bool)ShowGrainBoundry;
this.finishedLoadAction++;
if (this.finishedLoadAction > 0 && this.initScriptValues && this.appWorkspace.ScriptAutomatic)
this.startScriptAutomaticAction();
}
private bool bcBinaryChecked()
{
return bc != null && bc.BinaryChecked;
}
protected bool bcOriginChecked()
{
return bc != null && bc.OriginChecked;
}
///
/// 参数改变时,重新处理图像
///
///
///
private void bClassBinaryImplFinishAction(object sender, EventArgs e)
{
if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
this.documentWorkspace.Refresh();
else//###############################################################
AddRectangleToRectangleFCaps();
}
///
/// 显示原图/原图+二值图
///
///
///
private void bcOriginCheckedChanged(object sender, EventArgs e)
{
if (!bcOriginChecked())
{
if (bcBinaryChecked())
this.documentWorkspace.PhaseModels[0].choise = true;
if (getGrainBoundryChecked() && ShowGrainBoundryChecked())
this.documentWorkspace.PhaseModels[1].choise = true;
if (grainMethodType == 1 && ShowGrainColorChecked())
this.documentWorkspace.PhaseModels[2].choise = true;
}
else
{
this.documentWorkspace.PhaseModels[0].choise = false;
this.documentWorkspace.PhaseModels[1].choise = false;
this.documentWorkspace.PhaseModels[2].choise = false;
}
this.documentWorkspace.Refresh();
}
#endregion
#region 内部方法
///
/// 设置按钮
///
///
///
private void button_setting_Click(object sender, EventArgs e)
{
string templateName;
try
{
templateName = getTemplateName();
}
catch (Exception)
{
templateName = GSSClass.methodOfAssessment.resourcesName;
}
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)
{
if (this.lstView_img.Items.Count == 0) return;
GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
buildListBox_analysisResult(getCurrentWorkTag(), this.selectPicture);
}
///
/// 相1的图片,处理多视场使用
///
protected Mat PhaseModels1Mat;
protected Color PhaseModels1Color;
///
/// 晶界重现
///
///
///
private void btn_Grainboundarytoreproduce_Click(object sender, EventArgs e)
{
//if (this.documentWorkspace.PhaseModels.Count < 2 || /*this.documentWorkspace.PhaseModels[1].choise == true && */this.documentWorkspace.PhaseModels[1].mat == null)
//{
// MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformuctionfirst.text"));
// return;
//}
if (this.imageMat == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
return;
}
//1013###19326 晶粒度的晶界编辑页面,需要把辅助线带过去(客户编辑只处理辅助线位置的晶界)
GrainBoundaryEditingDialog boundaryEditingDialog = new GrainBoundaryEditingDialog(this.appWorkspace, this.menuId, this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index, this.documentWorkspace.PhaseModels[1].mat == null ? Color.Red : PhaseModels1Color/*this.panel1.BackColor*/
, this.documentWorkspace.PhaseModels[1].mat == null ? null : this.documentWorkspace.PhaseModels[1].mat.Clone(), ShowDrawClassView());
boundaryEditingDialog.GuideClass = GSSClass.GuideClass;
boundaryEditingDialog.SelectedItem = this.comboBox1.SelectedItem;
if (boundaryEditingDialog.ShowDialog() == DialogResult.OK && boundaryEditingDialog.PhaseMat != null)
{
string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
if (System.IO.File.Exists(xmlFilePath))
{
Base.SettingModel.GrainBoundryDectModel grainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
//sigma = grainBoundryDectModel.sigma;
if (!this.grainBoundaryDict.ContainsKey(getCurrentWorkTag()))
this.grainBoundaryDict.Add(getCurrentWorkTag(), grainBoundryDectModel.cloneModel());
else
this.grainBoundaryDict[getCurrentWorkTag()] = grainBoundryDectModel.cloneModel();
}
if (this.grainBoundaryDict[getCurrentWorkTag()].grainApplygrainboundaries != 1)
{//没有选择应用选项
if (this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
{
this.grainBoundaryMatDict.Remove(getCurrentWorkTag());
this.documentWorkspace.PhaseModels[1].mat = null;
if (PhaseModels1Mat != null)
{
PhaseModels1Mat.Dispose();
PhaseModels1Mat = null;
}
if (grainMethodType == 1)
if (GetClassNumberOfGrains() == 0)
this.documentWorkspace.Refresh();
else
AddRectangleToRectangleFCaps();
this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
//this.documentWorkspace.Refresh();
if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
this.documentWorkspace.Refresh();
else//###############################################################//#20991
AddRectangleToRectangleFCaps();
}
return;
}
PhaseModels1Color = boundaryEditingDialog.PhaseColor;
if (PhaseModels1Mat != null)
{
PhaseModels1Mat.Dispose();
PhaseModels1Mat = null;
}
if (getCurrentWorkspace().GraphicsList.IsExsitView())
PhaseModels1Mat = boundaryEditingDialog.PhaseMat.Clone();
this.documentWorkspace.PhaseModels[1].mat = boundaryEditingDialog.PhaseMat.Clone();
if (!this.grainBoundaryMatDict.ContainsKey(getCurrentWorkTag()))
this.grainBoundaryMatDict.Add(getCurrentWorkTag(), boundaryEditingDialog.PhaseMat.Clone());
else
this.grainBoundaryMatDict[getCurrentWorkTag()] = boundaryEditingDialog.PhaseMat.Clone();
//if (grainMethodType == 1)
// if (GetClassNumberOfGrains() == 0)
// this.documentWorkspace.Refresh();
// else
// AddRectangleToRectangleFCaps();
this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
if (grainMethodType == 1 && GetClassNumberOfGrains() == 0)
this.documentWorkspace.Refresh();
else//###############################################################//#20991
AddRectangleToRectangleFCaps();
this.documentWorkspace.Refresh();
}
}
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.refreshActionWhileImg_SelectedIndexChanged(false);
}
}
///
/// 导出项目
///
///
///
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 = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
Dictionary tagInfos = new Dictionary();
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> analysisContent = new List>();
List contentHeaderText2 = new List();
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
{
contentHeaderText2.Add(c.HeaderText);
}
analysisContent.Add(contentHeaderText2);
foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
{
List content = new List();
for (int i = 0; i < contentHeaderText2.Count; i++)
{
content.Add(item.Cells[i].Value.ToString());
}
analysisContent.Add(content);
}
List contentHeaderText = new List();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
contentHeaderText.Add(c.HeaderText);
}
analysisContent.Add(contentHeaderText);
foreach (DataGridViewRow item in this.dataGridView2.Rows)//################################
{
List content = new List();
for (int i = 0; i < contentHeaderText.Count; i++)
{
content.Add(item.Cells[i].Value.ToString());
}
analysisContent.Add(content);
}
//图片
bitList = new List();
List pNamesList = new List();
//中间数据
List exportModel = new List();
if (this.allShow)
{
foreach (KeyValuePair> kv in this.bitDic)
{
int cal_Index = int.Parse(kv.Key.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
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))
{
int cal_Index = int.Parse(item.Name.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
bitList.Add(bitDic[item.Name][0]);
bitList.Add(bitDic[item.Name][1]);
}
else if (bitDic.ContainsKey(item.Tag.ToString()))
{
int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
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))
{
int cal_Index = int.Parse(rowItem.Name.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
bitList.Add(bitDic[rowItem.Name][0]);
bitList.Add(bitDic[rowItem.Name][1]);
}
else if (bitDic.ContainsKey(rowItem.Tag.ToString()))
{
int cal_Index = int.Parse(rowItem.Tag.ToString().Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
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;
}
}
}
}
string dictPath = Application.StartupPath + "\\temp";
if (!System.IO.Directory.Exists(dictPath))
{
System.IO.Directory.CreateDirectory(dictPath);
}
DeleteFolder(dictPath);
pNames = new Dictionary();
int insertIn = 0;
for (int k = 0; k < bitList.Count; k += 2)
{//保存处理后的图片
List tempBit = new List();
tempBit.Add((Bitmap)bitList[k].Clone());
tempBit.Add((Bitmap)bitList[k+1].Clone());
this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
insertIn++;
}
this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, nodeItem.path, nodeItem.code, dictPath, pNames);
//保存项目信息到数据库
this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, nodeItem);
}
else
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
}
Dictionary pNames = new Dictionary();
///
/// 保存图片到本地
///
///
private void SaveAllImage(List bitList, string newPath, int originNum, int codeNum, string pName)
{
if (bitList != null && bitList.Count > 0)
{
for (int i = 0; i < bitList.Count; i++)
{
string bitPath = "";
//分别为原图和处理后的图命名
if (i % 2 == 0)
{
bitPath = newPath + "/" + "origin" + originNum + ".jpg";
pNames.Add("origin" + originNum, pName);
}
else
{
bitPath = newPath + "/" + codeNum + ".jpg";
pNames.Add(codeNum.ToString(), pName);
}
bitList[i].Save(bitPath);
}
}
}
public void DeleteFolder(string path)
{
foreach (string d in Directory.GetFileSystemEntries(path))
{
if (System.IO.File.Exists(d))
{
FileInfo fi = new FileInfo(d);
if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
fi.Attributes = FileAttributes.Normal;
System.IO.File.Delete(d);//直接删除其中的文件
}
else
{
DirectoryInfo d1 = new DirectoryInfo(d);
if (d1.GetFiles().Length != 0)
{
DeleteFolder(d1.FullName);
}
Directory.Delete(d);
}
}
}
///
/// 导出结果
///
///
///
private void button_exportResults_Click(object sender, EventArgs e)
{
if (this.listView2.Items.Count > 0)
{
List list = new List();
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 (table2.Rows.Count > 0) list.Add(table2);
if (table1.Rows.Count > 0) list.Add(table1);
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, HeaderTextUsable, false, true);
}
else
MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!");
}
///
/// 画布绘制
///
///
///
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);
}
}
///
/// 绘制
///
private void Draw(Graphics graphics)
{
// 抗锯齿
graphics.SmoothingMode = SmoothingMode.AntiAlias;
drawSubclass(graphics);
}
///
/// 计算汇总列表的平均晶粒度级别
///
///
protected virtual string getGradeTotalCal(DataGridViewRow dgvr, int digits = -1)
{
return "00A";
}
///
/// 取消全部显示
///
///
///
private void button16_Click(object sender, EventArgs e)
{
this.button11.Visible = true;
this.button16.Visible = false;
this.button11.Focus();
this.allShow = false;
this.dataGridView2.Rows.Clear();
if (this.listView2.SelectedItems.Count <= 0)
{
if (this.listView2.Items.Count > 0)
{
this.listView2.Items[this.listView2.Items.Count - 1].Selected = true;
}
else
{
return;
}
}
List> valueList = new List>();
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;
for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < dataTable1.Columns.Count; c++)
{
dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
continue;
}
if (c == 3)
value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
}
else
{
if (this.listView2.Items[0].Tag.Equals(dataTable.TableName))
{
dataTable1 = dataTable;
for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < dataTable1.Columns.Count; c++)
{
dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
continue;
}
if (c == 3)
value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
}
}
}
this.dataGridView_Total.Rows.Clear();
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = valueL.Average().ToString();
else if (itemValue[0] == 3)//级别
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));//############
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
this.dataGridView_Total.Rows.Add(dgvr);
this.RefreshDataGridView4();
return;
}
double grainNumber = 0;
if (getGbtType() == 3)
value_1 = 0;
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][grainMethodType == 1 ? 0 : 1].ToString());
if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 += (double)valuePairs["RectArea"];
}
}
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
if (getGbtType() == 3)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
else
{
dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
dgvr.Cells[2].Value = small_l.ToString();
if (getGbtType() == 4)
dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
else
dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
if (grainMethodType == 1)
{
if (dgvr.Cells.Count > 4)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
dgvr.Cells[4].Value = value_1.ToString();
value_1 = value_1 * 0.001 * 0.001;
}
if (dgvr.Cells.Count > 5)
{
if (getGbtType() == 4)
dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
else
dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
//##
this.RefreshDataGridView4();
}
///
/// 切换分析结果
///
///
///
private void listview2_SelectedIndexChanged(object sender, EventArgs e)
{
if (!this.allShow)
{
if (this.listView2.SelectedItems.Count <= 0)
return;
List> valueList = new List>();
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;
for (int rIndex = 0; rIndex < dataTable1.Rows.Count; rIndex++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < dataTable1.Columns.Count; c++)
{
dgvr.Cells[c].Value = dataTable1.Rows[rIndex][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(dataTable1.Rows[rIndex][c].ToString()));
continue;
}
if (c == 3)
value_1 += double.Parse(dataTable1.Rows[rIndex][c].ToString());
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += double.Parse(dataTable1.Rows[rIndex][c].ToString());
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
}
}
this.dataGridView_Total.Rows.Clear();
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = valueL.Average().ToString();
else if (itemValue[0] == 3)//级别
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
this.dataGridView_Total.Rows.Add(dgvr);
this.RefreshDataGridView4();
return;
}
double grainNumber = 0;
if (getGbtType() == 3)
value_1 = 0;
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;
}
if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[this.listView2.SelectedItems[i].Tag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 += (double)valuePairs["RectArea"];
}
grainNumber += double.Parse(dataTable1.Rows[0][grainMethodType == 1 ? 0 : 1].ToString());//###21939
}
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
if (getGbtType() == 3)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
else
{
dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
dgvr.Cells[2].Value = small_l.ToString();
if (getGbtType() == 4)
dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
else
dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
if (grainMethodType == 1)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
if (dgvr.Cells.Count > 4)
{
dgvr.Cells[4].Value = value_1.ToString();
value_1 = value_1 * 0.001 * 0.001;
}
if (dgvr.Cells.Count > 5)
{
if (getGbtType() == 4)
dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
else
dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
//##
this.RefreshDataGridView4();
}
}
///
/// 全部显示
///
///
///
private void button11_Click(object sender, EventArgs e)
{
if (this.listView2.Items.Count > 0)
{
this.button11.Visible = false;
this.button16.Visible = true;
this.button16.Focus();
this.allShow = true;
List> valueList = new List>();
double value_1 = 0;
double small_l = 0;
this.dataGridView2.Rows.Clear();
for (int i = 0; i < this.dataTables.Count; i++)
{
for (int rIndex = 0; rIndex < this.dataTables[i].Rows.Count; rIndex++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
{
dgvr.Cells[c].Value = this.dataTables[i].Rows[rIndex][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(this.dataTables[i].Rows[rIndex][c].ToString()));
continue;
}
if (c == 3)
value_1 += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += double.Parse(this.dataTables[i].Rows[rIndex][c].ToString());
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
this.dataGridView_Total.Rows.Clear();
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = valueL.Sum().ToString();
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = valueL.Average().ToString();
else if (itemValue[0] == 3)//级别
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
this.dataGridView_Total.Rows.Add(dgvr);
this.RefreshDataGridView4();
return;
}
double grainNumber = 0;
for (int i = 0; i < this.dataTable_Totals.Count; i++)
{
grainNumber += double.Parse(this.dataTable_Totals[i].Rows[0][grainMethodType == 1 ? 0 : 1].ToString());
}
if (getGbtType() == 3)
value_1 = 0;
for (int j = 0; j < this.listView2.Items.Count; j++)
{
if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 += (double)valuePairs["RectArea"];
}
}
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = (grainMethodType == 1 ? grainNumber : small_l).ToString();
if (getGbtType() == 3)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
else
{
dgvr.Cells[1].Value = (grainMethodType == 1 ? small_l : value_1).ToString();
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
dgvr.Cells[2].Value = small_l.ToString();
if (getGbtType() == 4)
dgvr.Cells[3].Value = (-6.6439 * Math.Log10(small_l * 0.001) - 3.2877).ToString();
else
dgvr.Cells[3].Value = (-6.643856 * Math.Log10(small_l * 0.001) - 3.288).ToString();
if (grainMethodType == 1)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
if (dgvr.Cells.Count >= 5)
{
dgvr.Cells[4].Value = value_1.ToString();
value_1 = value_1 * 0.001 * 0.001;
}
if (dgvr.Cells.Count >= 6)
{
if (getGbtType() == 4)
dgvr.Cells[5].Value = (3.32 * Math.Log10(1.0 / value_1) - 2.9542).ToString();
else
dgvr.Cells[5].Value = (3.321928 * Math.Log10(1.0 / value_1) - 2.954).ToString();
}
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
this.RefreshDataGridView4();
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
}
}
///
/// 分析结果删除
///
///
///
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;
}
}
if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[i].Tag.ToString()))
this.dict_Totals.Remove(this.listView2.SelectedItems[i].Tag.ToString());
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();
this.threeDButton.Enabled = false;
}
else
RefreshDataGridView4();
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
}
}
///
/// 小数位数
///
///
///
private void numericUpDown1_0_ValueChanged(object sender, EventArgs e)
{
this.RefreshDataGridView4();
this.RefreshWhileUpDown1_0ValueChanged();
}
///
/// 生成报告
///
///
///
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 = PaintDotNet.DbOpreate.DbBll.mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
Dictionary tagInfos = new Dictionary();
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 exportModel = new List();
if (this.allShow)
{
//中间数据
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 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];
//中间数据
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;
}
}
}
}
int exportModelIndex = 0;
//详细数据
List> analysisContent2;
if (grainMethodType == 1 || tempDataModel == null || tempDataModel.Count == 0)
analysisContent2 = null;
else
{
analysisContent2 = new List>();
List columnName2 = new List();
columnName2.Add(PdnResources.GetString("Menu.picture.Text"));
columnName2.AddRange(exportModel[0].dataList[0]);
analysisContent2.Add(columnName2);
foreach (var tempData in exportModel)
{
List> dataList = tempData.dataList;
for (int k = 1; k < dataList.Count; k++)
{
List strList = new List();
strList.Add(tempData.picName);
strList.AddRange(dataList[k]);
strList[1] = (++exportModelIndex).ToString();
analysisContent2.Add(strList);
}
}
}
//分析结果
List> analysisContent = new List>();
List contentHeaderText2 = new List();
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
{
contentHeaderText2.Add(c.HeaderText);
}
analysisContent.Add(contentHeaderText2);
foreach (DataGridViewRow item in this.dataGridView_Total.Rows)//##########################
{
List content = new List();
for (int i = 0; i < contentHeaderText2.Count; i++)
{
content.Add(item.Cells[i].Value.ToString());
}
analysisContent.Add(content);
}
List contentHeaderText = new List();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
contentHeaderText.Add(c.HeaderText);
}
analysisContent.Add(contentHeaderText);
foreach (DataGridViewRow item in this.dataGridView2.Rows)//##########################
{
List content = new List();
for (int i = 0; i < contentHeaderText.Count; i++)
{
content.Add(item.Cells[i].Value.ToString());
}
analysisContent.Add(content);
}
//图片
bitList = new List();
List pNamesList = new List();
if (this.allShow)
{
foreach (KeyValuePair> kv in this.bitDic)
{
int cal_Index = int.Parse(kv.Key.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
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))
{
int cal_Index = int.Parse(item.Name.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
bitList.Add(bitDic[item.Name][0]);
bitList.Add(bitDic[item.Name][1]);
}
else if (bitDic.ContainsKey(item.Tag.ToString()))
{
int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
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))
{
int cal_Index = int.Parse(item.Name.Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
bitList.Add(bitDic[item.Name][0]);
bitList.Add(bitDic[item.Name][1]);
}
else if (bitDic.ContainsKey(item.Tag.ToString()))
{
int cal_Index = int.Parse(item.Tag.ToString().Replace("img", ""));
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
pNamesList.Add(imgName);
bitList.Add(bitDic[item.Tag.ToString()][0]);
bitList.Add(bitDic[item.Tag.ToString()][1]);
}
}
}
string dictPath = Application.StartupPath + "\\temp";
if (!System.IO.Directory.Exists(dictPath))
{
System.IO.Directory.CreateDirectory(dictPath);
}
DeleteFolder(dictPath);
pNames = new Dictionary();
int insertIn = 0;
for (int k = 0; k < bitList.Count; k += 2)
{//保存处理后的图片
List tempBit = new List();
tempBit.Add((Bitmap)bitList[k].Clone());
tempBit.Add((Bitmap)bitList[k + 1].Clone());
this.SaveAllImage(tempBit, dictPath, insertIn + 1, insertIn + 1, pNamesList[insertIn]);
insertIn++;
}
this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos, dictPath, pNames, analysisContent2);
}
else
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!");
}
///
/// 切换辅助线
///
///
///
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox1SelectedItem = comboBox1.SelectedItem;
if (GSSClass.GuideClass.guideModel != null)
GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
{
if (this.imageMat == null)
{
int oldSelectIndex = -1;
for (int i = 0; i < this.comboBox1.Items.Count; i++)
{
if (GSSClass.GuideClass.guideModel.oldSelectItem != null && GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
{
oldSelectIndex = i;
}
}
if (this.comboBox1.SelectedIndex > 0)
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
if (oldSelectIndex > -1)
{
if (this.comboBox1.SelectedIndex != oldSelectIndex)
this.comboBox1.SelectedIndex = oldSelectIndex;
}
else if (this.comboBox1.Items.Count > 0)
this.comboBox1.SelectedIndex = 0;
return;
}
UpdateGuideStyle(true && !(this.initScriptValues && this.appWorkspace.ScriptAutomatic));
if (this.imageMat != null)
{
if (this.comboboxChange)
{
GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
}
InitRectangleF(true);
this.comboboxChange = true;
}
this.documentWorkspace.Refresh();
}
}
///
/// 辅助线设置
///
///
///
private void button9_Click(object sender, EventArgs e)
{
if (this.imageMat == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
return;
}
GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
GrainGuideSettingsDialog grainGuideStyleSettingsDialog = new GrainGuideSettingsDialog(grainMethodType == 1 ? 1 : 0, GSSClass.methodOfAssessment != null ? GSSClass.methodOfAssessment.guideXmlName : getModelName(), getTypeNames(), this.imageMat/*.Clone()*/, this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index
].GetRuler(MeasurementUnit.Micron));
grainGuideStyleSettingsDialog.StartPosition = FormStartPosition.CenterScreen;
grainGuideStyleSettingsDialog.ShowDialog(this);
}
///
/// 返回小数点位数的数值
///
///
protected int getNumericUpDown1Value()
{
return Convert.ToInt32(this.numericUpDown1_0.Value);
}
///
/// 刷新晶粒编号/刷新晶粒颜色?//############
///
///
///
/// 返回晶粒个数
protected virtual double GetClassNumberOfGrains()
{
return 0.0;
}
///
/// 颜色点击事件
///
///
///
protected void panel1_1_Click(object sender, EventArgs e)
{
this.panelC = (Panel)sender;
this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(((Panel)sender).BackColor);
this.colorsFormGrid.ShowDialog();
}
///
/// PanelC的调色板颜色改变
///
///
///
private void gridColorChanged(object sender, EventArgs e)
{
Color color = this.colorsFormGrid.UserPrimaryColor.ToColor();
//更改背景色,触发事件
if (this.panelC != null)
{
this.panelC.BackColor = color;
this.ColorPanelChanged(this.panelC);
this.panelC = null;
}
//关闭色板
this.colorsFormGrid.Close();
}
#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 辅助线拖动
///
/// 鼠标按下
///
///
///
protected virtual void OnMouseDown(object sender, MouseEventArgs e)
{
if (grainMethodType == 1)
{
if (this.documentWorkspace.CompositionSurface == null)
return;
// 换算后的点
PointF pointArea = documentWorkspace.GetScalePoint(e.Location);
//辅助线缩放
GSSClass.GuideClass.OnMouseDown(pointArea, sender, e);
//辅助线移动
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(pointArea))
{
GSSClass.GuideClass.m_canMove = true;
GSSClass.GuideClass.m_StartPoint = pointArea;
}
}
return;
}
// 换算后的点
PointF point1 = documentWorkspace.GetScalePoint(e.Location);
if (e.Button == MouseButtons.Left && e.Clicks == 1)
{
if (GSSClass.GuideClass.guideModel.RectangleFLine.Contains(point1))
{
GSSClass.GuideClass.m_canMove = true;
GSSClass.GuideClass.m_StartPoint = point1;
}
}
}
///
/// 移动
///
///
///
protected virtual void onMouseMove(object sender, MouseEventArgs e)
{
this.documentWorkspace.Refresh();
// 换算后的点
PointF point1 = documentWorkspace.GetScalePoint(e.Location);
//晶粒度不想让辅助线拖到图像外面
if (grainMethodType == 0 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron))
|| grainMethodType == 1 && this.documentWorkspace.CompositionSurface != null && GSSClass.GuideClass.onMouseAreaMove(point1, this.comboBox1.SelectedItem, e, this.documentWorkspace.CompositionSurface.Width, this.documentWorkspace.CompositionSurface.Height, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)))// 矩形缩放
{//缩放
GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
this.AddRectangleToRectangleFCaps();
this.documentWorkspace.Refresh();
}
else if (e.Button == MouseButtons.Left && GSSClass.GuideClass.m_canMove)
{//移动
//限制辅助线移动不能拖到图像外面
PointF m222_StartPoint = new PointF(point1.X, point1.Y);
double minX = GSSClass.GuideClass.m_StartPoint.X - GSSClass.GuideClass.guideModel.rectangleFLine.X;
if (point1.X < minX)
point1.X = (float)minX;
double maxX = GSSClass.GuideClass.m_StartPoint.X + this.documentWorkspace.CompositionSurface.Width - GSSClass.GuideClass.guideModel.RectangleFLine.Right;
if (point1.X > maxX)
point1.X = (float)maxX;
double minY = GSSClass.GuideClass.m_StartPoint.Y - GSSClass.GuideClass.guideModel.rectangleFLine.Y;
if (point1.Y < minY)
point1.Y = (float)minY;
double maxY = GSSClass.GuideClass.m_StartPoint.Y + this.documentWorkspace.CompositionSurface.Height - GSSClass.GuideClass.guideModel.RectangleFLine.Bottom;
if (point1.Y > maxY)
point1.Y = (float)maxY;
float offsetX = point1.X - GSSClass.GuideClass.m_StartPoint.X;
float offsetY = point1.Y - GSSClass.GuideClass.m_StartPoint.Y;
// 矩形偏移
GSSClass.GuideClass.guideModel.rectangleFLine.Offset(offsetX, offsetY);
GSSClass.GuideClass.guideModel.loctation = new PointF(GSSClass.GuideClass.guideModel.RectangleFLine.X + GSSClass.GuideClass.guideModel.RectangleFLine.Width / 2, GSSClass.GuideClass.guideModel.RectangleFLine.Y + GSSClass.GuideClass.guideModel.RectangleFLine.Height / 2);
GSSClass.GuideClass.m_StartPoint = m222_StartPoint;
if (grainMethodType == 0 && !(!getGrainBoundryChecked() && !getBinaryChecked()))
//##21247
this.AddRectangleToRectangleFCaps();
else if (grainMethodType == 0)
{
//##21247
this.MoveOriginCutOffPoints(offsetX, offsetY);
}
this.documentWorkspace.Refresh();
}
}
///
/// 鼠标抬起
///
///
///
protected virtual void onMouseUp(object sender, MouseEventArgs e)
{
GSSClass.GuideClass.m_canMove = false;
GSSClass.GuideClass.onMouseUp(sender, e);
}
#endregion
#endregion
#region 可调用方法
///
/// 是否显示原图
///
///
protected Boolean showOrimat()
{
return bcOriginChecked();
}
///
/// 获取小数点保留位数的显示字符串
///
///
///
protected string DecnumString(string doubleValue)
{
double outValue;
if (double.TryParse(string.IsNullOrEmpty(doubleValue) ? "0" : doubleValue, out outValue))
{
return Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
}
else
return doubleValue;
}
///
/// 设置晶粒颜色
///
protected void ShowGrainColorSettingDialog()
{
GrainColorSetting colorSettings = new GrainColorSetting(/*isAreaType ? 1 : 0, getModelName(), getTypeNames(), this.bitmap*/);
colorSettings.StartPosition = FormStartPosition.CenterScreen;
//colorSettings.ShowDialog(this)
if (colorSettings.ShowDialog() == DialogResult.OK)
{
//获取设置颜色的集合,按照等级从小到大排序
List colorOfGrades = colorSettings.getColorOfGrades();
GSSClass.setColorOfGrades.Clear();
GSSClass.setColorOfGrades.AddRange(colorOfGrades);
setMat2ColorOfLabelMat(-1);
};
}
///
/// 设置截点样式
///
protected void ShowGrainSurveyPointStyleSettingDialog()
{
GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSurveyPointStyleSettingDialog();//###
grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
grainSurveyPointStyleSettingDialog.ShowDialog(this);
}
///
/// 根据等级设置晶粒颜色
///
/// 连通域数量
private void setMat2ColorOfLabelMat(int nccomps)
{
Mat temp = GSSClass.getMat2ColorOfLabelMat(GSSClass.standardModel, nccomps, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
if (temp != null)
{
if (grainMethodType == 1)
{
if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
this.grainColorsMatDict[getCurrentWorkTag()] = temp.Clone();
else
this.grainColorsMatDict.Add(getCurrentWorkTag(), temp.Clone());
}
this.documentWorkspace.PhaseModels[2].mat = temp;
this.documentWorkspace.Refresh();
}
}
///
/// 更新截点样式
///
public void UpdateCupOffPointStyle()
{
GSSClass.styleClass.styleModel.UpdateCupOffPointStyle();
AddRectangleToRectangleFCaps();
}
///
/// 刷新分析结果数据
///
protected virtual void RefreshDataGridView4()
{
if (!this.allShow)
{
if (this.listView2.SelectedItems.Count > 0)
{
List> valueList = new List>();
double value_1 = 0;//面积法(汇总面积)、截点法(截点总数)
double small_l = 0;//面积法(汇总截距)、截点法(网格总长度)
this.dataGridView2.Rows.Clear();
for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
{
for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
{
if (this.dataTables[dataTableIndex].TableName.Equals(this.listView2.SelectedItems[j].Tag))
{
for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
{
double outValue;
if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
{
dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
}
else
dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
continue;
}
if (c == 3/*isAreaType && c == 3 || !isAreaType && c == 3*/)
value_1 += outValue;
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += outValue;
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
}
}
this.dataGridView_Total.Rows.Clear();
value_111 = -1;
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 3)//级别
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
this.dataGridView_Total.Rows.Add(dgvr);
return;
}
double grainNumber = 0;
if (getGbtType() == 3)
value_1 = 0;
for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
{
int dataTableIndex = 0;
for (int i = 0; i < this.dataTable_Totals.Count; i++)
{
if (this.dataTable_Totals[i].TableName.Equals(this.listView2.SelectedItems[j].Tag))
dataTableIndex = i;
}
if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
{
for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
{
grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
}
}
if (this.dict_Totals.ContainsKey(this.listView2.SelectedItems[j].Tag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[this.listView2.SelectedItems[j].Tag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 += (double)valuePairs["RectArea"];
}
}
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 3)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
{
dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 4)
dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
{
RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
//return;
}
if (grainMethodType == 1)
{
if (dgvr.Cells.Count > 4)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
value_1 = value_1 * 0.001 * 0.001;
}
if (dgvr.Cells.Count > 5)
{
if (getGbtType() == 4)
dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
}
else if (this.listView2.Items.Count > 0)
{
var firstTag = this.listView2.Items[0].Tag;
List> valueList = new List>();
double value_1 = 0;
double small_l = 0;
this.dataGridView2.Rows.Clear();
for (int dataTableIndex = 0; dataTableIndex < this.dataTables.Count; dataTableIndex++)
{
if (this.dataTables[dataTableIndex].TableName.Equals(firstTag))
{
for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++)
{
double outValue;
if (double.TryParse(string.IsNullOrEmpty(this.dataTables[dataTableIndex].Rows[r][c].ToString()) ? "0" :
this.dataTables[dataTableIndex].Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
{
dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
}
else
dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(this.dataTables[dataTableIndex].Rows[r][c].ToString()));
continue;
}
if (c == 3)
value_1 += outValue;
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += outValue;
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
}
this.dataGridView_Total.Rows.Clear();
value_111 = -1;
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 3)//级别
{
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
}
this.dataGridView_Total.Rows.Add(dgvr);
return;
////##
//this.RefreshDataGridView4();
}
double grainNumber = 0;
//for (int j = 0; j < this.listView2.SelectedItems.Count; j++)
{
int dataTableIndex = 0;
for (int i = 0; i < this.dataTable_Totals.Count; i++)
{
if (this.dataTable_Totals[i].TableName.Equals(firstTag/*this.listView2.SelectedItems[j].Tag*/))
dataTableIndex = i;
}
if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
{
for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
{
grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].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 = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 3)
{
if (this.dict_Totals.ContainsKey(firstTag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[firstTag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 = (double)valuePairs["RectArea"];
}
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
{
dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
//value_111 = small_l;
dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 4)
dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
value_111 = Math.Max(1, Math.Min(15, 15 - double.Parse(dgvr.Cells[3].Value.ToString()))) * 9;
if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
{
RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
//return;
}
if (grainMethodType == 1)
{
if (dgvr.Cells.Count > 4)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
value_1 = value_1 * 0.001 * 0.001;
}
if (dgvr.Cells.Count > 5)
{
if (getGbtType() == 4)
dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
}
}
else
{
System.Data.DataTable dataTable;
List> valueList = new List>();
double value_1 = 0;
double small_l = 0;
this.dataGridView2.Rows.Clear();
for (int i = this.dataTables.Count - 1; i >= 0; i--)
{
dataTable = this.dataTables[i];
for (int r = 0; r < dataTable.Rows.Count; r++)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
List valueL = new List();
for (int c = 0; c < dataTable.Columns.Count; c++)
{
double outValue;
if (double.TryParse(string.IsNullOrEmpty(dataTable.Rows[r][c].ToString()) ? "0" :
dataTable.Rows[r][c].ToString(), out outValue) && !DetailListStringIndex.Contains(c))
{
dgvr.Cells[c].Value = Math.Round(outValue, Convert.ToInt32(this.numericUpDown1_0.Value)) + "";
}
else
dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString();
if (IndexChangedFromIndex.Count > 0)
{
if (IndexChangedFromIndex.Contains(c))
valueL.Add(double.Parse(dataTable.Rows[r][c].ToString()));
continue;
}
if (c == 3)
value_1 += outValue;
if (grainMethodType == 1 && c == 4 || grainMethodType == 0 && c == 2)
small_l += outValue;
}
if (IndexChangedFromIndex.Count > 0)
valueList.Add(valueL);
this.dataGridView2.Rows.Add(dgvr);
}
}
this.dataGridView_Total.Rows.Clear();
if (IndexChangedFromIndex.Count > 0 && IndexChangedToIndex.Count > 0 && valueList.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
foreach (int itemkey in IndexChangedToIndex.Keys)
{
int[] itemValue = IndexChangedToIndex[itemkey];
List valueL = new List();//级别时会多算一遍,应该不影响什么
if (itemValue[1] >= 0)
foreach (List itemL in valueList)
{
valueL.Add(itemL[itemValue[1]]);
}
if (itemValue[0] == 1)//求和
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Sum(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 2)//平均
dgvr.Cells[itemkey].Value = "" + Math.Round(valueL.Average(), Convert.ToInt32(this.numericUpDown1_0.Value));
else if (itemValue[0] == 3)//级别
if (itemValue[1] < 0)
{
dgvr.Cells[itemkey].Value = getGradeTotalCal(dgvr, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
dgvr.Cells[itemkey].Value = getGradeValue(double.Parse(dgvr.Cells[itemValue[1]].Value.ToString()));
}
this.dataGridView_Total.Rows.Add(dgvr);
return;
////##
//this.RefreshDataGridView4();
}
double grainNumber = 0;
if (getGbtType() == 3)
value_1 = 0;
for (int j = 0; j < this.listView2.Items.Count; j++)
{
int dataTableIndex = 0;
for (int i = 0; i < this.dataTable_Totals.Count; i++)
{
if (this.dataTable_Totals[i].TableName.Equals(this.listView2.Items[j].Tag))
dataTableIndex = i;
}
if (this.dataTable_Totals.Count > dataTableIndex && this.dataTable_Totals[dataTableIndex].Rows.Count > 0)
{
for (int r = 0; r < this.dataTable_Totals[dataTableIndex].Rows.Count; r++)
{
grainNumber += double.Parse(this.dataTable_Totals[dataTableIndex].Rows[r][grainMethodType == 1 ? 0 : 1].ToString());
}
}
if (this.dict_Totals.ContainsKey(this.listView2.Items[j].Tag.ToString()))
{
Dictionary valuePairs = this.dict_Totals[this.listView2.Items[j].Tag.ToString()];
if (valuePairs.ContainsKey("RectArea"))
value_1 += (double)valuePairs["RectArea"];
}
}
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn Column in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = "" + Math.Round(grainMethodType == 1 ? grainNumber : small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 3)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
value_1 = value_1 * 0.001 * 0.001;
dgvr.Cells[1].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
else
{
dgvr.Cells[1].Value = "" + Math.Round(grainMethodType == 1 ? small_l : value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
if (grainMethodType == 1 && grainNumber > 0)
small_l = small_l / grainNumber;
else if (grainMethodType == 0 && value_1 > 0)
small_l = small_l / value_1;
dgvr.Cells[2].Value = "" + Math.Round(small_l, Convert.ToInt32(this.numericUpDown1_0.Value));
if (getGbtType() == 4)
dgvr.Cells[3].Value = "" + Math.Round(-6.6439 * Math.Log10(small_l * 0.001) - 3.2877, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[3].Value = "" + Math.Round(-6.643856 * Math.Log10(small_l * 0.001) - 3.288, Convert.ToInt32(this.numericUpDown1_0.Value));
if (grainMethodType == 1)
{
if (grainNumber > 0)
value_1 = value_1 / grainNumber;
dgvr.Cells[4].Value = "" + Math.Round(value_1, Convert.ToInt32(this.numericUpDown1_0.Value));
value_1 = value_1 * 0.001 * 0.001;
if (getGbtType() == 4)
dgvr.Cells[5].Value = "" + Math.Round(3.32 * Math.Log10(1.0 / value_1) - 2.9542, Convert.ToInt32(this.numericUpDown1_0.Value));
else
dgvr.Cells[5].Value = "" + Math.Round(3.321928 * Math.Log10(1.0 / value_1) - 2.954, Convert.ToInt32(this.numericUpDown1_0.Value));
}
}
this.dataGridView_Total.Rows.Add(dgvr);
}
}
}
///
/// 是否能取到二值的结果
///
///
protected Boolean getBinaryChecked()
{
return (bcBinaryChecked() && this.documentWorkspace.PhaseModels[0].mat != null);
}
///
/// 是否能取到晶界重现的结果
///
///
protected Boolean getGrainBoundryChecked()
{
if (this.documentWorkspace.PhaseModels.Count > 0)
{
return (/*this.checkBox1.Checked && */this.documentWorkspace.PhaseModels[1].mat != null);
}
return false;
}
//public void SetItemOrdinal(int itemOrdinal)
//{
// if (this.progressDialog.InvokeRequired)
// {
// this.progressDialog.BeginInvoke(new Procedure(SetItemOrdinal), new object[] { itemOrdinal });
// }
// else
// {
// this.itemOrdinal = itemOrdinal;
// this.totalWork = 0;
// this.totalProgress = 0;
// UpdateUI();
// }
//}
protected object comboBox1SelectedItem = null;
///
/// 返回当前选择的辅助线名称
///
///
protected string getCurrentGuideName()
{
return comboBox1SelectedItem/*this.comboBox1.SelectedItem*/ != null ? comboBox1SelectedItem/*this.comboBox1.SelectedItem*/.ToString() : "";
}
///
/// 返回当前选择的图片内容
///
///
protected DocumentWorkspace getCurrentWorkspace()
{
if (this.lstView_img.FocusedItem == null && this.lstView_img.SelectedItems.Count == 0)
return null;
return this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
}
///
/// 返回当前选择的图片tag
///
///
protected string getCurrentWorkTag()
{
return this.imageList_img.Images.Keys[this.lstView_img.FocusedItem != null ? this.lstView_img.FocusedItem.Index : this.lstView_img.SelectedItems[0].Index];
}
///
/// 获取面积法显示编号的颜色
///
///
protected Color getGrainBoundryColor()
{
return Color.Red;//#########################1 this.documentWorkspace.PhaseModels[1].color;// this.panel1.BackColor;
}
private double cal_gNum = 0;
private Mat cal_temp = null;
GrainSizeStandardModel cal1_StandardModel;
GrainSizeGuideModel cal1_GuideModel;
Mat cal1_Picture;
Mat cal_analyzeMat;
bool cal_BinaryChecked;
string cal1_Tag;
int cal1_Index;
bool cal1_RectFlag = false;
ProgressThreadProcClass procClass;
///
/// 刷新晶粒编号
///
/// 返回晶粒个数
protected double GetNumberOfGrains(GrainSizeStandardModel cal_StandardModel = null, GrainSizeGuideModel cal_GuideModel = null,
string cal_Tag = null, int cal_Index = -1, bool isRectFlag = false)
{
bool isCurrentTag = false;
if (cal_StandardModel == null)
cal_StandardModel = GSSClass.standardModel;
if (cal_GuideModel == null)
cal_GuideModel = GSSClass.GuideClass.guideModel;
if (cal_Tag == null || cal_Tag.Equals(getCurrentWorkTag()))
{
isCurrentTag = true;
cal_Tag = getCurrentWorkTag();
}
if (cal_Index == -1)
cal_Index = this.selectPicture;
if (cal_StandardModel.linePointList.Count <= 0)
return 0.0;//should never go here !
Mat cal_Picture;
Mat analyzeMat = new Mat();
bool BinaryChecked;
if (cal_Tag != null && !isCurrentTag)
BinaryChecked = (binaryClass.getModelMat(cal_Tag) != null);
else
BinaryChecked = getBinaryChecked();
if (getGrainBoundryChecked())
{//######################
cal_Picture = new Mat(/*cal_*/imageMat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
Mat /*cal_*/oldMat = this.documentWorkspace.PhaseModels[1].mat;
int Rows = oldMat.Rows;
int Cols = oldMat.Cols;
int[] point = new int[2];
//多通道图像的格式化
for (point[0] = 0; point[0] < Rows; point[0]++)
{
for (point[1] = 0; point[1] < Cols; point[1]++)
{
if (oldMat.At(point[0], point[1]).Item3 > 0)
{
cal_Picture.Set(point, new Vec4b(0, 0, 0, 255));
}
}
}
Cv2.Erode(cal_Picture, cal_Picture, null, null, 1);
/*cal_*/oldMat.CopyTo(analyzeMat);
}
else if (BinaryChecked)
{
Mat cal_Mat = (cal_Tag != null && !isCurrentTag) ? binaryClass.getModelMat(cal_Tag) : this.PhaseModel0Mat;
cal_Picture = new Mat(cal_Mat.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
int Rows = cal_Mat.Rows;
int Cols = cal_Mat.Cols;
int[] point = new int[2];
//多通道图像的格式化
for (point[0] = 0; point[0] < Rows; point[0]++)
{
for (point[1] = 0; point[1] < Cols; point[1]++)
{
if (cal_Mat.At(point[0], point[1]).Item3 > 0)
{
cal_Picture.Set(point, new Vec4b(0, 0, 0, 255));
}
}
}
cal_Mat.CopyTo(analyzeMat);
}
else
{
Mat cal_Mat;// = cal_ImageMat; Mat cal_ImageMat;// = this.bitmap;
if (cal_Tag != null && cal_Index >= 0 && cal_Index < this.appWorkspace.DocumentWorkspaces.Length)
cal_Mat = this.appWorkspace.DocumentWorkspaces[cal_Index].CompositionSurface.CreatedAliasedMat();
else
cal_Mat = this.imageMat.Clone();
cal_Picture = new Mat(cal_Mat/*matOrg*/.Size(), MatType.CV_8UC4, new Scalar(255, 255, 255, 255));
cal_Mat.CopyTo(cal_Picture);
cal_Mat.CopyTo(analyzeMat);
}
if (cal_temp != null)
{
cal_temp.Dispose();
cal_temp = null;
}
cal_gNum = 0;
cal1_StandardModel = cal_StandardModel;
cal1_GuideModel = cal_GuideModel;
cal1_Picture = cal_Picture;
cal_analyzeMat = analyzeMat;
cal1_Tag = cal_Tag;
cal_BinaryChecked = BinaryChecked;
cal1_Index = cal_Index;
cal1_RectFlag = isRectFlag;
//this.progressDialog = new TransferProgressDialog();
//this.progressDialog.Text = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.TransferProgress.Title");
//this.progressDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileOpenIcon.png").Reference);
//this.progressDialog.Title = PdnResources.GetString("DocumentWorkspace.ShowFileDialog.ItemText.Initializing");
//this.progressDialog.ProgressBar.Style = ProgressBarStyle.Marquee;
//this.progressDialog.ProgressBar.Maximum = maxPBValue;
//DoVerbHandler Delegate_do = new DoVerbHandler(ShowProcessWindow);
//////Thread.Sleep(30000);//隔30秒后判断一下是否完成
//////IAsyncResult result = Delegate_do.BeginInvoke(null, null);
//////while (!result.IsCompleted)
//////{
////// Console.WriteLine("子线程未完成2");
////// Thread.Sleep(10000);//每隔10秒判断一下是否完成
//////}
//////Console.WriteLine("-------子线程已完成-------");
////DoVerbHandler invoker = new DoVerbHandler(ShowProcessWindow);
////发起一个线程,异步执行打开一个新窗口
////this.progressDialog.BeginInvoke(new Procedure(SetItemCount), new object[] { itemCount });
//Delegate_do.BeginInvoke(null, null);
//////你需要在窗体遮罩的时候要做的事情
////DoVerbMethod();
//cal_gNum = GSSClass.GetNumberOfGrains(cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
// this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
//yourForm.Close();
procClass = new ProgressThreadProcClass();
procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(cal_Action/*applyDectAction*/), "正在处理"/*PdnResources.GetString("Menu.Grainboundarytoreproduce.text")*/);
//ProgressThreadProcClass procClass = new ProgressThreadProcClass();
//int itemCount = 100;
//ProgressThreadProcClass.IFileTransferProgressEvents progressEvents = new ProgressThreadProcClass.IFileTransferProgressEvents();
//System.Threading.ThreadStart copyThreadProc =
// delegate ()
// {
// try
// {
// gNum = GSSClass.GetNumberOfGrains(cal_StandardModel, cal_GuideModel/*getCurrentGuideName()*/, cal_Picture, analyzeMat, getGrainBoundryChecked() || BinaryChecked/*getBinaryChecked()*/,
// this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron), out temp);
// }
// catch (Exception ex)
// {
// }
// finally
// {
// progressEvents.EndOperation(OperationResult.Finished);
// }
// };
//procClass.StartProgressAction(this, itemCount, copyThreadProc, progressEvents, null);
//根据等级设置晶粒颜色
if (cal_temp != null)
{
if (grainMethodType == 1)
{
if (this.grainColorsMatDict.ContainsKey(cal_Tag))
this.grainColorsMatDict[cal_Tag] = cal_temp.Clone();
else
this.grainColorsMatDict.Add(cal_Tag, cal_temp.Clone());
}
if (cal_Index == this.selectPicture && cal_Tag == getCurrentWorkTag())
{
this.documentWorkspace.PhaseModels[2].mat = cal_temp;
this.documentWorkspace.Refresh();
}
}
return cal_gNum;
}
///
/// 事件处理示例方法
///
///
private void DoVerbMethod()
{
for (int i = 0; i < 100; i++)
{
System.Threading.Thread.Sleep(100);
}
}
private void ShowProcessWindow()
{
yourForm.StartPosition = FormStartPosition.CenterParent;
yourForm.lblTitleBackColor = Color.Transparent;
yourForm.ShowDialog();
}
///
/// 全局变量,yourForm为新窗口的名字
///
TransferProgressDialog yourForm = new TransferProgressDialog();
///
/// 你需要处理的事情的方法委托
///
///
public delegate void DoVerbHandler(/*object arg*/);
///
/// 目标选择 1不包含边缘 2边缘只处理内部 3边缘处理内外部
///
public int TargetSelection = 2;
private void cal_Action()
{
cal_gNum = GSSClass.GetNumberOfGrains(cal1_RectFlag, TargetSelection, cal1_StandardModel, cal1_GuideModel/*getCurrentGuideName()*/, cal1_Picture, cal_analyzeMat, getGrainBoundryChecked() || cal_BinaryChecked/*getBinaryChecked()*/,
this.appWorkspace.DocumentWorkspaces[cal1_Index].GetRuler(MeasurementUnit.Micron), out cal_temp);
if (procClass != null) procClass.DismissProgressAction(this);
}
///
/// 面积法组织分项数据列表的内容,并返回汇总截距(μm)和汇总面积(μm²)
///
private double[] addNewRowsToDatagridView2(GrainSizeStandardModel cal_StandardModel, GrainSizeGuideModel cal_GuideModel, string cal_Tag, int cal_Index)
{
double small_l = 0;
double area_sum = 0;
//显示编号
if (cal_StandardModel.massLabelPoints.Count > 0 && cal_StandardModel.currentStats != null)
{
this.dataGridView2.Rows.Clear();
string imgName = this.appWorkspace.DocumentWorkspaces[cal_Index].GetFriendlyName();
int index = 0;
int label;
//Dictionary measurementUnitDictionary = Startup.instance.rules;
//选择标尺的物理长度(1倍下的 微米/像素)
//this.physical_length = getCurrentWorkspace().GetRuler(MeasurementUnit.Micron);
double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[cal_Index].GetRuler(MeasurementUnit.Micron);
//double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
double aec;
double grainNumber = 1.0;
decimal NA;
foreach (int kvLabel in cal_StandardModel.massLabelPoints.Keys)
{
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
dgvr.Cells[0].Value = imgName;
dgvr.Cells[1].Value = cal_GuideModel.oldSelectItem.ToString();
dgvr.Cells[2].Value = (++index);//晶粒编号
label = kvLabel;
aec = cal_StandardModel.currentStats.At(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
dgvr.Cells[3].Value = aec/*areaField1*/;
area_sum += aec;
aec = aec * 0.001 * 0.001;
NA = Convert.ToDecimal(grainNumber / aec);
////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
double[] lengths = {3.88, 7.75 , 10.96, 15.50, 21.92, 31.0, 43.84, 62.0,
87.68, 124, 175.36, 248, 350.73, 496, 701.45, 992, 1402.9, 1984.0, 2805.8, 3968.0, 5611.6,
7936.0, 11223.2, 15872.0, 22446.4, 31744.1, 44892.9, 63488.1, 89785.8, 126976.3};
// 差值
decimal differenceNew;
decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)NA - 2.88, (double)NA - 126977.3)));
int first = 0;
if ((double)NA > lengths[lengths.Length - 1])
first = lengths.Length - 1;
else
for (int firstI = 0; firstI < lengths.Length; firstI++)
{
double item = lengths[firstI];
differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
if (differenceNew < differenceOld)
{
differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
first = firstI;
}
}
string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
"3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
"10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
string[] valueG = {"452.5", "320.0" , "269.1", "226.3", "190.3", "160.0", "134.5", "113.1",
"95.1", "80.0", "67.3", "56.6", "47.6", "40.0", "33.6", "28.3", "23.8", "20.0", "16.8", "14.1", "11.9",
"10.0", "8.4", "7.1", "5.9", "5.0", "4.2", "3.5", "3.0", "2.5"};//微米##晶粒截距
dgvr.Cells[4].Value = valueG[first];
small_l += double.Parse(valueG[first]);
dgvr.Cells[5].Value = valueGrade[first];
this.dataGridView2.Rows.Add(dgvr);
}
for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
{
System.Data.DataTable dataTable1 = dataTables[dataTableI];
if (dataTable1.TableName.Equals(cal_Tag))/*dataTable.TableName*/
dataTables.RemoveAt(dataTableI);
}
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.TableName = cal_Tag;
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
dataTable.Columns.Add(c.HeaderText);
}
for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
{
System.Data.DataRow dataRow = dataTable.NewRow();
for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
{
dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
}
dataTable.Rows.Add(dataRow);
}
this.dataTables.Add(dataTable);
}
return new double[] { small_l, area_sum };
}
#endregion
#region 需继承方法
///
/// 0,其他; 3,GBT6394的面积法; 4,ISO643
///
///
protected virtual int getGbtType()
{
return 0;
}
///
/// 返回保存的参数值-是否显示晶界,显示网格,显示截点
///
///
protected bool GetParamValue1(string param_key, out object ShowGrainBoundry)
{
bool foundItem = false;
ShowGrainBoundry = true;
foreach (var item in this.analysisModel.ListParam)
{
if (item.param_key.Equals(param_key) && item.menuId == this.menuId)//显示晶界
{
ShowGrainBoundry = item.value;
foundItem = true;
break;
}
}
return foundItem;
}
///
/// 是否显示晶界
///
///
protected virtual Boolean ShowGrainBoundryChecked()
{
return true;
}
///
/// 是否显示网格
///
///
protected virtual Boolean drawDisplaySections()
{
return true;
}
///
/// 是否用不同颜色显示晶粒
///
///
protected virtual Boolean ShowGrainColorChecked()
{
return true;
}
///
/// 是否显示视场
///
///
protected virtual Boolean ShowDrawClassView()
{
return false;
}
///
/// 小数点位数后调用的事件
///
protected virtual void RefreshWhileUpDown1_0ValueChanged()
{
}
///
/// 图片索引改变后调用的事件
///
protected virtual void refreshWhileImgChanged()
{
}
///
/// 获取对应级别的方法
///
///
///
protected virtual string getGradeValue(double smalll_index)
{
//对应级别 根据(smalll_index;//平均晶粒直径)
//area_sum += aec;
//aec = aec * 0.001 * 0.001;
//NA = Convert.ToDecimal(grainNumber / aec);
//////1013###19377##面积法位置,使用晶粒的实际面积去标准中的表进行对应,获取截距后,再进行平均的计算
decimal NA = Convert.ToDecimal(smalll_index);
double[] lengths = {508.0, 359.2 , 302.1, 254.0, 213.6, 179.6, 151.0, 127.0,
106.8, 89.8, 75.5, 63.5, 53.4, 44.9, 37.8, 31.8, 26.7, 22.5, 18.9, 15.9, 13.3,
11.2, 9.4, 7.9, 6.7, 5.6, 4.7, 4.0, 3.3, 2.8};
// 差值
decimal differenceNew;
decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max(smalll_index - 1.8, smalll_index - 509.0)));
int first = lengths.Length - 1;
for (int firstI = 0; firstI < lengths.Length; firstI++)
{
double item = lengths[firstI];
differenceNew = Math.Abs(NA - Convert.ToDecimal(item));
if (differenceNew < differenceOld)
{
differenceOld = Math.Abs(NA - Convert.ToDecimal(item));
first = firstI;
}
}
string[] valueGrade = {"00", "0" , "0.5", "1.0", "1.5", "2.0", "2.5", "3.0",
"3.5", "4.0", "4.5", "5.0", "5.5", "6.0", "6.5", "7.0", "7.5", "8.0", "8.5", "9.0", "9.5",
"10.0", "10.5", "11.0", "11.5", "12.0", "12.5", "13.0", "13.5", "14.0"};//显微晶粒度级别数G
return valueGrade[first];
}
///
/// 保存结果
///
/// 当前选择图片的tag
/// 当前选择图片的Index
protected virtual void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
{
bool replace = false;
int add = 0;
foreach (ListViewItem item in this.listView2.Items)
{
if (item.Tag.Equals(imagesKey))
{
add++;
if (saveAll)
{
replace = true;
break;
}
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
replace = true;
}
break;
}
}
if (!replace && this.listView2.Items.Count > 0 && add > 0)
return;
string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
if (!replace)
{
ListViewItem listViewItem = new ListViewItem();
listViewItem.SubItems[0].Text = imgName;
listViewItem.Tag = "" + imagesKey;
if (this.listView2.Items.Count == 0)
this.listView2.Items.Add(listViewItem);
else
this.listView2.Items.Insert(0, listViewItem);
this.threeDButton.Enabled = true;
}
if (grainMethodType == 1)
buildListBoxArea_analysisResult(imagesKey, analysisPicture);
else
buildListBoxCutOff_analysisResult(imagesKey, analysisPicture);
}
///
/// PanelC的调色板颜色改变
///
protected virtual void ColorPanelChanged(Panel panel)
{
}
///
/// 晶粒度辅助线: 计算当前不显示数据的过程
///
///
///
protected void calcOtherImgs(string imagesKey, int analysisPicture)
{
if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
GSSClass.GuideClass.guideDict.Add(imagesKey, GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/());
GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
//if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
{
float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
double multiple = 1.0;
if (recWidth > this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width)
{
multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / recWidth;
}
if (this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height < recHeight * multiple)//#21714
{
multiple = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / recHeight;
}
guideModel.rectangleFLineWidth = (float)(multiple * guideModel.rectangleFLineWidth);
guideModel.rectangleFLineHeight = (float)(multiple * guideModel.rectangleFLineHeight);
if (grainMethodType == 1)//#21714
GSSClass.GuideClass.UpdateScaleGuideAreaStyle(guideModel.oldSelectItem, guideModel, multiple);
else
GSSClass.GuideClass.UpdateScaleGuideStyle(guideModel.oldSelectItem, guideModel, recWidth, recHeight
, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron), multiple);
}
guideModel.loctation = new PointF(this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Width / 2, this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.Height / 2);
//if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
{
float recWidth = (float)(Math.Max(1, guideModel.rectangleFLineWidth / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
float recHeight = (float)(Math.Max(1, guideModel.rectangleFLineHeight / this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron)));
guideModel.RectangleFLine = new RectangleF(guideModel.loctation.X - recWidth / 2
, guideModel.loctation.Y - recHeight / 2
, recWidth, recHeight);//########################################
bool foundItem = false;
if (grainMethodType == 1)
{
if (this.imageMat != null && guideModel.oldSelectItem != null)
GSSClass.GuideClass.updateGuideAreaRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
}
else
if (this.imageMat != null && guideModel.oldSelectItem != null)
GSSClass.GuideClass.updateGuideRectLine(guideModel.oldSelectItem, guideModel, out foundItem, true/*guideTypeChanged*/, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
/////*this.*/
////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
if (foundItem)
AddRectangleToRectangleFCaps(imagesKey, analysisPicture);
//this.documentWorkspace.Refresh();
}
}
///
/// 截点法组织分项数据列表的内容,并返回网格总长度(μm)和截点总数
///
private double[] addCutOffNewRowsToDatagridView2(string imagesKey, int analysisPicture)
{
string imgName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
//string tag = getCurrentWorkTag();//imagesKey
double small_l = 0;
double count_sum = 0;
this.dataGridView2.Rows.Clear();
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
dgvr.Cells[0].Value = imgName;
if (analysisPicture != this.selectPicture)//更新二值图片
binaryClass.updateAnalysisData(imagesKey, analysisPicture);
GrainSizeGuideModel guideModel = this.GSSClass.GuideClass.guideModel;
if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
guideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
//else if (analysisPicture != this.selectPicture)//计算对应图片的数据
//{
// this.calcOtherImgs(imagesKey, analysisPicture);
//}
GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
else//计算对应图片的数据
{
}
if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
if (guideModel.oldSelectItem == null)//#######################
guideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
//if (analysisPicture != this.selectPicture)//计算对应图片的数据
//{
// this.calcOtherImgs(imagesKey, analysisPicture);
//}
dgvr.Cells[1].Value = guideModel.oldSelectItem;// this.comboBox1.SelectedItem;
double length = GSSClass.GuideClass.guideLength(guideModel/*this.comboBox1.SelectedItem*/);
small_l += length;
dgvr.Cells[2].Value = length;
double countPoints = styleModel.getCountPoints();
decimal M = 1;
double PL = (double)M * countPoints / length;
count_sum += countPoints;
dgvr.Cells[3].Value = countPoints;
dgvr.Cells[4].Value = 1.0 / PL;
if (getGbtType() == 4)
dgvr.Cells[5].Value = -6.6439 * Math.Log10(1.0 / PL * 0.001) - 3.2877;
else
dgvr.Cells[5].Value = -6.643856 * Math.Log10(1.0 / PL * 0.001) - 3.288;
this.dataGridView2.Rows.Add(dgvr);
for (int dataTableI = dataTables.Count - 1; dataTableI >= 0; dataTableI--)
{
System.Data.DataTable dataTable1 = dataTables[dataTableI];
if (dataTable1.TableName.Equals(imagesKey))
dataTables.RemoveAt(dataTableI);
}
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.TableName = imagesKey;
foreach (DataGridViewColumn c in this.dataGridView2.Columns)
{
dataTable.Columns.Add(c.HeaderText);
}
for (int r = 0; r < this.dataGridView2.Rows.Count; r++)
{
System.Data.DataRow dataRow = dataTable.NewRow();
for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++)
{
dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Rows[r].Cells[c].Value;
}
dataTable.Rows.Add(dataRow);
}
this.dataTables.Add(dataTable);
return new double[] { small_l, count_sum };
}
///
/// 截点法-保存结果
///
private void buildListBoxCutOff_analysisResult(string imagesKey, int analysisPicture)
{
//组织详细数据列表的内容,获取截距和截点数后,再进行平均的计算
double[] res_arr = addCutOffNewRowsToDatagridView2(imagesKey, analysisPicture);
double small_l = res_arr[0];
double grainNumber = res_arr[1];
this.dataGridView_Total.Rows.Clear();
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = small_l;
dgvr.Cells[1].Value = grainNumber;
if (grainNumber > 0)
small_l = small_l / grainNumber;
dgvr.Cells[2].Value = small_l;
if (getGbtType() == 4)
dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
else
dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
this.dataGridView_Total.Rows.Add(dgvr);
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.TableName = imagesKey;
foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
{
if (dataTable1.TableName.Equals(dataTable.TableName))
{
dataTable_Totals.Remove(dataTable1);
break;
}
}
if (this.dict_Totals.ContainsKey(dataTable.TableName))
this.dict_Totals.Remove(dataTable.TableName);
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
dataTable.Columns.Add(c.HeaderText);
for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
{
System.Data.DataRow dataRow = dataTable.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;
dataTable.Rows.Add(dataRow);
}
this.dataTable_Totals.Add(dataTable);
this.RefreshDataGridView4();
//保存处理后的图片
double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
List tempBit = new List();
Bitmap originalBit;// this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
if (analysisPicture != this.selectPicture)//更新处理前的图片
originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
else
originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);
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 (binaryClass.getModelMat(imagesKey) != null/*this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null*/)
{//(imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat
Mat targetMat = binaryClass.getModelMat(imagesKey);// this.PhaseModel0Mat;
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
else if (imagesKey.Equals(getCurrentWorkTag()) && this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
{
Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;// this.PhaseModel0Mat;
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
{
Mat targetMat = this.grainBoundaryMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
{
Mat targetMat = this.grainColorsMatDict[imagesKey];// this.documentWorkspace.PhaseModels[1].mat;
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
//if (this.documentWorkspace.PhaseModels[2].choise && this.documentWorkspace.PhaseModels[2].mat != null
// && !this.documentWorkspace.PhaseModels[2].mat.IsDisposed)
//{
// Mat targetMat = this.documentWorkspace.PhaseModels[2].mat;
// graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
//}
graphics.SmoothingMode = SmoothingMode.AntiAlias;
drawSubclass/*Draw*/(graphics, imagesKey, analysisPicture);
newBit.Tag = pantographRatio;
tempBit.Add(newBit);
if (bitDic.ContainsKey(imagesKey))
bitDic[imagesKey] = tempBit;
else
bitDic.Add(imagesKey, tempBit);
////this.
//this.phy
////拼接中间数据
//List> dataList = new List>();
//List columnName = new List();
//columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
//columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
//columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
//columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
//dataList.Add(columnName);
GrainPointStyleModel styleModel = this.GSSClass.styleClass.styleModel;
if (this.GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
styleModel = this.GSSClass.styleClass.styleDict[imagesKey];
//拼接中间数据
List> dataList = GSSClass.styleClass.getTableDataList(styleModel, this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron));
bool isExist = false;//是否已存在进行替换
int modelIndex = -1;//要替换的下标
for (int j = 0; j < tempDataModel.Count; j++)
{
if (tempDataModel[j].tagName.Equals(imagesKey))
{
isExist = true;
modelIndex = j;
break;
}
}
if (isExist && modelIndex > -1)
tempDataModel[modelIndex].dataList = dataList;
else
{
ExportProjectModel newModel = new ExportProjectModel();
newModel.tagName = imagesKey;
newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();//##################################
newModel.dataList = dataList;
tempDataModel.Add(newModel);
}
}
///
/// 面积法-保存结果
///
private void buildListBoxArea_analysisResult(string imagesKey, int analysisPicture)
{
if (analysisPicture != this.selectPicture)//更新二值图片
binaryClass.updateAnalysisData(imagesKey, analysisPicture);
GrainSizeGuideModel cal_GuideModel = this.GSSClass.GuideClass.guideModel;
if (this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
cal_GuideModel = this.GSSClass.GuideClass.guideDict[imagesKey];
//else if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
//{
// this.calcOtherImgs(imagesKey, analysisPicture);
//}
if (this.GSSClass.GuideClass.guideModel.oldSelectItem == null)
this.GSSClass.GuideClass.guideModel.oldSelectItem = this.comboBox1SelectedItem.ToString();
if (cal_GuideModel.oldSelectItem == null)//##
cal_GuideModel.oldSelectItem = this.GSSClass.GuideClass.guideModel.oldSelectItem;
GrainSizeStandardModel cal_StandardModel = this.GSSClass.standardModel;
if (imagesKey != null)
{
if (!this.GSSClass.standardDict.ContainsKey(imagesKey))
this.GSSClass.standardDict.Add(imagesKey, this.GSSClass.standardModel.cloneListParamModel());
cal_StandardModel = this.GSSClass.standardDict[imagesKey];
if (analysisPicture == this.selectPicture && imagesKey.Equals(getCurrentWorkTag()))
this.GSSClass.standardModel = this.GSSClass.standardDict[imagesKey];
}
if (analysisPicture != this.selectPicture)//根据选择的辅助线 计算对应图片的数据
//if (cal_StandardModel.linePointList.Count == 0)
this.calcOtherImgs(imagesKey, analysisPicture);
// 是否矩形辅助线
int isRect;
double aec0 = GSSClass.GuideClass.guideArea(cal_GuideModel, cal_GuideModel.oldSelectItem/*this.comboBox1.SelectedItem*/, out isRect, getGbtType());
//aec = aec * 0.001 * 0.001;
double grainNumber = GetNumberOfGrains(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture
, isRect == 1) + isRect;//自查# //面积内的晶粒数N。
//组织详细数据列表的内容,获取截距和面积后,再进行平均的计算<=>GBT6394面积法计算级别
double[] res_arr = addNewRowsToDatagridView2(cal_StandardModel, cal_GuideModel, imagesKey, analysisPicture);
//grainNumber = 8;
double small_l = res_arr[0];
double area_l = aec0;// res_arr[1];
this.dataGridView_Total.Rows.Clear();
DataGridViewRow dgvr = new DataGridViewRow();
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
{
dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
}
dgvr.Cells[0].Value = grainNumber;
if (getGbtType() == 3)
{
if (grainNumber > 0)
area_l = area_l / grainNumber;
double aec = area_l * 0.001 * 0.001;
double NA = (double)1/*grainNumber*/ / aec;//自查# //计算出实际试样检测面上(1倍)的每平方毫米内晶粒数:。
dgvr.Cells[1].Value = 3.321928 * Math.Log10(NA) - 2.954;//自查# //晶粒度级别数G计算
}
else
{
dgvr.Cells[1].Value = small_l;
if (grainNumber > 0)
small_l = small_l / grainNumber;
dgvr.Cells[2].Value = small_l;
if (getGbtType() == 4)
dgvr.Cells[3].Value = -6.6439 * Math.Log10(small_l * 0.001) - 3.2877;
else
dgvr.Cells[3].Value = -6.643856 * Math.Log10(small_l * 0.001) - 3.288;
if (grainNumber > 0)
area_l = area_l / grainNumber;
dgvr.Cells[4].Value = area_l;
double aec = area_l * 0.001 * 0.001;
double NA = (double)1/*grainNumber*/ / aec;
if (getGbtType() == 4)
dgvr.Cells[5].Value = 3.32 * Math.Log10(NA) - 2.9542;
else
dgvr.Cells[5].Value = 3.321928 * Math.Log10(NA) - 2.954;//!!!!!!!!!!!!!................................
}
this.dataGridView_Total.Rows.Add(dgvr);
System.Data.DataTable dataTable = new System.Data.DataTable();
dataTable.TableName = imagesKey;
foreach (System.Data.DataTable dataTable1 in dataTable_Totals)
{
if (dataTable1.TableName.Equals(dataTable.TableName))
{
dataTable_Totals.Remove(dataTable1);
break;
}
}
if (this.dict_Totals.ContainsKey(dataTable.TableName))
this.dict_Totals.Remove(dataTable.TableName);
foreach (DataGridViewColumn c in this.dataGridView_Total.Columns)
{
dataTable.Columns.Add(c.HeaderText);
}
for (int r = 0; r < this.dataGridView_Total.Rows.Count; r++)
{
System.Data.DataRow dataRow = dataTable.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;
}
dataTable.Rows.Add(dataRow);
}
this.dataTable_Totals.Add(dataTable);
if (getGbtType() == 3)
this.dict_Totals.Add(imagesKey, new Dictionary() { { "RectArea", aec0 } });
this.RefreshDataGridView4();
//保存处理后的图片
double pantographRatio = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
List tempBit = new List();
Bitmap originalBit;// this.bitmap;
if (analysisPicture != this.selectPicture)//更新处理前的图片
originalBit = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreateAliasedBitmap();
else
originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);
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 (binaryClass.getModelMat(imagesKey) != null)
{
Mat targetMat = binaryClass.getModelMat(imagesKey);
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
if (this.grainBoundaryMatDict.ContainsKey(imagesKey))
{
Mat targetMat = this.grainBoundaryMatDict[imagesKey];
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
if (this.grainColorsMatDict.ContainsKey(imagesKey) && !bcOriginChecked() && ShowGrainColorChecked())
{
Mat targetMat = this.grainColorsMatDict[imagesKey];
graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
}
graphics.SmoothingMode = SmoothingMode.AntiAlias;
drawSubclass(graphics, imagesKey, analysisPicture);
newBit.Tag = pantographRatio;
tempBit.Add(newBit);
if (bitDic.ContainsKey(imagesKey))
bitDic[imagesKey] = tempBit;
else
bitDic.Add(imagesKey, tempBit);
//拼接中间数据
List> dataList = new List>();
List columnName = new List();
columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
columnName.Add(PdnResources.GetString("Menu.Xoordinate.Text"));
columnName.Add(PdnResources.GetString("Menu.Yoordinate.Text"));
columnName.Add(PdnResources.GetString("Menu.Whethertheinternal.Text"));
//Dictionary measurementUnitDictionary = Startup.instance.rules;
//选择标尺的物理长度(1倍下的 微米/像素)
//double physical_area_length_Micron = measurementUnitDictionary[MeasurementUnit.Micron];
double physical_area_length_Micron = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetRuler(MeasurementUnit.Micron);
if (cal_StandardModel.currentStats != null && physical_area_length_Micron > 0)//##20544
{
columnName.Add("晶粒面积"/*PdnResources.GetString("Menu.Whethertheinternal.Text")*/);
}
//aec = currentStats.At(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron;//晶粒面积
dataList.Add(columnName);
if (cal_StandardModel.massLabelPoints.Count > 0)
{
int index = 0;
int outMaxIndex = cal_StandardModel.massLabelPoints.Count - 0 - cal_StandardModel.within;
foreach (var label in cal_StandardModel.massLabelPoints.Keys)//####################
{
var item = cal_StandardModel.massLabelPoints[label];
List strList = new List();
strList.Add(("" + (++index)).ToString());
strList.Add(item[2].ToString());
strList.Add(item[3].ToString());
if (outMaxIndex < index)
strList.Add(PdnResources.GetString("Menu.Yes.text"));
else
strList.Add(PdnResources.GetString("Menu.no.text"));
strList.Add((cal_StandardModel.currentStats.At(label/*hcomp*/, 4) * physical_area_length_Micron * physical_area_length_Micron).ToString());
dataList.Add(strList);
}
}
bool isExist = false;//是否已存在进行替换
int modelIndex = -1;//要替换的下标
for (int j = 0; j < tempDataModel.Count; j++)
{
if (tempDataModel[j].tagName.Equals(imagesKey))
{
isExist = true;
modelIndex = j;
break;
}
}
if (isExist && modelIndex > -1)
tempDataModel[modelIndex].dataList = dataList;
else
{
Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
newModel.tagName = imagesKey;
newModel.picName = this.appWorkspace.DocumentWorkspaces[analysisPicture].GetFriendlyName();
newModel.dataList = dataList;
tempDataModel.Add(newModel);
}
}
///
/// 保存子窗体参数
///
protected virtual void saveSonData()
{
}
///
/// 获取子窗体参数
///
protected virtual void getSonData()
{
}
///
/// 保存子窗体录制参数
///
protected virtual object saveRecordingData(string key)
{
return null;
}
protected virtual void SubclassInitialize()
{
throw new NotImplementedException();
}
///
/// 辅助线类型
///
///
protected virtual string[] getTypeNames()
{
return new string[] {
"",
""};
}
///
/// 辅助线配置文件名称
///
///
protected virtual string getModelName()
{
throw new NotImplementedException();
}
///
/// 报告模板命名
///
///
protected virtual string getTemplateName()
{
throw new NotImplementedException();
}
///
/// 项目工程内的文件夹路径名称
///
///
protected virtual string getProjectEngineeringName()
{
throw new NotImplementedException();
}
///
/// 是否绘制辅助线
///
///
///
protected virtual bool showGridChecked()
{
return false;
}
///
/// 是否绘制截点
///
///
///
protected virtual bool drawGuidePoints()
{
return false;
}
///
/// 是否绘制编号
///
///
///
protected virtual bool showGrainNumberChecked()
{
return false;
}
protected virtual void drawSubclass(Graphics graphics, string imagesKey = null, int analysisPicture = -1)
{
GrainSizeGuideModel cal_GuideModel = GSSClass.GuideClass.guideModel;
if (imagesKey != null && GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
cal_GuideModel = GSSClass.GuideClass.guideDict[imagesKey];
GrainPointStyleModel cal_StyleModel = GSSClass.styleClass.styleModel;
if (imagesKey != null && GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
cal_StyleModel = GSSClass.styleClass.styleDict[imagesKey];
GrainSizeStandardModel cal_StandardModel = GSSClass.standardModel;
if (imagesKey != null && GSSClass.standardDict.ContainsKey(imagesKey))
cal_StandardModel = GSSClass.standardDict[imagesKey];
//显示辅助线
if (showGridChecked())
if (grainMethodType == 1)
GSSClass.GuideClass.DrawAreaGuide(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
else
GSSClass.GuideClass.DrawGuideLines(graphics, cal_GuideModel.oldSelectItem != null ? cal_GuideModel.oldSelectItem : this.comboBox1.SelectedItem, cal_GuideModel);
//显示截点
if (drawGuidePoints())
cal_StyleModel.DrawGuidePoints(graphics);
//显示编号
if (showGrainNumberChecked() && cal_StandardModel.massLabelPoints.Count > 0)
{
int index = 0;
Font myFont = new Font("宋体", 12);
Brush bush = new SolidBrush(getGrainBoundryColor());//填充的颜色
foreach (var item in cal_StandardModel.massLabelPoints.Values)
{
graphics.DrawString("" + (++index), myFont, bush, (float)item[2] - 5, (float)item[3] - 5);
}
}
}
///
/// 实现手动添加在原图情况下的截点位置跟随辅助线的移动而移动
///
public void MoveOriginCutOffPoints(float offsetX, float offsetY)
{
Mat mat;
if (!getGrainBoundryChecked() && !getBinaryChecked())
{
mat = imageMat.Clone();
}
else
{
if (getGrainBoundryChecked())
{
if (this.documentWorkspace.PhaseModels[1].mat != null)
mat = this.documentWorkspace.PhaseModels[1].mat;
else
return;
}
else if (this.documentWorkspace.PhaseModels[0].mat != null)
{
mat = this.PhaseModel0Mat;
}
else
return;
}
if (mat == null)
return;
//##21247
GSSClass.MoveOriginCutOffPoints(offsetX, offsetY, this.getCurrentGuideName(), mat);
}
/////
///// 刷新图形边线点集合//#########################################
/////
/// 计算当前不显示数据的过程
/// 计算当前不显示数据的过程
private void AddRectangleToRectangleFCaps(string imagesKey = null, int analysisPicture = -1)
{
if (/*grainMethodType == 1 && */this.imageMat == null)//####################
return;
if (grainMethodType == 1)
{//###############################################
Mat cal_ImageMat;//= this.bitmap;
if (imagesKey != null && analysisPicture != -1)
cal_ImageMat = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreatedAliasedMat();
else
cal_ImageMat = this.imageMat;
string cal_GuideName = imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName();
GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, cal_ImageMat, cal_GuideName, 0, null, (analysisPicture != -1 ? this.appWorkspace.DocumentWorkspaces[analysisPicture] : getCurrentWorkspace()).GetRuler(MeasurementUnit.Micron));
this.documentWorkspace.Refresh();
return;
}
//this.analysisDict.
bool BinaryChecked;
if (imagesKey != null)
BinaryChecked = (binaryClass.getModelMat(imagesKey) != null);
else
BinaryChecked = getBinaryChecked();
Mat mat;
if (!getGrainBoundryChecked() && !BinaryChecked)//###########################
{
mat = imageMat.Clone();
}
else
{
if (getGrainBoundryChecked())
{
if (this.documentWorkspace.PhaseModels[1].mat != null)
mat = this.documentWorkspace.PhaseModels[1].mat;
else
return;
}
else if (BinaryChecked/*this.documentWorkspace.PhaseModels[0].mat != null*/)
{
mat = (imagesKey != null) ? binaryClass.getModelMat(imagesKey) : this.PhaseModel0Mat;
}
else
return;
}
if (mat == null)
return;
int matLevel = 0;
if (getGrainBoundryChecked())
matLevel = 2;
else if (BinaryChecked/*getBinaryChecked()*/)
matLevel = 1;
else if (!getGrainBoundryChecked() && !BinaryChecked/*getBinaryChecked()*/)
matLevel = 0;
Mat cal_imageMat = this.imageMat;
if (imagesKey != null)
cal_imageMat = this.appWorkspace.DocumentWorkspaces[analysisPicture].CompositionSurface.CreatedAliasedMat();
GSSClass.AddRectangleToRectangleFCaps(imagesKey, grainMethodType, cal_imageMat, (imagesKey != null ? GSSClass.GuideClass.guideDict[imagesKey].oldSelectItem : this.getCurrentGuideName()), matLevel, mat, (analysisPicture == -1 ? getCurrentWorkspace() : this.appWorkspace.DocumentWorkspaces[analysisPicture]).GetRuler(MeasurementUnit.Micron));
if (analysisPicture == -1 || analysisPicture == this.selectPicture)
this.documentWorkspace.Refresh();
}
///
/// 初始化矩形
///
private void InitRectangleF(bool guideTypeChanged)
{
if (this.imageMat != null && this.comboBox1.SelectedItem != null)
{
bool foundItem;
if (grainMethodType == 1)
GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideAreaRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
else
GSSClass.GuideClass.guideModel.RectangleFLine = GSSClass.GuideClass.guideRectLine(this.comboBox1.SelectedItem, out foundItem, guideTypeChanged, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
//if (foundItem)//#21756
this.AddRectangleToRectangleFCaps();
}
}
///
/// 更新辅助线及其样式
///
protected virtual void UpdateGuideStyle(bool showMessageAlert)
{
if (getCurrentWorkspace() == null)//#21319
return;
if (grainMethodType == 1)
GSSClass.GuideClass.UpdateGuideAreaStyle(this.imageMat, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
else//##19846
GSSClass.GuideClass.UpdateGuideStyle(imageMat, this.comboBox1.SelectedItem, showMessageAlert && this.comboBox1.SelectedIndex > 0, getCurrentWorkspace().GetRuler(MeasurementUnit.Micron));
}
///
/// 添加辅助线后更新下拉列表信息
///
///
public void AddComboboxValue(ArrayList arrayList)
{
if (!GSSClass.InitComboboxValue())
{
if (grainMethodType == 1)
GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
else
GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
}
if (arrayList != null && arrayList.Count > 0)
{
this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//this.comboBox1.SelectedItem = (string)ItemStringObject;
//comboBox1SelectedItem = comboBox1.SelectedItem;
////this.comboboxChange = false;
arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
this.comboBox1.DataSource = arrayList;
//this.comboboxChange = false;
int oldSelectIndex = -1;
for (int i = 0; i < this.comboBox1.Items.Count; i++)
{
if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
{
oldSelectIndex = i;
}
}
if (oldSelectIndex > -1)
this.comboBox1.SelectedIndex = oldSelectIndex;
else if (this.comboBox1.Items.Count > 0)
this.comboBox1.SelectedIndex = 0;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
}
//this.comboBox1.DataSource =
}
///
/// 辅助线维护
///
public virtual void InitComboboxValue(ArrayList arrayList)
{
UpdateCupOffPointStyle();
if (!GSSClass.InitComboboxValue())
{
if (grainMethodType == 1)
GSSClass.GuideClass.createGuideAreaClassModelsNamed(getModelName());
else
GSSClass.GuideClass.createGuideClassModelsNamed(getModelName());
}
this.comboBox1.DataSource = null;
if (arrayList != null && arrayList.Count > 0)
{
this.comboboxChange = false;
arrayList.Insert(0, PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text"));
this.comboBox1.DataSource = arrayList;
this.comboboxChange = false;
int oldSelectIndex = -1;
for (int i = 0; i < this.comboBox1.Items.Count; i++)
{
if (GSSClass.GuideClass.guideModel.oldSelectItem.Equals(this.comboBox1.Items[i]))
{
oldSelectIndex = i;
}
}
if (oldSelectIndex > -1)
this.comboBox1.SelectedIndex = oldSelectIndex;
else if (this.comboBox1.Items.Count > 0)
this.comboBox1.SelectedIndex = 0;
}
else
{
ArrayList arrayList1;
if (grainMethodType == 1)
arrayList1 = GSSClass.GuideClass.getComboboxArrayAreaList1();
else
arrayList1 = GSSClass.GuideClass.getComboboxArrayList1();
if (arrayList1.Count > 0)
{
this.comboBox1.DataSource = arrayList1;
this.comboBox1.SelectedIndex = 0;
}
}
UpdateGuideStyle(false);
this.documentWorkspace.Refresh();
}
#endregion
///
/// 保存参数的key,value和type
///
///
///
///
protected void saveParamValue(string param_key, string param_value, int param_type)
{
bool foundItem = false;
foreach (var item in this.analysisModel.ListParam)
{
if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
{
item.param_value = param_value;
item.setValue();
foundItem = true;
break;
}
}
if (!foundItem)
{
GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
analysisItem.menuId = this.menuId;
analysisItem.param_key = param_key;
analysisItem.param_type = param_type;
analysisItem.param_value = param_value;
analysisItem.setValue();
this.analysisModel.ListParam.Add(analysisItem);
}
}
///
/// 保存界面中的参数到model
///
private void saveDialogParamValues()
{
saveParamValue(ParamKey_ShowGrainNumber, showGrainNumberChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶粒编号
saveParamValue(ParamKey_ShowGrainColor, ShowGrainColorChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//用不同颜色显示晶粒
saveParamValue(ParamKey_displaygrainboundaries, ShowGrainBoundryChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示晶界
saveParamValue(ParamKey_displaygrid, showGridChecked() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示网格
saveParamValue(ParamKey_displaysections, drawDisplaySections() ? "0" : "1", (int)Base.Dtryt.Boolean);//显示截点
saveParamValue(ParamKey_comboBox1SelectedItem, comboBox1SelectedItem != null ? comboBox1SelectedItem.ToString() : "", (int)Base.Dtryt.ItemString);//选择的辅助线
saveParamValue(ParamKey_CalculatorDecimalDigits, Convert.ToInt32(this.numericUpDown1_0.Value).ToString(), (int)Base.Dtryt.Interger);
saveParamValue(ParamKey_OpenWhileExportReport, this.checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//生成报告时打开设置
saveParamValue(ParamKey_TargetSelection, this.TargetSelection.ToString(), (int)Base.Dtryt.Interger);
saveSonData();
}
private void GrainSizeStandardDialog_FormClosing(object sender, FormClosingEventArgs e)
{
#region [开启脚本录制]
if (appWorkspace.startScriptRecording)
{
getScriptRecording();
}
#endregion
this.saveDialogParamValues();
binaryClass.saveParams();
//xml保存路径
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
foreach (var analysisItem in this.analysisModel.ListParam)
{
bool foundItem = false;
foreach (var item in analysisModelXml.ListParam)
{
if (item.param_key.Equals(analysisItem.param_key) && item.menuId == this.menuId)
{
item.param_value = analysisItem.param_value;
foundItem = true;
break;
}
}
if (!foundItem)
{
GrainSizeAnalysisModel newMod = analysisItem.cloneModel();
newMod.value = null;//避免value为集合导致保存出错
analysisModelXml.ListParam.Add(newMod);
}
//analysisModelXml.ListParam.Add(analysisItem.cloneModel());
}
//按路径和名称保存xml文件
string userInfoXml = XmlSerializeHelper.XmlSerialize(analysisModelXml);
//保存xml
FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
}
///
/// 应用到全部
///
///
///
private void button_ApplyToAll_Click(object sender, EventArgs e)
{
if (this.lstView_img.Items.Count == 0) return;
if ((this.menuId != 11012101 && this.menuId != 11012102) && (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem)))
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
return;
}
//清空晶界重现除了当前图片之外的缓存数据
foreach (var itemKey in this.imageList_img.Images.Keys)
{
if (itemKey.Equals(getCurrentWorkTag()))
continue;
if (this.grainBoundaryMatDict.ContainsKey(itemKey))
this.grainBoundaryMatDict.Remove(itemKey);
if (this.grainBoundaryDict.ContainsKey(itemKey))
this.grainBoundaryDict.Remove(itemKey);
}
binaryClass.applyToAll(this.imageList_img.Images.Keys, getCurrentWorkTag());
this.saveDialogParamValues();
this.lstView_img.SelectedIndexChanged -= new System.EventHandler(this.lstView_img_SelectedIndexChanged);
try
{
currentOldSelectIndex = this.selectPicture;
for (int kselectPicture = 0; kselectPicture <= this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
{
if (currentOldSelectIndex == kselectPicture || kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
{//跳过当前选择的窗口,并最后回到当前窗口数据
if (kselectPicture == this.appWorkspace.DocumentWorkspaces.Count())
{
kselectPicture = currentOldSelectIndex;
this.analysisModel = this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]];
string imagesKeyCurrent = this.imageList_img.Images.Keys[kselectPicture];
GSSClass.standardModel = GSSClass.standardDict[imagesKeyCurrent];
GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[imagesKeyCurrent];
GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[imagesKeyCurrent];
this.lstView_img.EnsureVisible(kselectPicture);
this.lstView_img.Items[kselectPicture].Focused = true;
this.lstView_img.Items[kselectPicture].Selected = true;
this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
break;
}
continue;
}
if (this.analysisDict.ContainsKey(this.imageList_img.Images.Keys[kselectPicture]))
this.analysisDict[this.imageList_img.Images.Keys[kselectPicture]] = this.analysisModel.cloneListParamModel(this.menuId);
string imagesKey = this.imageList_img.Images.Keys[kselectPicture];
if (GSSClass.standardDict.ContainsKey(imagesKey))
GSSClass.standardDict[imagesKey] = new GrainSizeStandardModel();// GSSClass.standardModel.cloneListParamModel();
if (GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
GSSClass.GuideClass.guideDict[imagesKey] = GSSClass.GuideClass.guideModel.cloneModel/*cloneListParamModel*/();
if (GSSClass.styleClass.styleDict.ContainsKey(imagesKey))
GSSClass.styleClass.styleDict[imagesKey] = GSSClass.styleClass.styleModel.cloneListParamModel();
this.lstView_img.EnsureVisible(kselectPicture);
this.lstView_img.Items[kselectPicture].Focused = true;
this.lstView_img.Items[kselectPicture].Selected = true;
this.refreshActionWhileImg_SelectedIndexChanged(true, kselectPicture/*this.selectPicture*/);
}
}
catch (Exception ex)
{
}
finally
{
this.lstView_img.SelectedIndexChanged += new System.EventHandler(this.lstView_img_SelectedIndexChanged);
}
}
///
/// 保存全部
///
///
///
private void button_SaveAll_Click(object sender, EventArgs e)
{
if (this.imageList_img.Images.Keys.Count <= 1)
{
this.btn_saveresult.PerformClick();
return;
}
for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
{
string imagesKey = /*toDeleteImageKeysList*/this.imageList_img.Images.Keys[kselectPicture];
//string imagesKey = kselectPicture.ToString();
if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
{
MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
return;
}
}
bool replace = false;
int add = 0;
//#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
List toDeleteImageKeysList = new List();
for (int kselectPicture = 0; kselectPicture < this.imageList_img.Images.Keys.Count; kselectPicture++)
toDeleteImageKeysList.Add(this.imageList_img.Images.Keys[kselectPicture]);
for (int itemI = 0; itemI < this.listView2.Items.Count; itemI++)
{
ListViewItem item = this.listView2.Items[itemI];
//if (item.Tag.Equals(imagesKey))
if (this.imageList_img.Images.Keys.Contains(item.Tag.ToString()))
{
add++;
if (itemI == 0)
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?" /*+ "\n确定则全部替换,取消则跳过已保存的结果"*/, PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr != DialogResult.OK)
{
//toDeleteImageKeysList.Clear();
replace = false;
}
else
{
replace = true;
break;
}
}
toDeleteImageKeysList.Remove(item.Tag.ToString());
}
}
if (toDeleteImageKeysList.Count == 0 && !replace && this.listView2.Items.Count > 0 && add > 0)
return;
for (int kselectPicture = 0; kselectPicture < toDeleteImageKeysList.Count; kselectPicture++)
{
//for (int kselectPicture = 0; kselectPicture < this.appWorkspace.DocumentWorkspaces.Count(); kselectPicture++)
//{
string imagesKey = toDeleteImageKeysList/*this.imageList_img.Images.Keys*/[kselectPicture];
if (!this.GSSClass.GuideClass.guideDict.ContainsKey(imagesKey))
{
MessageBox.Show("请先应用到全部图片后进行保存全部操作"/* “或者计算每个图片数据后”PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!"*/);
return;
}
}
if (replace)
{
this.dataGridView_Total.Rows.Clear();
}
//#22510 -> 确定则全部替换,点击取消则只更新没有的结果已存在的不更新
for (int k = 0; k < toDeleteImageKeysList.Count; k++)
//for (int k = 0; k < this.appWorkspace.DocumentWorkspaces.Count(); k++)
buildListBox_analysisResult(toDeleteImageKeysList[k], this.imageList_img.Images.Keys.IndexOf(toDeleteImageKeysList[k]), true);
if (this.documentWorkspace.PhaseModels[2].mat != null && this.documentWorkspace.PhaseModels[2].mat.IsDisposed && this.grainColorsMatDict.ContainsKey(getCurrentWorkTag()))
{
this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()];
this.documentWorkspace.Refresh();
}
}
///
/// 刷新图片效果和数据时调用该方法
///
///
private void refreshActionWhileImg_SelectedIndexChanged(bool applyingToAll, int toSelectIndex = -1)
{
GSSClass.styleClass.PointKb = 0;//##21997
this.saveDialogParamValues();
this.binaryClass.saveMat(this.imageList_img.Images.Keys[this.selectPicture]);
//备份第一个显示图片的数据信息到dict中
if (GSSClass.GuideClass.guideDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
&& !GSSClass.GuideClass.guideDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
GSSClass.GuideClass.guideDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.GuideClass.guideModel);
if (GSSClass.styleClass.styleDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
&& !GSSClass.styleClass.styleDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
GSSClass.styleClass.styleDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.styleClass.styleModel);
if (GSSClass.standardDict.Count == 0 && this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
&& !GSSClass.standardDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture]))
GSSClass.standardDict.Add(this.imageList_img.Images.Keys[this.selectPicture], GSSClass.standardModel);
if (toSelectIndex >= 0/*applyingToAll*/)
this.imageMat = this.appWorkspace.DocumentWorkspaces[toSelectIndex].CompositionSurface.CreatedAliasedMat();
else
this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstView_img.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
string toSelectImageKey = getCurrentWorkTag();
if (toSelectIndex >= 0)
toSelectImageKey = this.imageList_img.Images.Keys[toSelectIndex];
if (!this.analysisDict.ContainsKey(toSelectImageKey))
this.analysisDict.Add(toSelectImageKey, this.analysisModel.cloneListParamModel(this.menuId));
//else
// this.analysisDict[getCurrentWorkTag()] = this.analysisModel.cloneListParamModel(this.menuId);
this.analysisModel = this.analysisDict[toSelectImageKey];
bool existGuideModel = true;
if (!GSSClass.GuideClass.guideDict.ContainsKey(toSelectImageKey))
{
if (/*toSelectIndex >= 0 && */GSSClass.GuideClass.guideModel.oldSelectItem == null && this.comboBox1.SelectedItem != null)
GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
GSSClass.GuideClass.guideDict.Add(toSelectImageKey, GSSClass.GuideClass.guideModel.cloneModel());
existGuideModel = false;
}
GSSClass.GuideClass.guideModel = GSSClass.GuideClass.guideDict[toSelectImageKey];
if (toSelectIndex >= 0 && this.comboBox1.SelectedItem != null)
GSSClass.GuideClass.guideModel.oldSelectItem = (string)this.comboBox1.SelectedItem;
if (!GSSClass.styleClass.styleDict.ContainsKey(toSelectImageKey))
GSSClass.styleClass.styleDict.Add(toSelectImageKey, GSSClass.styleClass.styleModel.cloneModel());
GSSClass.styleClass.styleModel = GSSClass.styleClass.styleDict[toSelectImageKey];
if (!GSSClass.standardDict.ContainsKey(toSelectImageKey))
GSSClass.standardDict.Add(toSelectImageKey, GSSClass.standardModel.cloneModel());
GSSClass.standardModel = GSSClass.standardDict[toSelectImageKey];
//二值化集成4
if (ShowDrawClassView())
binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone());
else
binaryClass.listView1_SelectedIndexChangedHideDrawClassView(this.imageMat.Clone(), toSelectImageKey);//###21974
//晶界重现
if (this.selectPicture >= 0 && this.selectPicture < this.imageList_img.Images.Keys.Count
&& this.grainBoundaryDict.ContainsKey(this.imageList_img.Images.Keys[this.selectPicture])
&& !this.grainBoundaryDict.ContainsKey(toSelectImageKey))
{//如果首次切换到该图片,或者点击了应用到全部,则将参数赋值
this.grainBoundaryDict.Add(toSelectImageKey, this.grainBoundaryDict[this.imageList_img.Images.Keys[this.selectPicture]].cloneModel());
}
if (toSelectIndex >= 0/*applyingToAll*/)
this.selectPicture = toSelectIndex;
else
this.selectPicture = this.lstView_img.FocusedItem.Index;
//选择了应用晶界重现但是没有计算结果,则进行晶界重现的计算
if (this.grainBoundaryDict.ContainsKey(toSelectImageKey) && this.grainBoundaryDict[toSelectImageKey].grainApplygrainboundaries == 1
&& !this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
{
procClass = new ProgressThreadProcClass();
procClass.StartProgressAutoAction(this, new System.Threading.ThreadStart(applyDectAction), PdnResources.GetString("Menu.Grainboundarytoreproduce.text"));
}
if (this.grainBoundaryMatDict.ContainsKey(toSelectImageKey))
{
this.documentWorkspace.PhaseModels[1].mat = this.grainBoundaryMatDict[toSelectImageKey].Clone();
this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && ShowGrainBoundryChecked());
}
else
this.documentWorkspace.PhaseModels[1].mat = null;
if (grainMethodType == 1)
{
if (this.grainColorsMatDict.ContainsKey(toSelectImageKey))
{
this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[toSelectImageKey].Clone();
this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && ShowGrainColorChecked());
}
else
this.documentWorkspace.PhaseModels[2].mat = null;
}
if (existGuideModel && !applyingToAll)//显示已经存在的数据即可,除非(还差应用到全部的信息没有处理),否则不必刷新
{
try
{
object ItemStringObject;
if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
{
this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
this.comboBox1.SelectedItem = (string)ItemStringObject;
comboBox1SelectedItem = comboBox1.SelectedItem;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
}
}
catch (Exception exc)
{
System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
}
this.documentWorkspace.Refresh();
refreshWhileImgChanged();
return;
}
DocumentWorkspace toSelectDocumentWorkspace = toSelectIndex >= 0 ? this.appWorkspace.DocumentWorkspaces[toSelectIndex] : getCurrentWorkspace();
if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
{
float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)));
double multiple = 1.0;
if (recWidth > this.documentWorkspace.CompositionSurface.Width)
{
multiple = this.documentWorkspace.CompositionSurface.Width / recWidth;
}
if (this.documentWorkspace.CompositionSurface.Height < recHeight * multiple)//#21714
{
multiple = this.documentWorkspace.CompositionSurface.Height / recHeight;
}
GSSClass.GuideClass.guideModel.rectangleFLineWidth = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineWidth);
GSSClass.GuideClass.guideModel.rectangleFLineHeight = (float)(multiple * GSSClass.GuideClass.guideModel.rectangleFLineHeight);
if (grainMethodType == 1)//#21714
GSSClass.GuideClass.UpdateScaleGuideAreaStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel
, multiple);
else
GSSClass.GuideClass.UpdateScaleGuideStyle((this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0 && this.comboBox1.SelectedItem != null) ? this.comboBox1.SelectedItem : "", GSSClass.GuideClass.guideModel, recWidth, recHeight
, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron), multiple);
}
GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
if (this.comboBox1.DataSource != null && this.comboBox1.SelectedIndex >= 0)
{
//UpdateGuideStyle(false);
float recWidth = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineWidth / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
float recHeight = (float)(Math.Max(1, GSSClass.GuideClass.guideModel.rectangleFLineHeight / toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron)));
GSSClass.GuideClass.guideModel.RectangleFLine = new RectangleF(GSSClass.GuideClass.guideModel.loctation.X - recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/ / 2
, GSSClass.GuideClass.guideModel.loctation.Y - recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/ / 2
, recWidth/*GSSClass.GuideClass.RectangleFLine.Width*/, recHeight/*GSSClass.GuideClass.RectangleFLine.Height*/);
bool foundItem = false;
if (grainMethodType == 1)
{
if (this.imageMat != null && this.comboBox1.SelectedItem != null)
GSSClass.GuideClass.updateGuideAreaRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
}
else
if (this.imageMat != null && this.comboBox1.SelectedItem != null)
GSSClass.GuideClass.updateGuideRectLine(this.comboBox1.SelectedItem, GSSClass.GuideClass.guideModel, out foundItem, true/*guideTypeChanged*/, toSelectDocumentWorkspace.GetRuler(MeasurementUnit.Micron));
/////*this.*/
////GSSClass.GuideClass.updateRectangleSize(getCurrentWorkspace().GetRuler(MeasurementUnit.Micron)/*physical_Micron*/);
if (foundItem)
AddRectangleToRectangleFCaps();
//this.documentWorkspace.Refresh();
}
else
InitRectangleF(false);
refreshWhileImgChanged();//#################################################应用到全部时候计算其他图片不需要刷新界面参数信息?
//InitComboboxValue(null);
try
{
object ItemStringObject;
if (GetParamValue1(ParamKey_comboBox1SelectedItem, out ItemStringObject))//切换选择的辅助线类型,以及需要备份和读取数据
this.comboBox1.SelectedItem = (string)ItemStringObject;
}
catch (Exception exc)
{
System.Console.WriteLine("this.comboBox1.SelectedItem: " + exc.ToString());
}
UpdateGuideStyle(!applyingToAll);
if (this.imageMat != null)
{
GSSClass.GuideClass.guideModel.loctation = new PointF(this.documentWorkspace.CompositionSurface.Width / 2, this.documentWorkspace.CompositionSurface.Height / 2);
InitRectangleF(true);
}
this.documentWorkspace.Refresh();
}
///
/// 3D效果,正十四面体预览
///
///
///
private void threeDButton_Click(object sender, EventArgs e)
{
if (RegularTetrahedron3D.GetStatus() > 0 && value_111 > 1)
{
RegularTetrahedron3D.UpdateRun(Math.Min(value_111, 200));
return;
}
if (value_111 > 1)
RegularTetrahedron3D.Run(Math.Min(value_111, 200));
else
RegularTetrahedron3D.Run(50/*this.appWorkspace*/);
}
private void applyDectAction()
{
string toSelectImageKey = this.imageList_img.Images.Keys[this.selectPicture];
OrgImg0 = GrainBoundaryEditingDialog.runDect(Color.FromArgb(grainBoundaryDict[toSelectImageKey].grainColor) /*Color.Red*//*this.panel1.BackColor*/, this.imageMat.Clone(), grainBoundaryDict[toSelectImageKey].m_AdOutParam_0, grainBoundaryDict[toSelectImageKey].m_AdOutParam_1, (int)grainBoundaryDict[toSelectImageKey].m_AdOutParam_2, (int)grainBoundaryDict[toSelectImageKey].m_AdOutParam_3
, grainBoundaryDict[toSelectImageKey].m_AdOutParam_4, grainBoundaryDict[toSelectImageKey].m_AdOutParam_5, grainBoundaryDict[toSelectImageKey].m_AdOutParam_6);
this.grainBoundaryMatDict.Add(toSelectImageKey, OrgImg0);
if (procClass != null) procClass.DismissProgressAction(this);
}
#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 = param.Lists;
string xmlFilePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainBoundryDectModel_" + this.menuId + ".xml";
if (System.IO.File.Exists(xmlFilePath))
{
GrainBoundryDectModel = Base.CommTool.XmlSerializeHelper.DESerializer(Base.CommTool.FileOperationHelper.ReadStringFromFile(xmlFilePath, System.IO.FileMode.Open));
}
foreach (var item in args)
{
item.value = setScriptRecording(item.key);
}
//找出二值相关参数 进行赋值
List isNullList = args.Where(m => m.value == null).ToList();
foreach (var item in isNullList)
{
item.value = binaryClass.setScriptRecording(item.key);
}
isNullList = args.Where(m => m.value == null).ToList();
foreach (var item in isNullList)
{
item.value = saveRecordingData(item.key);
}
appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
}
private object setScriptRecording(string key)
{
object value = null;
switch (key)
{
case "ShowGrainNumber":
value = showGrainNumberChecked();
break;
case "ShowGrainColor":
value = ShowGrainColorChecked();
break;
case "displaygrainboundaries":
value = ShowGrainBoundryChecked();
break;
case "displaygrid":
value = showGridChecked();
break;
case "displaysections":
value = drawDisplaySections();
break;
case "comboBox1SelectedItem":
value = comboBox1SelectedItem;
break;
case "CalculatorDecimalDigits":
value = Convert.ToInt32(this.numericUpDown1_0.Value);
break;
case "OpenWhileExportReport":
value = this.checkBox_generateReport_opensetting.Checked;
break;
case "TargetSelection":
value = this.TargetSelection;
break;
case "ExportResults":
value = false;
break;
case "ExportReports":
value = false;
break;
case "ExportProjects":
value = false;
break;
case "GrainApplygrainboundaries":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.grainApplygrainboundaries;
break;
case "lineColor":
value = GrainBoundryDectModel == null ? Color.Red.ToArgb() : GrainBoundryDectModel.grainColor;
break;
case "GrainAdOutParam_0":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_0;
break;
case "GrainAdOutParam_1":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_1;
break;
case "GrainAdOutParam_2":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_2;
break;
case "GrainAdOutParam_3":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_3;
break;
case "GrainAdOutParam_4":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_4;
break;
case "GrainAdOutParam_5":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_5;
break;
case "GrainAdOutParam_6":
value = GrainBoundryDectModel == null ? 0 : GrainBoundryDectModel.m_AdOutParam_6;
break;
}
return value;
}
#endregion
}
}