Commit f7f6a7c2 贾鹏旭

注释GC回收

1 个父辈 7dfece50
......@@ -32,7 +32,7 @@ namespace AccAOI
}
public FrmAoiSetting(string programPath, Image image = null, string defaultPath = "")
{
InitializeComponent();
InitializeComponent();
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
this.WindowState = FormWindowState.Maximized;
......@@ -61,7 +61,7 @@ namespace AccAOI
DefaultPath = defaultPath;
}
string CurrentCamera="";
string CurrentCamera = "";
private void FrmAoiSetting_Load(object sender, EventArgs e)
{
LoadTypes();
......@@ -86,7 +86,7 @@ namespace AccAOI
}
}
private void LoadTypes()
{
......@@ -102,7 +102,7 @@ namespace AccAOI
private void btnOpenImage_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title =AOIResourceCulture.GetValue( "打开本地图片");
openDialog.Title = AOIResourceCulture.GetValue("打开本地图片");
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";
......@@ -306,7 +306,7 @@ namespace AccAOI
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);
frmName.Text = AOIResourceCulture.GetValue("请输入新【{0}】名称", text);
DialogResult result = frmName.ShowDialog();
if (result.Equals(DialogResult.OK))
{
......@@ -318,7 +318,7 @@ namespace AccAOI
}
CloseCurrAoi();
// methodInfo.MethodName = Project.methodMap.Values.Count.ToString().PadLeft(2, '0') + "_" + text;
Project.methodMap.Add(methodInfo.MethodName, methodInfo);
ShowAoi(methodInfo);
aoiList.ItemAdd(methodInfo.MethodName);
......@@ -421,14 +421,14 @@ namespace AccAOI
}
}
private void aoiList_IndexChanged(object sender )
private void aoiList_IndexChanged(object sender)
{
// int index = aoiList.SelectedIndex;
// int index = aoiList.SelectedIndex;
if (aoiList.SelectedIndex >= 0 && (Project != null))
{
string text = aoiList.Text;
// List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values);
if (Project.methodMap.ContainsKey(text ))
// List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values);
if (Project.methodMap.ContainsKey(text))
{
AoiMethod method = Project.methodMap[text];
if (aoiControl != null && aoiControl.TitleName.Equals(method.MethodName))
......@@ -506,13 +506,13 @@ namespace AccAOI
lblTestResult.Text = "Result: null";
}
else
{
lblTestResult.Text = ControlUtil. GetResultsStr(result);
{
lblTestResult.Text = ControlUtil.GetResultsStr(result);
}
GC.Collect();
//GC.Collect();
CanSel = true;
}
private void btnDel_Click(object sender, EventArgs e)
{
if (BaseImg == null)
......@@ -637,23 +637,23 @@ namespace AccAOI
private void btnUpdateName_Click(object sender, EventArgs e)
{
// int index = aoiList.SelectedIndex;
if (aoiList.SelectedIndex >= 0 && (Project != null)&&(aoiControl!=null))
// int index = aoiList.SelectedIndex;
if (aoiList.SelectedIndex >= 0 && (Project != null) && (aoiControl != null))
{
string oldName = aoiList.Text;
if (Project.methodMap.ContainsKey(oldName))
{
// AoiMethod method = methods[index];
// string oldName = methods[index].MethodName;
// AoiMethod method = methods[index];
// string oldName = methods[index].MethodName;
List<string> allName = new List<string>(Project.methodMap.Keys);
allName.Remove(oldName);
FrmMethodName frmName = new FrmMethodName(oldName, allName);
FrmMethodName frmName = new FrmMethodName(oldName, allName);
frmName.Text = AOIResourceCulture.GetValue("请输入修改后的名称");
DialogResult result = frmName.ShowDialog();
if (result.Equals(DialogResult.OK))
{
string newName= frmName.MethodName;
string newName = frmName.MethodName;
if (newName.Equals(oldName))
{
return;
......@@ -670,19 +670,19 @@ namespace AccAOI
aoiList.ItemAdd(m.MethodName);
}
aoiControl.TitleName = newName;
}
else
{
return;
}
}
}
if (imageBox1.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
}
}
private void lblCurrImage_Click(object sender, EventArgs e)
......@@ -714,7 +714,8 @@ namespace AccAOI
needSaveImage.Save(fileName, ImageFormat.Bmp);
MyMessage.Show("保存成功");
}
}catch(Exception ex)
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
......@@ -755,7 +756,7 @@ namespace AccAOI
{
if (aoiControl != null && aoiControl.Visible)
{
//保存原来的
//保存原来的
AoiMethod OldMethod = aoiControl.GetAoiInfo();
AoiMethod methodInfo = OldMethod.GetClone();
string text = ControlUtil.GetMethodType(methodInfo);
......@@ -783,7 +784,7 @@ namespace AccAOI
btnImageChange_Click(null, null);
}
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!