Commit 264bb791 几米阳光

增加中英文处理

1 个父辈 4d98d7fa
......@@ -57,6 +57,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon>
</Compile>
<Compile Include="HIKCamera.cs" />
<Compile Include="BaslerCamera.cs" />
<Compile Include="FrmCodeLearn.cs">
......@@ -76,8 +82,12 @@
<Compile Include="HDLogUtil.cs" />
<Compile Include="ImageHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CodeResourceControl.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmCodeLearn.resx">
<DependentUpon>FrmCodeLearn.cs</DependentUpon>
</EmbeddedResource>
......@@ -86,6 +96,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="resources.txt" />
<Content Include="记录.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CodeLibrary
{
public class CodeResourceControl
{
public delegate string GetStrDelegate(string id, string defaultStr);
public static event GetStrDelegate GetStrEvent;
public delegate string GetStringDelegate(string id, string defaultStr, params object[] param);
public static event GetStringDelegate GetStringEvent;
//public delegate string GetIdStrDelegate(string className, string controlName );
//public static event GetIdStrDelegate GetIdStrEvent;
//public delegate string GetProStrDelegate(string className);
//public static event GetProStrDelegate GetProStrEvent;
public delegate string GetLanguageDelegate();
public static event GetLanguageDelegate GetLanguageEvent;
public static string GetLanguage()
{
string result = GetLanguageEvent?.Invoke();
if (result == null)
{
return "";
}
return result;
}
public static string GetString(string id, string defaultStr)
{
string result = GetStrEvent?.Invoke(id, defaultStr);
if (result == null)
{
return defaultStr;
}
return result;
}
public static string GetString(string id, string defaultStr, params object[] param)
{
string result = GetStringEvent?.Invoke(id, defaultStr, param);
if (result == null)
{
return defaultStr;
}
return result;
}
private static string spiltStr = "_";
private static string Text = "Text";
public static string GetTextIdStr(string className, string controlName)
{
return className + spiltStr + controlName + spiltStr + Text;
}
public static string GetTextIdStr(string className)
{
return className + spiltStr + Text;
}
}
}
namespace CodeLibrary
{
partial class FrmBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// FrmBase
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Name = "FrmBase";
this.Text = "FrmBase";
this.VisibleChanged += new System.EventHandler(this.FrmBase_VisibleChanged);
this.ResumeLayout(false);
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CodeLibrary
{
public partial class FrmBase : Form
{
public string CurrLanguage = "";
public string ClassName
{
get
{
return this.GetType().Name;
}
set
{
}
}
public FrmBase()
{
InitializeComponent();
}
public void LanguageProcess()
{
if (CurrLanguage.Equals(CodeResourceControl.GetLanguage()))
{
return;
}
string className = this.ClassName;
CurrLanguage = CodeResourceControl.GetLanguage();
string name= CodeResourceControl.GetString(CodeResourceControl.GetTextIdStr(className), this.Text);
if (!name.Equals("")) { this.Text=name; }
foreach (Control con in this.Controls)
{
if (con is Label || con is Button || con is RadioButton || con is CheckBox)
{
string newStr = CodeResourceControl.GetString(CodeResourceControl.GetTextIdStr(className, con.Name), con.Text);
if (!newStr.Equals(""))
{
con.Text = newStr;
con.Tag = newStr;
}
}
else if (con.Controls.Count > 0)
{
PreControlLanaguage(con);
}
}
}
private void PreControlLanaguage(Control partentControl)
{
string className = this.ClassName;
string newStr = CodeResourceControl.GetString(CodeResourceControl.GetTextIdStr(className, partentControl.Name), partentControl.Text);
if (!newStr.Equals(""))
{
partentControl.Text = newStr;
}
foreach (Control con in partentControl.Controls)
{
if (con is Label || con is Button || con is RadioButton || con is CheckBox)
{
newStr = CodeResourceControl.GetString(CodeResourceControl.GetTextIdStr(className, con.Name), con.Text);
if (!newStr.Equals(""))
{ con.Text = newStr; }
}
else if (con.Controls.Count > 0)
{
PreControlLanaguage(con);
}
}
}
private void FrmBase_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible.Equals(true))
{
LanguageProcess();
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -17,7 +17,7 @@ using System.IO;
namespace CodeLibrary
{
public partial class FrmCodeDecode : Form
public partial class FrmCodeDecode : FrmBase
{
private Stopwatch stopwatch = new Stopwatch();
......@@ -43,7 +43,7 @@ namespace CodeLibrary
{
cmbCodeType.Items.Add("QR Code");
cmbCodeType.SelectedIndex = 0;
}
}
}
private void LoadCamera()
{
......@@ -143,7 +143,7 @@ namespace CodeLibrary
Bitmap map = new Bitmap(pictureBox1.Image);
List<CodeInfo> result = HDCodeHelper.DecodeBarCode(map);
ShowCode(result);
txtResult.Text += "\r\n扫码结束耗时:" + stopwatch.Elapsed.ToString();
txtResult.Text += "\r\n elapsed time:" + stopwatch.Elapsed.ToString();
}
public void ShowImage(HObject ho_Image)
{
......@@ -176,7 +176,7 @@ namespace CodeLibrary
Bitmap map = new Bitmap(pictureBox1.Image);
HObject ho_image = HDCodeHelper.Bitmap2HObjectBpp24(map);
txtResult.Text += "\r\n转换图片耗时:" + stopwatch.Elapsed.ToString();
txtResult.Text += "\r\n elapsed time:" + stopwatch.Elapsed.ToString();
hWindowControl1.HalconWindow.SetPart(0, 0, map.Height, map.Width);
HOperatorSet.DispObj(ho_image, hWindowControl1.HalconWindow);
ShowImage(ho_image);
......@@ -197,7 +197,7 @@ namespace CodeLibrary
}
ShowCode(codeList);
txtResult.Text += "\r\n扫码结束耗时:" + stopwatch.Elapsed.ToString();
txtResult.Text += "\r\n elapsed time:" + stopwatch.Elapsed.ToString();
}
private void btnClearLog_Click(object sender, EventArgs e)
......
......@@ -13,7 +13,7 @@ using CodeLibrary;
namespace CodeLibrary
{
public partial class FrmCodeLearn : Form
public partial class FrmCodeLearn : FrmBase
{
private List<string> baslerNameList = new List<string>();
......
FrmCodeDecode_Text,二维码识别,Qr code recognition
FrmCodeDecode_label4_Text,参数路径,Parameters of the path
FrmCodeDecode_chbUseParam_Text,使用参数,operation parameter
FrmCodeDecode_btnAn_Text,变暗,darken
FrmCodeDecode_btnLight_Text,提亮,brighten
FrmCodeDecode_label3_Text,条码类型:,Bar code type:
FrmCodeDecode_label2_Text,相机列表:,Camera list:
FrmCodeDecode_btnExit_Text,退出,Exit
FrmCodeDecode_btnCameraImage_Text,相机获取图片,camera image
FrmCodeDecode_lblCount_Text,条码数量:,Barcode number:
FrmCodeDecode_btnClearLog_Text,清理日志,Clear log
FrmCodeDecode_btnDCode_Text,二维码识别,Qr code recognition
FrmCodeDecode_btnLearn_Text,学习,learn
FrmCodeDecode_btnbarCode_Text,一维码识别,One dimensional code recognition
FrmCodeDecode_btnGray_Text,图像转灰,Turning grey
FrmCodeDecode_btnErZhi_Text,二值化,binaryzation 
FrmCodeDecode_btnSelImage_Text,打开本地图片,Open local image
FrmCodeDecode_label1_Text,图片路径,Image path
FrmCodeLearn_Text,条码参数学习,Bar code parameter learning
FrmCodeLearn_chbHalcon_Text,Halcon获取图片,Halcon Get photo
FrmCodeLearn_label4_Text,图片路径,Image path
FrmCodeLearn_btnDelOld_Text,删除旧参数,Delete old parameter
FrmCodeLearn_chbUseCamera_Text,相机获取实时图片,camera image
FrmCodeLearn_btnSelImage_Text,打开本地图片,Open local image
FrmCodeLearn_chbTest_Text,学习结束自动识别测试,Automatic identification test
FrmCodeLearn_btnClearLog_Text,清理日志,Clear log
FrmCodeLearn_lblCount_Text,条码数量:,Barcode number:
FrmCodeLearn_label3_Text,参数路径,Parameters of the path
FrmCodeLearn_label2_Text,类型:,Type:
FrmCodeLearn_label1_Text,相机:,camera:
FrmCodeLearn_btnExit_Text,退出,Exit
FrmCodeLearn_btnStop_Text,结束学习,End of learning
FrmCodeLearn_btnOpen_Text,开始学习,start to learn
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!