123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929 |
- 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<InclusionDrawObject> selectedInclusion = new List<InclusionDrawObject>();
- // 选定夹杂物类型 操作 记录点
- 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<PhaseModel>();
- 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 [滑动选中]
- /// <summary>
- /// Left mouse button is pressed
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- private void OnMouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- this.selectedTypesOfInclusionsPoint = e.Location;
- }
- }
- /// <summary>
- /// Mouse is moved.
- /// None button is pressed, or left button is pressed.
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- 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) });
- }
- /// <summary>
- /// Right mouse button is released
- /// </summary>
- /// <param name="drawArea"></param>
- /// <param name="e"></param>
- 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<Inclusion> selectedInclusions = new List<Inclusion>();
- List<Inclusion> allInclusions = new List<Inclusion>();
- 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<Inclusion> selectedInclusions = new List<Inclusion>();
- List<Inclusion> allInclusions = new List<Inclusion>();
- 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
- }
- }
|