using OpenCvSharp;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Base.SettingModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Windows.Forms;
using Point = System.Drawing.Point;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.Base.Enum;
using PaintDotNet.Annotation.Enum;
using PaintDotNet.CustomControl;
using Application = System.Windows.Forms.Application;
using GroupBox = System.Windows.Forms.GroupBox;
using CheckBox = System.Windows.Forms.CheckBox;
using Button = System.Windows.Forms.Button;
using Label = System.Windows.Forms.Label;
using TextBox = System.Windows.Forms.TextBox;
using System.Data;
using PaintDotNet.DbOpreate.DbModel;
using PaintDotNet.Annotation;
using PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass;
namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.GBT24177
{
internal class MethodCutOffDialog : GrainSizeStandardDialog
{
///
/// 测定结果暂存
///
private List dataTable1s = new List();
///
/// 储存点击保存结果后的所有原图与分析图
///
private Dictionary> bitCeDingDic = new Dictionary>();
#region 组件
private GroupBox groupBox10;
private Button button10;
private Button button7_0;
private GroupBox groupBox11;
private CheckBox checkBox5_0;
private CheckBox checkBox4;
private CheckBox checkBox3_0;
private DataGridViewTextBoxColumn ColumnTotal1;
private DataGridViewTextBoxColumn ColumnTotal2;
private DataGridViewTextBoxColumn ColumnTotal3;
private DataGridViewTextBoxColumn ColumnTotal4;
private DataGridViewTextBoxColumn ColumnTotal5;
private DataGridViewTextBoxColumn ColumnTotal6;
private DataGridViewTextBoxColumn Column1;
private DataGridViewTextBoxColumn Column2;
private DataGridViewTextBoxColumn Column3;
private DataGridViewTextBoxColumn Column4;
private DataGridViewTextBoxColumn Column5;
private DataGridViewTextBoxColumn Column6;
private Button button8;
private Button button6_0;
#endregion 组件
#region 构造函数
public MethodCutOffDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, null, 0)
{
}
#endregion 构造函数
#region 初始化组件
private void InitializeLanguageText()
{
this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
this.button10.Text = PdnResources.GetString("Menu.Setting.Text");
this.button7_0.Text = PdnResources.GetString("Menu.1section.text");
this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
this.checkBox4.Text = PdnResources.GetString("Menu.displaygrid.text");
this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
this.Text = "GBT24177_2009(" + PdnResources.GetString("Menu.sectionmethod.text") + ")";
this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnTotal4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnTotal5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnTotal6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnTotal3,
this.ColumnTotal4,
this.ColumnTotal5,
this.ColumnTotal6});
//
// ColumnTotal1
//
this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Intersectinggrainnumber.Text");
this.ColumnTotal1.Name = "ColumnTotal1";
this.ColumnTotal1.ReadOnly = true;
//
// ColumnTotal2
//
this.ColumnTotal2.HeaderText = PdnResources.GetString("Menu.Numberofgrainsingrid.Text");
this.ColumnTotal2.Name = "ColumnTotal2";
this.ColumnTotal2.ReadOnly = true;
//
// ColumnTotal3
//
this.ColumnTotal3.HeaderText = PdnResources.GetString("Menu.Totalmeshlength.Text") + "(μm)";
this.ColumnTotal3.Name = "ColumnTotal3";
this.ColumnTotal3.ReadOnly = true;
//
// ColumnTotal4
//
this.ColumnTotal4.HeaderText = PdnResources.GetString("Menu.umberofpoints.Text");
this.ColumnTotal4.Name = "ColumnTotal4";
this.ColumnTotal4.ReadOnly = true;
//
// ColumnTotal5
//
this.ColumnTotal5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";
this.ColumnTotal5.Name = "ColumnTotal5";
this.ColumnTotal5.ReadOnly = true;
//
// ColumnTotal6
//
this.ColumnTotal6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
this.ColumnTotal6.Name = "ColumnTotal6";
this.ColumnTotal6.ReadOnly = true;
this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
this.Column3,
this.Column4,
this.Column5,
this.Column6});
//
// Column1
//
this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
//
// Column2
//
this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
//
// Column3
//
this.Column3.HeaderText = PdnResources.GetString("Menu.Gridlength.text") + "(μm)";
this.Column3.Name = "Graisize";
this.Column3.ReadOnly = true;
//
// Column4
//
this.Column4.HeaderText = PdnResources.GetString("Menu.Thenumberofsections.text");
this.Column4.Name = "Grainnumber";
this.Column4.ReadOnly = true;
//
// Column5
//
this.Column5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)";
this.Column5.Name = "Grainintercept";
this.Column5.ReadOnly = true;
//
// Column6
//
this.Column6.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
this.Column6.Name = "Graingrade";
this.Column6.ReadOnly = true;
this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
}
private void InitializeComponent()
{
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.button8 = new System.Windows.Forms.Button();
this.button6_0 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button7_0 = new System.Windows.Forms.Button();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.checkBox5_0 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox3_0 = new System.Windows.Forms.CheckBox();
this.groupBox_analysisResult1.SuspendLayout();
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.SuspendLayout();
//
// groupBox10
//
this.groupBox10.Controls.Add(this.button8);
this.groupBox10.Controls.Add(this.button6_0);
this.groupBox10.Controls.Add(this.button10);
this.groupBox10.Controls.Add(this.button7_0);
this.groupBox10.Location = new System.Drawing.Point(179, 370);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(208, 74);
this.groupBox10.TabIndex = 38;
this.groupBox10.TabStop = false;
//
// button8
//
this.button8.BackColor = System.Drawing.SystemColors.Control;
this.button8.Location = new System.Drawing.Point(107, 42);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(95, 26);
this.button8.TabIndex = 13;
this.button8.UseVisualStyleBackColor = false;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button6_0
//
this.button6_0.BackColor = System.Drawing.SystemColors.Control;
this.button6_0.Location = new System.Drawing.Point(6, 43);
this.button6_0.Name = "button6_0";
this.button6_0.Size = new System.Drawing.Size(95, 26);
this.button6_0.TabIndex = 12;
this.button6_0.UseVisualStyleBackColor = false;
this.button6_0.Click += new System.EventHandler(this.button6_0_Click);
//
// button10
//
this.button10.BackColor = System.Drawing.SystemColors.Control;
this.button10.Location = new System.Drawing.Point(107, 15);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(95, 26);
this.button10.TabIndex = 11;
this.button10.UseVisualStyleBackColor = false;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button7_0
//
this.button7_0.BackColor = System.Drawing.SystemColors.Control;
this.button7_0.Location = new System.Drawing.Point(6, 15);
this.button7_0.Name = "button7_0";
this.button7_0.Size = new System.Drawing.Size(95, 26);
this.button7_0.TabIndex = 8;
this.button7_0.UseVisualStyleBackColor = false;
this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
//
// groupBox11
//
this.groupBox11.Controls.Add(this.checkBox5_0);
this.groupBox11.Controls.Add(this.checkBox4);
this.groupBox11.Controls.Add(this.checkBox3_0);
this.groupBox11.Location = new System.Drawing.Point(393, 370);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(142, 74);
this.groupBox11.TabIndex = 39;
this.groupBox11.TabStop = false;
//
// checkBox5_0
//
this.checkBox5_0.AutoSize = true;
this.checkBox5_0.Checked = true;
this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox5_0.Location = new System.Drawing.Point(15, 53);
this.checkBox5_0.Name = "checkBox5_0";
this.checkBox5_0.Size = new System.Drawing.Size(72, 16);
this.checkBox5_0.TabIndex = 2;
this.checkBox5_0.UseVisualStyleBackColor = true;
this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Checked = true;
this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox4.Location = new System.Drawing.Point(15, 35);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(72, 16);
this.checkBox4.TabIndex = 1;
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
//
// checkBox3_0
//
this.checkBox3_0.AutoSize = true;
this.checkBox3_0.Checked = true;
this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox3_0.Location = new System.Drawing.Point(15, 17);
this.checkBox3_0.Name = "checkBox3_0";
this.checkBox3_0.Size = new System.Drawing.Size(72, 16);
this.checkBox3_0.TabIndex = 0;
this.checkBox3_0.UseVisualStyleBackColor = true;
this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
//
// MethodCutOffDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(1127, 810);
this.Controls.Add(this.groupBox10);
this.Controls.Add(this.groupBox11);
this.Name = "MethodCutOffDialog";
this.Controls.SetChildIndex(this.groupBox11, 0);
this.Controls.SetChildIndex(this.groupBox10, 0);
this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 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.groupBox_report, 0);
this.groupBox_analysisResult1.ResumeLayout(false);
this.groupBox10.ResumeLayout(false);
this.groupBox11.ResumeLayout(false);
this.groupBox11.PerformLayout();
this.ResumeLayout(false);
}
#endregion 初始化组件
#region 需继承方法
///
/// 是否显示晶界
///
///
protected override Boolean ShowGrainBoundryChecked()
{
return checkBox3_0.Checked;
}
//是否绘制辅助线
protected override bool showGridChecked()
{
return checkBox4.Checked;
}
//是否绘制截点
protected override bool drawGuidePoints()
{
return (imageMat != null && this.checkBox5_0.Checked);
}
//是否显示截点
protected override Boolean drawDisplaySections()//##1
{
return this.checkBox5_0.Checked;
}
//辅助线类型
protected override string[] getTypeNames()
{
return new string[] {
PdnResources.GetString("Menu.Verticalauxiliaryline.text"),
PdnResources.GetString("Menu.Horizontalauxiliaryline.text"),
PdnResources.GetString("Menu.Singlecircleauxiliaryline.text"),
PdnResources.GetString("Menu.Three-circleauxiliaryline.text"),
PdnResources.GetString("Menu.Compositeauxiliaryline.text")};
}
protected override string getTemplateName()
{
return "Template.Manager.item3.GrainSizeCutOff24177Method";
}
protected override string getProjectEngineeringName()
{
return "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text";
}
protected override string getModelName()
{
return "GrainSizeGuideStyleModel.xml";
}
protected override void SubclassInitialize()
{
InitializeComponent();
InitializeLanguageText();
DetailListNotDoubleIndex.Add(0);
DetailListNotDoubleIndex.Add(1);
}
#endregion
private void MethodCutOffDialog_Load(object sender, EventArgs e)
{
object ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
this.checkBox4.Checked = (bool)ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
//this.groupBox_img.Size = new System.Drawing.Size(158, 722);
//this.groupBox_review.Size = new System.Drawing.Size(575, 722);
//this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 800);
//this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 800);
//this.groupBox_report.Location = new System.Drawing.Point(974, 800);
}
protected override void refreshWhileImgChanged()
{
object ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
this.checkBox4.Checked = (bool)ShowGrainBoundry;
if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
}
///
/// 是否显示网格
///
///
///
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
this.documentWorkspace.Refresh();
}
///
/// 是否显示截点
///
///
///
private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
{
if (!this.checkBox4.Checked)
MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
this.documentWorkspace.Refresh();
}
///
/// 是否显示晶界
///
///
///
private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
{
if (!bcOriginChecked() && getGrainBoundryChecked() && checkBox3_0.Checked)
{
this.documentWorkspace.PhaseModels[1].choise = true;
}
else
{
this.documentWorkspace.PhaseModels[1].choise = false;
}
this.documentWorkspace.Refresh();
}
///
/// 设置截点样式
///
///
///
private void button10_Click(object sender, EventArgs e)
{
ShowGrainSurveyPointStyleSettingDialog();
}
///
/// 鼠标按下
///
///
///
protected override void OnMouseDown(object sender, MouseEventArgs e)
{
if (this.documentWorkspace.CompositionSurface == null)
return;
// 换算后的点
PointF point1 = documentWorkspace.GetScalePoint(e.Location);
if (point1.X <= this.documentWorkspace.CompositionSurface.Width
&& point1.X >= 0
&& point1.Y >= 0
&& point1.Y <= this.documentWorkspace.CompositionSurface.Height)
{
RectangleF rectangleF;
// 复合辅助线
int add = GSSClass.GuideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
if (add == 0 && GSSClass.styleClass.PointKb > 0)
rectangleF = GSSClass.GuideClass.guideModel.RectangleFLine;
//手动添加截点
if (this.documentWorkspace.ActiveTool == Annotation.Enum.DrawToolType.InclusionNoEffect && GSSClass.styleClass.OnMouseDownNext(point1, sender, e))
GSSClass.styleClass.OnMouseDownFirst(point1, rectangleF, GSSClass.standardModel.linePointList, e);
}
if (GSSClass.styleClass.PointKb == 0)
{
//辅助线缩放
GSSClass.GuideClass.OnMouseDown(point1, sender, e);
//辅助线移动
base.OnMouseDown(sender, e);//##
}
////手动删除截点或取消添加截点
//GSSClass.styleClass.OnMouseDownNext(point1, sender, e);
}
private void AllShow()
{
this.dataGridView2.Rows.Clear();
for (int i = 0; i < this.dataTables.Count; i++)
{
DataGridViewRow dgvr = new DataGridViewRow();
dgvr.Tag = this.dataTables[i].TableName;
foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
{
dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
}
for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
{
//if (c > 2 && c < 4)
// dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
//else
dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
}
this.dataGridView2.Rows.Add(dgvr);
}
}
private void button6_0_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
{
//MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
GSSClass.styleClass.PointKb = 1;
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
}
}
///
/// 1截点添加
///
///
///
private void button7_0_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
{
//MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
GSSClass.styleClass.PointKb = 2;
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
}
}
private void button8_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
{
//MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
GSSClass.styleClass.PointKb = 3;
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
}
}
}
}