增加赋值粘贴

This commit is contained in:
moco 2024-12-05 21:53:34 +08:00
parent d17358810f
commit db8c3ee65f
3 changed files with 168 additions and 18 deletions

View File

@ -1,5 +1,6 @@
using AntdUI; using AntdUI;
using MiniExcelLibs; using MiniExcelLibs;
using OpenCvSharp.Flann;
using PBAnaly.UI; using PBAnaly.UI;
using PBBiologyVC; using PBBiologyVC;
using ReaLTaiizor.Extension; using ReaLTaiizor.Extension;
@ -58,8 +59,20 @@ namespace PBAnaly.Module
public List<System.Drawing.Point> points; public List<System.Drawing.Point> points;
public Pseudo_infoVC pdinfovc; public Pseudo_infoVC pdinfovc;
} }
private enum ShapeForm
{
None,
Line,
Polygon,
Rect,
Circle
}
#endregion #endregion
#region #region
private ShapeForm curShape = ShapeForm.None;
private int curShapeIndex;
public int ImageIndex { get; set; }// 图片加载进来的序号 public int ImageIndex { get; set; }// 图片加载进来的序号
public bool Arrangement { get; set; } public bool Arrangement { get; set; }
private Dictionary<string, BioanalysisMannage> bioanalysisMannages; private Dictionary<string, BioanalysisMannage> bioanalysisMannages;
@ -105,7 +118,9 @@ namespace PBAnaly.Module
private bool rectOn = false; private bool rectOn = false;
private bool linepolygonON = false; private bool linepolygonON = false;
private bool isRecDragging = false; private bool isRecDragging = false;
private bool curIsCopy = false; // 是否需要拷贝
private List<RectAttribute> rectangles = new List<RectAttribute>(); // 存储所有绘制完成的矩形 private List<RectAttribute> rectangles = new List<RectAttribute>(); // 存储所有绘制完成的矩形
private RectAttribute oldCopyRect; //当前需要赋值的矩形
private System.Drawing.Rectangle? currentRectangle = null; // 当前正在绘制的矩形 private System.Drawing.Rectangle? currentRectangle = null; // 当前正在绘制的矩形
private System.Drawing.Point leftTopPoint; // 矩形左上角的起始点 private System.Drawing.Point leftTopPoint; // 矩形左上角的起始点
private bool drawRect = false; // 是否正在绘制 private bool drawRect = false; // 是否正在绘制
@ -117,6 +132,7 @@ namespace PBAnaly.Module
private bool drawCircle = false;//是否绘制圆 private bool drawCircle = false;//是否绘制圆
private bool isCirDragging = false; private bool isCirDragging = false;
private List<CirceAndInfo> CircleAndInfoList = new List<CirceAndInfo>(); private List<CirceAndInfo> CircleAndInfoList = new List<CirceAndInfo>();
private CirceAndInfo oldCopyCircle;
private System.Drawing.Point cirDragStart; private System.Drawing.Point cirDragStart;
private System.Drawing.Point circleCenter; private System.Drawing.Point circleCenter;
private System.Drawing.Point circleRadio; private System.Drawing.Point circleRadio;
@ -438,7 +454,9 @@ namespace PBAnaly.Module
imagePanel.image_pl.MouseMove += Image_pl_MouseMove; imagePanel.image_pl.MouseMove += Image_pl_MouseMove;
imagePanel.image_pl.MouseUp += Image_pl_MouseUp; imagePanel.image_pl.MouseUp += Image_pl_MouseUp;
imagePanel.image_pl.Paint += Image_pl_Paint; imagePanel.image_pl.Paint += Image_pl_Paint;
imagePanel.ctms_strop_delete.Click += Ctms_strop_delete_Click;
imagePanel.ctms_strop_copy.Click += Ctms_strop_copy_Click;
imagePanel.ctms_strop_stickup.Click += Ctms_strop_stickup_Click;
imagePaletteForm.hpb_line.Click += Hpb_line_Click; imagePaletteForm.hpb_line.Click += Hpb_line_Click;
@ -1600,33 +1618,115 @@ namespace PBAnaly.Module
} }
else if (e.Button == MouseButtons.Right) else if (e.Button == MouseButtons.Right)
{ {
imagePanel.ctms_strop.Enabled = true;
imagePanel.ctms_strop_copy.Enabled = false;
imagePanel.ctms_strop_stickup.Enabled = curIsCopy;
if (ImageProcess.IsPointOnLine(readLoction,startPoint,endPoint,CircleRadius)) if (ImageProcess.IsPointOnLine(readLoction,startPoint,endPoint,CircleRadius))
{ {
curShape = ShapeForm.Line;
}
else if (IsPointInCircle(readLoction, CircleAndInfoList, out var cner1, out var curRect, out var index1))
{
curShape = ShapeForm.Circle;
curShapeIndex = index1;
imagePanel.ctms_strop_copy.Enabled = true;
}
else if (IsPointInRectangles(readLoction, rectangles, out var cner, out var cr, out var index))
{
curShape = ShapeForm.Rect;
curShapeIndex = index;
imagePanel.ctms_strop_copy.Enabled = true;
}
else if (drawpolygon==false && IsPointInPolygon(readLoction, curPolygonAndInfoList))
{
curShape = ShapeForm.Polygon;
}
}
}
private void Ctms_strop_copy_Click(object sender, EventArgs e)
{
// 复制矩形 目前只允许复制矩形和圆形
switch (curShape)
{
case ShapeForm.None:
break;
case ShapeForm.Line:
break;
case ShapeForm.Polygon:
break;
case ShapeForm.Rect:
oldCopyRect = rectangles[curShapeIndex];
curIsCopy = true;
break;
case ShapeForm.Circle:
oldCopyCircle = CircleAndInfoList[curShapeIndex];
curIsCopy = true;
break;
default:
break;
}
}
private void Ctms_strop_stickup_Click(object sender, EventArgs e)
{
switch (curShape)
{
case ShapeForm.None:
break;
case ShapeForm.Line:
break;
case ShapeForm.Polygon:
break;
case ShapeForm.Rect:
rectangles.Add(oldCopyRect);
break;
case ShapeForm.Circle:
CircleAndInfoList.Add(oldCopyCircle);
break;
default:
break;
}
curIsCopy = false;
imagePanel.image_pl.Invalidate();
}
private void Ctms_strop_delete_Click(object sender, EventArgs e)
{
switch (curShape)
{
case ShapeForm.None:
break;
case ShapeForm.Line:
startPoint = new System.Drawing.Point(-10, 0); startPoint = new System.Drawing.Point(-10, 0);
endPoint = new System.Drawing.Point(-10, 0); endPoint = new System.Drawing.Point(-10, 0);
imagePanel.image_pl.Invalidate(); imagePanel.image_pl.Invalidate();
imagePaletteForm.flb_act_mm.Text = ("0"); imagePaletteForm.flb_act_mm.Text = ("0");
imagePaletteForm.flb_act_mm.Refresh(); imagePaletteForm.flb_act_mm.Refresh();
} break;
else if (IsPointInCircle(readLoction, CircleAndInfoList, out var cner1, out var curRect, out var index1)) case ShapeForm.Polygon:
{
CircleAndInfoList.RemoveAt(index1);
imagePanel.image_pl.Invalidate();
}
else if (IsPointInRectangles(readLoction, rectangles, out var cner, out var cr, out var index))
{
rectangles.RemoveAt(index);
imagePanel.image_pl.Invalidate();
}
else if (drawpolygon==false && IsPointInPolygon(readLoction, curPolygonAndInfoList))
{
PolygonAndInfoList.Clear(); PolygonAndInfoList.Clear();
curPolygonAndInfoList.points.Clear(); curPolygonAndInfoList.points.Clear();
curPolygonAndInfoList.pdinfovc = null; curPolygonAndInfoList.pdinfovc = null;
imagePanel.image_pl.Invalidate();
}
}
break;
case ShapeForm.Rect:
rectangles.RemoveAt(curShapeIndex);
break;
case ShapeForm.Circle:
CircleAndInfoList.RemoveAt(curShapeIndex);
break;
default:
break;
}
curShape = ShapeForm.None;
imagePanel.image_pl.Invalidate();
} }

View File

@ -28,6 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.wdb_title = new AntdUI.WindowBar(); this.wdb_title = new AntdUI.WindowBar();
this.panel1 = new AntdUI.Panel(); this.panel1 = new AntdUI.Panel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
@ -51,6 +52,11 @@
this.tlp_right_panel = new System.Windows.Forms.TableLayoutPanel(); this.tlp_right_panel = new System.Windows.Forms.TableLayoutPanel();
this.lb_wh = new AntdUI.Label(); this.lb_wh = new AntdUI.Label();
this.image_pr = new AntdUI.Image3D(); this.image_pr = new AntdUI.Image3D();
this.ctms_strop = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.ctms_strop_copy = new System.Windows.Forms.ToolStripMenuItem();
this.ctms_strop_stickup = new System.Windows.Forms.ToolStripMenuItem();
this.ctms_strop_delete = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
@ -61,6 +67,7 @@
this.pl_bg_panel.SuspendLayout(); this.pl_bg_panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.image_pl)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.image_pl)).BeginInit();
this.tlp_right_panel.SuspendLayout(); this.tlp_right_panel.SuspendLayout();
this.ctms_strop.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// wdb_title // wdb_title
@ -299,6 +306,7 @@
// //
// image_pl // image_pl
// //
this.image_pl.ContextMenuStrip = this.ctms_strop;
this.image_pl.Dock = System.Windows.Forms.DockStyle.Fill; this.image_pl.Dock = System.Windows.Forms.DockStyle.Fill;
this.image_pl.Location = new System.Drawing.Point(0, 0); this.image_pl.Location = new System.Drawing.Point(0, 0);
this.image_pl.Name = "image_pl"; this.image_pl.Name = "image_pl";
@ -348,6 +356,39 @@
this.image_pr.TabIndex = 1; this.image_pr.TabIndex = 1;
this.image_pr.Text = "image3D1"; this.image_pr.Text = "image3D1";
// //
// ctms_strop
//
this.ctms_strop.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripSeparator1,
this.ctms_strop_copy,
this.ctms_strop_stickup,
this.ctms_strop_delete});
this.ctms_strop.Name = "ctms_strop";
this.ctms_strop.Size = new System.Drawing.Size(181, 98);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
//
// ctms_strop_copy
//
this.ctms_strop_copy.Name = "ctms_strop_copy";
this.ctms_strop_copy.Size = new System.Drawing.Size(180, 22);
this.ctms_strop_copy.Text = "复制";
//
// ctms_strop_stickup
//
this.ctms_strop_stickup.Name = "ctms_strop_stickup";
this.ctms_strop_stickup.Size = new System.Drawing.Size(180, 22);
this.ctms_strop_stickup.Text = "粘贴";
//
// ctms_strop_delete
//
this.ctms_strop_delete.Name = "ctms_strop_delete";
this.ctms_strop_delete.Size = new System.Drawing.Size(180, 22);
this.ctms_strop_delete.Text = "删除";
//
// BioanalyImagePanel // BioanalyImagePanel
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -373,6 +414,7 @@
this.pl_bg_panel.ResumeLayout(false); this.pl_bg_panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.image_pl)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.image_pl)).EndInit();
this.tlp_right_panel.ResumeLayout(false); this.tlp_right_panel.ResumeLayout(false);
this.ctms_strop.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -401,5 +443,10 @@
public AntdUI.Checkbox cb_scientific; public AntdUI.Checkbox cb_scientific;
private AntdUI.Label label2; private AntdUI.Label label2;
public AntdUI.Label lb_imageIndex; public AntdUI.Label lb_imageIndex;
public System.Windows.Forms.ContextMenuStrip ctms_strop;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
public System.Windows.Forms.ToolStripMenuItem ctms_strop_copy;
public System.Windows.Forms.ToolStripMenuItem ctms_strop_stickup;
public System.Windows.Forms.ToolStripMenuItem ctms_strop_delete;
} }
} }

View File

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="ctms_strop.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>