Skip to content

Commit 67fe355

Browse files
Zixu_WangZixu_Wang
authored andcommitted
Add Simplified Chinese support.
1 parent db25cd8 commit 67fe355

File tree

8 files changed

+3237
-177
lines changed

8 files changed

+3237
-177
lines changed

SimilarImages/SimilarImages/Form1.Designer.cs

Lines changed: 90 additions & 166 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SimilarImages/SimilarImages/Form1.cs

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Diagnostics;
66
using System.Drawing;
77
using System.Drawing.Drawing2D;
8+
using System.Globalization;
89
using System.IO;
910
using System.Linq;
1011
using System.Windows.Forms;
@@ -19,6 +20,7 @@ public partial class Form1 : Form
1920
private ImageHash.HashEnum hashEnum = ImageHash.HashEnum.Difference;
2021
private InterpolationMode interpolationMode = InterpolationMode.Default;
2122
private List<Tuple<string, string, double>> tuples = null;
23+
private readonly bool isSimplifiedChinese = CultureInfo.CurrentUICulture.Name == "zh-CN";
2224

2325
public Form1()
2426
{
@@ -36,9 +38,11 @@ private void Form1_Load(object sender, EventArgs e)
3638

3739
private void btn_Directory_Click(object sender, EventArgs e)
3840
{
41+
string description = "Choose a folder to find similar images.";
42+
if (isSimplifiedChinese) { description = "选择一个文件夹来寻找相似的图片。"; }
3943
FolderBrowserDialog fbd = new FolderBrowserDialog
4044
{
41-
Description = "Choose a folder to find similar images.",
45+
Description = description,
4246
ShowNewFolderButton = false
4347
};
4448
fbd.ShowDialog();
@@ -83,6 +87,55 @@ private void cmb_Interpolation_SelectedIndexChanged(object sender, EventArgs e)
8387
}
8488
}
8589

90+
private void tb_Precision_Click(object sender, EventArgs e)
91+
{
92+
string tip = "Range: Greater than 8.\n" +
93+
"Usage: When sampling, resize images to \"Precision * Precision\".\n" +
94+
"Notice: Don't set it too large to run out of memory.";
95+
if (isSimplifiedChinese)
96+
{
97+
tip = "范围:大于 8。\n" +
98+
"用途:采样时将图片缩放至 “精度 * 精度”。\n" +
99+
"注意:不要设置得太大以免耗尽内存。";
100+
}
101+
toolTip1.SetToolTip((Control)sender, tip);
102+
}
103+
104+
private void cmb_Interpolation_Click(object sender, EventArgs e)
105+
{
106+
string tip = "The interpolation mode when resizing images";
107+
if (isSimplifiedChinese)
108+
{
109+
tip = "图片缩放时的插值模式";
110+
}
111+
toolTip1.SetToolTip((Control)sender, tip);
112+
}
113+
114+
private void cmb_Algorithm_Click(object sender, EventArgs e)
115+
{
116+
string tip = "The algorithm when calculating image hashes";
117+
if (isSimplifiedChinese)
118+
{
119+
tip = "计算图片哈希时使用的算法";
120+
}
121+
toolTip1.SetToolTip((Control)sender, tip);
122+
}
123+
124+
private void tb_Threshold_Click(object sender, EventArgs e)
125+
{
126+
string tip = "Range: 0-1.\n" +
127+
"Usage: Return results greater than the threshold.\n" +
128+
"Notice: Don't set a low threshold when processing mass images, " +
129+
"as the operation will take too long.";
130+
if (isSimplifiedChinese)
131+
{
132+
tip = "范围:0-1。\n" +
133+
"用途:返回大于阈值的结果。\n" +
134+
"注意:当图片数量较多时,不要使用低阈值,以免耗时太长。";
135+
}
136+
toolTip1.SetToolTip((Control)sender, tip);
137+
}
138+
86139
#endregion Config
87140

88141
#region Process
@@ -93,10 +146,23 @@ private void btn_Process_Click(object sender, EventArgs e)
93146
bool validThreshold = double.TryParse(tb_Threshold.Text, out threshold);
94147
bool validFolderPath = !string.IsNullOrEmpty(tb_Directory.Text);
95148

96-
if (!AssertConfig(validPrecision, "Please input valid precision.")) { return; }
97-
if (!AssertConfig(precision >= 8, "Precision should be greater than 8.")) { return; }
98-
if (!AssertConfig(validThreshold,"Please input valid threshold [0,1).")) { return; }
99-
if (!AssertConfig(validFolderPath, "Please input valid folder path.")) { return; }
149+
string tip1 = "Please input valid precision.";
150+
string tip2 = "Precision should be greater than 8.";
151+
string tip3 = "Please input valid threshold (0,1).";
152+
string tip4 = "Please input valid folder path.";
153+
if (isSimplifiedChinese)
154+
{
155+
tip1 = "请输入合适的精度值。";
156+
tip2 = "精度值需要大于 8。";
157+
tip3 = "请输入合适的阈值 (0,1)。";
158+
tip4 = "请输入合适的文件夹路径。";
159+
}
160+
161+
if (!AssertConfig(validPrecision, tip1)) { return; }
162+
if (!AssertConfig(precision >= 8, tip2)) { return; }
163+
if (!AssertConfig(validThreshold, tip3)) { return; }
164+
if (!AssertConfig(threshold > 0 && threshold < 1, tip3)) { return; }
165+
if (!AssertConfig(validFolderPath, tip4)) { return; }
100166

101167
progressBar1.Visible = true;
102168
lb_Empty.Visible = true;
@@ -108,7 +174,7 @@ private bool AssertConfig(bool successCondition, string failureTip)
108174
{
109175
if (!successCondition)
110176
{
111-
MessageBox.Show(failureTip, "Notice",
177+
MessageBox.Show(failureTip, isSimplifiedChinese ? "提示" : "Notice",
112178
MessageBoxButtons.OK, MessageBoxIcon.Information);
113179
}
114180
return successCondition;

0 commit comments

Comments
 (0)