Commit 9e076ac3 LN

BUG修改。增加图片保存功能

1 个父辈 7e5eeabf
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationIcon>aoi.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Asa.Theme"> <Reference Include="Asa.Theme">
<HintPath>..\dll\Asa.Theme.dll</HintPath> <HintPath>..\dll\Asa.Theme.dll</HintPath>
...@@ -95,5 +98,8 @@ ...@@ -95,5 +98,8 @@
<Name>AccAOI</Name> <Name>AccAOI</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="aoi.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file \ No newline at end of file
此文件类型无法预览
...@@ -260,6 +260,7 @@ namespace AccAOI ...@@ -260,6 +260,7 @@ namespace AccAOI
this.lblCurrImage.Size = new System.Drawing.Size(74, 22); this.lblCurrImage.Size = new System.Drawing.Size(74, 22);
this.lblCurrImage.TabIndex = 22; this.lblCurrImage.TabIndex = 22;
this.lblCurrImage.Text = "基准图:"; this.lblCurrImage.Text = "基准图:";
this.lblCurrImage.Click += new System.EventHandler(this.lblCurrImage_Click);
// //
// testImageBox1 // testImageBox1
// //
......
...@@ -414,13 +414,14 @@ namespace AccAOI ...@@ -414,13 +414,14 @@ namespace AccAOI
private void aoiList_IndexChanged(object sender ) private void aoiList_IndexChanged(object sender )
{ {
int index = aoiList.SelectedIndex; // int index = aoiList.SelectedIndex;
if (index >= 0 && (Project != null)) if (aoiList.SelectedIndex >= 0 && (Project != null))
{ {
List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values); string text = aoiList.Text;
if (index < methods.Count) // List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values);
if (Project.methodMap.ContainsKey(text ))
{ {
AoiMethod method = methods[index]; AoiMethod method = Project.methodMap[text];
if (aoiControl != null && aoiControl.TitleName.Equals(method.MethodName)) if (aoiControl != null && aoiControl.TitleName.Equals(method.MethodName))
{ {
return; return;
...@@ -616,14 +617,15 @@ namespace AccAOI ...@@ -616,14 +617,15 @@ namespace AccAOI
private void btnUpdateName_Click(object sender, EventArgs e) private void btnUpdateName_Click(object sender, EventArgs e)
{ {
int index = aoiList.SelectedIndex; // int index = aoiList.SelectedIndex;
if (index >= 0 && (Project != null)&&(aoiControl!=null)) if (aoiList.SelectedIndex >= 0 && (Project != null)&&(aoiControl!=null))
{ {
List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values); string oldName = aoiList.Text;
if (index < methods.Count)
if (Project.methodMap.ContainsKey(oldName))
{ {
// AoiMethod method = methods[index]; // AoiMethod method = methods[index];
string oldName = methods[index].MethodName; // string oldName = methods[index].MethodName;
List<string> allName = new List<string>(Project.methodMap.Keys); List<string> allName = new List<string>(Project.methodMap.Keys);
allName.Remove(oldName); allName.Remove(oldName);
FrmMethodName frmName = new FrmMethodName(oldName, allName); FrmMethodName frmName = new FrmMethodName(oldName, allName);
...@@ -636,12 +638,13 @@ namespace AccAOI ...@@ -636,12 +638,13 @@ namespace AccAOI
{ {
return; return;
} }
methods[index].MethodName = newName; Project.methodMap[oldName].MethodName = newName;
List<AoiMethod> methods = new List<AoiMethod>(Project.methodMap.Values);
//Project.methodMap.Remove(oldName); //Project.methodMap.Remove(oldName);
//Project.methodMap.Add(newName, method); //Project.methodMap.Add(newName, method);
Project.methodMap.Clear(); Project.methodMap.Clear();
aoiList.ItemClear(); aoiList.ItemClear();
foreach(AoiMethod m in methods) foreach (AoiMethod m in methods)
{ {
Project.methodMap.Add(m.MethodName, m); Project.methodMap.Add(m.MethodName, m);
aoiList.ItemAdd(m.MethodName); aoiList.ItemAdd(m.MethodName);
...@@ -661,6 +664,40 @@ namespace AccAOI ...@@ -661,6 +664,40 @@ namespace AccAOI
} }
} }
private void lblCurrImage_Click(object sender, EventArgs e)
{
try
{
Image needSaveImage = null;
if (testImageBox1.Visible)
{
needSaveImage = testImageBox1.Image;
}
else
{
needSaveImage = imageBox1.Image;
}
if (needSaveImage != null)
{
System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog();
saveFileDialog.Title = AOIResourceCulture.GetValue("保存项目");
saveFileDialog.Filter = "(*.bmp)|*.bmp";
System.Windows.Forms.DialogResult result = saveFileDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
string fileName = saveFileDialog.FileName;
needSaveImage.Save(fileName, ImageFormat.Bmp);
MyMessage.Show("保存成功");
}
}catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
} }
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!