Commit 6b869d1d LN

mark点增加打开图片功能

1 个父辈 dbc6add8
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
this.flatLabel2 = new Asa.Theme.FlatLabel(); this.flatLabel2 = new Asa.Theme.FlatLabel();
this.lblResult = new System.Windows.Forms.Label(); this.lblResult = new System.Windows.Forms.Label();
this.btnTest = new Asa.Theme.FlatButton(); this.btnTest = new Asa.Theme.FlatButton();
this.btnOpenImage = new Asa.Theme.FlatButton();
this.txtImage = new Asa.Theme.FlatText();
this.lblTime = new System.Windows.Forms.Label();
this.panParam.SuspendLayout(); this.panParam.SuspendLayout();
this.panResult.SuspendLayout(); this.panResult.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
...@@ -45,6 +48,9 @@ ...@@ -45,6 +48,9 @@
// //
// panResult // panResult
// //
this.panResult.Controls.Add(this.lblTime);
this.panResult.Controls.Add(this.txtImage);
this.panResult.Controls.Add(this.btnOpenImage);
this.panResult.Controls.Add(this.btnTest); this.panResult.Controls.Add(this.btnTest);
this.panResult.Controls.Add(this.lblResult); this.panResult.Controls.Add(this.lblResult);
this.panResult.Size = new System.Drawing.Size(298, 197); this.panResult.Size = new System.Drawing.Size(298, 197);
...@@ -80,9 +86,9 @@ ...@@ -80,9 +86,9 @@
// lblResult // lblResult
// //
this.lblResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); this.lblResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblResult.Font = new System.Drawing.Font("黑体", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblResult.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblResult.ForeColor = System.Drawing.Color.Red; this.lblResult.ForeColor = System.Drawing.Color.Red;
this.lblResult.Location = new System.Drawing.Point(39, 100); this.lblResult.Location = new System.Drawing.Point(29, 123);
this.lblResult.Name = "lblResult"; this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(231, 24); this.lblResult.Size = new System.Drawing.Size(231, 24);
this.lblResult.TabIndex = 4; this.lblResult.TabIndex = 4;
...@@ -92,7 +98,7 @@ ...@@ -92,7 +98,7 @@
// //
this.btnTest.ImageSize = new System.Drawing.Size(0, 0); this.btnTest.ImageSize = new System.Drawing.Size(0, 0);
this.btnTest.Inside = false; this.btnTest.Inside = false;
this.btnTest.Location = new System.Drawing.Point(104, 46); this.btnTest.Location = new System.Drawing.Point(141, 79);
this.btnTest.Name = "btnTest"; this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(90, 30); this.btnTest.Size = new System.Drawing.Size(90, 30);
this.btnTest.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); this.btnTest.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
...@@ -100,6 +106,38 @@ ...@@ -100,6 +106,38 @@
this.btnTest.Text = "测试结果"; this.btnTest.Text = "测试结果";
this.btnTest.Click += new System.EventHandler(this.btnTest_Click); this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
// //
// btnOpenImage
//
this.btnOpenImage.ImageSize = new System.Drawing.Size(0, 0);
this.btnOpenImage.Inside = false;
this.btnOpenImage.Location = new System.Drawing.Point(45, 79);
this.btnOpenImage.Name = "btnOpenImage";
this.btnOpenImage.Size = new System.Drawing.Size(90, 30);
this.btnOpenImage.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnOpenImage.TabIndex = 6;
this.btnOpenImage.Text = "打开本地图片";
this.btnOpenImage.Click += new System.EventHandler(this.btnOpenImage_Click);
//
// txtImage
//
this.txtImage.Font = new System.Drawing.Font("宋体", 9F);
this.txtImage.Inside = false;
this.txtImage.Location = new System.Drawing.Point(8, 33);
this.txtImage.Name = "txtImage";
this.txtImage.Size = new System.Drawing.Size(281, 30);
this.txtImage.TabIndex = 7;
//
// lblTime
//
this.lblTime.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblTime.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTime.ForeColor = System.Drawing.Color.Green;
this.lblTime.Location = new System.Drawing.Point(29, 158);
this.lblTime.Name = "lblTime";
this.lblTime.Size = new System.Drawing.Size(231, 24);
this.lblTime.TabIndex = 8;
this.lblTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// AioMarkControl // AioMarkControl
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
...@@ -120,5 +158,8 @@ ...@@ -120,5 +158,8 @@
private Asa.Theme.FlatLabel flatLabel1; private Asa.Theme.FlatLabel flatLabel1;
private System.Windows.Forms.Label lblResult; private System.Windows.Forms.Label lblResult;
private Asa.Theme.FlatButton btnTest; private Asa.Theme.FlatButton btnTest;
private Asa.Theme.FlatText txtImage;
private Asa.Theme.FlatButton btnOpenImage;
private System.Windows.Forms.Label lblTime;
} }
} }
...@@ -10,6 +10,7 @@ using System.Windows.Forms; ...@@ -10,6 +10,7 @@ using System.Windows.Forms;
using AOI; using AOI;
using System.Threading; using System.Threading;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.IO;
namespace AccAOI.control namespace AccAOI.control
{ {
...@@ -40,8 +41,22 @@ namespace AccAOI.control ...@@ -40,8 +41,22 @@ namespace AccAOI.control
{ {
if (this.AoiInfo is AoiMarkMethod) if (this.AoiInfo is AoiMarkMethod)
{ {
string fileName = txtImage.Text.ToString();
Image checkImg = null;
if (File.Exists(fileName))
{
//读取图片内容
checkImg = (Image)Image.FromFile(fileName).Clone();
}
if (checkImg == null)
{
checkImg = FrmAoiSetting.Img;
}
DateTime time = DateTime.Now;
AoiMarkMethod mark = (AoiMarkMethod)AoiInfo; AoiMarkMethod mark = (AoiMarkMethod)AoiInfo;
Image result= mark.FixImage(FrmAoiSetting.Img, FrmAoiSetting.Img); Image result= mark.FixImage(FrmAoiSetting.Img, checkImg);
TimeSpan span = DateTime.Now - time;
if (result == null) if (result == null)
{ {
this.aoiImage.Image = null; this.aoiImage.Image = null;
...@@ -51,9 +66,10 @@ namespace AccAOI.control ...@@ -51,9 +66,10 @@ namespace AccAOI.control
else else
{ {
lblResult.ForeColor = Color.Green; lblResult.ForeColor = Color.Green;
lblResult.Text = "OK"; lblResult.Text = "OK" ;
this.aoiImage.Image = result; this.aoiImage.Image = result;
} }
lblTime.Text= "耗时:" + Math.Round(span.TotalSeconds, 1)+ "秒";
} }
} }
...@@ -97,5 +113,23 @@ namespace AccAOI.control ...@@ -97,5 +113,23 @@ namespace AccAOI.control
} }
} }
private void btnOpenImage_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "打开本地图片";
openDialog.Filter = "All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*";
openDialog.DefaultExt = "png";
//openDialog.DefaultExt = "png";
System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
string fileName = openDialog.FileName;
txtImage.Text = fileName;
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!