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 PaintDotNet.DedicatedAnalysis.DuctileIron.Common; using System.Data; using Microsoft.Office.Interop.Excel; using Font = System.Drawing.Font; using DataTable = System.Data.DataTable; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using PaintDotNet.Data.Param; using PaintDotNet.Instrument; using PaintDotNet; using OpenCvSharp.Extensions; using Rectangle = System.Drawing.Rectangle; using System.Linq; using Metis.ParameterSet; using PaintDotNet.Base; namespace PaintDotNet.DeterminationOfNitridingDepth.GBT11354_2005 { internal class MetallographicMethodDialog : PdnBaseForm { #region 控件 private GroupBox groupBox1; private Button button2; private CheckBox checkBox2; private GroupBox groupBox2; private ListView listView1; private PaintDotNet.CustomControl.BinaryControl bc; private GroupBox groupBox7; private GroupBox groupBox8; private DataGridView dataGridView2; private Button button4; private ListView listView2; private NumericUpDown numericUpDown1; private Button button16; private Label label5; private Button button14; private Button button13; private DataGridView dataGridView4; private Button button12; private Button button11; private GroupBox groupBox3; private Button button6; private Button button5; private Button button3; private RadioButton radioButton1; private RadioButton radioButton3; private RadioButton radioButton2; private GroupBox groupBox4; private Label label1; private Label label2; private NumericUpDown numericUpDown2; private Label label3; private NumericUpDown numericUpDown3; private Panel panel1; private GroupBox groupBox5; private DataGridView dataGridView1; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn9; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn10; private DataGridViewTextBoxColumn Column1; private DataGridViewTextBoxColumn Column2; private DataGridViewTextBoxColumn Column5; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn6; private ImageList imageList1; private IContainer components; private Button button1; #endregion /// /// 主控件 /// private AppWorkspace appWorkspace; private bool canChange = false; //二值化集成1 BinaryClass binaryClass; private int menuId; private string menuName; /// /// 选中图片的mat /// private Mat imageMat; private DocumentWorkspaceWindow documentWorkspace; /// /// 公共按钮 /// private CommonControlButtons commonControlButtons; /// /// 储存点击保存结果后的所有原图与分析图 /// private Dictionary> bitDic = new Dictionary>(); /// /// 处理程序 /// private ParamObject action = new Data.Action.Action1010(); /// /// 调色板 /// private ColorsForm colorsForm1; /// /// 全部显示 /// private bool allShow = false; /// /// 标尺 /// private double unitLength; /// /// 数据展示 /// private DataTable dataTable; /// /// 存在视场标记 /// private bool existViewFlag = false; /// /// 线条绘制点矩形集合 /// private Dictionary rectangleFs = new Dictionary(); /// /// 线条绘制点矩形 /// private RectangleF[] rectangleFsArr = new RectangleF[2]; /// /// 线条矩形 /// private PointF[] pointFsLine = new PointF[4]; /// /// 分析结果暂存 /// private List dataTables = new List(); /// /// 保存用于生成报告的图片 /// private List bitList; /// /// 中间数据 /// private List tempDataModel = new List(); /// /// 鼠标状态(0:添加 1:删除 2:选择) /// private int mouseStatus = -1; /// /// 测量线类型(0:全方位 1:水平 2:垂直) /// private int lineStyle = -1; /// /// 线条矩形 /// private Dictionary rectangleFsLines = new Dictionary(); private int selectLineIndex = -1; private PointF movePointStart; bool canMove = false; int movePointIndex = -1; private ToolStrip toolStrip1; private Label label4; private NumericUpDown numericUpDown4; bool canAdd = false; private int defaultIndex = -1; /// /// 保存窗口参数 /// private GrainSizeAnalysisModel analysisModel; private const string ParamKey_Report = "report";//报告设置 private const string ParamKey_Whole = "whole";//全方位线 private const string ParamKey_Waterline = "waterline";//水平线 private const string ParamKey_Vertical = "vertical";//垂直线 private const string ParamKey_LineLength = "lineLength";//线长 private const string ParamKey_LineWidth = "lineWidth";//线宽 private const string ParamKey_LineColour = "lineColour";//线色 private const string ParamKey_FontSize = "fontSize";//字号 private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数 /// /// 是否脚本运行 /// private Boolean initScriptValues = false; public MetallographicMethodDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) { this.menuId = menuItem.MenuId; this.menuName = menuItem.Text; binaryClass = new BinaryClass(menuId); 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.appWorkspace = appWorkspace; InitializeComponent(); InitializeLanguageText(); // 标尺 //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength); // //初始化色板 // //调色板 this.colorsForm1 = new ColorsForm(); this.colorsForm1.StartPosition = FormStartPosition.CenterScreen; this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); // //初始化图像控件 // this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace); this.documentWorkspace.Dock = DockStyle.Fill; this.documentWorkspace.HookMouseEvents(); this.documentWorkspace.AuxiliaryLineEnabled = false; this.documentWorkspace.Visible = false; this.documentWorkspace.panel.MouseDown += OnMouseDown; this.documentWorkspace.panel.Paint += Panel_Paint; this.documentWorkspace.panel.MouseMove += onMouseMove; this.documentWorkspace.panel.MouseUp += OnMouseUp; this.groupBox7.Controls.Add(documentWorkspace); // //初始化操作按钮 // this.commonControlButtons = new CommonControlButtons(); this.commonControlButtons.Dock = DockStyle.Top; this.commonControlButtons.Height = 30; this.commonControlButtons.HideZoomToWindowAndActualSize(); this.commonControlButtons.Visible = false; this.groupBox7.Controls.Add(commonControlButtons); //初始化头 this.listView2.View = View.Details; ColumnHeader header0 = new ColumnHeader(); header0.Text = ""; header0.Width = 180; this.listView2.Columns.Add(header0); InitCommonButtonEvent(); Init(); InitPicList(); SetAnalyzeModelFromXml("Template.Manager.item3.NitridingLayerGBT11354"); //二值化集成2 bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件 binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") } , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构 binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件 //如果是脚本执行,将参数带入 if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null) { this.initScriptValues = true;//ScriptAutomatic //Boolean initScriptValues = true; ////在这里反射出对应功能的参数类 string className = InvariantData.path_Action + ".Action" + menuId; ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className); foreach (Args arg in param.Lists) { Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key)); if (param1.value != null) arg.Value = param1.value; getValue(arg.key, arg.Value); } appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数 } else {//读取上次关闭窗口时保存的参数 GetListParamModel(); } for (int i = 0; i < this.dataGridView1.Columns.Count; i++) { this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 0; i < this.dataGridView2.Columns.Count; i++) { this.dataGridView2.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 0; i < this.dataGridView4.Columns.Count; i++) { this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } } /// /// 初始化参数 /// private void Init() { this.Focus(); this.radioButton1.Checked = true; this.mouseStatus = -1; this.numericUpDown2.Value = 50; this.numericUpDown3.Value = 5; this.button11.Visible = true; this.button16.Visible = false; } private void ShowImgEvent(object sender, EventArgs e) { listView1.Focus(); if (this.defaultIndex != -1) { this.listView1.Items[defaultIndex].Focused = true; this.listView1.Items[defaultIndex].Selected = true; } } /// /// 初始化图片列表数据 /// public void InitPicList() { //初始化图片列表 for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++) { this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail); this.listView1.Items.Add("", i); this.listView1.Items[i].ImageIndex = i; this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace)) { defaultIndex = i; } } this.Shown += ShowImgEvent; } /// /// 刷新数据展示 /// private void RefrashData() { canChange = true; if (this.rectangleFs.Count == 0) return; this.dataGridView1.Rows.Clear(); int count = 0; foreach (var item in rectangleFs) { count++; DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn Column in this.dataGridView1.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6,Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength; dgvr.Cells[0].Value = "L" + count; dgvr.Cells[1].Value = Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView1.Rows.Add(dgvr); } dataTable = new DataTable(); foreach (DataGridViewColumn Column in this.dataGridView1.Columns) { dataTable.Columns.Add(Column.HeaderText); } count = 0; foreach (var item in rectangleFs) { count++; DataRow dataRow = dataTable.NewRow(); double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 15) * unitLength; dataRow[0] = "L" + count; dataRow[1] = length; this.dataTable.Rows.Add(dataRow); } double allLength = 0; for (int i = 0; i < dataTable.Rows.Count; i++) { allLength += Convert.ToDouble(dataTable.Rows[i][1]); } DataGridViewRow dgvr1 = new DataGridViewRow(); foreach (DataGridViewColumn Column in this.dataGridView1.Columns) { dgvr1.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } dgvr1.Cells[0].Value = PdnResources.GetString("Menu.Image.Average.Text"); dgvr1.Cells[1].Value = Math.Round(allLength / this.dataTable.Rows.Count, Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView1.Rows.Add(dgvr1); canChange = false; if (this.dataGridView1.DisplayedRowCount(false) == this.dataGridView1.RowCount) { //没有 this.dataGridViewTextBoxColumn10.Width = 242; } else { //有 this.dataGridViewTextBoxColumn10.Width = 227; } } //二值化集成3 #region 二值化相关方法 private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e) { #region [开启脚本录制] if (appWorkspace.startScriptRecording) { getScriptRecording(); } #endregion binaryClass.saveParams(); this.saveDialogParamValues(); //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 == analysisItem.menuId) { item.param_value = analysisItem.param_value; foundItem = true; break; } } if (!foundItem) analysisModelXml.ListParam.Add(analysisItem.cloneModel()); } //按路径和名称保存xml文件 string userInfoXml = XmlSerializeHelper.XmlSerialize(analysisModelXml); //保存xml FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create); } private void ShownChoiseItemAndInitData(object sender, EventArgs e) { binaryClass.RefreshHistogramControl1Values(); } /// /// 添加参数改变的监听 /// /// /// private void GrainSizeAnalysisMethodOfClasticRockDialog_Load(object sender, EventArgs e) { this.binaryClass.loadParams(); } private bool bcBinaryChecked() { return bc != null && bc.BinaryChecked; } private bool bcOriginChecked() { return bc != null && bc.OriginChecked; } /// /// 参数改变时,重新处理图像 /// /// /// private void bClassBinaryImplFinishAction(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } /// /// 显示原图/原图+二值图 /// /// /// private void bcOriginCheckedChanged(object sender, EventArgs e) { if (!bcOriginChecked()) { if (bcBinaryChecked()) this.documentWorkspace.PhaseModels[0].choise = true; } else { this.documentWorkspace.PhaseModels[0].choise = false; this.documentWorkspace.PhaseModels[1].choise = false; } this.documentWorkspace.Refresh(); } #endregion #region 公共控件 private void InitCommonButtonEvent() { this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click); this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click); this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click); this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click); this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click); this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click); } private void zoomInButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomIn(); } private void zoomOutButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomOut(); } private void zoomToWindowButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; } private void actualSizeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor; this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne; } private void pointerButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer; } private void mobileModeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode; } #endregion #region 初始化 private void InitializeLanguageText() { this.bc = new PaintDotNet.CustomControl.BinaryControl(); // // bc // this.bc.BinaryBackColor = System.Drawing.Color.Red; this.bc.BinaryChecked = false; this.bc.BinaryStyle = 1; this.bc.Location = new System.Drawing.Point(151, 59); this.bc.Name = "bc"; this.bc.OriginChecked = false; this.bc.scope1End = 0D; this.bc.scope1Start = 0D; this.bc.scope2End = 0D; this.bc.scope2Start = 0D; this.bc.scope3End = 0D; this.bc.scope3Start = 0D; this.bc.Size = new System.Drawing.Size(360, 292); this.bc.TabIndex = 21; this.Controls.Add(this.bc); this.Controls.SetChildIndex(this.bc, 0); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button2.Text = PdnResources.GetString("Menu.Saveresult.text"); this.checkBox2.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text"); this.button1.Text = PdnResources.GetString("Menu.Setting.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text"); this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Numberofnitridinglayers.text"); this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Totaldepthofnitridinglayer.text"); this.dataGridViewTextBoxColumn6.HeaderText = PdnResources.GetString("Menu.Averagedepthofnitridinglayer.text"); this.button4.Text = PdnResources.GetString("Menu.Exportproject.text"); this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text"); this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":"; this.button14.Text = PdnResources.GetString("Menu.Exportresults.text"); this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text"); this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text"); this.Column2.HeaderText = PdnResources.GetString("Menu.packet.text"); this.Column5.HeaderText = PdnResources.GetString("Menu.Depthofnitridinglayer.text"); this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button11.Text = PdnResources.GetString("Menu.Showall.text"); this.groupBox3.Text = PdnResources.GetString("Menu.Measurementbaseline.text"); this.radioButton1.Text = PdnResources.GetString("Menu.Fullline.text"); this.radioButton3.Text = PdnResources.GetString("Menu.Verticalline.text"); this.radioButton2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureHLine.Text"); this.button6.Text = PdnResources.GetString("Menu.Selectmeasurementline.text"); this.button5.Text = PdnResources.GetString("Menu.Deletemeasurementline.text"); this.button3.Text = PdnResources.GetString("Menu.Addmeasuringline.text"); this.groupBox4.Text = PdnResources.GetString("Menu.Basicsettingsofmeasuringline.text"); this.label3.Text = PdnResources.GetString("Menu.color.text") + ":"; this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.Linelength.text") + ":"; this.groupBox5.Text = PdnResources.GetString("Menu.datapresentation.text"); this.dataGridViewTextBoxColumn9.HeaderText = PdnResources.GetString("Menu.packet.text"); this.dataGridViewTextBoxColumn10.HeaderText = PdnResources.GetString("Menu.Depthofnitridinglayer.text"); this.Text = PdnResources.GetString("Menu.yerGBT11354_2005Metallogr.text"); this.label4.Text = PdnResources.GetString("Menu.Font.text") + PdnResources.GetString("Menu.size.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(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button2 = new System.Windows.Forms.Button(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.listView1 = new System.Windows.Forms.ListView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.button4 = new System.Windows.Forms.Button(); this.listView2 = new System.Windows.Forms.ListView(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.button16 = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); this.button14 = new System.Windows.Forms.Button(); this.button13 = new System.Windows.Forms.Button(); this.dataGridView4 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.button12 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.button6 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.numericUpDown4 = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.label3 = new System.Windows.Forms.Label(); this.numericUpDown3 = new System.Windows.Forms.NumericUpDown(); this.label2 = new System.Windows.Forms.Label(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox7.SuspendLayout(); this.groupBox8.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).BeginInit(); this.groupBox3.SuspendLayout(); this.groupBox4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.checkBox2); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(14, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1081, 50); this.groupBox1.TabIndex = 7; this.groupBox1.TabStop = false; // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.BackColor = System.Drawing.SystemColors.Control; this.button2.Location = new System.Drawing.Point(985, 14); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(84, 30); this.button2.TabIndex = 3; this.button2.UseVisualStyleBackColor = false; this.button2.Click += new System.EventHandler(this.button2_Click); // // checkBox2 // this.checkBox2.AutoSize = true; this.checkBox2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox2.Location = new System.Drawing.Point(105, 20); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(15, 14); this.checkBox2.TabIndex = 2; this.checkBox2.UseVisualStyleBackColor = true; // // button1 // this.button1.BackColor = System.Drawing.SystemColors.Control; this.button1.Location = new System.Drawing.Point(15, 14); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(84, 30); this.button1.TabIndex = 0; this.button1.UseVisualStyleBackColor = false; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox2 // this.groupBox2.Controls.Add(this.listView1); this.groupBox2.Location = new System.Drawing.Point(14, 68); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(135, 574); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; // // listView1 // this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView1.HideSelection = false; this.listView1.LargeImageList = this.imageList1; this.listView1.Location = new System.Drawing.Point(5, 17); this.listView1.MultiSelect = false; this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(124, 551); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); // // imageList1 // this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; this.imageList1.ImageSize = new System.Drawing.Size(64, 64); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; // // groupBox7 // this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox7.Controls.Add(this.toolStrip1); this.groupBox7.Location = new System.Drawing.Point(521, 68); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(580, 574); this.groupBox7.TabIndex = 21; this.groupBox7.TabStop = false; // // toolStrip1 // this.toolStrip1.Location = new System.Drawing.Point(3, 17); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(574, 25); this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // // groupBox8 // this.groupBox8.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.groupBox8.Controls.Add(this.dataGridView2); this.groupBox8.Controls.Add(this.button4); this.groupBox8.Controls.Add(this.listView2); this.groupBox8.Controls.Add(this.numericUpDown1); this.groupBox8.Controls.Add(this.button16); this.groupBox8.Controls.Add(this.label5); this.groupBox8.Controls.Add(this.button14); this.groupBox8.Controls.Add(this.button13); this.groupBox8.Controls.Add(this.dataGridView4); this.groupBox8.Controls.Add(this.button12); this.groupBox8.Controls.Add(this.button11); this.groupBox8.Location = new System.Drawing.Point(14, 648); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(1087, 273); this.groupBox8.TabIndex = 25; this.groupBox8.TabStop = false; // // dataGridView2 // this.dataGridView2.AllowUserToAddRows = false; this.dataGridView2.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.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2, this.dataGridViewTextBoxColumn6}); this.dataGridView2.Location = new System.Drawing.Point(228, 159); 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, 108); this.dataGridView2.TabIndex = 24; // // dataGridViewTextBoxColumn1 // dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle2; this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; this.dataGridViewTextBoxColumn1.ReadOnly = true; // // dataGridViewTextBoxColumn2 // dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle3; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.dataGridViewTextBoxColumn2.ReadOnly = true; // // dataGridViewTextBoxColumn6 // dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.dataGridViewTextBoxColumn6.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6"; this.dataGridViewTextBoxColumn6.ReadOnly = true; // // button4 // this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button4.BackColor = System.Drawing.SystemColors.Control; this.button4.Location = new System.Drawing.Point(941, 102); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(128, 26); this.button4.TabIndex = 23; this.button4.UseVisualStyleBackColor = false; this.button4.Click += new System.EventHandler(this.button4_Click); // // listView2 // this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.listView2.FullRowSelect = true; this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listView2.HideSelection = false; this.listView2.Location = new System.Drawing.Point(16, 56); this.listView2.Name = "listView2"; this.listView2.Size = new System.Drawing.Size(180, 210); this.listView2.TabIndex = 22; this.listView2.UseCompatibleStateImageBehavior = false; this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged); this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged); // // numericUpDown1 // this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.numericUpDown1.Location = new System.Drawing.Point(997, 163); this.numericUpDown1.Maximum = new decimal(new int[] { 10, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(56, 21); this.numericUpDown1.TabIndex = 21; this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // button16 // this.button16.BackColor = System.Drawing.SystemColors.Control; this.button16.Location = new System.Drawing.Point(16, 20); this.button16.Name = "button16"; this.button16.Size = new System.Drawing.Size(93, 26); this.button16.TabIndex = 20; this.button16.UseVisualStyleBackColor = false; this.button16.Click += new System.EventHandler(this.button16_Click); // // label5 // this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(958, 169); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 18; // // button14 // this.button14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button14.BackColor = System.Drawing.SystemColors.Control; this.button14.Location = new System.Drawing.Point(941, 68); this.button14.Name = "button14"; this.button14.Size = new System.Drawing.Size(128, 26); this.button14.TabIndex = 16; this.button14.UseVisualStyleBackColor = false; this.button14.Click += new System.EventHandler(this.button14_Click); // // button13 // this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button13.BackColor = System.Drawing.SystemColors.Control; this.button13.Location = new System.Drawing.Point(941, 34); this.button13.Name = "button13"; this.button13.Size = new System.Drawing.Size(128, 26); this.button13.TabIndex = 12; this.button13.UseVisualStyleBackColor = false; this.button13.Click += new System.EventHandler(this.button13_Click); // // dataGridView4 // this.dataGridView4.AllowUserToAddRows = false; this.dataGridView4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView4.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView4.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F); dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView4.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; this.dataGridView4.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView4.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, this.Column2, this.Column5}); this.dataGridView4.Location = new System.Drawing.Point(228, 20); this.dataGridView4.Name = "dataGridView4"; this.dataGridView4.ReadOnly = true; this.dataGridView4.RowHeadersVisible = false; this.dataGridView4.RowTemplate.Height = 23; this.dataGridView4.Size = new System.Drawing.Size(693, 133); this.dataGridView4.TabIndex = 15; // // Column1 // dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column1.DefaultCellStyle = dataGridViewCellStyle6; this.Column1.Name = "Column1"; this.Column1.ReadOnly = true; // // Column2 // dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column2.DefaultCellStyle = dataGridViewCellStyle7; this.Column2.Name = "Column2"; this.Column2.ReadOnly = true; // // Column5 // dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column5.DefaultCellStyle = dataGridViewCellStyle8; this.Column5.Name = "Column5"; this.Column5.ReadOnly = true; // // button12 // this.button12.BackColor = System.Drawing.SystemColors.Control; this.button12.Location = new System.Drawing.Point(145, 20); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(52, 26); this.button12.TabIndex = 13; this.button12.UseVisualStyleBackColor = false; this.button12.Click += new System.EventHandler(this.button12_Click); // // button11 // this.button11.BackColor = System.Drawing.SystemColors.Control; this.button11.Location = new System.Drawing.Point(15, 20); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(63, 26); this.button11.TabIndex = 12; this.button11.UseVisualStyleBackColor = false; this.button11.Click += new System.EventHandler(this.button11_Click); // // groupBox3 // this.groupBox3.Controls.Add(this.radioButton1); this.groupBox3.Controls.Add(this.radioButton3); this.groupBox3.Controls.Add(this.radioButton2); this.groupBox3.Controls.Add(this.button6); this.groupBox3.Controls.Add(this.button5); this.groupBox3.Controls.Add(this.button3); this.groupBox3.Location = new System.Drawing.Point(155, 366); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(360, 69); this.groupBox3.TabIndex = 26; this.groupBox3.TabStop = false; // // radioButton1 // this.radioButton1.AutoSize = true; this.radioButton1.Location = new System.Drawing.Point(13, 20); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(14, 13); this.radioButton1.TabIndex = 6; this.radioButton1.TabStop = true; this.radioButton1.UseVisualStyleBackColor = true; this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); // // radioButton3 // this.radioButton3.AutoSize = true; this.radioButton3.Location = new System.Drawing.Point(152, 20); this.radioButton3.Name = "radioButton3"; this.radioButton3.Size = new System.Drawing.Size(14, 13); this.radioButton3.TabIndex = 5; this.radioButton3.TabStop = true; this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged); // // radioButton2 // this.radioButton2.AutoSize = true; this.radioButton2.Location = new System.Drawing.Point(87, 20); this.radioButton2.Name = "radioButton2"; this.radioButton2.Size = new System.Drawing.Size(14, 13); this.radioButton2.TabIndex = 4; this.radioButton2.TabStop = true; this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); // // button6 // this.button6.Location = new System.Drawing.Point(236, 42); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(97, 23); this.button6.TabIndex = 3; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // // button5 // this.button5.Location = new System.Drawing.Point(125, 42); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(97, 23); this.button5.TabIndex = 2; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button3 // this.button3.Location = new System.Drawing.Point(14, 42); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(97, 23); this.button3.TabIndex = 0; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); this.button3.LostFocus += new System.EventHandler(this.button3_LostFocus); // // groupBox4 // this.groupBox4.Controls.Add(this.numericUpDown4); this.groupBox4.Controls.Add(this.label4); this.groupBox4.Controls.Add(this.panel1); this.groupBox4.Controls.Add(this.label3); this.groupBox4.Controls.Add(this.numericUpDown3); this.groupBox4.Controls.Add(this.label2); this.groupBox4.Controls.Add(this.numericUpDown2); this.groupBox4.Controls.Add(this.label1); this.groupBox4.Location = new System.Drawing.Point(155, 441); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(360, 76); this.groupBox4.TabIndex = 27; this.groupBox4.TabStop = false; // // numericUpDown4 // this.numericUpDown4.Location = new System.Drawing.Point(87, 45); this.numericUpDown4.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numericUpDown4.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown4.Name = "numericUpDown4"; this.numericUpDown4.Size = new System.Drawing.Size(55, 21); this.numericUpDown4.TabIndex = 7; this.numericUpDown4.Value = new decimal(new int[] { 20, 0, 0, 0}); this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(19, 49); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(0, 12); this.label4.TabIndex = 6; // // panel1 // this.panel1.BackColor = System.Drawing.Color.Lime; this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel1.Location = new System.Drawing.Point(265, 17); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(76, 20); this.panel1.TabIndex = 5; this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged); this.panel1.Click += new System.EventHandler(this.panel1_Click); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(223, 21); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(0, 12); this.label3.TabIndex = 4; // // numericUpDown3 // this.numericUpDown3.Location = new System.Drawing.Point(158, 17); this.numericUpDown3.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numericUpDown3.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown3.Name = "numericUpDown3"; this.numericUpDown3.Size = new System.Drawing.Size(55, 21); this.numericUpDown3.TabIndex = 3; this.numericUpDown3.Value = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(124, 21); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(0, 12); this.label2.TabIndex = 2; // // numericUpDown2 // this.numericUpDown2.Location = new System.Drawing.Point(56, 17); this.numericUpDown2.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numericUpDown2.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Size = new System.Drawing.Size(55, 21); this.numericUpDown2.TabIndex = 1; this.numericUpDown2.Value = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(19, 21); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 0; // // groupBox5 // this.groupBox5.Controls.Add(this.dataGridView1); this.groupBox5.Location = new System.Drawing.Point(155, 513); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(360, 129); this.groupBox5.TabIndex = 28; this.groupBox5.TabStop = false; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle9.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle9; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn9, this.dataGridViewTextBoxColumn10}); this.dataGridView1.Location = new System.Drawing.Point(6, 20); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(348, 101); this.dataGridView1.TabIndex = 4; this.dataGridView1.SelectionChanged += new System.EventHandler(this.dataGridView1_SelectionChanged); // // dataGridViewTextBoxColumn9 // dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn9.DefaultCellStyle = dataGridViewCellStyle10; this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9"; this.dataGridViewTextBoxColumn9.ReadOnly = true; this.dataGridViewTextBoxColumn9.Width = 103; // // dataGridViewTextBoxColumn10 // dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.dataGridViewTextBoxColumn10.DefaultCellStyle = dataGridViewCellStyle11; this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10"; this.dataGridViewTextBoxColumn10.ReadOnly = true; this.dataGridViewTextBoxColumn10.Width = 242; // // MetallographicMethodDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1107, 933); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox8); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.KeyPreview = true; this.Name = "MetallographicMethodDialog"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing); this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData); this.Load += new System.EventHandler(this.GrainSizeAnalysisMethodOfClasticRockDialog_Load); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MetallographicMethodDialog_KeyDown); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MetallographicMethodDialog_KeyUp); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox7, 0); this.Controls.SetChildIndex(this.groupBox8, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.Controls.SetChildIndex(this.groupBox4, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); this.groupBox8.ResumeLayout(false); this.groupBox8.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).EndInit(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); this.groupBox5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } private void panel1_Click(object sender, EventArgs e) { this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor); this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed)); this.colorsForm1.ShowDialog(); } private void panel1Changed(object sender, EventArgs e) { this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor(); this.colorsForm1.Close(); } /// /// ListView图片选择改变事件 /// /// /// private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected) { this.unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); this.commonControlButtons.Visible = true; existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView(); this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat(); rectangleFs.Clear(); //二值化集成4 binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone()); if (bcOriginChecked()) { this.documentWorkspace.PhaseModels[0].choise = false; this.documentWorkspace.PhaseModels[1].choise = false; this.documentWorkspace.Refresh(); } rectangleFsArr = new RectangleF[] { }; rectangleFs.Clear(); pointFsLine = new PointF []{ }; this.dataGridView1.Rows.Clear(); selectLineIndex = -1; rectangleFsLines.Clear(); } } /// /// 画布绘制 /// /// /// 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 AdjustableArrowCap lineCap = new AdjustableArrowCap(6, 6, true); /// /// 绘制 /// /// private void Draw(Graphics graphics) { graphics.SmoothingMode = SmoothingMode.AntiAlias; Pen linePen = new Pen(this.panel1.BackColor,Convert.ToInt32(this.numericUpDown3.Value)); Pen linePen1 = new Pen(this.panel1.BackColor, Convert.ToInt32(this.numericUpDown3.Value)); linePen.CustomStartCap = lineCap; linePen.CustomEndCap = lineCap; int drawIndex = -1; foreach (var item in rectangleFs) { drawIndex++; if (selectLineIndex != -1 && drawIndex == this.selectLineIndex) { linePen.DashStyle = DashStyle.DashDot; } else linePen.DashStyle = DashStyle.Solid; graphics.DrawLine(linePen, new PointF(item.Key[0].X + 6, item.Key[0].Y + 6), new PointF(item.Key[1].X + 6, item.Key[1].Y + 6)); PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6); PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6); double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(startPoint.X) + 6, Convert.ToInt32(startPoint.Y) + 6), new Point(Convert.ToInt32(endPoint.X) + 6, Convert.ToInt32(endPoint.Y) + 6), Convert.ToInt32(this.numericUpDown1.Value)) * unitLength; //计算需要旋转的角度 double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y)); if (item.Value == 0) { // // 绘制两侧竖线 // double sAngle1 = 270 + angle; double eAngle1 = 90 + angle; Point point3 = new Point(); Point point4 = new Point(); Point point5 = new Point(); Point point6 = new Point(); if (sAngle1 is double.NaN && eAngle1 is double.NaN) { } else { point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1); point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1); point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1); point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown2.Value / 2)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1); } graphics.DrawLine(linePen1, point3, point4); graphics.DrawLine(linePen1, point5, point6); SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value))); PointF cen1 = new PointF((point3.X + point5.X) / 2, (point3.Y + point5.Y) / 2); PointF cen2 = new PointF((point4.X + point6.X) / 2, (point4.Y + point6.Y) / 2); PointF drawP1 = new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2); PointF drawP2 = new PointF(cen2.X - sizeF.Width / 2, cen2.Y - sizeF.Height / 2); PointF drawP3; if (angle < 90) drawP3 = drawP1; else drawP3 = drawP2; Matrix mtxSave = graphics.Transform; Matrix matrix = graphics.Transform; // 画布旋转 if (angle < 90) { matrix.RotateAt((float)angle, new PointF(cen1.X, cen1.Y)); graphics.Transform = matrix; } else { angle = BasicCalculationHelper.Angle(endPoint, startPoint, new PointF(endPoint.X, startPoint.Y)); matrix.RotateAt((float)angle, new PointF(cen2.X, cen2.Y)); graphics.Transform = matrix; } graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), drawP3); //还原为原始旋转矩阵 graphics.Transform = mtxSave; matrix.Dispose(); } else if(item.Value == 1) { graphics.DrawLine(linePen1, new PointF(startPoint.X, startPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2)) , new PointF(startPoint.X, startPoint.Y + Convert.ToInt32(this.numericUpDown2.Value / 2))); graphics.DrawLine(linePen1, new PointF(endPoint.X, endPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2)) , new PointF(endPoint.X, endPoint.Y + Convert.ToInt32(this.numericUpDown2.Value / 2))); SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value))); PointF cen1 = new PointF((startPoint.X + endPoint.X) / 2, startPoint.Y - Convert.ToInt32(this.numericUpDown2.Value / 2)); graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2)); } else if (item.Value == 2) { graphics.DrawLine(linePen1, new PointF(startPoint.X - Convert.ToInt32(this.numericUpDown2.Value / 2), startPoint.Y) , new PointF(startPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), startPoint.Y)); graphics.DrawLine(linePen1, new PointF(endPoint.X - Convert.ToInt32(this.numericUpDown2.Value / 2), endPoint.Y) , new PointF(endPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), endPoint.Y)); SizeF sizeF = graphics.MeasureString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value))); PointF cen1 = new PointF(startPoint.X + Convert.ToInt32(this.numericUpDown2.Value / 2), (startPoint.Y + endPoint.Y) / 2); Matrix mtxSave = graphics.Transform; Matrix matrix = graphics.Transform; matrix.RotateAt((float)90, new PointF(cen1.X, cen1.Y)); graphics.Transform = matrix; graphics.DrawString(Math.Round(length, Convert.ToInt32(this.numericUpDown1.Value)) + "μm", new Font("宋体", Convert.ToInt32(this.numericUpDown4.Value)), new SolidBrush(Color.Black), new PointF(cen1.X - sizeF.Width / 2, cen1.Y - sizeF.Height / 2)); //还原为原始旋转矩阵 graphics.Transform = mtxSave; matrix.Dispose(); } if (selectLineIndex != -1 && drawIndex == this.selectLineIndex) { graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[0]); graphics.FillRectangle(new SolidBrush(Color.Black), item.Key[1]); } } System.Drawing.Drawing2D.GraphicsPath myGraphicsPath; Region myRegion; int selectIndex = -1; foreach (var item in rectangleFsLines) { selectIndex++; myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); myRegion = new Region(); myGraphicsPath.Reset(); myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] }); myRegion.MakeEmpty(); myRegion.Union(myGraphicsPath); //graphics.FillRegion(new SolidBrush(Color.Black), myRegion); } linePen.Dispose(); linePen1.Dispose(); } /// /// 鼠标按下 /// /// /// private void OnMouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Left) { // 换算后的点 PointF point1 = documentWorkspace.GetScalePoint(e.Location); selectLineIndex = -1; if (mouseStatus == 0) { canAdd = true; rectangleFsArr = new RectangleF[2]; pointFsLine = new PointF[4]; rectangleFsArr[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12); rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12); Dictionary rectangleFs1 = new Dictionary(); foreach (var item in rectangleFs) { rectangleFs1.Add(item.Key, item.Value); } rectangleFs = new Dictionary(); rectangleFs = rectangleFs1; if (lineStyle == 0) rectangleFs.Add(rectangleFsArr, 0); else if (lineStyle == 1) rectangleFs.Add(rectangleFsArr, 1); else if (lineStyle == 2) rectangleFs.Add(rectangleFsArr, 2); if (lineStyle == 0) rectangleFsLines.Add(pointFsLine, 0); else if (lineStyle == 1) rectangleFsLines.Add(pointFsLine, 1); else if (lineStyle == 2) rectangleFsLines.Add(pointFsLine, 2); } if (mouseStatus == 2) { System.Drawing.Drawing2D.GraphicsPath myGraphicsPath; Region myRegion; int selectIndex = -1; foreach (var item in rectangleFsLines) { selectIndex++; myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); myRegion = new Region(); myGraphicsPath.Reset(); myGraphicsPath.AddPolygon(new PointF[] { item.Key[0], item.Key[1], item.Key[2], item.Key[3] }); myRegion.MakeEmpty(); myRegion.Union(myGraphicsPath); //返回判断点是否在多边形里 //RectangleF rectangleF = myRegion.GetBounds(rag) bool myPoint = myRegion.IsVisible(point1); if (myPoint) { selectLineIndex = selectIndex; break; } } if (selectLineIndex == -1) { selectIndex = -1; foreach (var item in rectangleFs) { selectIndex++; if (item.Key[0].Contains(point1)) { selectLineIndex = selectIndex; break; } else if (item.Key[1].Contains(point1)) { selectLineIndex = selectIndex; break; } } } //else // { // if(this.dataGridView1.Rows.Count > selectLineIndex) // this.dataGridView1.Rows[selectLineIndex].Selected = true; //} } if (mouseStatus == 2) { int indexRectangleFs = -1; foreach (var item in rectangleFs) { indexRectangleFs++; System.Drawing.Drawing2D.GraphicsPath myGraphicsPath; Region myRegion; int indexRectangleFsLines = -1; bool myPoint = false; foreach (var item1 in rectangleFsLines) { indexRectangleFsLines++; if (indexRectangleFs == indexRectangleFsLines) { myGraphicsPath = new System.Drawing.Drawing2D.GraphicsPath(); myRegion = new Region(); myGraphicsPath.Reset(); myGraphicsPath.AddPolygon(new PointF[] { item1.Key[0], item1.Key[1], item1.Key[2], item1.Key[3] }); myRegion.MakeEmpty(); myRegion.Union(myGraphicsPath); //返回判断点是否在多边形里 myPoint = myRegion.IsVisible(point1); if (myPoint) { break; } } } if (item.Key[0].Contains(point1)) { movePointStart = point1; movePointIndex = 0; canMove = true; } else if (item.Key[1].Contains(point1)) { movePointStart = point1; movePointIndex = 1; canMove = true; } else if (myPoint) { movePointStart = point1; movePointIndex = 2; canMove = true; } } } } } PointF point1; /// /// 移动 /// /// /// private void onMouseMove(object sender, MouseEventArgs e) { // 换算后的点 this.point1 = documentWorkspace.GetScalePoint(e.Location); // 全方位线 if (lineStyle == 0) { if (mouseStatus == 0 && canAdd) { rectangleFsArr[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12); PointF startPoint = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + 6); PointF endPoint = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + 6); //计算需要旋转的角度 double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y)); double sAngle1 = 270 + angle; double eAngle1 = 90 + angle; Point point3 = new Point(); Point point4 = new Point(); Point point5 = new Point(); Point point6 = new Point(); if (sAngle1 is double.NaN && eAngle1 is double.NaN) { } else { point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1); point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1); point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1); point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1); } pointFsLine[0] = point3; pointFsLine[1] = point4; pointFsLine[2] = point6; pointFsLine[3] = point5; } } // 水平线 else if (lineStyle == 1) { if (mouseStatus == 0 && canAdd) { rectangleFsArr[1] = new RectangleF(point1.X - 6, rectangleFsArr[0].Y, 12, 12); pointFsLine[0] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y + (float)(this.numericUpDown3.Value / 2) + 9); pointFsLine[1] = new PointF(rectangleFsArr[0].X + 6, rectangleFsArr[0].Y - (float)(this.numericUpDown3.Value / 2) + 3); pointFsLine[3] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y + (float)(this.numericUpDown3.Value / 2) + 9); pointFsLine[2] = new PointF(rectangleFsArr[1].X + 6, rectangleFsArr[1].Y - (float)(this.numericUpDown3.Value / 2) + 3); } } // 垂直线 else if (lineStyle == 2) { if (mouseStatus == 0 && canAdd) { rectangleFsArr[1] = new RectangleF(rectangleFsArr[0].X, point1.Y - 6, 12, 12); pointFsLine[0] = new PointF(rectangleFsArr[0].X + (float)(this.numericUpDown3.Value / 2) + 9, rectangleFsArr[0].Y + 6); pointFsLine[1] = new PointF(rectangleFsArr[0].X - (float)(this.numericUpDown3.Value / 2) + 3, rectangleFsArr[0].Y + 6); pointFsLine[3] = new PointF(rectangleFsArr[1].X + (float)(this.numericUpDown3.Value / 2) + 9, rectangleFsArr[1].Y + 6); pointFsLine[2] = new PointF(rectangleFsArr[1].X - (float)(this.numericUpDown3.Value / 2) + 3, rectangleFsArr[1].Y + 6); } } if (this.mouseStatus == 2 && canMove) { if (this.selectLineIndex != -1) { int indexRectangleFs = -1; foreach (var item in rectangleFs) { indexRectangleFs++; if (selectLineIndex == indexRectangleFs) { // 全方位线 if (item.Value == 0) { // 线条起始点移动 if (movePointIndex == 0) { item.Key[0] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12); } else if (movePointIndex == 1) { item.Key[1] = new RectangleF(point1.X - 6, point1.Y - 6, 12, 12); } else if (movePointIndex == 2) { item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); movePointStart = point1; } PointF startPoint = new PointF(item.Key[0].X + 6, item.Key[0].Y + 6); PointF endPoint = new PointF(item.Key[1].X + 6, item.Key[1].Y + 6); //计算需要旋转的角度 double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y)); double sAngle1 = 270 + angle; double eAngle1 = 90 + angle; Point point3 = new Point(); Point point4 = new Point(); Point point5 = new Point(); Point point6 = new Point(); if (sAngle1 is double.NaN && eAngle1 is double.NaN) { } else { point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1); point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1); point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1); point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1); } int indexRectangleFsLines = -1; foreach (var item1 in rectangleFsLines) { indexRectangleFsLines++; if (indexRectangleFsLines == indexRectangleFs) { item1.Key[0] = point3; item1.Key[1] = point4; item1.Key[2] = point6; item1.Key[3] = point5; } } } // 水平线 else if (item.Value == 1) { // 线条起始点移动 if (movePointIndex == 0) { item.Key[0] = new RectangleF(point1.X - 6, item.Key[1].Y, 12, 12); } else if (movePointIndex == 1) { item.Key[1] = new RectangleF(point1.X - 6, item.Key[0].Y, 12, 12); } else if (movePointIndex == 2) { item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); movePointStart = point1; } int selectIndex = -1; foreach (var item1 in rectangleFsLines) { selectIndex++; if (selectIndex == selectLineIndex) { item1.Key[0] = new PointF(item.Key[0].X + 6, item.Key[0].Y + (float)(this.numericUpDown3.Value / 2) + 9); item1.Key[1] = new PointF(item.Key[0].X + 6, item.Key[0].Y - (float)(this.numericUpDown3.Value / 2) + 3); item1.Key[3] = new PointF(item.Key[1].X + 6, item.Key[1].Y + (float)(this.numericUpDown3.Value / 2) + 9); item1.Key[2] = new PointF(item.Key[1].X + 6, item.Key[1].Y - (float)(this.numericUpDown3.Value / 2) + 3); } } } // 垂直线 else if (item.Value == 2) { // 线条起始点移动 if (movePointIndex == 0) { item.Key[0] = new RectangleF(item.Key[1].X, point1.Y - 6, 12, 12); } else if (movePointIndex == 1) { item.Key[1] = new RectangleF(item.Key[0].X, point1.Y - 6, 12, 12); } else if (movePointIndex == 2) { item.Key[0].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); item.Key[1].Offset(point1.X - movePointStart.X, point1.Y - movePointStart.Y); movePointStart = point1; } int selectIndex = -1; foreach (var item1 in rectangleFsLines) { selectIndex++; if (selectIndex == selectLineIndex) { item1.Key[0] = new PointF(item.Key[0].X + (float)(this.numericUpDown3.Value / 2) + 9, item.Key[0].Y + 6); item1.Key[1] = new PointF(item.Key[0].X - (float)(this.numericUpDown3.Value / 2) + 3, item.Key[0].Y + 6); item1.Key[3] = new PointF(item.Key[1].X + (float)(this.numericUpDown3.Value / 2) + 9, item.Key[1].Y + 6); item1.Key[2] = new PointF(item.Key[1].X - (float)(this.numericUpDown3.Value / 2) + 3, item.Key[1].Y + 6); } } } } } } } this.documentWorkspace.Refresh(); } private void MouseMoveRefRec() { foreach (var item in rectangleFsLines) { PointF startPoint = new PointF((item.Key[0].X + item.Key[1].X) / 2, (item.Key[0].Y + item.Key[1].Y) / 2); PointF endPoint = new PointF((item.Key[2].X + item.Key[3].X) / 2, (item.Key[2].Y + item.Key[3].Y) / 2); // 全方位线 if (item.Value == 0) { if (item.Key.Length > 3) { //计算需要旋转的角度 double angle = BasicCalculationHelper.Angle(startPoint, endPoint, new PointF(startPoint.X, endPoint.Y)); double sAngle1 = 270 + angle; double eAngle1 = 90 + angle; Point point3 = new Point(); Point point4 = new Point(); Point point5 = new Point(); Point point6 = new Point(); if (sAngle1 is double.NaN && eAngle1 is double.NaN) { } else { point3 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), sAngle1); point4 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(startPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(startPoint.Y)), new Point(Convert.ToInt32(startPoint.X), Convert.ToInt32(startPoint.Y)), eAngle1); point5 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), sAngle1); point6 = BasicCalculationHelper.GetAnglePoint(new Point((Convert.ToInt32(endPoint.X) + Convert.ToInt32(this.numericUpDown3.Value / 2 + 3)), Convert.ToInt32(endPoint.Y)), new Point(Convert.ToInt32(endPoint.X), Convert.ToInt32(endPoint.Y)), eAngle1); } item.Key[0] = point3; item.Key[1] = point4; item.Key[2] = point6; item.Key[3] = point5; } } // 水平线 else if (item.Value == 1) { if (item.Key.Length > 3) { item.Key[0] = new PointF(startPoint.X, startPoint.Y + (float)(this.numericUpDown3.Value / 2) + 3); item.Key[1] = new PointF(startPoint.X, startPoint.Y - (float)(this.numericUpDown3.Value / 2) - 3); item.Key[3] = new PointF(endPoint.X, endPoint.Y + (float)(this.numericUpDown3.Value / 2) + 3); item.Key[2] = new PointF(endPoint.X, endPoint.Y - (float)(this.numericUpDown3.Value / 2) - 3); } } // 垂直线 else if (item.Value == 2) { if (item.Key.Length > 3) { item.Key[0] = new PointF(startPoint.X + (float)(this.numericUpDown3.Value / 2) + 3, startPoint.Y); item.Key[1] = new PointF(startPoint.X - (float)(this.numericUpDown3.Value / 2) - 3, startPoint.Y); item.Key[3] = new PointF(endPoint.X + (float)(this.numericUpDown3.Value / 2) + 3, endPoint.Y); item.Key[2] = new PointF(endPoint.X - (float)(this.numericUpDown3.Value / 2) - 3, endPoint.Y); } } } this.documentWorkspace.Refresh(); } /// /// 鼠标抬起 /// /// /// private void OnMouseUp(object sender, MouseEventArgs e) { canAdd = false; canMove = false; movePointIndex = -1; RefrashData(); if(mouseStatus == 2) SelectDataRow(); } private void SelectDataRow() { if (this.dataGridView1.Rows.Count > selectLineIndex && selectLineIndex >= 0) this.dataGridView1.Rows[selectLineIndex].Selected = true; if (dataGridView1.SelectedRows.Count > 0) selectLineIndex = dataGridView1.SelectedRows[0].Index; } /// /// 添加测量线 /// /// /// private void button3_Click(object sender, EventArgs e) { this.mouseStatus = 0; this.selectLineIndex = -1; } private void button3_LostFocus(object sender, EventArgs e) { this.mouseStatus = -1; } private void button5_LostFocus(object sender, EventArgs e) { this.mouseStatus = -1; } private void button6_LostFocus(object sender, EventArgs e) { this.mouseStatus = -1; } /// /// 删除测量线 /// /// /// private void button5_Click(object sender, EventArgs e) { this.mouseStatus = 1; if (this.mouseStatus == 1) { if (selectLineIndex == -1) { MessageBox.Show("请先选择要删除的测量线!"); return; } int deleteIndex = -1; foreach (var item in rectangleFs) { deleteIndex++; if (deleteIndex == selectLineIndex) { rectangleFs.Remove(item.Key); break; } } deleteIndex = -1; foreach (var item in rectangleFsLines) { deleteIndex++; if (deleteIndex == selectLineIndex) { rectangleFsLines.Remove(item.Key); break; } } selectLineIndex--; if (selectLineIndex < -1) selectLineIndex = -1; if (rectangleFs.Count == 0) this.dataGridView1.Rows.Clear(); RefrashData(); if (mouseStatus == 2) SelectDataRow(); this.documentWorkspace.Refresh(); } } /// /// 选择测量线 /// /// /// private void button6_Click(object sender, EventArgs e) { this.mouseStatus = 2; this.selectLineIndex = -1; } /// /// 全方位线 /// /// /// private void radioButton1_CheckedChanged(object sender, EventArgs e) { this.lineStyle = 0; this.mouseStatus = 0; this.button3.Focus(); } /// /// 水平线 /// /// /// private void radioButton2_CheckedChanged(object sender, EventArgs e) { this.lineStyle = 1; this.mouseStatus = 0; this.button3.Focus(); } /// /// 垂直线 /// /// /// private void radioButton3_CheckedChanged(object sender, EventArgs e) { this.lineStyle = 2; this.mouseStatus = 0; this.button3.Focus(); } /// /// 线长 /// /// /// private void numericUpDown2_ValueChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } /// /// 线宽 /// /// /// private void numericUpDown3_ValueChanged(object sender, EventArgs e) { MouseMoveRefRec(); } /// /// 颜色 /// /// /// private void panel1_BackColorChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } /// /// Ctrl键按下(平行线) /// /// /// private void MetallographicMethodDialog_KeyDown(object sender, KeyEventArgs e) { if (e.Control) { this.radioButton2.Checked = true; } else if (e.Alt) { this.radioButton3.Checked = true; } else if (e.KeyData == Keys.Delete) { //if(this.mouseStatus == 1) //{ if (selectLineIndex == -1) { MessageBox.Show("请先选择要删除的测量线!"); return; } int deleteIndex = -1; foreach (var item in rectangleFs) { deleteIndex++; if (deleteIndex == selectLineIndex) { rectangleFs.Remove(item.Key); break; } } deleteIndex = -1; foreach (var item in rectangleFsLines) { deleteIndex++; if (deleteIndex == selectLineIndex) { rectangleFsLines.Remove(item.Key); break; } } selectLineIndex--; if (selectLineIndex < -1) selectLineIndex = -1; if (rectangleFs.Count == 0) this.dataGridView1.Rows.Clear(); RefrashData(); if (mouseStatus == 2) SelectDataRow(); this.documentWorkspace.Refresh(); //} } } private void MetallographicMethodDialog_KeyUp(object sender, KeyEventArgs e) { if(e.KeyData == Keys.ControlKey || e.KeyData == Keys.Menu) { this.radioButton1.Checked = true; } } /// /// 小数改变 /// /// /// private void numericUpDown1_ValueChanged(object sender, EventArgs e) { RefrashData(); RefreshDataGridView4(); RefreshResultStatistics(); this.documentWorkspace.Refresh(); } /// /// 保存结果 /// /// /// private void button2_Click(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!"); return; } if (this.dataGridView1.Rows.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Noresultdata.text")+"!"); return; } string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName(); string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index]; DataTable dataTable = new DataTable(); bool replace = false; int add = 0; foreach (ListViewItem item in this.listView2.Items) { if (item.Tag.Equals(tag)) { add++; DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { replace = true; this.listView2.Items.Remove(item); } break; } } if (replace || this.listView2.Items.Count == 0 || add == 0) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SubItems[0].Text = imgName; listViewItem.Tag = "" + tag; if (this.listView2.Items.Count == 0) this.listView2.Items.Add(listViewItem); else this.listView2.Items.Insert(0, listViewItem); this.dataGridView4.Rows.Clear(); for (int i = 0; i < this.dataTable.Rows.Count; i++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = tag; foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); } dgvr.Cells[0].Value = imgName; dgvr.Cells[1].Value = this.dataTable.Rows[i][0]; dgvr.Cells[2].Value = Math.Round(Convert.ToDouble(this.dataTable.Rows[i][1]), Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView4.Rows.Add(dgvr); } dataTable.TableName = tag; foreach (System.Data.DataTable dataTable1 in dataTables) { if (dataTable1.TableName.Equals(dataTable.TableName)) { dataTables.Remove(dataTable1); break; } } foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dataTable.Columns.Add(c.HeaderText); } for (int i = 0; i < this.dataTable.Rows.Count; i++) { DataRow dataRow = dataTable.NewRow(); dataRow[0] = imgName; dataRow[1] = this.dataTable.Rows[i][0]; dataRow[2] = this.dataTable.Rows[i][1]; dataTable.Rows.Add(dataRow); } this.dataTables.Add(dataTable); if (this.allShow) AllShow(); this.listView2.Items[0].Selected = true; if (this.documentWorkspace.PhaseModels[0].mat != null) { //保存处理后的图片 double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数 List tempBit = new List(); Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); originalBit.Tag = pantographRatio; tempBit.Add(originalBit); Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat); Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat); Graphics graphics = Graphics.FromImage(newBit); graphics.DrawImage(processedBit, new PointF(0, 0)); Draw(graphics); newBit.Tag = pantographRatio; tempBit.Add(newBit); if (bitDic.ContainsKey(tag)) bitDic[tag] = tempBit; else bitDic.Add(tag, tempBit); } //拼接中间数据 List> dataList = new List>(); List columnName = new List(); columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text")); columnName.Add(PdnResources.GetString("Menu.Linelength.text")+"(μm)"); columnName.Add(PdnResources.GetString("Menu.Startingcoordinates.text")); columnName.Add(PdnResources.GetString("Menu.Endpointcoordinates.Text")); dataList.Add(columnName); int no = 0; foreach (var item in rectangleFs) { double length = BasicCalculationHelper.GetDistance(new Point(Convert.ToInt32(item.Key[0].X) + 6, Convert.ToInt32(item.Key[0].Y) + 6), new Point(Convert.ToInt32(item.Key[1].X) + 6, Convert.ToInt32(item.Key[1].Y) + 6), 10) * unitLength; no++; List strList = new List(); strList.Add("" + no); strList.Add("" + length); strList.Add("(" + (Convert.ToInt32(item.Key[0].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[0].Y) + 6).ToString() + ")"); strList.Add("(" + (Convert.ToInt32(item.Key[1].X) + 6).ToString() + "," + (Convert.ToInt32(item.Key[1].Y) + 6).ToString() + ")"); dataList.Add(strList); } bool isExist = false;//是否已存在进行替换 int modelIndex = -1;//要替换的下标 for (int j = 0; j < tempDataModel.Count; j++) { if (tempDataModel[j].tagName.Equals(tag)) { isExist = true; modelIndex = j; break; } } if (isExist && modelIndex > -1) tempDataModel[modelIndex].dataList = dataList; else { ExportProjectModel newModel = new ExportProjectModel(); newModel.tagName = tag; newModel.picName = imgName; newModel.dataList = dataList; tempDataModel.Add(newModel); } } } /// /// 取消全部显示 /// /// /// private void button16_Click(object sender, EventArgs e) { this.button11.Visible = true; this.button16.Visible = false; this.button11.Focus(); this.allShow = false; List dataTables1 = new List(); foreach (var dataTable in this.dataTables) { if (this.listView2.SelectedItems.Count > 0) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (item.Tag.Equals(dataTable.TableName)) dataTables1.Add(dataTable); } } else { if (this.listView2.Items[0].Tag.Equals(dataTable.TableName)) dataTables1.Add(dataTable); } } this.dataGridView4.Rows.Clear(); foreach (System.Data.DataTable item in dataTables1) { if (dataTables.Count > 0) { for (int r = 0; r < item.Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = item.TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < item.Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(item.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString(); else dgvr.Cells[c].Value = item.Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } if(this.listView2.SelectedItems.Count == 0) { if (this.listView2.Items.Count > 0) this.listView2.Items[0].Selected = true; } RefreshResultStatistics(); } /// /// 全部显示 /// /// /// 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; AllShow(); RefreshResultStatistics(); } else { MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!"); } } private void AllShow() { this.dataGridView4.Rows.Clear(); for (int i = this.dataTables.Count - 1; i >= 0; i--) { for (int r = 0; r < this.dataTables[i].Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[i].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[i].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString(); else dgvr.Cells[c].Value = this.dataTables[i].Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } /// /// 切换分析结果 /// /// /// private void listView2_SelectedIndexChanged(object sender, EventArgs e) { if (!this.allShow) { if (this.listView2.SelectedItems.Count > 0) { List dataTableIndex = new List(); for (int i = 0; i < this.dataTables.Count; i++) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (this.dataTables[i].TableName.Equals(item.Tag)) dataTableIndex.Add(i); } } if (this.dataTables.Count == 0) return; this.dataGridView4.Rows.Clear(); foreach (int item in dataTableIndex) { if (this.dataTables[item].Rows.Count > 0) { for (int r = 0; r < this.dataTables[item].Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[item].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[item].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString(); else dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } } RefreshResultStatistics(); } /// /// 刷新结果统计数据 /// private void RefreshResultStatistics() { if(allShow) { this.dataGridView2.Rows.Clear(); // 渗氮层总深度 double totalDepth = 0; foreach (ListViewItem listViewItem in this.listView2.Items) { for (int i = 0; i < this.dataTables.Count; i++) { if (listViewItem.Tag.Equals(dataTables[i].TableName)) { for (int r = 0; r < dataTables[i].Rows.Count; r++) { totalDepth += Convert.ToDouble(dataTables[i].Rows[r][2]); } } } } DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); } dgvr.Cells[0].Value = this.listView2.Items.Count; dgvr.Cells[1].Value = Math.Round(totalDepth, Convert.ToInt32(this.numericUpDown1.Value)); dgvr.Cells[2].Value = Math.Round(totalDepth / this.listView2.Items.Count, Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView2.Rows.Add(dgvr); } else { if (this.listView2.SelectedItems.Count == 0) return; this.dataGridView2.Rows.Clear(); // 渗氮层总深度 double totalDepth = 0; foreach (ListViewItem listViewItem in this.listView2.SelectedItems) { for (int i = 0; i < this.dataTables.Count; i++) { if (listViewItem.Tag.Equals(dataTables[i].TableName)) { for (int r = 0; r < dataTables[i].Rows.Count; r++) { totalDepth += Convert.ToDouble(dataTables[i].Rows[r][2]); } } } } DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); } dgvr.Cells[0].Value = this.listView2.SelectedItems.Count; dgvr.Cells[1].Value = Math.Round(totalDepth, Convert.ToInt32(this.numericUpDown1.Value)); dgvr.Cells[2].Value = Math.Round(totalDepth / this.listView2.SelectedItems.Count, Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView2.Rows.Add(dgvr); } } /// /// 未选择分析结果 /// /// /// private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (!this.allShow) { if (this.listView2.SelectedItems.Count == 0) { this.dataGridView2.Rows.Clear(); this.dataGridView4.Rows.Clear(); } } } /// /// 分析结果删除 /// /// /// 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) { List detaleName = new List(); int selectIndex = this.listView2.SelectedItems[0].Index; foreach (ListViewItem item in this.listView2.SelectedItems) { detaleName.Add(item.Tag.ToString()); this.listView2.Items.Remove(item); } foreach (string item in detaleName) { foreach (var dataTable in this.dataTables) { if (dataTable.TableName.Equals(item)) { this.dataTables.Remove(dataTable); break; } } if (bitDic.ContainsKey(item)) bitDic.Remove(item); } if (this.listView2.Items.Count == 0) { this.dataGridView2.Rows.Clear(); this.dataGridView4.Rows.Clear(); } else { if (selectIndex == 0) this.listView2.Items[0].Selected = true; else this.listView2.Items[selectIndex - 1].Selected = true; RefreshDataGridView4(); } } } else { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!"); } } else { MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!"); } } /// /// 刷新分析结果数据 /// private void RefreshDataGridView4() { if (!this.allShow) { if (this.listView2.SelectedItems.Count > 0) { List dataTableIndex = new List(); for (int i = 0; i < this.dataTables.Count; i++) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[0].Tag)) dataTableIndex.Add(i); } } if (this.dataTables.Count == 0) return; this.dataGridView4.Rows.Clear(); foreach (int item in dataTableIndex) { if (this.dataTables[item].Rows.Count > 0) { for (int r = 0; r < this.dataTables[item].Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[item].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[item].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString(); else dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } } else { this.dataGridView4.Rows.Clear(); DataTable dataTable = new DataTable(); 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(); dgvr.Tag = dataTable.TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < dataTable.Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[r][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString(); else dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } /// /// 生成报告 /// /// /// private void button13_Click(object sender, EventArgs e) { if (this.checkBox2.Checked) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.NitridingLayerGBT11354"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify)) { //获取word书签与excel单元格的关系,以字典方式存储 List mic_module_infos = 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>(); for (int i = 0; i < this.dataGridView4.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView4.Columns[0].HeaderText); content1.Add(this.dataGridView4.Columns[1].HeaderText); content1.Add(this.dataGridView4.Columns[2].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString()); analysisContent.Add(content1); } List content2 = new List(); analysisContent.Add(content2); for (int i = 0; i < this.dataGridView2.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView2.Columns[0].HeaderText); content1.Add(this.dataGridView2.Columns[1].HeaderText); content1.Add(this.dataGridView2.Columns[2].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString()); analysisContent.Add(content1); } bitList = new List(); if (this.allShow) { foreach (KeyValuePair> kv in this.bitDic) { bitList.Add(kv.Value[0]); bitList.Add(kv.Value[1]); } } else { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (bitDic.ContainsKey(item.Tag.ToString())) { bitList.Add(bitDic[item.Tag.ToString()][0]); bitList.Add(bitDic[item.Tag.ToString()][1]); } } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos); } else MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); } /// /// 导出结果 /// /// /// private void button14_Click(object sender, EventArgs e) { if (this.listView2.Items.Count > 0) { System.Data.DataSet ds = new DataSet(); DataTable table1 = new DataTable(); table1.TableName = PdnResources.GetString("Menu.breakdown.text"); foreach (DataGridViewColumn c in this.dataGridView4.Columns) { table1.Columns.Add(c.HeaderText); } for (int r = 0; r < this.dataGridView4.Rows.Count; r++) { DataRow dataRow = table1.NewRow(); if (r == 0) { for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++) { dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Columns[c].HeaderText; } table1.Rows.Add(dataRow); } dataRow = table1.NewRow(); for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++) { dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Rows[r].Cells[c].Value; } table1.Rows.Add(dataRow); } DataTable table2 = new DataTable(); table2.TableName = PdnResources.GetString("Menu.statisaatics.text"); foreach (DataGridViewColumn c in this.dataGridView2.Columns) { table2.Columns.Add(c.HeaderText); } for (int r = 0; r < this.dataGridView2.Rows.Count; r++) { DataRow dataRow = table2.NewRow(); if (r == 0) { for (int c = 0; c < this.dataGridView2.Rows[r].Cells.Count; c++) { dataRow[this.dataGridView2.Columns[c].HeaderText] = this.dataGridView2.Columns[c].HeaderText; } table2.Rows.Add(dataRow); } dataRow = table2.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; } table2.Rows.Add(dataRow); } if (table1.Rows.Count > 0) ds.Tables.Add(table1); if (table2.Rows.Count > 0) ds.Tables.Add(table2); if (ds.Tables.Count > 0) DataToExcle(ds); } else { MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!"); } } /// /// 导出多 Sheet 报表 /// /// 要导出的数据 public void DataToExcle(System.Data.DataSet ds) { try { if (ds.Tables == null || ds.Tables.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Nonedata.Text")+"!"); return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.DefaultExt = "xlsx"; saveFileDialog.Title = PdnResources.GetString("Menu.ExportdatatoEXECLtable.Text"); saveFileDialog.FileName = PdnResources.GetString("Menu.yermetallographicmethod.text") + DateTime.Now.ToString("yyyyMMddhhmmss"); saveFileDialog.Filter = "microsoft office execl files (*.xlsx)|*.xlsx"; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { List list = new List(); foreach (System.Data.DataTable itemTable in ds.Tables) list.Add(itemTable); this.appWorkspace.ExportDataToExcelWithProgress(list, saveFileDialog.FileName, true, false, true); } } catch (Exception e) { throw e; } } /// /// 设置 /// /// /// private void button1_Click(object sender, EventArgs e) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.NitridingLayerGBT11354"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } /// /// 导出项目 /// /// /// private void button4_Click(object sender, EventArgs e) { try { if (this.analyzeSettingModel == null) { MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text")); return; } //获取项目工程内的文件夹路径 ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.DeterminationOfNitridingDepth.Text", this.analyzeSettingModel.savePath); if (item != null) { //向文件夹内保存图片和报告 if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify)) { //获取word书签与excel单元格的关系,以字典方式存储 List mic_module_infos = 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>(); for (int i = 0; i < this.dataGridView4.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView4.Columns[0].HeaderText); content1.Add(this.dataGridView4.Columns[1].HeaderText); content1.Add(this.dataGridView4.Columns[2].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString()); analysisContent.Add(content1); } List content2 = new List(); analysisContent.Add(content2); for (int i = 0; i < this.dataGridView2.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView2.Columns[0].HeaderText); content1.Add(this.dataGridView2.Columns[1].HeaderText); content1.Add(this.dataGridView2.Columns[2].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dataGridView2.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView2.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView2.Rows[i].Cells[2].Value.ToString()); analysisContent.Add(content1); } bitList = new List(); if (this.allShow) { foreach (KeyValuePair> kv in this.bitDic) { bitList.Add(kv.Value[0]); bitList.Add(kv.Value[1]); } } else { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { foreach (ListViewItem itemL2 in this.listView2.SelectedItems) { if (bitDic.ContainsKey(itemL2.Tag.ToString())) { bitList.Add(bitDic[itemL2.Tag.ToString()][0]); bitList.Add(bitDic[itemL2.Tag.ToString()][1]); } } } } //中间数据 if (!this.allShow) { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { List exportModel = new List(); foreach (ListViewItem rowItem in this.listView2.SelectedItems) { foreach (ExportProjectModel model in this.tempDataModel) { if (model.tagName.Equals(rowItem.Tag)) { ExportProjectModel tempModel = new ExportProjectModel(); tempModel.tagName = model.tagName; tempModel.picName = model.picName; tempModel.dataList = model.dataList; exportModel.Add(tempModel); break; } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code); } } else this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code); } else { MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); return; } //保存项目信息到数据库 this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item); } } catch (Exception) { } } private void dataGridView1_SelectionChanged(object sender, EventArgs e) { //if (!canChange) //{ // SelectDataRow(); //} } private void numericUpDown4_ValueChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } #region 参数保存及提取 /// /// 保存参数的key,value和type /// /// /// /// private 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_Report, checkBox2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置 saveParamValue(ParamKey_Whole, radioButton1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//全方位线 saveParamValue(ParamKey_Waterline, radioButton2.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//水平线 saveParamValue(ParamKey_Vertical, radioButton3.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//垂直线 saveParamValue(ParamKey_LineLength, numericUpDown2 != null ? numericUpDown2.Value.ToString() : "50", (int)Base.Dtryt.Decimal);//线长 saveParamValue(ParamKey_LineWidth, numericUpDown3 != null ? numericUpDown3.Value.ToString() : "5", (int)Base.Dtryt.Decimal);//线宽 saveParamValue(ParamKey_LineColour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//线颜色 saveParamValue(ParamKey_FontSize, numericUpDown4 != null ? numericUpDown4.Value.ToString() : "20", (int)Base.Dtryt.Decimal);//字号 saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "2", (int)Base.Dtryt.Decimal);//保留小数位数 } /// /// 获取保存的参数 /// private void GetListParamModel() { if (this.analysisModel != null) { for (int i = 0; i < this.analysisModel.ListParam.Count; i++) { switch (this.analysisModel.ListParam[i].param_key) { case ParamKey_Report: checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_Whole: radioButton1.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_Waterline: radioButton2.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_Vertical: radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_LineLength: numericUpDown2.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; case ParamKey_LineWidth: numericUpDown3.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; case ParamKey_LineColour: panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_FontSize: numericUpDown4.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; case ParamKey_DecimalPlace: numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; } } } } #endregion #region [脚本相关] private void getValue(string key, object value) { switch (key) { case "parameter1": var val = Convert.ToInt32(value); switch (val) { case 1: radioButton1.Checked = true; break; case 2: radioButton2.Checked = true; break; case 3: radioButton3.Checked = true; break; } break; case "parameter2": numericUpDown2.Value = Convert.ToDecimal(value); break; case "parameter3": numericUpDown3.Value = Convert.ToDecimal(value); break; case "parameter4": numericUpDown4.Value = Convert.ToDecimal(value); break; case "parameter5": panel1.BackColor = Color.FromArgb((int)value); break; case "OpenWhileExportReport": checkBox2.Checked = Convert.ToBoolean(value); break; case "CalculatorDecimalDigits": numericUpDown1.Value = Convert.ToDecimal(value); break; } } #endregion #region [脚本录制] private void getScriptRecording() { string className = InvariantData.path_Action + ".Action" + menuId; ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className); List args = param.Lists; 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); } appWorkspace.SetScriptStartRecording(this.menuId, menuName, args); } private object setScriptRecording(string key) { object value = null; switch (key) { case "parameter1": if (radioButton1.Checked) { value = 1; } else if (radioButton2.Checked) { value = 2; } else if (radioButton3.Checked) { value = 3; } break; case "parameter2": value = numericUpDown2.Value; break; case "parameter3": value = numericUpDown3.Value; break; case "parameter4": value = numericUpDown4.Value; break; case "parameter5": value = panel1.BackColor.ToArgb(); break; case "OpenWhileExportReport": value = checkBox2.Checked; break; case "CalculatorDecimalDigits": value = numericUpDown1.Value; break; case "ExportResults": value = false; break; case "ExportReports": value = false; break; case "ExportProjects": value = false; break; } return value; } #endregion } }