Commit 0fdda9d7 LN

1

1 个父辈 b3c9937e
......@@ -31,7 +31,9 @@ namespace AOI
/// <returns></returns>
public GraphicsPath GetSearchPath()
{
if(RoiPath != null && SearchPathZoom > 0)
try
{
if (RoiPath != null && SearchPathZoom > 0)
{
GraphicsPath SearchPath = new GraphicsPath(RoiPath.PathPoints, RoiPath.PathTypes);
Matrix matrix = new Matrix();
......@@ -53,6 +55,10 @@ namespace AOI
return SearchPath;
}
return RoiPath;
}catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}return null;
}
/// <summary>
......
......@@ -38,14 +38,14 @@ namespace AccAOI
// BaseImg = image;
// Project = new AoiProject(image);
string result = "";
Project= AoiProject.Load(programPath,out result);
Project = AoiProject.Load(programPath, out result);
if (!result.Equals(""))
{
MessageBox.Show("加载项目" + programPath + "失败:\r\n" + result);
}
else
{
currProjectFileName= programPath;
currProjectFileName = programPath;
}
}
if (image != null)
......@@ -133,7 +133,7 @@ namespace AccAOI
} //将图片保存到本地重新加载
// string filePath = Application.StartupPath + @"\aimage\" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + DateTime.Now.Millisecond.ToString().PadLeft(3, '0') ;
string filePath = Application.StartupPath + @"\aimage\";
string fileName = @"\test.bmp";
string fileName = @"\base.bmp";
using (Bitmap img = CameraManager.GetCamerImage(camera))
{
if (img != null)
......@@ -145,6 +145,11 @@ namespace AccAOI
}
img.Save(filePath + fileName, ImageFormat.Bmp);
}
else
{
MessageBox.Show("获取图片失败");
return;
}
}
GC.Collect();
Image file = (Image)Image.FromFile(filePath + fileName);
......@@ -163,7 +168,7 @@ namespace AccAOI
btnImageChange_Click(null, null);
}
}
catch(Exception ex)
catch (Exception ex)
{
Console.WriteLine("btnGetCameraImg_Click Error:" + ex.ToString());
MessageBox.Show(ex.ToString());
......@@ -318,7 +323,7 @@ namespace AccAOI
aoiControl.FormBorderStyle = FormBorderStyle.None;
aoiControl.StartPosition = FormStartPosition.CenterParent;
aoiControl.Location = new Point(0, 0);
aoiControl.BImageBox=this.imageBox1;
aoiControl.BImageBox = this.imageBox1;
aoiControl.AoiInfo = method;
aoiControl.Size = panAoi.Size;
aoiControl.TitleName = method.MethodName;
......@@ -332,14 +337,14 @@ namespace AccAOI
//Image threshImage = CutImage(imageBox1.Image, currPath);
//cutImage = threshImage;
aoiControl.SetCurrPath(currPath,true);
aoiControl.SetCurrPath(currPath, true);
}
aoiControl.Show();
aoiControl.ShowAoiInfo();
}
private void SaveCurrAoi()
{
if (aoiControl != null &&aoiControl.Visible)
if (aoiControl != null && aoiControl.Visible)
{
AoiMethod method = aoiControl.GetAoiInfo();
......@@ -383,7 +388,8 @@ namespace AccAOI
{
aoiList.Index = index;
ShowAoi(Project.methodMap[key]);
}index++;
}
index++;
}
}
if (imageBox1.Visible.Equals(false))
......@@ -435,8 +441,9 @@ namespace AccAOI
}
currPath = imageBox1.SelectionRegion;
aoiControl.SetCurrPath( currPath);
}catch(Exception ex)
aoiControl.SetCurrPath(currPath);
}
catch (Exception ex)
{
}
......@@ -486,7 +493,7 @@ namespace AccAOI
}
if (this.aoiControl != null)
{
DialogResult result= MessageBox.Show("确定删除 " + aoiControl.AoiInfo.MethodName + " ?", "确认提示", MessageBoxButtons.OKCancel);
DialogResult result = MessageBox.Show("确定删除 " + aoiControl.AoiInfo.MethodName + " ?", "确认提示", MessageBoxButtons.OKCancel);
if (result.Equals(DialogResult.OK))
{
if (Project.methodMap.ContainsKey(aoiControl.AoiInfo.MethodName))
......@@ -561,11 +568,32 @@ namespace AccAOI
MessageBox.Show("清先选择相机");
return;
}
Bitmap img = CameraManager.GetCamerImage(camera);
string filePath = Application.StartupPath + @"\aimage\";
string fileName = @"\test.bmp";
using (Bitmap img = CameraManager.GetCamerImage(camera))
{
if (img != null)
{
string path = Path.GetFullPath(filePath);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
img.Save(filePath + fileName, ImageFormat.Bmp);
}
else
{
MessageBox.Show("获取图片失败");
return;
}
}
GC.Collect();
Image file = (Image)Image.FromFile(filePath + fileName);
TestImage = new Bitmap(file);
file.Dispose();
//读取图片内容
TestImage = (Image)img.Clone();
testImageBox1.Image = TestImage;
if (testImageBox1.Visible.Equals(false))
{
......@@ -573,5 +601,4 @@ namespace AccAOI
}
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!