using PaintDotNet.Annotation; using PaintDotNet.Annotation.Command; using PaintDotNet.Annotation.DedicatedAnalysis; using PaintDotNet.Annotation.Enum; using PaintDotNet.Base.DedicatedAnalysis.Inclusions; using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model; using PaintDotNet.Base.Functionodel; using PaintDotNet.CustomControl; using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.MethodOfAssessment; using static PaintDotNet.DedicatedAnalysis.Inclusions.InclusionsStandardDialog; namespace PaintDotNet.DedicatedAnalysis.Inclusions { class InclusionEditDialog: Form { #region 属性 private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button btn_close; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label3; private System.Windows.Forms.NumericUpDown numericUpDown2; private System.Windows.Forms.NumericUpDown numericUpDown1; private System.Windows.Forms.Label label2; private System.Windows.Forms.GroupBox groupBox_review; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private Label label5; private Label label1; private Label label6; private TextBox textBox3; private NumericUpDown numericUpDown3; private ComboBox comboBox2; private ComboBox comboBox1; private DocumentItem documentItem; private CommonControlButtons commonControlButtons; private DocumentWorkspaceWindow documentWorkspace; private AppWorkspace appWorkspace; private AnalysisResult analysisResult; private System.Action closeCallback; private ISurfaceBox drawArea; private ComboBox comboBox3; private Label label7; private bool is_showRectangle; private bool is_showOval; private int is_full; private int isK; private List selectedInclusion = new List(); // 选定夹杂物类型 操作 记录点 private System.Drawing.Point? selectedTypesOfInclusionsPoint = null; private System.Drawing.RectangleF? selectedTypesOfInclusionsRectangle = null; private enum SelectionMode { None, NetSelection, // group selection is active Move, // object(s) are moves Size // object is resized } #endregion #region 初始化 private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.btn_close.Text = PdnResources.GetString("Form.OkButton.Text"); this.button2.Text = PdnResources.GetString("ConfirmLanguageDialog.CancelTB.ActionText"); this.groupBox2.Text = PdnResources.GetString("Menu.Inclusionproperties.text"); this.label6.Text = PdnResources.GetString("Menu.Chemicalproperties.text"); this.label5.Text = PdnResources.GetString("Menu.Typeofinclusion.text"); this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Classificationofinclusions.text"); this.label4.Text = PdnResources.GetString("Menu.area.text"); this.label3.Text = PdnResources.GetString("Menu.width.text"); this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"); this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox3.Text = PdnResources.GetString("Menu.operation.text"); this.button5.Text = PdnResources.GetString("Menu.polygonadd.text"); this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button3.Text = PdnResources.GetString("Menu.Split.text"); this.button1.Text = PdnResources.GetString("Menu.combination.text"); this.label7.Text = PdnResources.GetString("Menu.color.text"); this.Text = PdnResources.GetString("Menu.Inclusionsedit.text"); } private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.btn_close = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.comboBox3 = new System.Windows.Forms.ComboBox(); this.label7 = new System.Windows.Forms.Label(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.textBox3 = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown3 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.label2 = new System.Windows.Forms.Label(); this.groupBox_review = new System.Windows.Forms.GroupBox(); this.groupBox3 = 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.button1 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.groupBox3.SuspendLayout(); 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.btn_close); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1145, 53); this.groupBox1.TabIndex = 12; this.groupBox1.TabStop = false; // // btn_close // this.btn_close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btn_close.Location = new System.Drawing.Point(972, 21); this.btn_close.Name = "btn_close"; this.btn_close.Size = new System.Drawing.Size(75, 23); this.btn_close.TabIndex = 3; this.btn_close.UseVisualStyleBackColor = true; this.btn_close.Click += new System.EventHandler(this.btn_close_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.Location = new System.Drawing.Point(1053, 21); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // groupBox2 // this.groupBox2.Controls.Add(this.comboBox3); this.groupBox2.Controls.Add(this.label7); this.groupBox2.Controls.Add(this.comboBox2); this.groupBox2.Controls.Add(this.comboBox1); this.groupBox2.Controls.Add(this.textBox3); this.groupBox2.Controls.Add(this.label6); this.groupBox2.Controls.Add(this.label5); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.numericUpDown2); this.groupBox2.Controls.Add(this.numericUpDown3); this.groupBox2.Controls.Add(this.numericUpDown1); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Location = new System.Drawing.Point(12, 71); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(224, 408); this.groupBox2.TabIndex = 18; this.groupBox2.TabStop = false; // // comboBox3 // this.comboBox3.FormattingEnabled = true; this.comboBox3.Location = new System.Drawing.Point(100, 135); this.comboBox3.Name = "comboBox3"; this.comboBox3.Size = new System.Drawing.Size(111, 20); this.comboBox3.TabIndex = 13; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(12, 139); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(0, 12); this.label7.TabIndex = 12; // // comboBox2 // this.comboBox2.FormattingEnabled = true; this.comboBox2.Location = new System.Drawing.Point(100, 161); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(111, 20); this.comboBox2.TabIndex = 11; // // comboBox1 // this.comboBox1.FormattingEnabled = true; this.comboBox1.Items.AddRange(new object[] { "α", "β", "γ", "δ"}); this.comboBox1.Location = new System.Drawing.Point(100, 187); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(111, 20); this.comboBox1.TabIndex = 10; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // textBox3 // this.textBox3.Location = new System.Drawing.Point(100, 244); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(111, 21); this.textBox3.TabIndex = 9; this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(12, 247); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(0, 12); this.label6.TabIndex = 7; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(12, 164); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 7; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 190); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 7; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(12, 79); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(0, 12); this.label4.TabIndex = 7; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(12, 52); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(0, 12); this.label3.TabIndex = 8; // // numericUpDown2 // this.numericUpDown2.DecimalPlaces = 10; this.numericUpDown2.Location = new System.Drawing.Point(100, 50); this.numericUpDown2.Maximum = new decimal(new int[] { 1241513983, 370409800, 542101, 0}); this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.ReadOnly = true; this.numericUpDown2.Size = new System.Drawing.Size(111, 21); this.numericUpDown2.TabIndex = 5; this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); // // numericUpDown3 // this.numericUpDown3.DecimalPlaces = 10; this.numericUpDown3.Location = new System.Drawing.Point(100, 77); this.numericUpDown3.Maximum = new decimal(new int[] { 1241513983, 370409800, 542101, 0}); this.numericUpDown3.Name = "numericUpDown3"; this.numericUpDown3.ReadOnly = true; this.numericUpDown3.Size = new System.Drawing.Size(111, 21); this.numericUpDown3.TabIndex = 6; this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged); // // numericUpDown1 // this.numericUpDown1.DecimalPlaces = 10; this.numericUpDown1.Location = new System.Drawing.Point(100, 24); this.numericUpDown1.Maximum = new decimal(new int[] { 1241513983, 370409800, 542101, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.ReadOnly = true; this.numericUpDown1.Size = new System.Drawing.Size(111, 21); this.numericUpDown1.TabIndex = 6; this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(12, 26); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(0, 12); this.label2.TabIndex = 4; // // groupBox_review // this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox_review.Location = new System.Drawing.Point(242, 71); this.groupBox_review.Name = "groupBox_review"; this.groupBox_review.Size = new System.Drawing.Size(915, 661); this.groupBox_review.TabIndex = 19; this.groupBox_review.TabStop = false; // // groupBox3 // this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox3.Controls.Add(this.button5); this.groupBox3.Controls.Add(this.button4); this.groupBox3.Controls.Add(this.button3); this.groupBox3.Controls.Add(this.button1); this.groupBox3.Location = new System.Drawing.Point(12, 485); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(224, 247); this.groupBox3.TabIndex = 20; this.groupBox3.TabStop = false; // // button5 // this.button5.Location = new System.Drawing.Point(95, 49); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(75, 23); this.button5.TabIndex = 0; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button4 // this.button4.Location = new System.Drawing.Point(14, 49); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(75, 23); this.button4.TabIndex = 0; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.Location = new System.Drawing.Point(95, 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); // // button1 // this.button1.Location = new System.Drawing.Point(14, 20); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // InclusionEditDialog // this.ClientSize = new System.Drawing.Size(1177, 744); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox_review); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Name = "InclusionEditDialog"; this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.groupBox3.ResumeLayout(false); this.ResumeLayout(false); } public void Initialize(AnalysisResult tempAnalysisResult) { this.FormClosed += new FormClosedEventHandler(formClosed); InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings; this.comboBox2.Items.AddRange(inclusionsGlobalSettings.typeDics.Keys.ToArray()); this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); this.comboBox3.Items.AddRange(inclusionsGlobalSettings.colorOfInclusions.Keys.ToArray()); this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged); // //初始化图像控件 // this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace); this.documentWorkspace.Cursor = Cursors.Default; this.documentWorkspace.Dock = DockStyle.Fill; this.documentWorkspace.HookMouseEvents(); this.documentWorkspace.AuxiliaryLineEnabled = false; this.documentWorkspace.Visible = false; this.groupBox_review.Controls.Add(documentWorkspace); this.documentWorkspace.Visible = true; this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelect; this.documentWorkspace.Document = Document.FromImageMat(this.documentItem.imageMat.Clone()); this.documentWorkspace.GraphicsList = this.documentItem.graphicsList; this.documentWorkspace.PhaseModels = new List(); this.documentWorkspace.PhaseModels.AddRange(this.documentItem.phaseModels); this.drawArea = this.documentWorkspace; this.documentWorkspace.panel.MouseDown += OnMouseDown; this.documentWorkspace.panel.MouseUp += OnMouseUp; this.documentWorkspace.panel.MouseMove += OnMouseMove; // //初始化操作按钮 // this.commonControlButtons = new CommonControlButtons(); this.commonControlButtons.Dock = DockStyle.Top; this.commonControlButtons.Height = 30; this.commonControlButtons.HideZoomToWindowAndActualSize(); this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click); this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click); this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click); this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click); this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click); this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click); groupBox_review.Controls.Add(this.commonControlButtons); foreach (var item in tempAnalysisResult.inclusions) { this.documentWorkspace.GraphicsList.Add(new InclusionDrawObject(this.documentWorkspace, item)); } ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, tempAnalysisResult.inclusions,true,is_showOval, is_full); } #endregion #region 构造函数 public InclusionEditDialog(string Text, AppWorkspace appWorkspace, DocumentItem documentItem , AnalysisResult analysisResult, System.Action closeCallback, bool is_showRectangle, bool is_showOval,int is_full,int isK) { this.appWorkspace = appWorkspace; this.documentItem = documentItem; this.analysisResult = analysisResult; this.closeCallback = closeCallback; this.isK = isK; this.is_showOval = is_showOval; this.is_showRectangle = is_showRectangle; this.is_full = is_full; InitializeComponent(); InitializeLanguageText(); Initialize(analysisResult); string[] titleList = Text.Split('_'); if (titleList.Count() > 0 && titleList[0] == "EN10247") { this.label1.Visible = true; this.comboBox1.Visible = true; } else { this.label1.Visible = false; this.comboBox1.Visible = false; } MethodOfAssessment.activeMethod.is_full = is_full; } #endregion #region 事件 #region 公共按钮 private void zoomInButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomIn(); } private void zoomOutButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomOut(); } private void zoomToWindowButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; } private void actualSizeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor; this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne; } private void pointerButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionSelect; } private void mobileModeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode; } #endregion #region [滑动选中] /// /// Left mouse button is pressed /// /// /// private void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.selectedTypesOfInclusionsPoint = e.Location; } } /// /// Mouse is moved. /// None button is pressed, or left button is pressed. /// /// /// private void OnMouseMove(object sender, MouseEventArgs e) { Pen pen = new Pen(Color.Black,3); if (this.selectedTypesOfInclusionsPoint == null) { return; } this.documentWorkspace.Refresh(); float x = Math.Min(this.selectedTypesOfInclusionsPoint.Value.X, e.Location.X); float y = Math.Min(this.selectedTypesOfInclusionsPoint.Value.Y, e.Location.Y); float width = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.X - e.Location.X); float height = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.Y - e.Location.Y); this.documentWorkspace.panel.CreateGraphics().DrawRectangles(pen, new RectangleF[] { new RectangleF(x, y, width, height) }); } /// /// Right mouse button is released /// /// /// private void OnMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.selectedInclusion.Clear(); if (this.selectedTypesOfInclusionsPoint == null) { return; } var startPoint = this.documentWorkspace.GetScalePoint(this.selectedTypesOfInclusionsPoint.Value); var lastPoint = this.documentWorkspace.GetScalePoint(e.Location); RectangleF rectangle = new RectangleF(Math.Min(lastPoint.X , startPoint.X), Math.Min(lastPoint.Y, startPoint.Y), Math.Abs(lastPoint.X - startPoint.X), Math.Abs(lastPoint.Y - startPoint.Y)); for (int i = 0; i < drawArea.GraphicsList.Count; i++) { if (!(drawArea.GraphicsList[i] is InclusionDrawObject)) { continue; } InclusionDrawObject drawObject = (InclusionDrawObject)drawArea.GraphicsList[i]; if (rectangle.Contains(drawObject.inclusion.rectProfile) || rectangle.IntersectsWith(drawObject.inclusion.rectProfile)) { drawObject.drawToolType = DrawToolType.InclusionSelect; drawObject.Selected = true; this.selectedInclusion.Add(drawObject); } } // 先清除事件 操作完再加回来 this.numericUpDown1.ValueChanged -= new System.EventHandler(this.numericUpDown1_ValueChanged); this.numericUpDown2.ValueChanged -= new System.EventHandler(this.numericUpDown2_ValueChanged); this.numericUpDown3.ValueChanged -= new System.EventHandler(this.numericUpDown3_ValueChanged); this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged); this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged); this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged); this.textBox3.TextChanged -= new System.EventHandler(this.textBox3_TextChanged); if (selectedInclusion.Count == 1) { if (selectedInclusion[0].inclusion.shape == ParticleShape.Globular && selectedInclusion[0].inclusion.arrangement == InclusionArrangement.Scattered) { this.label2.Text = PdnResources.GetString("Menu.diameter.text"); this.label3.Visible = false; this.numericUpDown2.Visible = false; this.numericUpDown1.Value = new Decimal(selectedInclusion[0].inclusion.diameter); } else { this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"); this.label3.Visible = true; this.numericUpDown2.Visible = true; this.numericUpDown1.Value = new Decimal(selectedInclusion[0].inclusion.physicalLength); this.numericUpDown2.Value = new Decimal(selectedInclusion[0].inclusion.physicalWidth); } if (this.isK == 1) { this.numericUpDown3.Value = new Decimal(selectedInclusion[0].inclusion.areaK); } else { this.numericUpDown3.Value = new Decimal(selectedInclusion[0].inclusion.area); } this.comboBox1.Text = selectedInclusion[0].inclusion.classes.ToString(); this.comboBox3.Text = selectedInclusion[0].inclusion.color == null ? "" : selectedInclusion[0].inclusion.color.colorName; this.comboBox2.Text = selectedInclusion[0].inclusion.type.type; this.textBox3.Text = selectedInclusion[0].inclusion.chemicalCharacteristics; this.numericUpDown1.ReadOnly = false; this.numericUpDown2.ReadOnly = false; this.numericUpDown3.ReadOnly = false; this.comboBox1.Enabled = true; this.comboBox2.Enabled = true; this.comboBox3.Enabled = true; this.textBox3.ReadOnly = false; } else { this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"); this.numericUpDown2.Visible = true; this.label3.Visible = true; this.numericUpDown1.ReadOnly = true; this.numericUpDown2.ReadOnly = true; this.numericUpDown3.ReadOnly = true; this.comboBox1.Enabled = false; this.comboBox2.Enabled = false; this.comboBox3.Enabled = false; this.textBox3.ReadOnly = true; this.numericUpDown1.Value = 0; this.numericUpDown2.Value = 0; this.numericUpDown3.Value = 0; this.comboBox1.Text = ""; this.comboBox2.Text = ""; this.textBox3.Text = ""; } this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged); this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged); this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged); this.selectedTypesOfInclusionsPoint = null; this.selectedTypesOfInclusionsRectangle = null; } this.documentWorkspace.Refresh(); } #endregion private void button1_Click(object sender, EventArgs e) { var surface = this.documentWorkspace; List selectedInclusions = new List(); List allInclusions = new List(); InclusionsStandard standard = MethodOfAssessment.activeMethod.inclusionsStandard; for (int i = surface.GraphicsList.Count - 1; i >= 0; i--) { DrawObject drawObject = surface.GraphicsList[i]; if (drawObject.drawToolType == DrawToolType.InclusionSelect) { surface.GraphicsList.RemoveObj(drawObject); InclusionDrawObject inclusionDraw = (InclusionDrawObject)drawObject; allInclusions.Add(inclusionDraw.inclusion); if (drawObject.Selected) { selectedInclusions.Add(inclusionDraw.inclusion); } } } if (selectedInclusions.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectinclusionsfirst.text")); ToolInclusionSelect.DrawInclusion(surface, allInclusions,is_full); return; } standard.inclusionsCombination(allInclusions, selectedInclusions); ToolInclusionSelect.DrawInclusion(surface, allInclusions, is_full); } private void button3_Click(object sender, EventArgs e) { var surface = this.documentWorkspace; List selectedInclusions = new List(); List allInclusions = new List(); InclusionsStandard standard = null; for (int i = surface.GraphicsList.Count - 1; i >= 0; i--) { DrawObject drawObject = surface.GraphicsList[i]; if (drawObject.drawToolType == DrawToolType.InclusionSelect) { surface.GraphicsList.RemoveObj(drawObject); InclusionDrawObject inclusionDraw = (InclusionDrawObject)drawObject; if (standard == null) { standard = inclusionDraw.inclusion.standard; } allInclusions.Add(inclusionDraw.inclusion); if (drawObject.Selected) { selectedInclusions.Add(inclusionDraw.inclusion); } } } standard.inclusionsCombinationSplit(allInclusions, selectedInclusions); surface.Refresh(); ToolInclusionSelect.DrawInclusion(surface, allInclusions, is_full); } private void formClosed(object sender, EventArgs e) { this.closeCallback(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button5_Click(object sender, EventArgs e) { this.documentWorkspace.panel.MouseDown -= OnMouseDown; this.documentWorkspace.panel.MouseUp -= OnMouseUp; this.documentWorkspace.panel.MouseMove -= OnMouseMove; this.documentWorkspace.panel.MouseUp += StopWrite; this.documentWorkspace.ActiveTool = DrawToolType.InclusionPolygon; } private void StopWrite(object sender, MouseEventArgs e) { this.documentWorkspace.panel.MouseUp -= StopWrite; this.documentWorkspace.panel.MouseDown += OnMouseDown; this.documentWorkspace.panel.MouseUp += OnMouseUp; this.documentWorkspace.panel.MouseMove += OnMouseMove; this.btn_close.Focus(); } private void btn_close_Click(object sender, EventArgs e) { if (this.isK != 1) { analysisResult.inclusions.Clear(); for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++) { DrawObject drawObject = this.documentWorkspace.GraphicsList[i]; if (drawObject.drawToolType == DrawToolType.InclusionSelect) { analysisResult.inclusions.Add(((InclusionDrawObject)drawObject).inclusion); } } } else { for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++) { DrawObject drawObject = this.documentWorkspace.GraphicsList[i]; if (drawObject.drawToolType == DrawToolType.InclusionSelect) { if (((InclusionDrawObject)drawObject).inclusion.isEdit == 1) { analysisResult.inclusions.Add(((InclusionDrawObject)drawObject).inclusion); } else { ((InclusionDrawObject)drawObject).inclusion.isEdit = 2; } } } } analysisResult.buildResultBody(); this.Close(); } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } if (selectedInclusion[0].inclusion.shape == ParticleShape.Globular && selectedInclusion[0].inclusion.arrangement == InclusionArrangement.Scattered) { selectedInclusion[0].inclusion.physicalLength = Decimal.ToDouble(this.numericUpDown1.Value); } else { selectedInclusion[0].inclusion.diameter = Decimal.ToDouble(this.numericUpDown1.Value); } } private void numericUpDown2_ValueChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } selectedInclusion[0].inclusion.physicalWidth = Decimal.ToDouble(this.numericUpDown2.Value); } private void numericUpDown3_ValueChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } selectedInclusion[0].inclusion.area = Decimal.ToDouble(this.numericUpDown3.Value); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } selectedInclusion[0].inclusion.classes = (ClassesOfInclusions)Enum.Parse(typeof(ClassesOfInclusions), this.comboBox1.Text); } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings; selectedInclusion[0].inclusion.type = inclusionsGlobalSettings.typeDics[this.comboBox2.Text]; this.documentWorkspace.Refresh(); } private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings; selectedInclusion[0].inclusion.color = inclusionsGlobalSettings.colorOfInclusions[this.comboBox3.Text]; this.documentWorkspace.Refresh(); } private void textBox3_TextChanged(object sender, EventArgs e) { if (selectedInclusion.Count != 1) { return; } selectedInclusion[0].inclusion.chemicalCharacteristics = this.textBox3.Text; this.documentWorkspace.Refresh(); } private void button4_Click(object sender, EventArgs e) { if (selectedInclusion.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectinclusions.text")); return; } if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletetheinclusions?.text")+"?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { foreach (var item in selectedInclusion) { this.analysisResult.inclusions.Remove(item.inclusion); this.documentWorkspace.GraphicsList.RemoveObj(item); } selectedInclusion.Clear(); this.documentWorkspace.Refresh(); } } #endregion #region 私有方法 #endregion } }