Commit bd2d05c4 LN

手势图可以局部放大显示

1 个父辈 0e2aedd6
......@@ -2717,6 +2717,7 @@
<data name = "handWork" xml:space = "preserve"> <value> Assembling </value> </data>
<data name = "handCount" xml:space = "preserve"> <value> Number </value> </data>
<data name = "handTime" xml:space = "preserve"> <value> Total Time </value> </data>
<data name = "FrmWork_linkLabel1_Text" xml:space = "preserve"> <value> reduction </value> </data>
<data name="查询出错" xml:space="preserve">
<value>Query Error</value>
......
......@@ -2701,4 +2701,5 @@
<data name = "handWork" xml:space = "preserve"> <value> 组装中 </value> </data>
<data name = "handCount" xml:space = "preserve"> <value> 次数 </value> </data>
<data name = "handTime" xml:space = "preserve"> <value> 总时长 </value> </data>
<data name = "FrmWork_linkLabel1_Text" xml:space = "preserve"> <value> reduction </value> </data>
</root>
\ No newline at end of file
......@@ -2874,4 +2874,5 @@
<data name="没有找到记录" xml:space="preserve">
<value>没有找到记录</value>
</data>
<data name = "FrmWork_linkLabel1_Text" xml:space = "preserve"> <value> 显示原图 </value> </data>
</root>
\ No newline at end of file
......@@ -99,6 +99,7 @@
this.系统ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lblBoardPoint = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.groupBox3.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
......@@ -130,7 +131,7 @@
this.btnIo.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
this.btnIo.FlatAppearance.BorderSize = 0;
this.btnIo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnIo.Location = new System.Drawing.Point(567, 583);
this.btnIo.Location = new System.Drawing.Point(687, 580);
this.btnIo.Name = "btnIo";
this.btnIo.Size = new System.Drawing.Size(51, 30);
this.btnIo.TabIndex = 280;
......@@ -702,6 +703,10 @@
this.picHandsVideo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.picHandsVideo.TabIndex = 277;
this.picHandsVideo.TabStop = false;
this.picHandsVideo.Paint += new System.Windows.Forms.PaintEventHandler(this.picHandsVideo_Paint);
this.picHandsVideo.MouseDown += new System.Windows.Forms.MouseEventHandler(this.picHandsVideo_MouseDown);
this.picHandsVideo.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picHandsVideo_MouseMove);
this.picHandsVideo.MouseUp += new System.Windows.Forms.MouseEventHandler(this.picHandsVideo_MouseUp);
//
// lblNotices
//
......@@ -904,11 +909,24 @@
this.lblBoardPoint.Size = new System.Drawing.Size(609, 23);
this.lblBoardPoint.TabIndex = 272;
//
// linkLabel1
//
this.linkLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkLabel1.AutoSize = true;
this.linkLabel1.Location = new System.Drawing.Point(570, 583);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(65, 12);
this.linkLabel1.TabIndex = 281;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "reduction ";
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// FrmWork
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1479, 652);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.groupBoard);
this.Controls.Add(this.btnWorkInfo);
this.Controls.Add(this.btnStartWorking);
......@@ -1029,5 +1047,6 @@
private System.Windows.Forms.Panel panHand;
private System.Windows.Forms.PictureBox picHandsVideo;
private System.Windows.Forms.Label lblHandInfo;
private System.Windows.Forms.LinkLabel linkLabel1;
}
}
\ No newline at end of file
......@@ -93,9 +93,7 @@ namespace TSA_V
{
radioButton2.Checked = true;
AutoVisiable(true);
}
}
}
else
{
......@@ -146,10 +144,12 @@ namespace TSA_V
{
groupHand.Visible = true;
groupBoard.Visible = true;
linkLabel1.Visible = true;
}
else
{
linkLabel1.Visible = false;
groupHand.Visible = false;
groupBoard.Visible = true;
groupBoard.Location = new Point(groupHand.Location.X, groupHand.Location.Y);
......@@ -1181,6 +1181,9 @@ namespace TSA_V
}
private bool mstart = false;
private string lastMsg = "";
private bool isDrawing = false;
private float xBili = 1F;
private float yBili = 1F;
private void VideoThreadRun()
{
mstart = true;
......@@ -1198,7 +1201,11 @@ namespace TSA_V
picHandsVideo.Image.Dispose();
picHandsVideo.Image = null;
}
picHandsVideo.Image = bitmap;
xBili = bitmap.Width*1F / picHandsVideo.Width;
yBili= bitmap.Height*1F/ picHandsVideo.Height;
picHandsVideo.Image = CropImage(bitmap, selectedRectangle);
}
string curr = (HandRecordManager.currHasPoint ? ResourceCulture.GetString("handWork","组装中" ):"");
......@@ -1231,5 +1238,105 @@ namespace TSA_V
LogUtil.error("StopVideo 出错:" + ex.ToString());
}
}
private bool cutImg = false;
private Rectangle selectedRectangle;
private void picHandsVideo_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
// 记录选中的框
selectedRectangle = new Rectangle(e.X, e.Y, 0, 0);
picHandsVideo.Invalidate();
isDrawing = true;
}
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
cutImg = false;
selectedRectangle = new Rectangle(0,0,0,0);
}
private void picHandsVideo_MouseMove(object sender, MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Button == MouseButtons.Left)
{
// 更新选中的框大小
selectedRectangle.Width = e.X - selectedRectangle.X;
selectedRectangle.Height = e.Y - selectedRectangle.Y;
picHandsVideo.Invalidate();
}
}
private Bitmap CropImage(Bitmap image, Rectangle cropRectangle)
{
if (cropRectangle == null || cropRectangle.IsEmpty || cropRectangle.Width <= 0 || cropRectangle.Height <= 0 || isDrawing || (!cutImg))
{
return (Bitmap)image;
}
int nWidth = (int)(cropRectangle.Width * xBili);
int yHeight = (int)(cropRectangle.Height * yBili);
int sX=(int)(cropRectangle.X*xBili) ;
int sY=(int)(cropRectangle.Y*yBili );
Rectangle newRect = new Rectangle(sX, sY, nWidth, yHeight);
Bitmap croppedImage = new Bitmap(nWidth, yHeight);
using (Graphics g = Graphics.FromImage(croppedImage))
{
g.DrawImage(image, new Rectangle(0, 0, nWidth, yHeight), newRect, GraphicsUnit.Pixel);
}
return croppedImage;
}
private void picHandsVideo_MouseUp(object sender, MouseEventArgs e)
{
base.OnMouseUp(e);
try
{
isDrawing = false;
if (e.Button == MouseButtons.Left)
{
if (selectedRectangle == null || selectedRectangle.IsEmpty || selectedRectangle.Width <= 0 || selectedRectangle.Height <= 0)
{
cutImg = false;
}
else
{
cutImg = true;
}
if (picHandsVideo.Image != null)
{
Image img = picHandsVideo.Image;
if (img != null)
{
picHandsVideo.Image = CropImage((Bitmap)img, selectedRectangle);
}
}
}
}
catch (Exception ex)
{
LogUtil.error("出错:" + ex.ToString());
}
}
private void picHandsVideo_Paint(object sender, PaintEventArgs e)
{
if (isDrawing)
{
if (selectedRectangle == null || selectedRectangle.IsEmpty || selectedRectangle.Width <= 0 || selectedRectangle.Height <= 0)
{
return;
}
// 绘制白色边框
using (Pen pen = new Pen(Color.White, 2))
{
e.Graphics.DrawRectangle(pen, selectedRectangle);
}
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!