Commit c56c58e0 LN

增加复制功能

1 个父辈 169fa747
...@@ -105,5 +105,10 @@ namespace AOI ...@@ -105,5 +105,10 @@ namespace AOI
{ {
return GetRoiImage(image, RoiPath, needCut); return GetRoiImage(image, RoiPath, needCut);
} }
public AoiMethod GetClone()
{
return (AoiMethod)this.MemberwiseClone();
}
} }
} }
...@@ -10,7 +10,27 @@ namespace AccAOI ...@@ -10,7 +10,27 @@ namespace AccAOI
{ {
public class ControlUtil public class ControlUtil
{ {
public static string GetMethodType(AoiMethod method)
{
if (method is AoiBlobMethod)
{
return ControlType.AOIBlob;
}
else if (method is AoiMarkMethod)
{
return ControlType.Mark;
}
else if (method is AoiMethodRgb)
{
return ControlType.AOIRGB;
}
else if (method is AoiTemplateMethod)
{
return ControlType.Match;
}
return "";
}
public static AoiMethod GetMethod(string type) public static AoiMethod GetMethod(string type)
{ {
AoiMethod methodInfo = null; AoiMethod methodInfo = null;
......
...@@ -56,6 +56,7 @@ namespace AccAOI ...@@ -56,6 +56,7 @@ namespace AccAOI
this.lblTestResult = new System.Windows.Forms.Label(); this.lblTestResult = new System.Windows.Forms.Label();
this.testImageBox1 = new Acc.ImageBox.AccImageBox(); this.testImageBox1 = new Acc.ImageBox.AccImageBox();
this.imageBox1 = new Acc.ImageBox.AccImageBox(); this.imageBox1 = new Acc.ImageBox.AccImageBox();
this.btnCopy = new Asa.Theme.FlatButton();
this.panTest.SuspendLayout(); this.panTest.SuspendLayout();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
...@@ -195,7 +196,7 @@ namespace AccAOI ...@@ -195,7 +196,7 @@ namespace AccAOI
this.btnDel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnDel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnDel.ImageSize = new System.Drawing.Size(0, 0); this.btnDel.ImageSize = new System.Drawing.Size(0, 0);
this.btnDel.Inside = false; this.btnDel.Inside = false;
this.btnDel.Location = new System.Drawing.Point(7, 141); this.btnDel.Location = new System.Drawing.Point(9, 104);
this.btnDel.Name = "btnDel"; this.btnDel.Name = "btnDel";
this.btnDel.Size = new System.Drawing.Size(135, 30); this.btnDel.Size = new System.Drawing.Size(135, 30);
this.btnDel.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); this.btnDel.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
...@@ -356,10 +357,25 @@ namespace AccAOI ...@@ -356,10 +357,25 @@ namespace AccAOI
this.imageBox1.TabIndex = 4; this.imageBox1.TabIndex = 4;
this.imageBox1.SelectionRegionChanged += new System.EventHandler(this.imageBox1_SelectionRegionChanged); this.imageBox1.SelectionRegionChanged += new System.EventHandler(this.imageBox1_SelectionRegionChanged);
// //
// btnCopy
//
this.btnCopy.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnCopy.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnCopy.ImageSize = new System.Drawing.Size(0, 0);
this.btnCopy.Inside = false;
this.btnCopy.Location = new System.Drawing.Point(7, 140);
this.btnCopy.Name = "btnCopy";
this.btnCopy.Size = new System.Drawing.Size(135, 30);
this.btnCopy.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnCopy.TabIndex = 26;
this.btnCopy.Text = "复制";
this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click);
//
// FrmAoiSetting // FrmAoiSetting
// //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1270, 641); this.ClientSize = new System.Drawing.Size(1270, 641);
this.Controls.Add(this.btnCopy);
this.Controls.Add(this.panTest); this.Controls.Add(this.panTest);
this.Controls.Add(this.btnLan); this.Controls.Add(this.btnLan);
this.Controls.Add(this.btnUpdateName); this.Controls.Add(this.btnUpdateName);
...@@ -418,5 +434,6 @@ namespace AccAOI ...@@ -418,5 +434,6 @@ namespace AccAOI
private System.Windows.Forms.Panel panTest; private System.Windows.Forms.Panel panTest;
private System.Windows.Forms.Label lblTestResult; private System.Windows.Forms.Label lblTestResult;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private Asa.Theme.FlatButton btnCopy;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -792,5 +792,43 @@ namespace AccAOI ...@@ -792,5 +792,43 @@ namespace AccAOI
} }
LoadTypes(); LoadTypes();
} }
private void btnCopy_Click(object sender, EventArgs e)
{
if (aoiControl != null && aoiControl.Visible)
{
//保存原来的
AoiMethod OldMethod = aoiControl.GetAoiInfo();
AoiMethod methodInfo = OldMethod.GetClone();
string text = ControlUtil.GetMethodType(methodInfo);
string defaultName = Project.methodMap.Values.Count.ToString().PadLeft(2, '0') + "_" + text;
FrmMethodName frmName = new FrmMethodName(defaultName, new List<string>(Project.methodMap.Keys));
frmName.Text = AOIResourceCulture.GetValue("请输入新【{0}】名称", text);
DialogResult result = frmName.ShowDialog();
if (result.Equals(DialogResult.OK))
{
methodInfo.MethodName = frmName.MethodName;
}
else
{
return;
}
CloseCurrAoi();
Project.methodMap.Add(methodInfo.MethodName, methodInfo);
ShowAoi(methodInfo);
aoiList.ItemAdd(methodInfo.MethodName);
aoiList.SelectedIndex = Project.methodMap.Count - 1;
if (imageBox1.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
}
}
} }
} }
...@@ -5,6 +5,7 @@ FrmAoiSetting_flatButton1_Text=Get test image ...@@ -5,6 +5,7 @@ FrmAoiSetting_flatButton1_Text=Get test image
FrmAoiSetting_flatButton2_Text=Select test image FrmAoiSetting_flatButton2_Text=Select test image
FrmAoiSetting_btnImageChange_Text=Switch to test Image FrmAoiSetting_btnImageChange_Text=Switch to test Image
FrmAoiSetting_btnDel_Text=Delete FrmAoiSetting_btnDel_Text=Delete
FrmAoiSetting_btnCopy_Text=Copy
FrmAoiSetting_btnExcute_Text=Execute FrmAoiSetting_btnExcute_Text=Execute
FrmAoiSetting_btnGetCameraImg_Text=Get standard Image FrmAoiSetting_btnGetCameraImg_Text=Get standard Image
FrmAoiSetting_flatLabel1_Text=Cameras: FrmAoiSetting_flatLabel1_Text=Cameras:
......
...@@ -5,6 +5,7 @@ FrmAoiSetting_flatButton1_Text=获取测试图片 ...@@ -5,6 +5,7 @@ FrmAoiSetting_flatButton1_Text=获取测试图片
FrmAoiSetting_flatButton2_Text=选择测试图片 FrmAoiSetting_flatButton2_Text=选择测试图片
FrmAoiSetting_btnImageChange_Text=切换为测试图片 FrmAoiSetting_btnImageChange_Text=切换为测试图片
FrmAoiSetting_btnDel_Text=删除 FrmAoiSetting_btnDel_Text=删除
FrmAoiSetting_btnCopy_Text=复制
FrmAoiSetting_btnExcute_Text=执行 FrmAoiSetting_btnExcute_Text=执行
FrmAoiSetting_btnGetCameraImg_Text=获取基准图片 FrmAoiSetting_btnGetCameraImg_Text=获取基准图片
FrmAoiSetting_flatLabel1_Text=相机: FrmAoiSetting_flatLabel1_Text=相机:
......
...@@ -1223,7 +1223,12 @@ namespace Acc.ImageBox ...@@ -1223,7 +1223,12 @@ namespace Acc.ImageBox
} }
} }
} }
public virtual void SetImage(Image img)
{
this.SizeMode = ImageBoxSizeMode.Fit;
Image = img;
this.SizeMode = ImageBoxSizeMode.Normal;
}
/// <summary> /// <summary>
/// Gets or sets the image. /// Gets or sets the image.
/// </summary> /// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!