| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 |
- using OpenCvSharp;
- using PaintDotNet;
- using PaintDotNet.Annotation.DedicatedAnalysis;
- using PaintDotNet.Annotation.Enum;
- using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
- using PaintDotNet.CustomControl;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Annotations;
- using System.Windows.Forms;
- namespace Metis.DedicatedAnalysis.Inclusions.New_DIN50602_1985
- {
- internal partial class MethodKInclusionEditSec : Form
- {
- private GroupBox groupBox1;
- private GroupBox groupBox2;
- private GroupBox groupBox3;
- private GroupBox groupBox4;
- private Button button2;
- private Button button1;
- private Label label8;
- private Label label7;
- private Label label6;
- private Label label5;
- private Label label4;
- private Label label3;
- private Label label2;
- private Label label1;
- private Button button4;
- private Button button3;
- private System.ComponentModel.IContainer components = null;
- private InclusionEditModel inclusionEditModel;
- private InclusionEditModel oldInclusionEditModel;
- private CommonControlButtons commonControlButtons;
- private AppWorkspace appWorkspace;
- private Bitmap bitmap;
- private MethodKInclusionEditDialog methodKInclusionEdit;
- private System.Drawing.Point? selectedTypesOfInclusionsPoint = null;
- private List<Particle> selectedInclusion = new List<Particle>();
- private Mat thisOriginalImage;
- /// <summary>
- /// 图像面板
- /// </summary>
- private DocumentWorkspaceWindow documentWorkspace;
- public MethodKInclusionEditSec(InclusionEditModel inclusionEditModel, AppWorkspace appWorkspace, MethodKInclusionEditDialog methodKInclusionEdit,Mat OriginalImage)
- {
- this.inclusionEditModel = inclusionEditModel;
- this.appWorkspace = appWorkspace;
- this.methodKInclusionEdit = methodKInclusionEdit;
- this.oldInclusionEditModel = inclusionEditModel;
- InitializeComponent();
- #region [初始化夹杂物属性属性]
- this.label2.Text = this.inclusionEditModel.data.physicalLength.ToString();
- this.label4.Text = this.inclusionEditModel.data.physicalWidth.ToString();
- this.label6.Text = this.inclusionEditModel.data.areaK.ToString();
- this.label8.Text = this.inclusionEditModel.data.type.type.ToString();
- #endregion
- #region [图像面板相关]
- //
- //初始化图像控件
- //
- this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
- this.documentWorkspace.Cursor = Cursors.Default;
- this.documentWorkspace.Dock = DockStyle.Fill;
- this.documentWorkspace.HookMouseEvents();
- this.documentWorkspace.Visible = true;
- this.documentWorkspace.panel.MouseDown += new MouseEventHandler(this.OnMouseDown);
- this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.OnMouseMove);
- this.documentWorkspace.panel.MouseUp += new MouseEventHandler(this.documentWorkspace_panel_MouseUp);
- this.documentWorkspace.panel.Paint += new PaintEventHandler(DrawPaintEvent);
- //PdnBaseForm.RegisterFormHotKey(Keys.Delete, OnDeleteHotKeyPressed);
- this.groupBox4.Controls.Add(this.documentWorkspace);
- this.commonControlButtons = new CommonControlButtons();
- this.commonControlButtons.Dock = DockStyle.Top;
- this.commonControlButtons.Height = 30;
- this.commonControlButtons.HideZoomToWindowAndActualSize();
- this.groupBox4.Controls.Add(commonControlButtons);
- InitCommonButtonEvent();
- Mat mat = new Mat(OriginalImage, new Rect(this.inclusionEditModel.data.rectProfile.X, this.inclusionEditModel.data.rectProfile.Y, this.inclusionEditModel.data.rectProfile.Width, this.inclusionEditModel.data.rectProfile.Height));
- this.bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(mat);
- Document document = Document.FromImage(this.bitmap);
- this.documentWorkspace.Document = document;
- this.documentWorkspace.Refresh();
- int x = this.oldInclusionEditModel.data.rectProfile.X;
- int y = this.oldInclusionEditModel.data.rectProfile.Y;
- for (int i = 0; i < this.inclusionEditModel.data.particles.Count; i++)
- {
- this.inclusionEditModel.data.particles[i].rectProfile = new System.Drawing.Rectangle(this.inclusionEditModel.data.particles[i].rectProfile.X - x, this.inclusionEditModel.data.particles[i].rectProfile.Y - y, this.oldInclusionEditModel.data.particles[i].rectProfile.Width, this.inclusionEditModel.data.particles[i].rectProfile.Height);
- for (int j = 0; j < this.inclusionEditModel.data.particles[i].points2.Length; j++)
- {
- this.inclusionEditModel.data.particles[i].points2[j].X -= x;
- this.inclusionEditModel.data.particles[i].points2[j].Y -= y;
- }
- }
- ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, new List<Inclusion>() { this.inclusionEditModel.data }, false, false, 2,false);
- #endregion
- }
- #region [初始控件]
- private void InitCommonButtonEvent()
- {
- this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
- this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
- this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
- this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
- this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
- this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
- }
- private void zoomInButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != null)
- this.documentWorkspace.ZoomIn();
- }
- private void zoomOutButton_Click(object sender, EventArgs e)
- {
- if (this.bitmap != null)
- 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 = DrawToolType.Pointer;
- }
- private void mobileModeButton_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.ActiveTool = DrawToolType.MoveMode;
- }
- #endregion
- #region Windows Form Designer geneAnnotation.Enum.rated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.label8 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- 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.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(18, 18);
- this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox1.Size = new System.Drawing.Size(1164, 80);
- this.groupBox1.TabIndex = 14;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "操作";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(1042, 26);
- this.button2.Margin = new System.Windows.Forms.Padding(4);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(112, 34);
- this.button2.TabIndex = 1;
- this.button2.Text = "关闭";
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(921, 26);
- this.button1.Margin = new System.Windows.Forms.Padding(4);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(112, 34);
- this.button1.TabIndex = 0;
- this.button1.Text = "确定";
- 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.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox2.Controls.Add(this.label8);
- this.groupBox2.Controls.Add(this.label7);
- this.groupBox2.Controls.Add(this.label6);
- this.groupBox2.Controls.Add(this.label5);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.label2);
- this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Location = new System.Drawing.Point(18, 106);
- this.groupBox2.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox2.Size = new System.Drawing.Size(441, 274);
- this.groupBox2.TabIndex = 15;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "夹杂物属性";
- //
- // label8
- //
- this.label8.AutoSize = true;
- this.label8.Location = new System.Drawing.Point(132, 224);
- this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(62, 18);
- this.label8.TabIndex = 7;
- this.label8.Text = "label8";
- //
- // label7
- //
- this.label7.AutoSize = true;
- this.label7.Location = new System.Drawing.Point(28, 224);
- this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(62, 18);
- this.label7.TabIndex = 6;
- this.label7.Text = "类型:";
- //
- // label6
- //
- this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(132, 168);
- this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(62, 18);
- this.label6.TabIndex = 5;
- this.label6.Text = "label6";
- //
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(28, 168);
- this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(62, 18);
- this.label5.TabIndex = 4;
- this.label5.Text = "面积:";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(132, 108);
- this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(62, 18);
- this.label4.TabIndex = 3;
- this.label4.Text = "label4";
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(28, 108);
- this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(62, 18);
- this.label3.TabIndex = 2;
- this.label3.Text = "宽度:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(132, 54);
- this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(62, 18);
- this.label2.TabIndex = 1;
- this.label2.Text = "label2";
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(28, 54);
- this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(62, 18);
- this.label1.TabIndex = 0;
- this.label1.Text = "长度:";
- //
- // groupBox3
- //
- this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox3.Controls.Add(this.button4);
- this.groupBox3.Controls.Add(this.button3);
- this.groupBox3.Location = new System.Drawing.Point(18, 382);
- this.groupBox3.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox3.Size = new System.Drawing.Size(441, 274);
- this.groupBox3.TabIndex = 16;
- this.groupBox3.TabStop = false;
- this.groupBox3.Text = "夹杂物操作";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(32, 93);
- this.button4.Margin = new System.Windows.Forms.Padding(4);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(112, 34);
- this.button4.TabIndex = 1;
- this.button4.Text = "添加";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(32, 30);
- this.button3.Margin = new System.Windows.Forms.Padding(4);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(112, 34);
- this.button3.TabIndex = 0;
- this.button3.Text = "删除";
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // groupBox4
- //
- this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox4.Location = new System.Drawing.Point(468, 106);
- this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
- this.groupBox4.Name = "groupBox4";
- this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox4.Size = new System.Drawing.Size(714, 550);
- this.groupBox4.TabIndex = 17;
- this.groupBox4.TabStop = false;
- //
- // MethodKInclusionEditSec
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1200, 675);
- this.Controls.Add(this.groupBox4);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.Margin = new System.Windows.Forms.Padding(4);
- this.Name = "MethodKInclusionEditSec";
- this.Text = "夹杂物编辑";
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- this.groupBox3.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 面板绘制事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DrawPaintEvent(object sender, PaintEventArgs e)
- {
- if (this.selectedInclusion.Count > 0)
- {
- Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
- int wid = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Width : this.documentWorkspace.CompositionSurface.Width;
- int hei = this.documentWorkspace.CompositionSurface == null ? this.documentWorkspace.Height : this.documentWorkspace.CompositionSurface.Height;
- int width = (int)(wid * this.documentWorkspace.ScaleFactor.Ratio);
- int height = (int)(hei * 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);
- Pen pen = new Pen(Color.Blue,1);
- for (int i = 0; i < this.selectedInclusion.Count; i++)
- {
- Rectangle rectangle = new Rectangle(this.selectedInclusion[i].rectProfile.X, this.selectedInclusion[i].rectProfile.Y, this.selectedInclusion[i].rectProfile.Width == 0 ? 5 : this.selectedInclusion[i].rectProfile.Width, this.selectedInclusion[i].rectProfile.Height == 0 ? 5 : this.selectedInclusion[i].rectProfile.Height);
- e.Graphics.DrawRectangle(pen, rectangle);
- }
- e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
- e.Graphics.TranslateTransform(-x, -y);
- }
- }
- #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.selectedInclusion.Clear();
- 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) });
- }
- #endregion
- #endregion
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button3_Click(object sender, EventArgs e)
- {
- if (this.selectedInclusion.Count == 0)
- {
- return;
- }
- foreach (var item in this.selectedInclusion)
- {
- this.inclusionEditModel.data.removeParticles(item);
- }
- this.selectedInclusion.Clear();
- ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, new List<Inclusion>() { this.inclusionEditModel.data }, false, false, 2, false);
- this.label2.Text = this.inclusionEditModel.data.physicalLength.ToString();
- this.label4.Text = this.inclusionEditModel.data.physicalWidth.ToString();
- this.label6.Text = this.inclusionEditModel.data.areaK.ToString();
- this.label8.Text = this.inclusionEditModel.data.type.type.ToString();
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- this.documentWorkspace.panel.MouseDown -= new MouseEventHandler(this.OnMouseDown);
- this.documentWorkspace.panel.MouseMove -= new MouseEventHandler(this.OnMouseMove);
- this.documentWorkspace.panel.MouseUp -= new MouseEventHandler(this.documentWorkspace_panel_MouseUp);
- this.documentWorkspace.panel.MouseUp += StopWrite;
- this.documentWorkspace.SetInclusion(this.inclusionEditModel.data);
- this.documentWorkspace.ActiveTool = DrawToolType.InclusionNewPolygon;
- }
- private void StopWrite(object sender, MouseEventArgs e)
- {
- this.label2.Text = this.inclusionEditModel.data.physicalLength.ToString();
- this.label4.Text = this.inclusionEditModel.data.physicalWidth.ToString();
- this.label6.Text = this.inclusionEditModel.data.areaK.ToString();
- this.label8.Text = this.inclusionEditModel.data.type.type.ToString();
- this.documentWorkspace.panel.MouseUp -= StopWrite;
- this.documentWorkspace.panel.MouseDown += OnMouseDown;
- this.documentWorkspace.panel.MouseUp += documentWorkspace_panel_MouseUp;
- this.documentWorkspace.panel.MouseMove += OnMouseMove;
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- int x = this.oldInclusionEditModel.data.rectProfile.X;
- int y = this.oldInclusionEditModel.data.rectProfile.Y;
- for (int i = 0; i < this.inclusionEditModel.data.particles.Count; i++)
- {
- this.inclusionEditModel.data.particles[i].rectProfile = new System.Drawing.Rectangle(this.inclusionEditModel.data.particles[i].rectProfile.X + x, this.inclusionEditModel.data.particles[i].rectProfile.Y + y, this.oldInclusionEditModel.data.particles[i].rectProfile.Width, this.inclusionEditModel.data.particles[i].rectProfile.Height);
- for (int j = 0; j < this.inclusionEditModel.data.particles[i].points2.Length; j++)
- {
- this.inclusionEditModel.data.particles[i].points2[j].X += x;
- this.inclusionEditModel.data.particles[i].points2[j].Y += y;
- }
- }
- this.methodKInclusionEdit.rootEditCallBack(this.inclusionEditModel);
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- int x = this.oldInclusionEditModel.data.rectProfile.X;
- int y = this.oldInclusionEditModel.data.rectProfile.Y;
- for (int i = 0; i < this.inclusionEditModel.data.particles.Count; i++)
- {
- this.inclusionEditModel.data.particles[i].rectProfile = new System.Drawing.Rectangle(this.inclusionEditModel.data.particles[i].rectProfile.X + x, this.inclusionEditModel.data.particles[i].rectProfile.Y + y, this.oldInclusionEditModel.data.particles[i].rectProfile.Width, this.inclusionEditModel.data.particles[i].rectProfile.Height);
- for (int j = 0; j < this.inclusionEditModel.data.particles[i].points2.Length; j++)
- {
- this.inclusionEditModel.data.particles[i].points2[j].X += x;
- this.inclusionEditModel.data.particles[i].points2[j].Y += y;
- }
- }
- this.methodKInclusionEdit.rootEditCallBack(this.inclusionEditModel);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void documentWorkspace_panel_MouseUp(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 < this.documentWorkspace.GraphicsList.Count; i++)
- {
- if (!(this.documentWorkspace.GraphicsList[i] is InclusionDrawObject))
- {
- continue;
- }
- InclusionDrawObject drawObject = (InclusionDrawObject)this.documentWorkspace.GraphicsList[i];
- foreach (Particle particle in drawObject.inclusion.particles)
- {
- if (rectangle.Contains(particle.rectProfile) || rectangle.IntersectsWith(particle.rectProfile))
- {
- this.selectedInclusion.Add(particle);
- }
- }
- }
- this.selectedTypesOfInclusionsPoint = null;
- }
- this.documentWorkspace.Refresh();
- }
- }
- }
|