using Metis.ParameterSet; using OpenCvSharp.Extensions; using PaintDotNet.Base; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.Functionodel; using PaintDotNet.CustomControl; using PaintDotNet.Data.Param; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using PaintDotNet.Instrument; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Entity.Migrations.Infrastructure; using System.Diagnostics.Contracts; using System.Drawing; using System.Drawing.Drawing2D; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.DedicatedAnalysis.SteelDecarburization.IOS3887_2017 { /// /// 金相法 /// internal class MetallographicMethod3887Dialog : PdnBaseForm { #region 基础控件 private Button button1; private CheckBox checkBox1; private Button button2; private GroupBox groupBox2; private ListView listView1; private GroupBox groupBox3; private GroupBox groupBox4; private Button button5; private Button button4; private Button button3; private GroupBox groupBox5; private TextBox textBox2; private TextBox textBox1; private Label label2; private Label label1; private GroupBox groupBox6; private Panel panel1; private Label label4; private Label label3; private Panel panel5; private Panel panel4; private Panel panel3; private Panel panel2; private GroupBox groupBox7; private CheckBox checkBox3; private CheckBox checkBox2; private GroupBox groupBox8; private DataGridView dataGridView1; private GroupBox groupBox9; private Button button6; private Button button7; private ListView listView2; private DataGridView dataGridView2; private Button button9; private Button button8; private NumericUpDown numericUpDown1; private Label label8; private Label label9; private Label label10; private ImageList imageList1; private IContainer components; private GroupBox groupBox1; private TrackBar trackBar1; private TrackBar trackBar2; private Button button10; #endregion /// /// 调色板 /// PaintDotNet.ColorsForm colorsForm1; PaintDotNet.ColorsForm colorsForm2; PaintDotNet.ColorsForm colorsForm3; PaintDotNet.ColorsForm colorsForm4; PaintDotNet.ColorsForm colorsForm5; /// /// 主控件 /// private AppWorkspace appWorkspace; /// /// 图像面板 /// private DocumentWorkspaceWindow documentWorkspace; /// /// 公共按钮 /// private CommonControlButtons commonControlButtons; /// /// 0:添加 1:选择 2:删除 /// private int operationK = -1; /// /// 被选择的线 /// private int selected = -1; /// /// 起止点 /// private System.Drawing.PointF startPoint, endPoint; /// /// 存储所有线的点集合 /// private List pointList = new List(); /// /// 测量点 /// public List rectangleFList = new List(); /// /// 存储当前线的点集合 /// private PointF[] nowLine; /// /// 线的总数 /// private int lineCount = 0; /// /// 计算结果的表格集合 /// private List resultTableList = new List(); /// /// 保存用于生成报告的图片 /// private List bitList; /// /// 储存点击保存结果后的所有原图与分析图 /// private Dictionary> bitDic = new Dictionary>(); /// /// 是否显示全部 /// private bool showAll = false; /// /// 辅助计算偏移量-移动线两端的点 /// private PointF lastPoint = new PointF(0, 0); /// /// 辅助计算偏移量-移动线中间的点 /// private PointF tempPoint = new PointF(0, 0); /// /// 判断图形是否可移动 /// private bool canMove = false; /// /// 移动线上的哪一个点 /// private int movePointIndex = -1; /// /// 单位标尺 /// private double unitLength = 1; /// /// 中间数据 /// private List tempDataModel = new List(); /// /// 端点减 /// private int rectless = InvariantData.rectless; private CheckBox checkBox6; private CheckBox checkBox5; private CheckBox checkBox4; /// /// 端点加 /// private int rectplus = InvariantData.rectplus; private int defaultIndex = -1; private int menuId; private string menuName; /// /// 是否脚本运行 /// private Boolean initScriptValues = false; /// /// 保存窗口参数 /// private GrainSizeAnalysisModel analysisModel; private const string ParamKey_Report = "report";//报告设置 private const string ParamKey_LineLength = "lineLength";//线长 private const string ParamKey_LineWidth = "lineWidth";//线宽 private const string ParamKey_Baseline = "baseline";//基准线 private const string ParamKey_Surface = "surface";//钢样表面 private const string ParamKey_Whole = "whole";//完全 private const string ParamKey_WholeColour = "wholeColour";//完全颜色 private const string ParamKey_Valid = "valid";//有效 private const string ParamKey_ValidColour = "validColour";//有效颜色 private const string ParamKey_Part = "part";//部分 private const string ParamKey_PartColour = "partColour";//部分颜色 private const string ParamKey_WholeGauge = "wholeGauge";//完全测量 private const string ParamKey_ValidGauge = "validGauge";//有效测量 private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数 public MetallographicMethod3887Dialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) { this.menuId = menuItem.MenuId; this.menuName = menuItem.Text; 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(); InitGridHeader(); InitOtherTools(); //如果是脚本执行,将参数带入 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(); } InitPicList(); InitCommonButtonEvent(); AddPictureBoxEvent(); SetAnalyzeModelFromXml("Template.Manager.item3.MetallographicMethod3887"); } 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; } } private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button2.Text = PdnResources.GetString("Menu.Saveresult.text"); this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text"); this.button1.Text = PdnResources.GetString("Menu.Setting.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text"); this.groupBox3.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox4.Text = PdnResources.GetString("Menu.Measurementbaseline.text"); this.button5.Text = PdnResources.GetString("Menu.Deletemeasurementline.text"); this.button4.Text = PdnResources.GetString("Menu.Selectmeasurementline.text"); this.button3.Text = PdnResources.GetString("Menu.Addmeasuringline.text"); this.groupBox5.Text = PdnResources.GetString("Menu.Basicsettingsofmeasuringline.text"); this.label2.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.Linelength.text") + ":"; this.groupBox6.Text = PdnResources.GetString("Menu.Colorsetting.text"); this.checkBox6.Text = PdnResources.GetString("Menu.Partiallydecarburizedlayer.text") + ":"; this.checkBox5.Text = PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text") + ":"; this.checkBox4.Text = PdnResources.GetString("Menu.Completelydecarburizedlayer.text") + ":"; this.label4.Text = PdnResources.GetString("Menu.Steelsamplesurface.text") + ":"; this.label3.Text = PdnResources.GetString("Menu.Baseline.text") + ":"; this.groupBox7.Text = PdnResources.GetString("Menu.Measurementlayerselection.text"); this.checkBox3.Text = PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"); this.checkBox2.Text = PdnResources.GetString("Menu.Completelydecarburizedlayer.text"); this.groupBox8.Text = PdnResources.GetString("Menu.datapresentation.text"); this.groupBox9.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.button10.Text = PdnResources.GetString("Menu.Exportproject.text"); this.label8.Text = PdnResources.GetString("Menu.Decimal.text") + ":"; this.button9.Text = PdnResources.GetString("Menu.Exportresults.text"); this.button8.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text"); this.button7.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button6.Text = PdnResources.GetString("Menu.Showall.text"); this.Text = "ISO 3887-2017(" + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Metallographicmethod.text") + ")"; } private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button2 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.listView1 = new System.Windows.Forms.ListView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.button5 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.trackBar2 = new System.Windows.Forms.TrackBar(); this.trackBar1 = new System.Windows.Forms.TrackBar(); this.textBox2 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.checkBox6 = new System.Windows.Forms.CheckBox(); this.checkBox5 = new System.Windows.Forms.CheckBox(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.panel5 = new System.Windows.Forms.Panel(); this.panel4 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.groupBox9 = new System.Windows.Forms.GroupBox(); this.button10 = new System.Windows.Forms.Button(); this.label10 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.label8 = new System.Windows.Forms.Label(); this.button9 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.dataGridView2 = new System.Windows.Forms.DataGridView(); this.listView2 = new System.Windows.Forms.ListView(); this.button7 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); this.groupBox6.SuspendLayout(); this.groupBox7.SuspendLayout(); this.groupBox8.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.groupBox9.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).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.checkBox1); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(14, 3); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1081, 50); this.groupBox1.TabIndex = 1; this.groupBox1.TabStop = false; // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); 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 = 2; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // checkBox1 // this.checkBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.checkBox1.AutoSize = true; this.checkBox1.Location = new System.Drawing.Point(141, 21); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(15, 14); this.checkBox1.TabIndex = 1; this.checkBox1.UseVisualStyleBackColor = true; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); 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 = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox2.Controls.Add(this.listView1); this.groupBox2.Location = new System.Drawing.Point(14, 60); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(135, 497); this.groupBox2.TabIndex = 2; 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, 474); 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; // // groupBox3 // this.groupBox3.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.groupBox3.Location = new System.Drawing.Point(515, 60); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(580, 496); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; // // groupBox4 // this.groupBox4.Controls.Add(this.button5); this.groupBox4.Controls.Add(this.button4); this.groupBox4.Controls.Add(this.button3); this.groupBox4.Location = new System.Drawing.Point(156, 60); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(353, 58); this.groupBox4.TabIndex = 4; this.groupBox4.TabStop = false; // // button5 // this.button5.Location = new System.Drawing.Point(203, 20); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(75, 23); this.button5.TabIndex = 2; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button4 // this.button4.Location = new System.Drawing.Point(109, 20); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(75, 23); this.button4.TabIndex = 1; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.Location = new System.Drawing.Point(16, 20); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 0; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // groupBox5 // this.groupBox5.Controls.Add(this.trackBar2); this.groupBox5.Controls.Add(this.trackBar1); this.groupBox5.Controls.Add(this.textBox2); this.groupBox5.Controls.Add(this.textBox1); this.groupBox5.Controls.Add(this.label2); this.groupBox5.Controls.Add(this.label1); this.groupBox5.Location = new System.Drawing.Point(156, 125); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(353, 71); this.groupBox5.TabIndex = 5; this.groupBox5.TabStop = false; // // trackBar2 // this.trackBar2.Cursor = System.Windows.Forms.Cursors.Hand; this.trackBar2.Location = new System.Drawing.Point(219, 24); this.trackBar2.Maximum = 50; this.trackBar2.Minimum = 1; this.trackBar2.Name = "trackBar2"; this.trackBar2.Size = new System.Drawing.Size(85, 45); this.trackBar2.TabIndex = 5; this.trackBar2.TickStyle = System.Windows.Forms.TickStyle.None; this.trackBar2.Value = 3; this.trackBar2.Scroll += new System.EventHandler(this.trackBar2_Scroll); this.trackBar2.ValueChanged += new System.EventHandler(this.trackBar2_ValueChanged); // // trackBar1 // this.trackBar1.Cursor = System.Windows.Forms.Cursors.Hand; this.trackBar1.Location = new System.Drawing.Point(42, 24); this.trackBar1.Maximum = 50; this.trackBar1.Minimum = 1; this.trackBar1.Name = "trackBar1"; this.trackBar1.Size = new System.Drawing.Size(91, 45); this.trackBar1.TabIndex = 4; this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None; this.trackBar1.Value = 40; this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll); this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(307, 24); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(35, 21); this.textBox2.TabIndex = 3; this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress); this.textBox2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyUp); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(136, 24); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(35, 21); this.textBox1.TabIndex = 2; this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); this.textBox1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyUp); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(183, 28); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(0, 12); this.label2.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 28); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 0; // // groupBox6 // this.groupBox6.Controls.Add(this.checkBox6); this.groupBox6.Controls.Add(this.checkBox5); this.groupBox6.Controls.Add(this.checkBox4); this.groupBox6.Controls.Add(this.panel5); this.groupBox6.Controls.Add(this.panel4); this.groupBox6.Controls.Add(this.panel3); this.groupBox6.Controls.Add(this.panel2); this.groupBox6.Controls.Add(this.panel1); this.groupBox6.Controls.Add(this.label4); this.groupBox6.Controls.Add(this.label3); this.groupBox6.Location = new System.Drawing.Point(156, 202); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(354, 95); this.groupBox6.TabIndex = 6; this.groupBox6.TabStop = false; // // checkBox6 // this.checkBox6.AutoSize = true; this.checkBox6.Location = new System.Drawing.Point(166, 68); this.checkBox6.Name = "checkBox6"; this.checkBox6.Size = new System.Drawing.Size(15, 14); this.checkBox6.TabIndex = 11; this.checkBox6.UseVisualStyleBackColor = true; this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged); // // checkBox5 // this.checkBox5.AutoSize = true; this.checkBox5.Location = new System.Drawing.Point(166, 46); this.checkBox5.Name = "checkBox5"; this.checkBox5.Size = new System.Drawing.Size(15, 14); this.checkBox5.TabIndex = 10; this.checkBox5.UseVisualStyleBackColor = true; this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged); // // checkBox4 // this.checkBox4.AutoSize = true; this.checkBox4.Location = new System.Drawing.Point(166, 23); this.checkBox4.Name = "checkBox4"; this.checkBox4.Size = new System.Drawing.Size(15, 14); this.checkBox4.TabIndex = 9; this.checkBox4.UseVisualStyleBackColor = true; this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); // // panel5 // this.panel5.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel5.Location = new System.Drawing.Point(264, 67); this.panel5.Name = "panel5"; this.panel5.Size = new System.Drawing.Size(75, 18); this.panel5.TabIndex = 8; this.panel5.Click += new System.EventHandler(this.panel5_Click); // // panel4 // this.panel4.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel4.Location = new System.Drawing.Point(264, 44); this.panel4.Name = "panel4"; this.panel4.Size = new System.Drawing.Size(75, 18); this.panel4.TabIndex = 7; this.panel4.Click += new System.EventHandler(this.panel4_Click); // // panel3 // this.panel3.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.panel3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel3.Location = new System.Drawing.Point(264, 21); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(75, 18); this.panel3.TabIndex = 6; this.panel3.Click += new System.EventHandler(this.panel3_Click); // // panel2 // this.panel2.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel2.Location = new System.Drawing.Point(72, 44); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(75, 18); this.panel2.TabIndex = 6; this.panel2.Click += new System.EventHandler(this.panel2_Click); // // panel1 // this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel1.Location = new System.Drawing.Point(72, 21); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(75, 18); this.panel1.TabIndex = 5; this.panel1.Click += new System.EventHandler(this.panel1_Click); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(11, 46); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(0, 12); this.label4.TabIndex = 1; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(11, 24); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(0, 12); this.label3.TabIndex = 0; // // groupBox7 // this.groupBox7.Controls.Add(this.checkBox3); this.groupBox7.Controls.Add(this.checkBox2); this.groupBox7.Location = new System.Drawing.Point(156, 303); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(353, 58); this.groupBox7.TabIndex = 7; this.groupBox7.TabStop = false; // // checkBox3 // this.checkBox3.AutoSize = true; this.checkBox3.Checked = true; this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox3.Location = new System.Drawing.Point(142, 25); this.checkBox3.Name = "checkBox3"; this.checkBox3.Size = new System.Drawing.Size(15, 14); this.checkBox3.TabIndex = 1; this.checkBox3.UseVisualStyleBackColor = true; this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged); // // checkBox2 // this.checkBox2.AutoSize = true; this.checkBox2.Checked = true; this.checkBox2.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox2.Location = new System.Drawing.Point(26, 25); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(15, 14); this.checkBox2.TabIndex = 0; this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); // // groupBox8 // this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox8.Controls.Add(this.dataGridView1); this.groupBox8.Location = new System.Drawing.Point(155, 367); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(353, 189); this.groupBox8.TabIndex = 8; this.groupBox8.TabStop = false; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.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.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.Color.White; this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; this.dataGridView1.Location = new System.Drawing.Point(7, 21); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(340, 162); this.dataGridView1.TabIndex = 0; // // groupBox9 // this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox9.Controls.Add(this.button10); this.groupBox9.Controls.Add(this.label10); this.groupBox9.Controls.Add(this.label9); this.groupBox9.Controls.Add(this.numericUpDown1); this.groupBox9.Controls.Add(this.label8); this.groupBox9.Controls.Add(this.button9); this.groupBox9.Controls.Add(this.button8); this.groupBox9.Controls.Add(this.dataGridView2); this.groupBox9.Controls.Add(this.listView2); this.groupBox9.Controls.Add(this.button7); this.groupBox9.Controls.Add(this.button6); this.groupBox9.Location = new System.Drawing.Point(14, 562); this.groupBox9.Name = "groupBox9"; this.groupBox9.Size = new System.Drawing.Size(1081, 204); this.groupBox9.TabIndex = 9; this.groupBox9.TabStop = false; // // button10 // this.button10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button10.Location = new System.Drawing.Point(941, 101); this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(128, 26); this.button10.TabIndex = 10; this.button10.UseVisualStyleBackColor = true; this.button10.Click += new System.EventHandler(this.button10_Click); // // label10 // this.label10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label10.AutoSize = true; this.label10.ForeColor = System.Drawing.SystemColors.ScrollBar; this.label10.Location = new System.Drawing.Point(927, 9); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(11, 192); this.label10.TabIndex = 9; this.label10.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|"; // // label9 // this.label9.AutoSize = true; this.label9.ForeColor = System.Drawing.SystemColors.ScrollBar; this.label9.Location = new System.Drawing.Point(210, 9); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(11, 192); this.label9.TabIndex = 8; this.label9.Text = "|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|\r\n|"; // // numericUpDown1 // this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.numericUpDown1.Location = new System.Drawing.Point(993, 162); this.numericUpDown1.Maximum = new decimal(new int[] { 10, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(70, 21); this.numericUpDown1.TabIndex = 7; this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // label8 // this.label8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(957, 167); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(0, 12); this.label8.TabIndex = 6; // // button9 // this.button9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button9.Location = new System.Drawing.Point(941, 68); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(128, 26); this.button9.TabIndex = 5; this.button9.UseVisualStyleBackColor = true; this.button9.Click += new System.EventHandler(this.button9_Click); // // button8 // this.button8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button8.Location = new System.Drawing.Point(941, 34); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(128, 26); this.button8.TabIndex = 4; this.button8.UseVisualStyleBackColor = true; this.button8.Click += new System.EventHandler(this.button8_Click); // // dataGridView2 // this.dataGridView2.AllowUserToAddRows = false; this.dataGridView2.AllowUserToDeleteRows = 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.Color.White; this.dataGridView2.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None; this.dataGridView2.Location = new System.Drawing.Point(228, 20); this.dataGridView2.MultiSelect = false; this.dataGridView2.Name = "dataGridView2"; this.dataGridView2.RowHeadersVisible = false; this.dataGridView2.RowTemplate.Height = 23; this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView2.Size = new System.Drawing.Size(693, 176); this.dataGridView2.TabIndex = 3; // // 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.HideSelection = false; this.listView2.Location = new System.Drawing.Point(16, 56); this.listView2.Name = "listView2"; this.listView2.Size = new System.Drawing.Size(181, 140); this.listView2.TabIndex = 2; this.listView2.UseCompatibleStateImageBehavior = false; this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged); // // button7 // this.button7.Location = new System.Drawing.Point(145, 20); this.button7.Name = "button7"; this.button7.Size = new System.Drawing.Size(52, 26); this.button7.TabIndex = 1; this.button7.UseVisualStyleBackColor = true; this.button7.Click += new System.EventHandler(this.button7_Click); // // button6 // this.button6.Location = new System.Drawing.Point(16, 20); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(93, 26); this.button6.TabIndex = 0; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // // MetallographicMethod3887Dialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1107, 771); this.Controls.Add(this.groupBox9); this.Controls.Add(this.groupBox8); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Name = "MetallographicMethod3887Dialog"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MetallographicMethod3887Dialog_FormClosing); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.Controls.SetChildIndex(this.groupBox4, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.Controls.SetChildIndex(this.groupBox6, 0); this.Controls.SetChildIndex(this.groupBox7, 0); this.Controls.SetChildIndex(this.groupBox8, 0); this.Controls.SetChildIndex(this.groupBox9, 0); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox4.ResumeLayout(false); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); this.groupBox6.ResumeLayout(false); this.groupBox6.PerformLayout(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); this.groupBox8.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.groupBox9.ResumeLayout(false); this.groupBox9.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit(); this.ResumeLayout(false); } /// /// 初始化其他控件 /// private void InitOtherTools() { // //初始化图像控件 // this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace); this.documentWorkspace.Dock = DockStyle.Fill; this.documentWorkspace.HookMouseEvents(); this.documentWorkspace.AuxiliaryLineEnabled = false; this.documentWorkspace.Visible = false; this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.NullTool; this.groupBox3.Controls.Add(documentWorkspace); // //初始化操作按钮 // this.commonControlButtons = new CommonControlButtons(); this.commonControlButtons.Dock = DockStyle.Top; this.commonControlButtons.Height = 30; this.commonControlButtons.HideZoomToWindowAndActualSize(); this.commonControlButtons.Visible = false; this.groupBox3.Controls.Add(commonControlButtons); // //调色板 // this.colorsForm1 = new ColorsForm(); this.colorsForm1.StartPosition = FormStartPosition.CenterScreen; this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsForm2 = new ColorsForm(); this.colorsForm2.StartPosition = FormStartPosition.CenterScreen; this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsForm3 = new ColorsForm(); this.colorsForm3.StartPosition = FormStartPosition.CenterScreen; this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsForm4 = new ColorsForm(); this.colorsForm4.StartPosition = FormStartPosition.CenterScreen; this.colorsForm4.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.colorsForm5 = new ColorsForm(); this.colorsForm5.StartPosition = FormStartPosition.CenterScreen; this.colorsForm5.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); // //颜色panel给定初始值 // this.panel1.BackColor = Color.Red; this.panel2.BackColor = Color.Blue; this.panel3.BackColor = Color.Green; this.panel4.BackColor = Color.Pink; this.panel5.BackColor = Color.Yellow; // //滚动条与输入框值匹配 // this.textBox1.Text = "" + this.trackBar1.Value; this.textBox2.Text = "" + this.trackBar2.Value; // //按钮绑定事件 // this.button3.LostFocus += new System.EventHandler(this.button3_LostFocus); //// ////获取系统标尺-微米 //// //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength); } /// /// 初始化图片列表数据 /// 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 InitGridHeader() { // //数据展示表 // this.dataGridView1.ColumnHeadersHeight = 50; DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn(); h1.Width = 72; DataGridViewTextBoxColumn h2 = new DataGridViewTextBoxColumn(); h2.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h2.Width = 66; DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn(); h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h3.Width = 66; DataGridViewTextBoxColumn h4 = new DataGridViewTextBoxColumn(); h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h4.Width = 66; DataGridViewTextBoxColumn h5 = new DataGridViewTextBoxColumn(); h5.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h5.Width = 66; this.dataGridView1.Columns.Add(h1); this.dataGridView1.Columns.Add(h2); this.dataGridView1.Columns.Add(h3); this.dataGridView1.Columns.Add(h4); this.dataGridView1.Columns.Add(h5); DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1); helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.packet.text"))); helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.Completelydecarburizedlayer.text"))); helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"))); helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"))); helper.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Totaldecarburizationlayer.text"))); this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[0].ReadOnly = true; this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中 this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[1].ReadOnly = true; this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[2].ReadOnly = true; this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[3].ReadOnly = true; this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dataGridView1.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView1.Columns[4].ReadOnly = true; this.dataGridView1.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.AllowUserToResizeColumns = false; // //分析结果表 // this.dataGridView2.ColumnHeadersHeight = 30; DataGridViewTextBoxColumn h6 = new DataGridViewTextBoxColumn(); h6.Width = 115; DataGridViewTextBoxColumn h7 = new DataGridViewTextBoxColumn(); //h7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h7.Width = 115; DataGridViewTextBoxColumn h8 = new DataGridViewTextBoxColumn(); //h8.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h8.Width = 115; DataGridViewTextBoxColumn h9 = new DataGridViewTextBoxColumn(); //h9.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h9.Width = 115; DataGridViewTextBoxColumn h10 = new DataGridViewTextBoxColumn(); //h10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h10.Width = 115; DataGridViewTextBoxColumn h11 = new DataGridViewTextBoxColumn(); //h11.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; h11.Width = 115; this.dataGridView2.Columns.Add(h6); this.dataGridView2.Columns.Add(h7); this.dataGridView2.Columns.Add(h8); this.dataGridView2.Columns.Add(h9); this.dataGridView2.Columns.Add(h10); this.dataGridView2.Columns.Add(h11); DataGridViewHelper helper2 = new DataGridViewHelper(this.dataGridView2); helper2.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.picture.Text"))); helper2.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.packet.text"))); helper2.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Completelydecarburizedlayer.text"))); helper2.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text"))); helper2.Headers.Add(new DataGridViewHelper.TopHeader(4, 1, PdnResources.GetString("Menu.Partiallydecarburizedlayer.text"))); helper2.Headers.Add(new DataGridViewHelper.TopHeader(5, 1, PdnResources.GetString("Menu.Totaldecarburizationlayer.text"))); this.dataGridView2.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[0].ReadOnly = true; this.dataGridView2.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[1].ReadOnly = true; this.dataGridView2.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[2].ReadOnly = true; this.dataGridView2.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[3].ReadOnly = true; this.dataGridView2.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[4].ReadOnly = true; this.dataGridView2.Columns[5].SortMode = DataGridViewColumnSortMode.NotSortable; this.dataGridView2.Columns[5].ReadOnly = true; this.dataGridView2.AllowUserToResizeRows = false; this.dataGridView2.AllowUserToResizeColumns = false; // //左下表 // this.listView2.View = View.Details; ColumnHeader header0 = new ColumnHeader(); header0.Text = PdnResources.GetString("Menu.Resultlist.Text"); header0.Width = 175; this.listView2.Columns.Add(header0); } /// /// 初始化画布按键功能 /// 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; } /// /// 添加画布绑定事件 /// private void AddPictureBoxEvent() { this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.BoxMouseDownHandler); this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.BoxMouseMoveHandler); this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.BoxMouseUpHandler); this.documentWorkspace.panel.Paint += new PaintEventHandler(this.BoxPaintHandler); } /// /// 调色板回调函数 /// /// /// private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } /// /// 添加内容单元格 /// /// /// /// private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag) { DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell(); textboxcell.Value = text; textboxcell.Tag = tag; return textboxcell; } /// /// 设置按钮 /// /// /// private void button1_Click(object sender, EventArgs e) { AnalyzeSettingDialog metallographicMethodSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.MetallographicMethod3887"); if (metallographicMethodSetDialog.hasModule) { metallographicMethodSetDialog.StartPosition = FormStartPosition.CenterScreen; metallographicMethodSetDialog.ShowDialog(); } else { metallographicMethodSetDialog = null; } } /// /// 保存结果按钮 /// /// /// private void button2_Click(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count > 0) { string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName(); string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index]; bool replace = false; int rowIndex = 0; if (this.dataGridView1.Rows.Count > 0) { if (this.listView2.Items.Count > 0) { foreach (ListViewItem item in this.listView2.Items) { if (item.Name.Equals(tag)) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if(dr == DialogResult.OK) { replace = true; } else { return; } break; } } } //有重名需要替换 if (replace) { for(int i = 0; i < this.resultTableList.Count; i++) { if (this.resultTableList[i].TableName.Equals(tag)) { rowIndex = i; this.resultTableList.Remove(this.resultTableList[i]); if (this.pointList.Count > 0) { double avg1 = 0; double avg2 = 0; double avg3 = 0; double avg4 = 0; DataTable dt = new DataTable(tag); dt.Columns.Add(PdnResources.GetString("Menu.picture.Text")); dt.Columns.Add(PdnResources.GetString("Menu.packet.text")); dt.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); for (int j = 0; j < this.pointList.Count; j++) { PointF[] pf = pointList[j]; DataRow dataRow = dt.NewRow(); dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName; dataRow[PdnResources.GetString("Menu.packet.text")] = "L" + (j + 1); if (pf[2] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = 0; else { double dis1 = BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = dis1; avg1 += dis1; } if (pf[3] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = 0; else { double dis2 = BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = dis2; avg2 += dis2; } if (pf[2] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = 0; else { double dis3 = BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = dis3; avg3 += dis3; } double dis4 = BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = dis4; avg4 += dis4; dt.Rows.Add(dataRow); } DataRow avgRow = dt.NewRow(); avgRow[PdnResources.GetString("Menu.picture.Text")] = imgName; avgRow[PdnResources.GetString("Menu.packet.text")] = PdnResources.GetString("Menu.Image.Average.Text"); avgRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = avg1 / lineCount; avgRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = avg2 / lineCount; avgRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = avg3 / lineCount; avgRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = avg4 / lineCount; dt.Rows.Add(avgRow); resultTableList.Insert(rowIndex, dt); } } } } //新增 else { ListViewItem listViewItem = new ListViewItem(); listViewItem.Name = tag; listViewItem.SubItems[0].Text = imgName; this.listView2.Items.Add(listViewItem); this.listView2.SelectedItems.Clear(); this.listView2.Items[this.listView2.Items.Count - 1].Selected = true; if (this.pointList.Count > 0) { //重新计算平均值 double avg1 = 0; double avg2 = 0; double avg3 = 0; double avg4 = 0; DataTable dt = new DataTable(tag); dt.Columns.Add(PdnResources.GetString("Menu.picture.Text")); dt.Columns.Add(PdnResources.GetString("Menu.packet.text")); dt.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); dt.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); for (int i = 0; i < this.pointList.Count; i++) { PointF[] pf = pointList[i]; DataRow dataRow = dt.NewRow(); dataRow[PdnResources.GetString("Menu.picture.Text")] = imgName; dataRow[PdnResources.GetString("Menu.packet.text")] = "L" + (i + 1); if (pf[2] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = 0; else { double dis1 = BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = dis1; avg1 += dis1; } if (pf[3] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = 0; else { double dis2 = BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = dis2; avg2 += dis2; } if (pf[2] == PointF.Empty) dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = 0; else { double dis3 = BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = dis3; avg3 += dis3; } double dis4 = BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength; dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = dis4; avg4 += dis4; dt.Rows.Add(dataRow); } DataRow avgRow = dt.NewRow(); avgRow[PdnResources.GetString("Menu.picture.Text")] = imgName; avgRow[PdnResources.GetString("Menu.packet.text")] = PdnResources.GetString("Menu.Image.Average.Text"); avgRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = avg1 / lineCount; avgRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = avg2 / lineCount; avgRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = avg3 / lineCount; avgRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = avg4 / lineCount; dt.Rows.Add(avgRow); resultTableList.Add(dt); } } RefreshDataGridView2(); //保存处理后的图片 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 newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat); Graphics graphics = Graphics.FromImage(newBit); if (this.documentWorkspace.phaseModels != null && this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.phaseModels[0].mat); 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.packet.text")); columnName.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); columnName.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); columnName.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); columnName.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); dataList.Add(columnName); if (this.pointList.Count > 0) { for (int i = 0; i < this.pointList.Count; i++) { PointF[] pf = pointList[i]; List strList = new List(); strList.Add("L" + (i + 1)); if (pf[2] == PointF.Empty) strList.Add("0"); else strList.Add((BasicCalculationHelper.GetDistance(pf[2], pf[0], 10) * unitLength).ToString()); if (pf[3] == PointF.Empty) strList.Add("0"); else strList.Add((BasicCalculationHelper.GetDistance(pf[3], pf[0], 10) * unitLength).ToString()); if (pf[2] == PointF.Empty) strList.Add("0"); else strList.Add((BasicCalculationHelper.GetDistance(pf[1], pf[2], 10) * unitLength).ToString()); strList.Add((BasicCalculationHelper.GetDistance(pf[1], pf[0], 10) * unitLength).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); } } else { MessageBox.Show(PdnResources.GetString("Menu.Pleasedrawthemeasuringlinefirst.text")); } } else { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapictaurefirst.Text")); } } /// /// 刷新分析结果表 /// private void RefreshDataGridView2() { this.dataGridView2.Rows.Clear(); if (this.showAll) { if (this.resultTableList.Count > 0) { foreach (DataTable dt in resultTableList) { for(int i = 0; i < dt.Rows.Count; i++) { DataGridViewRow row = new DataGridViewRow(); row.Height = 30; row.Cells.Add(CreateTextBoxCell(dt.Rows[i][0].ToString(), "")); row.Cells.Add(CreateTextBoxCell(dt.Rows[i][1].ToString(), "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][2].ToString()) ? "0" : dt.Rows[i][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][3].ToString()) ? "0" : dt.Rows[i][3].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][4].ToString()) ? "0" : dt.Rows[i][4].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[i][5].ToString()) ? "0" : dt.Rows[i][5].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); this.dataGridView2.Rows.Add(row); } } } } else { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { for (int i = 0; i < this.listView2.SelectedItems.Count; i++) { string tableName = this.listView2.SelectedItems[i].Name; foreach (DataTable dt in resultTableList) { if (dt.TableName.Equals(tableName)) { for (int j = 0; j < dt.Rows.Count; j++) { DataGridViewRow row = new DataGridViewRow(); row.Height = 30; row.Cells.Add(CreateTextBoxCell(dt.Rows[j][0].ToString(), "")); row.Cells.Add(CreateTextBoxCell(dt.Rows[j][1].ToString(), "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][2].ToString()) ? "0" : dt.Rows[j][2].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][3].ToString()) ? "0" : dt.Rows[j][3].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][4].ToString()) ? "0" : dt.Rows[j][4].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); row.Cells.Add(CreateTextBoxCell(Math.Round(double.Parse(string.IsNullOrEmpty(dt.Rows[j][5].ToString()) ? "0" : dt.Rows[j][5].ToString()), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); this.dataGridView2.Rows.Add(row); } } } } } } } /// /// 添加测量线按钮 /// /// /// private void button3_Click(object sender, EventArgs e) { operationK = 0; selected = -1; this.documentWorkspace.Refresh(); } /// /// 选择测量线按钮 /// /// /// private void button4_Click(object sender, EventArgs e) { operationK = 1; } /// /// 删除测量线按钮 /// /// /// private void button5_Click(object sender, EventArgs e) { if (selected > -1) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.pointList.Remove(this.pointList[selected]); this.rectangleFList.Remove(this.rectangleFList[selected]); selected = -1; lineCount--; RefreshDataGridView1(); this.documentWorkspace.Refresh(); } } else MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text")); } /// /// 按键DELETE删除测量线 /// /// /// protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Delete) { if (selected > -1) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodmeasurementline.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.pointList.Remove(this.pointList[selected]); this.rectangleFList.Remove(this.rectangleFList[selected]); selected = -1; lineCount--; RefreshDataGridView1(); this.documentWorkspace.Refresh(); } } else MessageBox.Show(PdnResources.GetString("Menu.Pleaseseleceletedfirst.text")); } return true; //return base.ProcessCmdKey(ref msg, keyData); } /// /// 全部显示按钮 /// /// /// private void button6_Click(object sender, EventArgs e) { if(this.button6.Text == PdnResources.GetString("Menu.Showall.text")) { this.button6.Text = PdnResources.GetString("Menu.Cancelshowall.text"); this.showAll = true; RefreshDataGridView2(); } else if (this.button6.Text == PdnResources.GetString("Menu.Cancelshowall.text")) { this.button6.Text = PdnResources.GetString("Menu.Showall.text"); this.showAll = false; RefreshDataGridView2(); } } /// /// 删除按钮 /// /// /// private void button7_Click(object sender, EventArgs e) { if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallanalysisrlete.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { for (int i = 0; i < this.listView2.SelectedItems.Count; i++) { string tableName = this.listView2.SelectedItems[i].Name; foreach (DataTable dt in resultTableList) { if (dt.TableName.Equals(tableName)) { resultTableList.Remove(dt); break; } } if (bitDic.ContainsKey(tableName)) bitDic.Remove(tableName); foreach (ExportProjectModel model in this.tempDataModel) { if (model.tagName.Equals(tableName)) { this.tempDataModel.Remove(model); break; } } } foreach (ListViewItem item in this.listView2.Items) { if (item.Selected) this.listView2.Items.Remove(item); } RefreshDataGridView2(); } } } /// /// 生成报告按钮 /// /// /// private void button8_Click(object sender, EventArgs e) { if (this.checkBox1.Checked) this.button1.PerformClick(); 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>(); List contentHead = new List(); contentHead.Add(PdnResources.GetString("Menu.picture.Text")); contentHead.Add(PdnResources.GetString("Menu.packet.text")); contentHead.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); analysisContent.Add(contentHead); foreach (DataGridViewRow item in this.dataGridView2.Rows) { List content = new List(); content.Add(item.Cells[0].Value.ToString()); content.Add(item.Cells[1].Value.ToString()); content.Add(item.Cells[2].Value.ToString()); content.Add(item.Cells[3].Value.ToString()); content.Add(item.Cells[4].Value.ToString()); content.Add(item.Cells[5].Value.ToString()); analysisContent.Add(content); } //图片 bitList = new List(); if (this.showAll) { 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.Name)) { bitList.Add(bitDic[item.Name][0]); bitList.Add(bitDic[item.Name][1]); } } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos); } else MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); } /// /// 导出结果按钮 /// /// /// private void button9_Click(object sender, EventArgs e) { if (this.listView2.Items.Count > 0) { SaveFileDialog exe = new SaveFileDialog(); exe.Filter = "Execl files (*.xlsx)|*.xlsx"; exe.FilterIndex = 0; exe.RestoreDirectory = true; exe.Title = "Export Excel File"; exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); exe.FileName = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Metallographicmethod.text")+"ASTME1077" + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddHHmmss"); DialogResult dr = exe.ShowDialog(); if (dr != DialogResult.OK) return; DataTable dtb = new DataTable(); dtb.Columns.Add(PdnResources.GetString("Menu.picture.Text")); dtb.Columns.Add(PdnResources.GetString("Menu.packet.text")); dtb.Columns.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); dtb.Columns.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); dtb.Columns.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); dtb.Columns.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); for(int i = 0; i < this.dataGridView2.Rows.Count; i++) { DataRow dataRow = dtb.NewRow(); dataRow[PdnResources.GetString("Menu.picture.Text")] = this.dataGridView2.Rows[i].Cells[0].Value; dataRow[PdnResources.GetString("Menu.packet.text")] = this.dataGridView2.Rows[i].Cells[1].Value; dataRow[PdnResources.GetString("Menu.Completelydecarburizedlayer.text")] = this.dataGridView2.Rows[i].Cells[2].Value; dataRow[PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")] = this.dataGridView2.Rows[i].Cells[3].Value; dataRow[PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")] = this.dataGridView2.Rows[i].Cells[4].Value; dataRow[PdnResources.GetString("Menu.Totaldecarburizationlayer.text")] = this.dataGridView2.Rows[i].Cells[5].Value; dtb.Rows.Add(dataRow); } List list = new List(); list.Add(dtb); this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true); } else { MessageBox.Show(PdnResources.GetString("Menu.Noanalysineratereport.text") + "!"); } } /// /// 图像索引切换选中事件 /// /// /// private void listView1_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected) { unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); this.documentWorkspace.phaseModels.Clear(); /// /// 选中图片的bitmap OpenCvSharp.Mat imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat(); Document document = Document.FromImageMat(imageMat.Clone()); this.documentWorkspace.Document = document; this.documentWorkspace.Visible = true; //this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList; if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count == 0) { this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels; } else { this.documentWorkspace.phaseModels.Add(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].AnalysisPhaseModel); } this.commonControlButtons.Visible = true; pointList = new List(); rectangleFList = new List(); lineCount = 0; this.dataGridView1.Rows.Clear(); } } /// /// 添加测量线按钮失去焦点 /// /// /// private void button3_LostFocus(object sender, EventArgs e) { operationK = -1; selected = -1; this.documentWorkspace.Refresh(); } /// /// 限制只可以输入0-9数字以及退格键 /// /// /// private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b')//这是允许输入退格键              { int len = this.textBox1.Text.Length; if (len < 1 && e.KeyChar == '0') { e.Handled = true; } else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字                  { e.Handled = true; } } } /// /// 对输入值做限制 /// /// /// private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) this.textBox1.Text = "1"; if (Convert.ToInt32(this.textBox1.Text) > 50) this.textBox1.Text = "50"; this.trackBar1.Value = Convert.ToInt32(this.textBox1.Text); } /// /// 限制只可以输入0-9数字以及退格键 /// /// /// private void textBox2_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar != '\b')//这是允许输入退格键              { int len = this.textBox1.Text.Length; if (len < 1 && e.KeyChar == '0') { e.Handled = true; } else if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字                  { e.Handled = true; } } } /// /// 对输入值做限制 /// /// /// private void textBox2_KeyUp(object sender, KeyEventArgs e) { if (string.IsNullOrEmpty(this.textBox2.Text)) this.textBox2.Text = "1"; if (Convert.ToInt32(this.textBox2.Text) > 50) this.textBox2.Text = "50"; this.trackBar2.Value = Convert.ToInt32(this.textBox2.Text); } /// /// 基准线panel被点击 /// /// /// private void panel1_Click(object sender, EventArgs e) { this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor); this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.colorsForm1Changed)); this.colorsForm1.ShowDialog(); } private void colorsForm1Changed(object sender, EventArgs e) { this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor(); this.colorsForm1.Close(); this.documentWorkspace.Refresh(); } /// /// 钢样表面panel被点击 /// /// /// private void panel2_Click(object sender, EventArgs e) { this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor); this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.colorsForm2Changed)); this.colorsForm2.ShowDialog(); } private void colorsForm2Changed(object sender, EventArgs e) { this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor(); this.colorsForm2.Close(); this.documentWorkspace.Refresh(); } /// /// 完全脱碳层panel被点击 /// /// /// private void panel3_Click(object sender, EventArgs e) { this.colorsForm3.UserPrimaryColor = ColorBgra.FromColor(this.panel3.BackColor); this.colorsForm3.setSaveBtn_Click(new System.EventHandler(this.colorsForm3Changed)); this.colorsForm3.ShowDialog(); } private void colorsForm3Changed(object sender, EventArgs e) { this.panel3.BackColor = this.colorsForm3.UserPrimaryColor.ToColor(); this.colorsForm3.Close(); this.documentWorkspace.Refresh(); } /// /// 有效脱碳层panel被点击 /// /// /// private void panel4_Click(object sender, EventArgs e) { this.colorsForm4.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor); this.colorsForm4.setSaveBtn_Click(new System.EventHandler(this.colorsForm4Changed)); this.colorsForm4.ShowDialog(); } private void colorsForm4Changed(object sender, EventArgs e) { this.panel4.BackColor = this.colorsForm4.UserPrimaryColor.ToColor(); this.colorsForm4.Close(); this.documentWorkspace.Refresh(); } /// /// 部分脱碳层panel被点击 /// /// /// private void panel5_Click(object sender, EventArgs e) { this.colorsForm5.UserPrimaryColor = ColorBgra.FromColor(this.panel5.BackColor); this.colorsForm5.setSaveBtn_Click(new System.EventHandler(this.colorsForm5Changed)); this.colorsForm5.ShowDialog(); } private void colorsForm5Changed(object sender, EventArgs e) { this.panel5.BackColor = this.colorsForm5.UserPrimaryColor.ToColor(); this.colorsForm5.Close(); this.documentWorkspace.Refresh(); } /// /// 线长滚动条滚动事件 /// /// /// private void trackBar1_Scroll(object sender, EventArgs e) { this.textBox1.Text = "" + this.trackBar1.Value; } private void trackBar1_ValueChanged(object sender, EventArgs e) { if (this.documentWorkspace != null) { this.documentWorkspace.Refresh(); } } /// /// 线宽滚动条滚动事件 /// /// /// private void trackBar2_Scroll(object sender, EventArgs e) { this.textBox2.Text = "" + this.trackBar2.Value; } private void trackBar2_ValueChanged(object sender, EventArgs e) { if (this.documentWorkspace != null) { this.documentWorkspace.Refresh(); } } /// /// 完全脱碳层选择框选中事件 /// /// /// private void checkBox2_CheckedChanged(object sender, EventArgs e) { if(this.pointList.Count > 0) { if (this.checkBox2.Checked && this.checkBox3.Checked) { foreach(PointF[] pf in pointList) { pf[2] = new PointF((pf[0].X + pf[3].X) / 2f, (pf[0].Y + pf[3].Y) / 2f); } } if (this.checkBox2.Checked && !this.checkBox3.Checked) { foreach (PointF[] pf in pointList) { pf[2] = new PointF((pf[0].X + pf[1].X) / 2f, (pf[0].Y + pf[1].Y) / 2f); } } if (!this.checkBox2.Checked) { foreach (PointF[] pf in pointList) { pf[2] = PointF.Empty; } } RefreshDataGridView1(); this.documentWorkspace.Refresh(); } } /// /// 有效脱碳层选择框选中事件 /// /// /// private void checkBox3_CheckedChanged(object sender, EventArgs e) { if (this.pointList.Count > 0) { if (this.checkBox3.Checked && this.checkBox2.Checked) { foreach (PointF[] pf in pointList) { pf[3] = new PointF((pf[2].X + pf[1].X) / 2f, (pf[2].Y + pf[1].Y) / 2f); } } if (this.checkBox3.Checked && !this.checkBox2.Checked) { foreach (PointF[] pf in pointList) { pf[3] = new PointF((pf[0].X + pf[1].X) / 2f, (pf[0].Y + pf[1].Y) / 2f); } } if (!this.checkBox3.Checked) { foreach (PointF[] pf in pointList) { pf[3] = PointF.Empty; } } RefreshDataGridView1(); this.documentWorkspace.Refresh(); } } /// /// 小数数字框值改变 /// /// /// private void numericUpDown1_ValueChanged(object sender, EventArgs e) { if (this.numericUpDown1.Value > this.numericUpDown1.Maximum) this.numericUpDown1.Value = this.numericUpDown1.Maximum; if (this.numericUpDown1.Value < this.numericUpDown1.Minimum) this.numericUpDown1.Value = this.numericUpDown1.Minimum; RefreshDataGridView1(); RefreshDataGridView2(); if (this.documentWorkspace != null) { this.documentWorkspace.Refresh(); } } /// /// 鼠标按下 /// /// /// private void BoxMouseDownHandler(object sender, MouseEventArgs e) { if (operationK >= 0 && e.Button == MouseButtons.Left) { PointF downPoint = this.documentWorkspace.GetScalePoint(e.Location); if (operationK == 0) { startPoint = endPoint = downPoint; nowLine = new PointF[4]; nowLine[0] = startPoint; nowLine[1] = endPoint; pointList.Add(nowLine); } else if (operationK == 1) { lastPoint.X = downPoint.X; lastPoint.Y = downPoint.Y; tempPoint.X = downPoint.X; tempPoint.Y = downPoint.Y; for (int i = rectangleFList.Count - 1; i >= 0; i--) { if (rectangleFList[i].Contains(downPoint)) { selected = i; canMove = true; } } if(selected > -1 && pointList != null && pointList.Count > 0) { int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5; int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5; if (new RectangleF(pointList[selected][0].X - tempLess, pointList[selected][0].Y - tempLess, tempPlus, tempPlus).Contains(downPoint)) movePointIndex = 0; else if (new RectangleF(pointList[selected][1].X - tempLess, pointList[selected][1].Y - tempLess, tempPlus, tempPlus).Contains(downPoint)) movePointIndex = 1; else if (pointList[selected][2] != PointF.Empty && new RectangleF(pointList[selected][2].X - tempLess, pointList[selected][2].Y - tempLess, tempPlus, tempPlus).Contains(downPoint)) movePointIndex = 2; else if (pointList[selected][3] != PointF.Empty && new RectangleF(pointList[selected][3].X - tempLess, pointList[selected][3].Y - tempLess, tempPlus, tempPlus).Contains(downPoint)) movePointIndex = 3; else movePointIndex = -1; this.documentWorkspace.Refresh(); } if (canMove) return; selected = -1; } } } /// /// 鼠标移动 /// /// /// private void BoxMouseMoveHandler(object sender, MouseEventArgs e) { this.documentWorkspace.panel.Cursor = Cursors.Default; if (operationK >= 0 && e.Button == MouseButtons.Left) { PointF movePoint = this.documentWorkspace.GetScalePoint(e.Location); if (operationK == 0) { this.endPoint = movePoint; pointList[lineCount][1] = endPoint; } else if (operationK == 1 && selected > -1 && canMove) { float dx = movePoint.X - lastPoint.X; float dy = movePoint.Y - lastPoint.Y; float dxTemp = movePoint.X - tempPoint.X; float dyTemp = movePoint.Y - tempPoint.Y; lastPoint.X = movePoint.X; lastPoint.Y = movePoint.Y; if (movePointIndex == -1) { RectangleF rectangleF = new RectangleF(); rectangleF = rectangleFList[selected]; if (rectangleF.Contains(movePoint)) this.documentWorkspace.panel.Cursor = Cursors.SizeAll; rectangleF.X += dx; rectangleF.Y += dy; rectangleFList[selected] = rectangleF; for (int i = 0; i < pointList[selected].Count(); i++) { if (pointList[selected][i] == PointF.Empty) continue; pointList[selected][i].X += dx; pointList[selected][i].Y += dy; } } else if (movePointIndex == 0) { pointList[selected][0].X += dx; pointList[selected][0].Y += dy; if (checkBox2.Checked && checkBox3.Checked) { pointList[selected][2] = new PointF((2 * pointList[selected][0].X + pointList[selected][1].X) / 3f, (2 * pointList[selected][0].Y + pointList[selected][1].Y) / 3f); pointList[selected][3] = new PointF((pointList[selected][0].X + 2 * pointList[selected][1].X) / 3f, (pointList[selected][0].Y + 2 * pointList[selected][1].Y) / 3f); } else if (checkBox2.Checked && !checkBox3.Checked) { pointList[selected][2] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f, (pointList[selected][0].Y + pointList[selected][1].Y) / 2f); pointList[selected][3] = PointF.Empty; } else if (!checkBox2.Checked && checkBox3.Checked) { pointList[selected][3] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f, (pointList[selected][0].Y + pointList[selected][1].Y) / 2f); pointList[selected][2] = PointF.Empty; } else { pointList[selected][2] = PointF.Empty; pointList[selected][3] = PointF.Empty; } rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]); } else if (movePointIndex == 1) { pointList[selected][1].X += dx; pointList[selected][1].Y += dy; if (checkBox2.Checked && checkBox3.Checked) { pointList[selected][2] = new PointF((2 * pointList[selected][0].X + pointList[selected][1].X) / 3f, (2 * pointList[selected][0].Y + pointList[selected][1].Y) / 3f); pointList[selected][3] = new PointF((pointList[selected][0].X + 2 * pointList[selected][1].X) / 3f, (pointList[selected][0].Y + 2 * pointList[selected][1].Y) / 3f); } else if (checkBox2.Checked && !checkBox3.Checked) { pointList[selected][2] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f, (pointList[selected][0].Y + pointList[selected][1].Y) / 2f); pointList[selected][3] = PointF.Empty; } else if (!checkBox2.Checked && checkBox3.Checked) { pointList[selected][3] = new PointF((pointList[selected][0].X + pointList[selected][1].X) / 2f, (pointList[selected][0].Y + pointList[selected][1].Y) / 2f); pointList[selected][2] = PointF.Empty; } else { pointList[selected][2] = PointF.Empty; pointList[selected][3] = PointF.Empty; } rectangleFList[selected] = CalcOtherRectangle(pointList[selected][0], pointList[selected][1]); } else if (movePointIndex == 2) { //测量线是一条垂线 if (pointList[selected][0].X == pointList[selected][1].X) { pointList[selected][2].Y += dy; if (pointList[selected][3] == PointF.Empty) pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][2].Y); else pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][3].Y, pointList[selected][2].Y); } //测量线是一条平行线 else if (pointList[selected][0].Y == pointList[selected][1].Y) { pointList[selected][2].X += dx; if (pointList[selected][3] == PointF.Empty) pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][2].X); else pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][3].X, pointList[selected][2].X); } //其他情况 else { float k = (pointList[selected][1].Y - pointList[selected][0].Y) / (pointList[selected][1].X - pointList[selected][0].X); float b = pointList[selected][0].Y - k * pointList[selected][0].X; if (Math.Abs(dxTemp) >= Math.Abs(dyTemp)) { pointList[selected][2].X += dx; if (pointList[selected][3] == PointF.Empty) pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][2].X); else pointList[selected][2].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][3].X, pointList[selected][2].X); pointList[selected][2].Y = k * pointList[selected][2].X + b; } else { pointList[selected][2].Y += dy; if (pointList[selected][3] == PointF.Empty) pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][2].Y); else pointList[selected][2].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][3].Y, pointList[selected][2].Y); pointList[selected][2].X = (pointList[selected][2].Y - b) / k; } } } else if (movePointIndex == 3) { //测量线是一条垂线 if (pointList[selected][0].X == pointList[selected][1].X) { pointList[selected][3].Y += dy; if (pointList[selected][2] == PointF.Empty) pointList[selected][3].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][3].Y); else pointList[selected][3].Y = FormatCoordinate(pointList[selected][2].Y, pointList[selected][1].Y, pointList[selected][3].Y); } //测量线是一条平行线 else if (pointList[selected][0].Y == pointList[selected][1].Y) { pointList[selected][3].X += dx; if (pointList[selected][2] == PointF.Empty) pointList[selected][3].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][3].X); else pointList[selected][3].X = FormatCoordinate(pointList[selected][2].X, pointList[selected][1].X, pointList[selected][3].X); } //其他情况 else { float k = (pointList[selected][1].Y - pointList[selected][0].Y) / (pointList[selected][1].X - pointList[selected][0].X); float b = pointList[selected][0].Y - k * pointList[selected][0].X; if (Math.Abs(dxTemp) >= Math.Abs(dyTemp)) { pointList[selected][3].X += dx; if (pointList[selected][2] == PointF.Empty) pointList[selected][3].X = FormatCoordinate(pointList[selected][0].X, pointList[selected][1].X, pointList[selected][3].X); else pointList[selected][3].X = FormatCoordinate(pointList[selected][2].X, pointList[selected][1].X, pointList[selected][3].X); pointList[selected][3].Y = k * pointList[selected][3].X + b; } else { pointList[selected][3].Y += dy; if (pointList[selected][2] == PointF.Empty) pointList[selected][3].Y = FormatCoordinate(pointList[selected][0].Y, pointList[selected][1].Y, pointList[selected][3].Y); else pointList[selected][3].Y = FormatCoordinate(pointList[selected][2].Y, pointList[selected][1].Y, pointList[selected][3].Y); pointList[selected][3].X = (pointList[selected][3].Y - b) / k; } } } } this.documentWorkspace.Refresh(); } } /// /// 鼠标抬起 /// /// /// private void BoxMouseUpHandler(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Left) { if (operationK == 0) { if (startPoint != null && endPoint != null && startPoint != endPoint) { if (checkBox2.Checked && checkBox3.Checked) { pointList[lineCount][2] = new PointF((2 * startPoint.X + endPoint.X) / 3f, (2 * startPoint.Y + endPoint.Y) / 3f); pointList[lineCount][3] = new PointF((startPoint.X + 2 * endPoint.X) / 3f, (startPoint.Y + 2 * endPoint.Y) / 3f); } else if (checkBox2.Checked && !checkBox3.Checked) { pointList[lineCount][2] = new PointF((startPoint.X + endPoint.X) / 2f, (startPoint.Y + endPoint.Y) / 2f); } else if (!checkBox2.Checked && checkBox3.Checked) { pointList[lineCount][3] = new PointF((startPoint.X + endPoint.X) / 2f, (startPoint.Y + endPoint.Y) / 2f); } RectangleF rectangleF = CalcOtherRectangle(pointList[lineCount][0], pointList[lineCount][1]); rectangleFList.Add(rectangleF); lineCount++; AddContentToDataGridView(); } else { pointList.RemoveAt(pointList.Count - 1); } this.documentWorkspace.Refresh(); } else if (operationK == 1) { canMove = false; movePointIndex = -1; RefreshDataGridView1(); } } } /// /// 绘制事件 /// /// /// private void BoxPaintHandler(object sender, PaintEventArgs e) { if (this.documentWorkspace.CompositionSurface != null) { 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); } } // /// 存储字号与颜色字典 /// public Dictionary colourFont = new Dictionary() { { "20", Color.Black } }; /// /// 绘制 /// private void Draw(Graphics graphics) { graphics.SmoothingMode = SmoothingMode.AntiAlias; Pen standardPen = new Pen(this.panel1.BackColor, this.trackBar2.Value);//基准线画笔 Pen surfacePen = new Pen(this.panel2.BackColor, this.trackBar2.Value);//钢样表面画笔 Pen completePen = new Pen(this.panel3.BackColor, this.trackBar2.Value);//完全脱碳层画笔 Pen validPen = new Pen(this.panel4.BackColor, this.trackBar2.Value);//有效脱碳层画笔 Pen partPen = new Pen(this.panel5.BackColor, this.trackBar2.Value);//部分脱碳层画笔 Pen borderPen = new Pen(Color.Black);//填充点外圈 SolidBrush insideBrush = new SolidBrush(Color.White);//填充点内圈 Pen rectPen = new Pen(Color.Black); rectPen.DashStyle = DashStyle.Custom; float[] dashArray = { 2.0f,3.0f }; rectPen.DashPattern = dashArray; if (pointList.Count > 0) { foreach(PointF[] pointFs in pointList) { PointF[] pf = pointFs; if (pointFs.Count() > 1 && pointFs[0] != pointFs[1]) { float lineLength = this.trackBar1.Value / 2f; double angle = Math.Round(BasicCalculationHelper.AngleText(pointFs[0], pointFs[1], new PointF(pointFs[0].X + lineLength, pointFs[0].Y)), 10); //判断第二个点相对于第一个点的象限 int x2 = (int)(pointFs[1].X - pointFs[0].X); if (x2 == 0) x2 = 1; int y2 = (int)(pointFs[1].Y - pointFs[0].Y); if (y2 == 0) y2 = 1; int i2 = 0; if (x2 > 0 && y2 > 0) //第4象限 { i2 = 4; } else if (x2 > 0 && y2 < 0) //第1象限 { i2 = 1; } else if (x2 < 0 && y2 < 0) //第2象限 { i2 = 2; } else if (x2 < 0 && y2 > 0) //第3象限 { i2 = 3; } double sAngle1; double eAngle1; double sAngle2; double eAngle2; if (i2 == 1 || i2 == 2) { sAngle1 = 360 - angle; eAngle1 = 180 - angle; sAngle2 = 270 - angle; eAngle2 = 90 - angle; } else { sAngle1 = angle; eAngle1 = 180 + angle; sAngle2 = 270 + angle; eAngle2 = 90 + angle; } graphics.DrawLine(standardPen, pointFs[0], pointFs[1]); if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2)) { PointF assistPoint1 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], sAngle2); PointF assistPoint2 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[0].X + lineLength), pointFs[0].Y), pointFs[0], eAngle2); PointF assistPoint3 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], sAngle2); PointF assistPoint4 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[1].X + lineLength), pointFs[1].Y), pointFs[1], eAngle2); graphics.DrawLine(surfacePen, assistPoint1, assistPoint2); graphics.DrawLine(partPen, assistPoint3, assistPoint4); if (this.checkBox2.Checked) { if (i2 == 1 || i2 == 2) { if (this.checkBox6.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint4.X, assistPoint4.Y - 10); } } else { if (this.checkBox6.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint3.X, assistPoint3.Y - 10); } } } } if (pointFs[2] != PointF.Empty && checkBox2.Checked) { if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2)) { PointF assistPoint5 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[2].X + lineLength), pointFs[2].Y), pointFs[2], sAngle2); PointF assistPoint6 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[2].X + lineLength), pointFs[2].Y), pointFs[2], eAngle2); graphics.DrawLine(completePen, assistPoint5, assistPoint6); if (i2 == 1 || i2 == 2) { if (this.checkBox4.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint6.X, assistPoint6.Y - 10); } } else { if (this.checkBox4.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint5.X, assistPoint5.Y - 10); } } } } if (pointFs[3] != PointF.Empty && checkBox3.Checked) { if (!double.IsNaN(sAngle1) && !double.IsNaN(eAngle1) && !double.IsNaN(sAngle2) && !double.IsNaN(eAngle2)) { PointF assistPoint7 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[3].X + lineLength), pointFs[3].Y), pointFs[3], sAngle2); PointF assistPoint8 = BasicCalculationHelper.GetAnglePoint(new PointF((pointFs[3].X + lineLength), pointFs[3].Y), pointFs[3], eAngle2); graphics.DrawLine(validPen, assistPoint7, assistPoint8); if (i2 == 1 || i2 == 2) { if (this.checkBox5.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint8.X, assistPoint8.Y - 10); } } else { if (this.checkBox5.Checked) { graphics.DrawString(double.Parse(CreateTextBoxCell(BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength + "", "").Value.ToString()).ToString("F" + this.numericUpDown1.Value), new Font("宋体", float.Parse(colourFont.Keys.First()), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), new SolidBrush(colourFont.Values.First()), assistPoint7.X, assistPoint7.Y - 10); } } } } } } if (selected > -1) { int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)); int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)); graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][0].X - tempLess), (int)(pointList[selected][0].Y - tempLess), tempPlus, tempPlus)); graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][0].X - tempLess, pointList[selected][0].Y - tempLess, tempPlus, tempPlus)); graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][1].X - tempLess), (int)(pointList[selected][1].Y - tempLess), tempPlus, tempPlus)); graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][1].X - tempLess, pointList[selected][1].Y - tempLess, tempPlus, tempPlus)); if (pointList[selected][2] != PointF.Empty && checkBox2.Checked) { graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][2].X - tempLess), (int)(pointList[selected][2].Y - tempLess), tempPlus, tempPlus)); graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][2].X - tempLess, pointList[selected][2].Y - tempLess, tempPlus, tempPlus)); } if (pointList[selected][3] != PointF.Empty && checkBox3.Checked) { graphics.DrawRectangle(borderPen, new Rectangle((int)(pointList[selected][3].X - tempLess), (int)(pointList[selected][3].Y - tempLess), tempPlus, tempPlus)); graphics.FillRectangle(insideBrush, new RectangleF(pointList[selected][3].X - tempLess, pointList[selected][3].Y - tempLess, tempPlus, tempPlus)); } graphics.DrawRectangle(rectPen, rectangleFList[selected].X, rectangleFList[selected].Y, rectangleFList[selected].Width, rectangleFList[selected].Height); } } standardPen.Dispose(); surfacePen.Dispose(); completePen.Dispose(); validPen.Dispose(); partPen.Dispose(); borderPen.Dispose(); insideBrush.Dispose(); rectPen.Dispose(); } private void checkBox4_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void checkBox5_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void checkBox6_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } /// /// 计算外接矩形 /// private RectangleF CalcOtherRectangle(PointF p1, PointF p2) { RectangleF rectangleF = new RectangleF(); if (p1.X > p2.X) rectangleF.X = p2.X; else rectangleF.X = p1.X; if (p1.Y > p2.Y) rectangleF.Y = p2.Y; else rectangleF.Y = p1.Y; rectangleF.Width = Math.Abs(p2.X - p1.X); rectangleF.Height = Math.Abs(p2.Y - p1.Y); int tempLess = (int)(InvariantData.rectless * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5; int tempPlus = (int)(InvariantData.rectplus * (this.documentWorkspace.ScaleFactor.Ratio < 1 ? 1 / this.documentWorkspace.ScaleFactor.Ratio : 1)) * 5; return new RectangleF(rectangleF.X - tempLess, rectangleF.Y - tempLess, rectangleF.Width + tempPlus, rectangleF.Height + tempPlus); } /// /// 向数据展示表插入数据 /// private void AddContentToDataGridView() { PointF[] pf = pointList[lineCount - 1]; DataGridViewRow row = new DataGridViewRow(); row.Height = 37; row.Cells.Add(CreateTextBoxCell("L" + (lineCount), "")); //完全脱碳层 if (pf[2] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //有效脱碳层 if (pf[3] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //部分脱碳层 if (pf[2] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //总脱碳层 row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); if (this.dataGridView1.Rows.Count == 0) { this.dataGridView1.Rows.Add(row); DataGridViewRow rowAvg = new DataGridViewRow(); rowAvg.Height = 36; rowAvg.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Image.Average.Text"), "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); this.dataGridView1.Rows.Add(rowAvg); } else { this.dataGridView1.Rows.Insert(lineCount - 1, row); this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[1].Value = Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[2].Value = Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[3].Value = Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value)); this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[4].Value = Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value)); } this.dataGridView1.ClearSelection(); this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 2].Selected = true; } /// /// 计算指定索引列的平均值 /// /// /// private double CalculateAverage(int ColumnIndex) { double sum = 0; double avg = 0; if (this.dataGridView1.Rows.Count > 0) { for (int i = 0; i < lineCount; i++) { try { double cellValue = double.Parse(this.dataGridView1.Rows[i].Cells[ColumnIndex].Value.ToString()); sum += cellValue; } catch (Exception e) { continue; } } avg = sum / lineCount; } return avg; } /// /// 分析结果列表选择切换 /// /// /// private void listView2_SelectedIndexChanged(object sender, EventArgs e) { if (this.showAll) return; RefreshDataGridView2(); } /// /// 刷新数据展示表 /// private void RefreshDataGridView1() { int selectedRowIndex = -1; if (this.dataGridView1.Rows.Count > 0) selectedRowIndex = this.dataGridView1.SelectedRows[0].Index; this.dataGridView1.Rows.Clear(); for(int i = 0; i < pointList.Count; i++) { PointF[] pf = pointList[i]; DataGridViewRow row = new DataGridViewRow(); row.Height = 37; row.Cells.Add(CreateTextBoxCell("L" + (i + 1), "")); //完全脱碳层 if (pf[2] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[2], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //有效脱碳层 if (pf[3] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[3], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //部分脱碳层 if (pf[2] == PointF.Empty) row.Cells.Add(CreateTextBoxCell("0", "")); else row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[2], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); //总脱碳层 row.Cells.Add(CreateTextBoxCell(double.Parse((BasicCalculationHelper.GetDistance(pf[1], pf[0], Convert.ToInt32(this.numericUpDown1.Value)) * unitLength).ToString("F" + this.numericUpDown1.Value)) + "", "")); this.dataGridView1.Rows.Add(row); } if (this.dataGridView1.Rows.Count > 0) { DataGridViewRow rowAvg = new DataGridViewRow(); rowAvg.Height = 36; rowAvg.Cells.Add(CreateTextBoxCell(PdnResources.GetString("Menu.Image.Average.Text"), "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(1), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(2), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(3), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); rowAvg.Cells.Add(CreateTextBoxCell(Math.Round(CalculateAverage(4), Convert.ToInt32(this.numericUpDown1.Value)) + "", "")); this.dataGridView1.Rows.Add(rowAvg); } this.dataGridView1.ClearSelection(); if (selectedRowIndex > this.dataGridView1.Rows.Count - 1) selectedRowIndex = this.dataGridView1.Rows.Count - 1; if (selectedRowIndex < 0) selectedRowIndex = 0; if (this.dataGridView1.Rows.Count > 0) this.dataGridView1.Rows[selectedRowIndex].Selected = true; } /// /// 格式化坐标点 /// /// 参考点1 /// 参考点2 /// 需比对的点 /// private float FormatCoordinate(float coordinateA, float coordinateB, float basicCoordinate) { float coordinate = basicCoordinate; float[] pointArr = new float[] { coordinateA, coordinateB }; if (coordinate > pointArr.Max() - 3) coordinate = pointArr.Max() - 3; if (coordinate < pointArr.Min() + 3) coordinate = pointArr.Min() + 3; return coordinate; } /// /// 导出项目按钮 /// /// /// private void button10_Click(object sender, EventArgs e) { try { if (this.analyzeSettingModel == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!"); return; } //获取项目工程内的文件夹路径 ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.SteelDecarburization.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>(); List contentHead = new List(); contentHead.Add(PdnResources.GetString("Menu.picture.Text")); contentHead.Add(PdnResources.GetString("Menu.packet.text")); contentHead.Add(PdnResources.GetString("Menu.Completelydecarburizedlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Effectivedecarbonizationlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Partiallydecarburizedlayer.text")); contentHead.Add(PdnResources.GetString("Menu.Totaldecarburizationlayer.text")); analysisContent.Add(contentHead); foreach (DataGridViewRow rowItem in this.dataGridView2.Rows) { List content = new List(); content.Add(rowItem.Cells[0].Value.ToString()); content.Add(rowItem.Cells[1].Value.ToString()); content.Add(rowItem.Cells[2].Value.ToString()); content.Add(rowItem.Cells[3].Value.ToString()); content.Add(rowItem.Cells[4].Value.ToString()); content.Add(rowItem.Cells[5].Value.ToString()); analysisContent.Add(content); } //图片 bitList = new List(); if (this.showAll) { 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 rowItem in this.listView2.SelectedItems) { if (bitDic.ContainsKey(rowItem.Name)) { bitList.Add(bitDic[rowItem.Name][0]); bitList.Add(bitDic[rowItem.Name][1]); } } } } //中间数据 if (!this.showAll) { 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.Name)) { 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) { } } #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, checkBox1.Checked ? "0" : "1", (int)PaintDotNet.Base.Dtryt.Boolean);//报告设置 saveParamValue(ParamKey_LineLength, trackBar1 != null ? trackBar1.Value.ToString() : "40", (int)Base.Dtryt.Interger);//线长 saveParamValue(ParamKey_LineWidth, trackBar2 != null ? trackBar2.Value.ToString() : "3", (int)Base.Dtryt.Interger);//线宽 saveParamValue(ParamKey_Baseline, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//基准线颜色 saveParamValue(ParamKey_Surface, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//钢样表面颜色 saveParamValue(ParamKey_Whole, checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//完全 saveParamValue(ParamKey_WholeColour, panel3.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//完全颜色 saveParamValue(ParamKey_Valid, checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//有效 saveParamValue(ParamKey_ValidColour, panel4.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//有效颜色 saveParamValue(ParamKey_Part, checkBox6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//部分 saveParamValue(ParamKey_PartColour, panel5.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//部分颜色 saveParamValue(ParamKey_WholeGauge, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//完全测量 saveParamValue(ParamKey_ValidGauge, checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//有效测量 saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (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: checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_LineLength: trackBar1.Value = (int)this.analysisModel.ListParam[i].value; textBox1.Text = "" + trackBar1.Value; break; case ParamKey_LineWidth: trackBar2.Value = (int)this.analysisModel.ListParam[i].value; textBox2.Text = "" + trackBar2.Value; break; case ParamKey_Baseline: panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_Surface: panel2.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_Whole: checkBox4.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_WholeColour: panel3.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_Valid: checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_ValidColour: panel4.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_Part: checkBox6.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_PartColour: panel5.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_WholeGauge: checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_ValidGauge: checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_DecimalPlace: numericUpDown1.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; } } } } private void MetallographicMethod3887Dialog_FormClosing(object sender, FormClosingEventArgs e) { #region [开启脚本录制] if (appWorkspace.startScriptRecording) { getScriptRecording(); } #endregion 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); } #endregion #region [脚本相关] private void getValue(string key, object value) { switch (key) { case "parameter1": trackBar1.Value = Convert.ToInt32(value); textBox1.Text = value.ToString(); break; case "parameter2": trackBar2.Value = Convert.ToInt32(value); textBox2.Text = value.ToString(); break; case "parameter3": panel1.BackColor = Color.FromArgb((int)value); break; case "parameter4": checkBox4.Checked = Convert.ToBoolean(value); break; case "parameter5": panel3.BackColor = Color.FromArgb((int)value); break; case "parameter6": panel2.BackColor = Color.FromArgb((int)value); break; case "parameter7": checkBox5.Checked = Convert.ToBoolean(value); break; case "parameter8": panel4.BackColor = Color.FromArgb((int)value); break; case "parameter9": checkBox6.Checked = Convert.ToBoolean(value); break; case "parameter10": panel5.BackColor = Color.FromArgb((int)value); break; case "parameter11": checkBox2.Checked = Convert.ToBoolean(value); break; case "parameter12": checkBox3.Checked = Convert.ToBoolean(value); break; case "OpenWhileExportReport": checkBox1.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); } appWorkspace.SetScriptStartRecording(this.menuId, menuName, args); } private object setScriptRecording(string key) { object value = null; switch (key) { case "parameter1": value = trackBar1.Value; break; case "parameter2": value = trackBar2.Value; break; case "parameter3": value = panel1.BackColor.ToArgb(); break; case "parameter4": value = checkBox4.Checked; break; case "parameter5": value = panel3.BackColor.ToArgb(); break; case "parameter6": value = panel2.BackColor.ToArgb(); break; case "parameter7": value = checkBox5.Checked; break; case "parameter8": value = panel4.BackColor.ToArgb(); break; case "parameter9": value = checkBox6.Checked; break; case "parameter10": value = panel5.BackColor.ToArgb(); break; case "parameter11": value = checkBox2.Checked; break; case "parameter12": value = checkBox3.Checked; break; case "OpenWhileExportReport": value = checkBox1.Checked; break; case "CalculatorDecimalDigits": value = numericUpDown1.Value; break; } return value; } #endregion } }