Commit b94db01c LN

界面调整。

1 个父辈 0c2c49b3
......@@ -12,6 +12,7 @@ namespace AOI
{
public abstract class AoiMethod
{
public string MethodName { get; set; }
/// <summary>
/// 兴趣区域路径
/// </summary>
......
......@@ -82,5 +82,7 @@ namespace AOI
this.methodMap = JsonUtil.DeserializeJsonToObject<Dictionary<string, AoiMethod>>(methodMapJson);
}
}
}
......@@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AOI.rgb
namespace AOI
{
/// <summary>
/// 颜色抽取
......@@ -14,10 +14,10 @@ namespace AOI.rgb
public class AoiMethodRgb : AoiMethod
{
public int minR = 1;
public int maxR = 1;
public int maxR = 255;
public int minG = 1;
public int maxG = 255;
public int minB = 255;
public int minB = 1;
public int maxB = 255;
/// <summary>
/// 抽取出的像素最小占比
......
......@@ -84,6 +84,7 @@
<Compile Include="FrmAoiSetting.Designer.cs">
<DependentUpon>FrmAoiSetting.cs</DependentUpon>
</Compile>
<Compile Include="FormUtil.cs" />
<Compile Include="imageBoxEx\DragHandle.cs" />
<Compile Include="imageBoxEx\DragHandleAnchor.cs" />
<Compile Include="imageBoxEx\DragHandleCollection.cs" />
......
......@@ -30,7 +30,6 @@
{
this.buttonOpen = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.imageBox = new ImageBoxEx();
this.R = new System.Windows.Forms.Label();
this.maxR = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
......@@ -40,8 +39,9 @@
this.maxG = new System.Windows.Forms.NumericUpDown();
this.minB = new System.Windows.Forms.NumericUpDown();
this.maxB = new System.Windows.Forms.NumericUpDown();
this.imageBoxEx1 = new ImageBoxEx();
this.labelCount = new System.Windows.Forms.Label();
this.imageBoxEx1 = new AccAOI.ImageBoxEx();
this.imageBox = new AccAOI.ImageBoxEx();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.maxR)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.minR)).BeginInit();
......@@ -72,21 +72,6 @@
this.panel1.Size = new System.Drawing.Size(457, 388);
this.panel1.TabIndex = 3;
//
// imageBox
//
this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageBox.DragHandleSize = 9;
this.imageBox.Location = new System.Drawing.Point(0, 0);
this.imageBox.Name = "imageBox";
this.imageBox.SelectionColor = System.Drawing.Color.Empty;
this.imageBox.SelectionMode = Cyotek.Windows.Forms.ImageBoxSelectionMode.Rectangle;
this.imageBox.ShowPixelGrid = true;
this.imageBox.Size = new System.Drawing.Size(457, 388);
this.imageBox.TabIndex = 2;
this.imageBox.Text = "imageBoxEx1";
this.imageBox.Selected += new System.EventHandler<System.EventArgs>(this.imageBox_Selected);
this.imageBox.SelectionRegionChanged += new System.EventHandler(this.imageBox_SelectionRegionChanged);
//
// R
//
this.R.AutoSize = true;
......@@ -207,6 +192,15 @@
0});
this.maxB.ValueChanged += new System.EventHandler(this.maxB_ValueChanged);
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(540, 376);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(11, 12);
this.labelCount.TabIndex = 22;
this.labelCount.Text = "0";
//
// imageBoxEx1
//
this.imageBoxEx1.DragHandleSize = 9;
......@@ -215,14 +209,20 @@
this.imageBoxEx1.Size = new System.Drawing.Size(230, 159);
this.imageBoxEx1.TabIndex = 21;
//
// labelCount
// imageBox
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(540, 376);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(11, 12);
this.labelCount.TabIndex = 22;
this.labelCount.Text = "0";
this.imageBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageBox.DragHandleSize = 9;
this.imageBox.Location = new System.Drawing.Point(0, 0);
this.imageBox.Name = "imageBox";
this.imageBox.SelectionColor = System.Drawing.Color.Empty;
this.imageBox.SelectionMode = Cyotek.Windows.Forms.ImageBoxSelectionMode.Rectangle;
this.imageBox.ShowPixelGrid = true;
this.imageBox.Size = new System.Drawing.Size(457, 388);
this.imageBox.TabIndex = 2;
this.imageBox.Text = "imageBoxEx1";
this.imageBox.Selected += new System.EventHandler<System.EventArgs>(this.imageBox_Selected);
this.imageBox.SelectionRegionChanged += new System.EventHandler(this.imageBox_SelectionRegionChanged);
//
// Form1
//
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccAOI
{
public class FormUtil
{
public static int GetIntValue(Asa.Theme.FlatText text)
{
int value = 0;
try
{
value = int.Parse(text.Text);
}
catch (Exception ex)
{
value = 0;
}
return value;
}
}
}
......@@ -29,8 +29,6 @@
private void InitializeComponent()
{
this.aoiList = new Asa.Theme.FlatList();
this.imageBox1 = new Cyotek.Windows.Forms.ImageBox();
this.aoiControl = new AccAOI.control.ABaseControl();
this.btnOpenPro = new Asa.Theme.FlatButton();
this.btnSavePro = new Asa.Theme.FlatButton();
this.btnNewAoi = new Asa.Theme.FlatButton();
......@@ -39,6 +37,8 @@
this.cmbCameraList = new Asa.Theme.FlatCombo();
this.btnGetCameraImg = new Asa.Theme.FlatButton();
this.comType = new Asa.Theme.FlatCombo();
this.panAoi = new System.Windows.Forms.Panel();
this.imageBox1 = new AccAOI.ImageBoxEx();
this.SuspendLayout();
//
// aoiList
......@@ -54,28 +54,6 @@
this.aoiList.TabIndex = 2;
this.aoiList.IndexChanged += new System.EventHandler(this.aoiList_IndexChanged);
//
// imageBox1
//
this.imageBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.imageBox1.Location = new System.Drawing.Point(625, 40);
this.imageBox1.Name = "imageBox1";
this.imageBox1.Size = new System.Drawing.Size(637, 592);
this.imageBox1.TabIndex = 4;
this.imageBox1.Text = "imageBox1";
//
// aoiControl
//
this.aoiControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.aoiControl.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.aoiControl.Location = new System.Drawing.Point(304, 40);
this.aoiControl.Name = "aoiControl";
this.aoiControl.Size = new System.Drawing.Size(315, 593);
this.aoiControl.TabIndex = 5;
this.aoiControl.TitleName = "斑点分析";
//
// btnOpenPro
//
this.btnOpenPro.ImageSize = new System.Drawing.Size(0, 0);
......@@ -165,10 +143,34 @@
this.comType.Size = new System.Drawing.Size(109, 30);
this.comType.TabIndex = 14;
//
// panAoi
//
this.panAoi.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.panAoi.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(4)))), ((int)(((byte)(4)))), ((int)(((byte)(4)))));
this.panAoi.Location = new System.Drawing.Point(302, 40);
this.panAoi.Name = "panAoi";
this.panAoi.Size = new System.Drawing.Size(317, 592);
this.panAoi.TabIndex = 15;
//
// imageBox1
//
this.imageBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.imageBox1.DragHandleSize = 9;
this.imageBox1.Location = new System.Drawing.Point(625, 40);
this.imageBox1.Name = "imageBox1";
this.imageBox1.SelectionMode = Cyotek.Windows.Forms.ImageBoxSelectionMode.Rectangle;
this.imageBox1.Size = new System.Drawing.Size(637, 592);
this.imageBox1.TabIndex = 4;
this.imageBox1.SelectionRegionChanged += new System.EventHandler(this.imageBox1_SelectionRegionChanged);
//
// FrmAoiSetting
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1271, 641);
this.Controls.Add(this.panAoi);
this.Controls.Add(this.comType);
this.Controls.Add(this.btnGetCameraImg);
this.Controls.Add(this.cmbCameraList);
......@@ -177,7 +179,6 @@
this.Controls.Add(this.btnNewAoi);
this.Controls.Add(this.btnSavePro);
this.Controls.Add(this.btnOpenPro);
this.Controls.Add(this.aoiControl);
this.Controls.Add(this.imageBox1);
this.Controls.Add(this.aoiList);
this.Location = new System.Drawing.Point(0, 0);
......@@ -187,7 +188,6 @@
this.Load += new System.EventHandler(this.FrmAoiSetting_Load);
this.Controls.SetChildIndex(this.aoiList, 0);
this.Controls.SetChildIndex(this.imageBox1, 0);
this.Controls.SetChildIndex(this.aoiControl, 0);
this.Controls.SetChildIndex(this.btnOpenPro, 0);
this.Controls.SetChildIndex(this.btnSavePro, 0);
this.Controls.SetChildIndex(this.btnNewAoi, 0);
......@@ -196,6 +196,7 @@
this.Controls.SetChildIndex(this.cmbCameraList, 0);
this.Controls.SetChildIndex(this.btnGetCameraImg, 0);
this.Controls.SetChildIndex(this.comType, 0);
this.Controls.SetChildIndex(this.panAoi, 0);
this.ResumeLayout(false);
}
......@@ -203,15 +204,16 @@
#endregion
private Asa.Theme.FlatList aoiList;
private Cyotek.Windows.Forms.ImageBox imageBox1;
private ImageBoxEx imageBox1;
private Asa.Theme.FlatButton btnOpenPro;
private Asa.Theme.FlatButton btnSavePro;
private Asa.Theme.FlatButton btnNewAoi;
private Asa.Theme.FlatButton btnOpenImage;
private control.ABaseControl aoiControl;
private Asa.Theme.FlatLabel flatLabel1;
private Asa.Theme.FlatCombo cmbCameraList;
private Asa.Theme.FlatButton btnGetCameraImg;
private Asa.Theme.FlatCombo comType;
private System.Windows.Forms.Panel panAoi;
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -13,6 +14,7 @@ namespace AccAOI
{
public partial class FrmAoiSetting : Asa.Theme.FlatForm
{
private control.ABaseControl aoiControl = null;
private Image Img = null;
private AoiProject Project = null;
public FrmAoiSetting()
......@@ -37,13 +39,15 @@ namespace AccAOI
comType.ItemAdd("Mark点设置");
comType.ItemAdd("斑点分析");
comType.ItemAdd("颜色抽取");
comType.Text = "Mark点设置";
}
private void btnOpenImage_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "打开本地图片";
openDialog.Filter = "(*.jpg)|*.jpg|(*.png)|*.png|(*.bmp)|*.bmp";
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)
......@@ -97,6 +101,7 @@ namespace AccAOI
MessageBox.Show("没有项目可保存");
return;
}
SaveCurrAoi();
System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
saveFileDialog.Title = "保存项目";
saveFileDialog.Filter = "(*.data)|*.data|(*.*)|*.*";
......@@ -129,43 +134,189 @@ namespace AccAOI
return;
}
string text = comType.Text;
CloseCurrAoi();
AoiMethod methodInfo = null;
if (text.Equals("Mark点设置"))
{
aoiControl = new control.AioMarkControl();
this.aoiControl.TitleName = "Mark点设置";
methodInfo = new AoiMarkMethod();
}
else if (text.Equals("斑点分析"))
{
aoiControl = new control.AoiBlobControl();
this.aoiControl.TitleName = "斑点分析";
methodInfo = new AoiBlobMethod();
}
else
{
aoiControl = new control.AoiRgbControl();
this.aoiControl.TitleName = "颜色抽取";
methodInfo = new AoiMethodRgb();
}
this.aoiControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.aoiControl.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
methodInfo.MethodName = Project.methodMap.Values.Count.ToString().PadLeft(2, '0') + "_" + text;
Project.methodMap.Add(methodInfo.MethodName, methodInfo);
ShowAoi(methodInfo);
aoiList.ItemAdd(aoiControl.TitleName);
}
private void ShowAoi(AoiMethod method)
{
if (aoiControl == null)
{
if(method is AoiBlobMethod)
{
aoiControl = new control.AoiBlobControl();
}else if(method is AoiMarkMethod)
{
aoiControl = new control.AioMarkControl();
}else if(method is AoiMethodRgb)
{
aoiControl = new control.AoiRgbControl();
}
}
this.aoiControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
aoiControl.FormBorderStyle = FormBorderStyle.None;
aoiControl.StartPosition = FormStartPosition.CenterParent;
aoiControl.Location = new Point(0, 0);
aoiControl.SetImageBox(this.imageBox1);
aoiControl.AoiInfo = method;
aoiControl.Size = panAoi.Size;
aoiControl.TitleName = method.MethodName;
aoiControl.TopLevel = false;
aoiControl.Parent = panAoi;
aoiControl.Show();
aoiControl.ShowAoiInfo();
if (method.RoiPath != null)
{
currPath = method.RoiPath;
imageBox1.SelectionRegion = method.RoiPath.GetBounds();
Image threshImage = CutImage(imageBox1.Image, currPath);
cutImage = threshImage;
aoiControl.currPath = currPath;
aoiControl.aoiImage.Image = threshImage;
}
}
private void SaveCurrAoi()
{
if (aoiControl != null &&aoiControl.Visible)
{
AoiMethod method = aoiControl.GetAoiInfo();
//更新
if (Project.methodMap.ContainsKey(method.MethodName))
{
Project.methodMap[method.MethodName] = method;
}
}
}
private void CloseCurrAoi()
{
SaveCurrAoi();
if (aoiControl != null)
{
if (aoiControl.Visible)
{
aoiControl.Close();
}
aoiControl.Dispose();
aoiControl = null;
}
}
private void ShowPorject()
{
if (Project != null)
{
aoiList.ItemClear();
if (Project.methodMap.Count > 0)
{
foreach(string key in Project.methodMap.Keys)
{
aoiList.ItemAdd(key);
}
aoiList.Index = 0;
}
}
}
private void aoiList_IndexChanged(object sender, EventArgs e)
{
int index = aoiList.Index;
if (index >= 0)
if (index >= 0 && (Project != null))
{
List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values);
if (index < methods.Count)
{
AoiMethod method = methods[index];
if (aoiControl != null && aoiControl.TitleName.Equals(method.MethodName))
{
return;
}
else
{
CloseCurrAoi();
ShowAoi(method);
}
}
}
}
private Image cutImage = null;
private GraphicsPath currPath = null;
private void imageBox1_SelectionRegionChanged(object sender, EventArgs e)
{
try
{
if (imageBox1.Image == null || this.Img == null || aoiControl == null)
{
return;
}
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(100, 0);
RectangleF region = imageBox1.SelectionRegion;
currPath = new GraphicsPath();
if (aoiControl.AreaType.Equals(1))
{
currPath.AddRectangle(region);
}
else
{
currPath.AddEllipse(region);
}
Image threshImage = CutImage(imageBox1.Image, currPath);
cutImage = threshImage;
aoiControl.currPath = currPath;
aoiControl.aoiImage.Image = threshImage;
}catch(Exception ex)
{
}
}
private Image CutImage(Image src, GraphicsPath path)
{
var bounds = path.GetBounds();
Bitmap b = new Bitmap(src.Width, src.Height);
using (Graphics g = Graphics.FromImage(b))
{
var br = new TextureBrush(src);
g.FillPath(br, path);
}
if (bounds.Width > 0 && bounds.Height > 0)
{
Bitmap result = new Bitmap((int)bounds.Width, (int)bounds.Height);
var srcRect = bounds;
var dstRect = new RectangleF(0, 0, bounds.Width, bounds.Height);
bounds.Location = System.Drawing.Point.Empty;
using (Graphics g = Graphics.FromImage(result))
{
bounds.Location = System.Drawing.Point.Empty;
g.DrawImage(b, dstRect, srcRect, GraphicsUnit.Pixel);
}
return result;
}
return null;
}
}
}
......@@ -35,7 +35,8 @@
this.panResult = new Asa.Theme.FlatPanel();
this.btnClearArea = new Asa.Theme.FlatButton();
this.btnSetArea = new Asa.Theme.FlatButton();
this.aoiImage = new Cyotek.Windows.Forms.ImageBox();
this.btnYuan = new Asa.Theme.FlatButton();
this.aoiImage = new AccAOI.ImageBoxEx();
this.SuspendLayout();
//
// panControl
......@@ -46,7 +47,7 @@
this.panControl.Inside = false;
this.panControl.Location = new System.Drawing.Point(0, 0);
this.panControl.Name = "panControl";
this.panControl.Size = new System.Drawing.Size(311, 671);
this.panControl.Size = new System.Drawing.Size(308, 696);
this.panControl.TabIndex = 0;
this.panControl.Text = "斑点分析";
//
......@@ -57,7 +58,7 @@
this.panAreaImage.Inside = false;
this.panAreaImage.Location = new System.Drawing.Point(4, 27);
this.panAreaImage.Name = "panAreaImage";
this.panAreaImage.Size = new System.Drawing.Size(301, 212);
this.panAreaImage.Size = new System.Drawing.Size(298, 212);
this.panAreaImage.TabIndex = 1;
this.panAreaImage.Text = "区域图片";
//
......@@ -68,9 +69,9 @@
this.panAreaSet.Inside = false;
this.panAreaSet.Location = new System.Drawing.Point(4, 244);
this.panAreaSet.Name = "panAreaSet";
this.panAreaSet.Size = new System.Drawing.Size(301, 69);
this.panAreaSet.Size = new System.Drawing.Size(298, 69);
this.panAreaSet.TabIndex = 3;
this.panAreaSet.Text = "区域设置";
this.panAreaSet.Text = "区域设置-矩形";
//
// panParam
//
......@@ -79,18 +80,19 @@
this.panParam.Inside = false;
this.panParam.Location = new System.Drawing.Point(4, 319);
this.panParam.Name = "panParam";
this.panParam.Size = new System.Drawing.Size(301, 167);
this.panParam.Size = new System.Drawing.Size(298, 167);
this.panParam.TabIndex = 4;
this.panParam.Text = "参数设置";
//
// panResult
//
this.panResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
this.panResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panResult.Inside = false;
this.panResult.Location = new System.Drawing.Point(4, 491);
this.panResult.Name = "panResult";
this.panResult.Size = new System.Drawing.Size(301, 163);
this.panResult.Size = new System.Drawing.Size(298, 197);
this.panResult.TabIndex = 5;
this.panResult.Text = "结果判断";
//
......@@ -98,39 +100,55 @@
//
this.btnClearArea.ImageSize = new System.Drawing.Size(0, 0);
this.btnClearArea.Inside = false;
this.btnClearArea.Location = new System.Drawing.Point(26, 275);
this.btnClearArea.Location = new System.Drawing.Point(204, 274);
this.btnClearArea.Name = "btnClearArea";
this.btnClearArea.Size = new System.Drawing.Size(119, 30);
this.btnClearArea.Size = new System.Drawing.Size(90, 30);
this.btnClearArea.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnClearArea.TabIndex = 6;
this.btnClearArea.Text = "清除区域";
this.btnClearArea.Text = "清除";
this.btnClearArea.Click += new System.EventHandler(this.btnClearArea_Click);
//
// btnSetArea
//
this.btnSetArea.ImageSize = new System.Drawing.Size(0, 0);
this.btnSetArea.Inside = false;
this.btnSetArea.Location = new System.Drawing.Point(151, 275);
this.btnSetArea.Location = new System.Drawing.Point(12, 274);
this.btnSetArea.Name = "btnSetArea";
this.btnSetArea.Size = new System.Drawing.Size(119, 30);
this.btnSetArea.Size = new System.Drawing.Size(90, 30);
this.btnSetArea.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnSetArea.TabIndex = 7;
this.btnSetArea.Text = "矩形区域";
this.btnSetArea.Text = "矩形";
this.btnSetArea.Click += new System.EventHandler(this.btnSetArea_Click);
//
// btnYuan
//
this.btnYuan.ImageSize = new System.Drawing.Size(0, 0);
this.btnYuan.Inside = false;
this.btnYuan.Location = new System.Drawing.Point(108, 274);
this.btnYuan.Name = "btnYuan";
this.btnYuan.Size = new System.Drawing.Size(90, 30);
this.btnYuan.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnYuan.TabIndex = 8;
this.btnYuan.Text = "椭圆";
this.btnYuan.Click += new System.EventHandler(this.btnYuan_Click);
//
// aoiImage
//
this.aoiImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.aoiImage.DragHandleSize = 9;
this.aoiImage.Location = new System.Drawing.Point(9, 53);
this.aoiImage.Name = "aoiImage";
this.aoiImage.Size = new System.Drawing.Size(291, 182);
this.aoiImage.Size = new System.Drawing.Size(288, 182);
this.aoiImage.TabIndex = 2;
this.aoiImage.Text = "imageBox1";
//
// ABaseControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ClientSize = new System.Drawing.Size(312, 700);
this.Controls.Add(this.btnYuan);
this.Controls.Add(this.btnSetArea);
this.Controls.Add(this.btnClearArea);
this.Controls.Add(this.panResult);
......@@ -139,20 +157,21 @@
this.Controls.Add(this.aoiImage);
this.Controls.Add(this.panAreaImage);
this.Controls.Add(this.panControl);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "ABaseControl";
this.Size = new System.Drawing.Size(315, 674);
this.ResumeLayout(false);
}
#endregion
private Asa.Theme.FlatPanel panAreaImage;
private Cyotek.Windows.Forms.ImageBox aoiImage;
private Asa.Theme.FlatPanel panAreaSet;
private Asa.Theme.FlatButton btnClearArea;
private Asa.Theme.FlatButton btnSetArea;
private Asa.Theme.FlatPanel panControl;
protected Asa.Theme.FlatPanel panParam;
protected Asa.Theme.FlatPanel panResult;
public ImageBoxEx aoiImage;
private Asa.Theme.FlatButton btnYuan;
}
}
......@@ -8,10 +8,12 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Cyotek.Windows.Forms;
using AOI;
using System.Drawing.Drawing2D;
namespace AccAOI.control
{
public partial class ABaseControl : UserControl
public partial class ABaseControl : Form
{
public ABaseControl()
{
......@@ -22,10 +24,52 @@ namespace AccAOI.control
get { return panControl.Text; }
set { panControl.Text = value; }
}
/// <summary>
/// 区域类型,1=矩形,2=圆形
/// </summary>
public int AreaType = 1;
/// <summary>
/// 区域信息
/// </summary>
public GraphicsPath currPath = null;
internal ImageBoxEx BImageBox;
public ImageBox BImageBox
internal AoiMethod AoiInfo;
public void SetImageBox(ImageBoxEx box)
{
this.BImageBox = box;
}
public void SeetAoiInfo(AoiMethod aoi)
{
this.AoiInfo = aoi;
}
public virtual void ShowAoiInfo()
{
}public virtual AoiMethod GetAoiInfo()
{
return AoiInfo;
}
private void btnSetArea_Click(object sender, EventArgs e)
{
AreaType = 1;
panAreaSet.Text = "区域设置-矩形";
}
private void btnYuan_Click(object sender, EventArgs e)
{
get;set;
AreaType = 2;
panAreaSet.Text = "区域设置-椭圆";
}
private void btnClearArea_Click(object sender, EventArgs e)
{
this.BImageBox.CleearArea();
this.aoiImage.Image = null;
}
}
}
......@@ -30,18 +30,15 @@
{
this.SuspendLayout();
//
// panParam
//
this.panParam.Size = new System.Drawing.Size(302, 166);
//
// panResult
//
this.panResult.Size = new System.Drawing.Size(302, 88);
this.panResult.Size = new System.Drawing.Size(298, 197);
//
// AioMarkControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 700);
this.Name = "AioMarkControl";
this.TitleName = "Mark设置";
this.ResumeLayout(false);
......
......@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AOI;
namespace AccAOI.control
{
......@@ -16,5 +17,13 @@ namespace AccAOI.control
{
InitializeComponent();
}
public override AoiMethod GetAoiInfo()
{
if (currPath != null)
{
this.AoiInfo.RoiPath = currPath;
}
return base.GetAoiInfo();
}
}
}
......@@ -46,12 +46,13 @@
//
// panParam
//
this.panParam.Location = new System.Drawing.Point(2, 319);
this.panParam.Size = new System.Drawing.Size(302, 146);
//
// panResult
//
this.panResult.Location = new System.Drawing.Point(4, 471);
this.panResult.Size = new System.Drawing.Size(302, 192);
this.panResult.Location = new System.Drawing.Point(2, 471);
this.panResult.Size = new System.Drawing.Size(302, 216);
//
// flatLabel1
//
......@@ -183,6 +184,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 699);
this.Controls.Add(this.flatLabel4);
this.Controls.Add(this.txtmaxNum);
this.Controls.Add(this.txtminNum);
......
......@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AOI;
namespace AccAOI.control
{
......@@ -22,5 +23,54 @@ namespace AccAOI.control
int value = trackBarThresh.Value;
lblthresh.Text = value.ToString();
}
public override void ShowAoiInfo()
{
if(this.AoiInfo is AoiBlobMethod)
{
AoiBlobMethod aInfo = (AoiBlobMethod)AoiInfo;
if (aInfo.thresh < 0)
{
trackBarThresh.Value = 0;
}
else
{
trackBarThresh.Value = aInfo.thresh;
}
chkwhiteOnBlack.Checked = aInfo.whiteOnBlack;
txtmaxArea.Text = aInfo.maxArea.ToString();
txtminArea.Text = aInfo.minArea.ToString();
txtmaxNum.Text = aInfo.maxNum.ToString();
txtminNum.Text = aInfo.minNum.ToString();
}
}
public override AoiMethod GetAoiInfo()
{
if (this.AoiInfo is AoiBlobMethod)
{
AoiBlobMethod aInfo = (AoiBlobMethod)AoiInfo;
if (trackBarThresh.Value.Equals(0))
{
aInfo.thresh = -1;
}
else
{
aInfo.thresh= trackBarThresh.Value;
}
aInfo.whiteOnBlack= chkwhiteOnBlack.Checked ;
aInfo.maxArea = FormUtil.GetIntValue(txtmaxArea);
aInfo.minArea = FormUtil.GetIntValue(txtminArea);
aInfo.maxNum = FormUtil.GetIntValue(txtmaxNum);
aInfo.minNum = FormUtil.GetIntValue(txtminNum);
if (currPath != null)
{
aInfo.RoiPath = currPath;
}
}
return AoiInfo;
}
}
}
......@@ -48,11 +48,11 @@
//
// panParam
//
this.panParam.Size = new System.Drawing.Size(302, 166);
this.panParam.Size = new System.Drawing.Size(291, 166);
//
// panResult
//
this.panResult.Size = new System.Drawing.Size(302, 180);
this.panResult.Size = new System.Drawing.Size(291, 189);
//
// flatLabel5
//
......@@ -210,6 +210,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 700);
this.Controls.Add(this.flatLabel7);
this.Controls.Add(this.txtMaxB);
this.Controls.Add(this.txtMinB);
......
......@@ -6,7 +6,8 @@ using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms;
using AOI;
namespace AccAOI.control
{
......@@ -16,5 +17,42 @@ namespace AccAOI.control
{
InitializeComponent();
}
public override void ShowAoiInfo()
{
if (this.AoiInfo is AoiMethodRgb)
{
AoiMethodRgb aInfo = (AoiMethodRgb)AoiInfo;
txtMinR.Text = aInfo.minR.ToString();
txtMaxR.Text = aInfo.maxR.ToString();
txtMinG.Text = aInfo.minG.ToString();
txtMaxG.Text = aInfo.maxG.ToString();
txtMaxB.Text = aInfo.maxB.ToString();
txtMinB.Text = aInfo.minB.ToString();
txtminRate.Text = aInfo.minRate.ToString();
txtmaxRate.Text = aInfo.maxRate.ToString();
}
}
public override AoiMethod GetAoiInfo()
{
if (this.AoiInfo is AoiMethodRgb)
{
AoiMethodRgb aInfo = (AoiMethodRgb)AoiInfo;
aInfo.minR = FormUtil.GetIntValue(txtMinR);
aInfo.maxR = FormUtil.GetIntValue(txtMaxR);
aInfo.minG = FormUtil.GetIntValue(txtMinG);
aInfo.maxG = FormUtil.GetIntValue(txtMaxG);
aInfo.maxB = FormUtil.GetIntValue(txtMaxB);
aInfo.minB = FormUtil.GetIntValue(txtMinB);
aInfo.minRate = FormUtil.GetIntValue(txtminRate);
aInfo.maxRate = FormUtil.GetIntValue(txtmaxRate);
if (currPath != null)
{
aInfo.RoiPath = currPath;
}
}
return AoiInfo;
}
}
}
......@@ -2,16 +2,16 @@
namespace AccAOI
{
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
// If you use this control in your applications, attribution, donations or contributions are welcome.
internal class DragHandle
public class DragHandle
{
#region Public Constructors
......
namespace AccAOI
{
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
// If you use this control in your applications, attribution, donations or contributions are welcome.
internal enum DragHandleAnchor
public enum DragHandleAnchor
{
None,
......
......@@ -4,16 +4,16 @@ using System.Drawing;
namespace AccAOI
{
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
// If you use this control in your applications, attribution, donations or contributions are welcome.
internal class DragHandleCollection : IEnumerable<DragHandle>
public class DragHandleCollection : IEnumerable<DragHandle>
{
#region Instance Fields
......
......@@ -6,18 +6,22 @@ using System.Windows.Forms;
namespace AccAOI
{
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Cyotek ImageBox
// Copyright (c) 2010-2014 Cyotek.
// http://cyotek.com
// http://cyotek.com/blog/tag/imagebox
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// Licensed under the MIT License. See imagebox-license.txt for the full text.
// If you use this control in your applications, attribution, donations or contributions are welcome.
// If you use this control in your applications, attribution, donations or contributions are welcome.
public class ImageBoxEx : ImageBox
public class ImageBoxEx : ImageBox
{
#region Instance Fields
public void CleearArea()
{
}
#region Instance Fields
private readonly DragHandleCollection _dragHandles;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!