Commit 469cabf7 几米阳光

1

1 个父辈 14393650
...@@ -18,13 +18,22 @@ namespace CodeLibrary ...@@ -18,13 +18,22 @@ namespace CodeLibrary
public static string China = "zh-CN"; public static string China = "zh-CN";
public static string English = "en-US"; public static string English = "en-US";
private static Dictionary<string, string> chineseMap = new Dictionary<string, string>(); private static Dictionary<string, string> chineseMap = new Dictionary<string, string>();
internal static string GetString(object selCamera, string v)
{
throw new NotImplementedException();
}
private static Dictionary<string, string> englishMap = new Dictionary<string, string>(); private static Dictionary<string, string> englishMap = new Dictionary<string, string>();
public delegate string GetLanguageDelegate(); public delegate string GetLanguageDelegate();
public static event GetLanguageDelegate GetLanguageEvent; public static event GetLanguageDelegate GetLanguageEvent;
public static string GetLanguage() public static string GetLanguage()
{ {
return English; if (GetLanguageEvent == null)
{
return China;
}
string result = GetLanguageEvent?.Invoke(); string result = GetLanguageEvent?.Invoke();
if (result == null) if (result == null)
{ {
...@@ -126,6 +135,27 @@ namespace CodeLibrary ...@@ -126,6 +135,27 @@ namespace CodeLibrary
HDLogUtil.error("CodeResourceControl" + ex.ToString()); HDLogUtil.error("CodeResourceControl" + ex.ToString());
} }
} }
/// <summary>
/// 请先选择相机
/// </summary>
public static string selCamera = "selCamera";
/// <summary>
/// 请先选择图片
/// </summary>
public static string selImage = "selImage";
/// <summary>
/// 提示
/// </summary>
public static string title = "title";
/// <summary>
/// 获取二维码图片为空
/// </summary>
public static string imageIsNull = "imageIsNull";
/// <summary>
/// 确定删除文件:
/// </summary>
public static string sureDelete = "sureDelete";
} }
......
...@@ -27,7 +27,11 @@ namespace CodeLibrary ...@@ -27,7 +27,11 @@ namespace CodeLibrary
{ {
InitializeComponent(); InitializeComponent();
} }
private string selCamera = CodeResourceControl.GetString(CodeResourceControl.selCamera, "请先选择相机");
private string selImage = CodeResourceControl.GetString(CodeResourceControl.selImage, "请先选择图片");
private string title = CodeResourceControl.GetString(CodeResourceControl.title, "提示");
private string imageIsNull = CodeResourceControl.GetString(CodeResourceControl.imageIsNull, "获取二维码图片为空");
private string sureDelete = CodeResourceControl.GetString(CodeResourceControl.sureDelete, "确定删除文件:");
private void FrmMain_Load(object sender, EventArgs e) private void FrmMain_Load(object sender, EventArgs e)
{ {
...@@ -69,8 +73,8 @@ namespace CodeLibrary ...@@ -69,8 +73,8 @@ namespace CodeLibrary
private void btnSelImage_Click(object sender, EventArgs e) private void btnSelImage_Click(object sender, EventArgs e)
{ {
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog(); System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "选择二维码图片"; openDialog.Title = selImage;
openDialog.Filter = "图片(*.jpg)|*.jpg|图片(*.png)|*.png|图片(*.bmp)|*.bmp"; openDialog.Filter = "(*.jpg)|*.jpg|(*.png)|*.png|(*.bmp)|*.bmp";
//openDialog.DefaultExt = "png"; //openDialog.DefaultExt = "png";
System.Windows.Forms.DialogResult result = openDialog.ShowDialog(); System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel) if (result == System.Windows.Forms.DialogResult.Cancel)
...@@ -81,7 +85,7 @@ namespace CodeLibrary ...@@ -81,7 +85,7 @@ namespace CodeLibrary
string filename = txtPath.Text; string filename = txtPath.Text;
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))
{ {
MessageBox.Show("获取二维码图片为空"); MessageBox.Show(imageIsNull);
} }
pictureBox1.Image = null; pictureBox1.Image = null;
//读取图片内容 //读取图片内容
...@@ -93,7 +97,7 @@ namespace CodeLibrary ...@@ -93,7 +97,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null || txtPath.Text.Equals("")) if (pictureBox1.Image == null || txtPath.Text.Equals(""))
{ {
MessageBox.Show("请先选择图片","提示",MessageBoxButtons.OK,MessageBoxIcon.Error); MessageBox.Show(selImage,title,MessageBoxButtons.OK,MessageBoxIcon.Error);
return; return;
} }
Bitmap map = new Bitmap(pictureBox1.Image); Bitmap map = new Bitmap(pictureBox1.Image);
...@@ -104,7 +108,7 @@ namespace CodeLibrary ...@@ -104,7 +108,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null || txtPath.Text.Equals("")) if (pictureBox1.Image == null || txtPath.Text.Equals(""))
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage ,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
Bitmap map = new Bitmap(pictureBox1.Image); Bitmap map = new Bitmap(pictureBox1.Image);
...@@ -117,7 +121,7 @@ namespace CodeLibrary ...@@ -117,7 +121,7 @@ namespace CodeLibrary
{ {
if (list.Count > 0) if (list.Count > 0)
{ {
txtResult.Text += "\r\n识别到二维码:"; txtResult.Text += "\r\n code list:";
foreach (CodeInfo code in list) foreach (CodeInfo code in list)
{ {
txtResult.Text += "\r\n" + ""+code.CodeType+" (X:" + code.X + ",Y:" + code.Y + ") " + code.CodeStr; txtResult.Text += "\r\n" + ""+code.CodeType+" (X:" + code.X + ",Y:" + code.Y + ") " + code.CodeStr;
...@@ -125,7 +129,7 @@ namespace CodeLibrary ...@@ -125,7 +129,7 @@ namespace CodeLibrary
} }
else else
{ {
txtResult.Text += "\r\n未识别到二维码"; txtResult.Text += "\r\n no code ";
} }
} }
...@@ -133,7 +137,7 @@ namespace CodeLibrary ...@@ -133,7 +137,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null ) if (pictureBox1.Image == null )
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage ,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
int count = cmbCount.SelectedIndex + 1; int count = cmbCount.SelectedIndex + 1;
...@@ -166,7 +170,7 @@ namespace CodeLibrary ...@@ -166,7 +170,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null) if (pictureBox1.Image == null)
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage ,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
int count = cmbCount.SelectedIndex + 1; int count = cmbCount.SelectedIndex + 1;
...@@ -211,7 +215,7 @@ namespace CodeLibrary ...@@ -211,7 +215,7 @@ namespace CodeLibrary
string camerName = cmbCamera.Text; string camerName = cmbCamera.Text;
if (index < 0) if (index < 0)
{ {
MessageBox.Show("请先选择相机"); MessageBox.Show(selCamera);
return null; return null;
} }
if (baslerNameList.Contains(camerName)) if (baslerNameList.Contains(camerName))
...@@ -253,7 +257,7 @@ namespace CodeLibrary ...@@ -253,7 +257,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null || txtPath.Text.Equals("")) if (pictureBox1.Image == null || txtPath.Text.Equals(""))
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage ,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
Bitmap map = new Bitmap(pictureBox1.Image); Bitmap map = new Bitmap(pictureBox1.Image);
...@@ -265,7 +269,7 @@ namespace CodeLibrary ...@@ -265,7 +269,7 @@ namespace CodeLibrary
{ {
if (pictureBox1.Image == null || txtPath.Text.Equals("")) if (pictureBox1.Image == null || txtPath.Text.Equals(""))
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage ,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
Bitmap map = new Bitmap(pictureBox1.Image); Bitmap map = new Bitmap(pictureBox1.Image);
......
...@@ -22,7 +22,11 @@ namespace CodeLibrary ...@@ -22,7 +22,11 @@ namespace CodeLibrary
{ {
InitializeComponent(); InitializeComponent();
} }
private string selCamera =CodeResourceControl.GetString(CodeResourceControl.selCamera, "请先选择相机");
private string selImage = CodeResourceControl.GetString(CodeResourceControl.selImage, "请先选择图片");
private string title = CodeResourceControl.GetString(CodeResourceControl.title, "提示");
private string imageIsNull = CodeResourceControl.GetString(CodeResourceControl.imageIsNull, "获取二维码图片为空");
private string sureDelete = CodeResourceControl.GetString(CodeResourceControl.sureDelete, "确定删除文件:");
private Bitmap GetCameraBitmap() private Bitmap GetCameraBitmap()
{ {
Bitmap bitmap = null; Bitmap bitmap = null;
...@@ -30,7 +34,7 @@ namespace CodeLibrary ...@@ -30,7 +34,7 @@ namespace CodeLibrary
string camerName = cmbCamera.Text; string camerName = cmbCamera.Text;
if (index < 0) if (index < 0)
{ {
MessageBox.Show("请先选择相机"); MessageBox.Show(selCamera);
return null; return null;
} }
if (baslerNameList.Contains(camerName)) if (baslerNameList.Contains(camerName))
...@@ -62,7 +66,7 @@ namespace CodeLibrary ...@@ -62,7 +66,7 @@ namespace CodeLibrary
cameraName = cmbHalconCamera.Text; cameraName = cmbHalconCamera.Text;
if (cameraName.Equals("")) if (cameraName.Equals(""))
{ {
MessageBox.Show("请先选择相机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selCamera,title, MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
} }
...@@ -87,7 +91,7 @@ namespace CodeLibrary ...@@ -87,7 +91,7 @@ namespace CodeLibrary
if (pictureBox1.Image == null) if (pictureBox1.Image == null)
{ {
MessageBox.Show("请先选择图片", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(selImage,title ,MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
Bitmap bitmap = new Bitmap( pictureBox1.Image); Bitmap bitmap = new Bitmap( pictureBox1.Image);
...@@ -217,8 +221,8 @@ namespace CodeLibrary ...@@ -217,8 +221,8 @@ namespace CodeLibrary
private void btnSelImage_Click(object sender, EventArgs e) private void btnSelImage_Click(object sender, EventArgs e)
{ {
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog(); System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
openDialog.Title = "选择二维码图片"; openDialog.Title = selImage;
openDialog.Filter = "图片(*.jpg)|*.jpg|图片(*.png)|*.png|图片(*.bmp)|*.bmp"; openDialog.Filter = "(*.jpg)|*.jpg|(*.png)|*.png|(*.bmp)|*.bmp";
//openDialog.DefaultExt = "png"; //openDialog.DefaultExt = "png";
System.Windows.Forms.DialogResult result = openDialog.ShowDialog(); System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel) if (result == System.Windows.Forms.DialogResult.Cancel)
...@@ -229,7 +233,7 @@ namespace CodeLibrary ...@@ -229,7 +233,7 @@ namespace CodeLibrary
string filename = txtPath.Text; string filename = txtPath.Text;
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename))
{ {
MessageBox.Show("获取二维码图片为空"); MessageBox.Show(imageIsNull);
} }
pictureBox1.Image = null; pictureBox1.Image = null;
//读取图片内容 //读取图片内容
...@@ -260,7 +264,7 @@ namespace CodeLibrary ...@@ -260,7 +264,7 @@ namespace CodeLibrary
} }
FileInfo file = new FileInfo(path); FileInfo file = new FileInfo(path);
DialogResult result = MessageBox.Show("确定删除文件:" +file.Name+ "", "确认删除", MessageBoxButtons.YesNo); DialogResult result = MessageBox.Show(sureDelete +file.Name+ "", title, MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes)) if (result.Equals(DialogResult.Yes))
{ {
File.Delete(path); File.Delete(path);
......
...@@ -31,3 +31,8 @@ FrmCodeLearn_label1_Text,相机:,camera: ...@@ -31,3 +31,8 @@ FrmCodeLearn_label1_Text,相机:,camera:
FrmCodeLearn_btnExit_Text,退出,Exit FrmCodeLearn_btnExit_Text,退出,Exit
FrmCodeLearn_btnStop_Text,结束学习,End of learning FrmCodeLearn_btnStop_Text,结束学习,End of learning
FrmCodeLearn_btnOpen_Text,开始学习,start to learn FrmCodeLearn_btnOpen_Text,开始学习,start to learn
selCamera,请先选择相机,Please select camera
selImage,请先选择图片,Please select picture
title,提示,Notice
imageIsNull,获取二维码图片为空,Get the two-dimensional code picture is empty
sureDelete,确定删除文件:,Make sure to delete the file:
\ No newline at end of file \ No newline at end of file
...@@ -65,7 +65,7 @@ namespace OnLineStore.Common ...@@ -65,7 +65,7 @@ namespace OnLineStore.Common
} }
sw.Close(); sw.Close();
fs.Close(); fs.Close();
DialogResult result = MessageBox.Show("CSV文件保存成功!"); //DialogResult result = MessageBox.Show("CSV文件保存成功!");
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!