Skip to content

Commit 6d256bb

Browse files
authored
Add files via upload
1 parent 94adc1d commit 6d256bb

File tree

6 files changed

+462
-0
lines changed

6 files changed

+462
-0
lines changed

src/tools/hash/hash.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30611.23
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hash", "Hash\Hash.csproj", "{7B4F25A2-6A5F-4EC5-A96C-A51244F32C87}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7B4F25A2-6A5F-4EC5-A96C-A51244F32C87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7B4F25A2-6A5F-4EC5-A96C-A51244F32C87}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7B4F25A2-6A5F-4EC5-A96C-A51244F32C87}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7B4F25A2-6A5F-4EC5-A96C-A51244F32C87}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {8D7015E2-893E-450A-83FD-BC0EE72D740A}
24+
EndGlobalSection
25+
EndGlobal

src/tools/hash/hash/Program.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Windows.Forms;
3+
4+
namespace Nilesoft
5+
{
6+
static class Program
7+
{
8+
/// <summary>
9+
/// The main entry point for the application.
10+
/// </summary>
11+
[STAThread]
12+
static void Main(string[] args)
13+
{
14+
Application.SetHighDpiMode(HighDpiMode.SystemAware);
15+
Application.EnableVisualStyles();
16+
Application.SetCompatibleTextRenderingDefault(false);
17+
18+
if(args.Length == 0)
19+
Application.Run(new frmGroups());
20+
else
21+
{
22+
if(args[0] == "-compact")
23+
Application.Run(new frmMain());
24+
else //if(args[0] == "-full")
25+
Application.Run(new frmGroups());
26+
}
27+
}
28+
}
29+
}

src/tools/hash/hash/forms.cs

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Drawing;
4+
using System.Windows.Forms;
5+
6+
namespace Nilesoft
7+
{
8+
public class frmGroups : Form
9+
{
10+
private IContainer components = null;
11+
private Button btn_hash;
12+
private TextBox txt_input;
13+
private TextBox txt_result;
14+
private TextBox txt_format;
15+
private CheckBox chkUperCase;
16+
private CheckBox chkIdent;
17+
18+
public frmGroups()
19+
{
20+
InitializeComponent();
21+
}
22+
23+
private void result(string[] a)
24+
{
25+
try
26+
{
27+
string result = "";
28+
foreach (string text in a)
29+
{
30+
if (!string.IsNullOrWhiteSpace(text))
31+
{
32+
string fmt = txt_format.Text.Trim();
33+
if (fmt.Length > 0)
34+
fmt = !chkUperCase.Checked ? (fmt + text) : (fmt.ToUpper() + text.ToUpper());
35+
else
36+
fmt = fmt = ((!chkUperCase.Checked) ? text : text.ToUpper());
37+
38+
fmt = fmt.Replace(' ', '_').Replace('-', '_');
39+
40+
result += $"constexpr auto {fmt} = {Hash.ToString(text.Trim())};\r\n";
41+
}
42+
}
43+
44+
txt_result.Text = result;
45+
}
46+
catch
47+
{
48+
txt_input.Focus();
49+
}
50+
}
51+
52+
private void btn_hash_Click(object sender, EventArgs e)
53+
{
54+
txt_result.Clear();
55+
result(txt_input.Lines);
56+
}
57+
58+
private void txt_input_TextChanged(object sender, EventArgs e)
59+
{
60+
if (!string.IsNullOrEmpty(txt_result.Text))
61+
{
62+
txt_result.Clear();
63+
}
64+
if (!string.IsNullOrEmpty(txt_input.Text))
65+
{
66+
try
67+
{
68+
result(txt_input.Lines);
69+
}
70+
catch
71+
{
72+
txt_input.Focus();
73+
}
74+
}
75+
}
76+
private void txt_format_TextChanged(object sender, EventArgs e)
77+
{
78+
if (!string.IsNullOrEmpty(txt_result.Text))
79+
{
80+
txt_result.Clear();
81+
}
82+
83+
if (!string.IsNullOrEmpty(txt_format.Text))
84+
{
85+
try
86+
{
87+
result(txt_input.Lines);
88+
}
89+
catch
90+
{
91+
txt_format.Focus();
92+
}
93+
}
94+
}
95+
96+
private void chkIdent_CheckStateChanged(object sender, EventArgs e)
97+
{
98+
if(chkIdent.Checked)
99+
{
100+
if(!txt_format.Text.StartsWith("IDENT_", StringComparison.OrdinalIgnoreCase))
101+
{
102+
txt_format.Text = "IDENT_" + txt_format.Text;
103+
}
104+
}
105+
else
106+
{
107+
if(txt_format.Text.StartsWith("IDENT_", StringComparison.OrdinalIgnoreCase))
108+
{
109+
txt_format.Text = txt_format.Text.Remove(0, 6);
110+
}
111+
}
112+
}
113+
114+
protected override void Dispose(bool disposing)
115+
{
116+
if (disposing && components != null)
117+
{
118+
components.Dispose();
119+
}
120+
base.Dispose(disposing);
121+
}
122+
123+
private void InitializeComponent()
124+
{
125+
base.SuspendLayout();
126+
btn_hash = new Button()
127+
{
128+
Anchor = (AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
129+
Location = new Point(12, 349),
130+
Name = "btn_hash",
131+
Size = new Size(715, 36),
132+
TabIndex = 1,
133+
Text = "Hash",
134+
UseVisualStyleBackColor = true
135+
};
136+
137+
btn_hash.Click += btn_hash_Click;
138+
139+
txt_input = new TextBox()
140+
{
141+
Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
142+
Location = new Point(12, 48),
143+
Multiline = true,
144+
Name = "txt_input",
145+
ScrollBars = ScrollBars.Both,
146+
Size = new Size(321, 295),
147+
TabIndex = 2
148+
};
149+
150+
txt_input.TextChanged += txt_input_TextChanged;
151+
152+
txt_result = new TextBox()
153+
{
154+
Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right),
155+
Location = new Point(339, 48),
156+
Multiline = true,
157+
Name = "txt_result",
158+
ReadOnly = true,
159+
ScrollBars = ScrollBars.Both,
160+
Size = new Size(388, 295),
161+
TabIndex = 3
162+
};
163+
164+
txt_format = new TextBox()
165+
{
166+
Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right),
167+
Location = new Point(12, 12),
168+
Name = "txt_format",
169+
Size = new Size(500, 20),
170+
TabIndex = 4,
171+
Text= "IDENT_"
172+
};
173+
174+
txt_format.TextChanged += txt_format_TextChanged;
175+
176+
chkUperCase = new CheckBox()
177+
{
178+
AutoSize = true,
179+
Checked = true,
180+
CheckState = CheckState.Checked,
181+
Location = new Point(650, 14),
182+
Name = "checkBox1",
183+
Size = new Size(82, 17),
184+
TabIndex = 5,
185+
Text = "Upper Case",
186+
UseVisualStyleBackColor = true,
187+
Anchor = (AnchorStyles.Top | AnchorStyles.Right),
188+
};
189+
190+
chkIdent = new CheckBox()
191+
{
192+
AutoSize = true,
193+
Checked = true,
194+
CheckState = CheckState.Checked,
195+
Location = new Point(570, 14),
196+
Name = "checkBox2",
197+
Size = new Size(82, 17),
198+
TabIndex = 5,
199+
Text = "ident",
200+
UseVisualStyleBackColor = true,
201+
Anchor = (AnchorStyles.Top | AnchorStyles.Right),
202+
};
203+
204+
chkIdent.CheckStateChanged += chkIdent_CheckStateChanged;
205+
206+
base.Controls.Add(chkIdent);
207+
base.Controls.Add(chkUperCase);
208+
base.Controls.Add(txt_format);
209+
base.Controls.Add(txt_result);
210+
base.Controls.Add(txt_input);
211+
base.Controls.Add(btn_hash);
212+
213+
base.AutoScaleDimensions = new SizeF(6f, 13f);
214+
base.AutoScaleMode = AutoScaleMode.Font;
215+
base.ClientSize = new Size(739, 397);
216+
217+
base.Name = "frmGeroups";
218+
Text = "Hash";
219+
base.ResumeLayout(false);
220+
base.PerformLayout();
221+
}
222+
}
223+
224+
public class frmMain : Form
225+
{
226+
private IContainer components = null;
227+
private Button button1;
228+
private TextBox textBox1;
229+
private TextBox textBox2;
230+
231+
public frmMain()
232+
{
233+
InitializeComponent();
234+
}
235+
236+
private void button1_Click(object sender, EventArgs e)
237+
{
238+
try
239+
{
240+
textBox2.Clear();
241+
if (!string.IsNullOrEmpty(textBox1.Text))
242+
{
243+
textBox2.Text = Hash.ToString(textBox1.Text);
244+
}
245+
}
246+
catch
247+
{
248+
textBox1.Focus();
249+
}
250+
}
251+
252+
private void textBox1_TextChanged(object sender, EventArgs e)
253+
{
254+
if (!string.IsNullOrEmpty(textBox2.Text))
255+
{
256+
textBox2.Clear();
257+
}
258+
if (!string.IsNullOrEmpty(textBox1.Text))
259+
{
260+
try
261+
{
262+
textBox2.Text = Hash.ToString(textBox1.Text);
263+
}
264+
catch
265+
{
266+
textBox1.Focus();
267+
}
268+
}
269+
}
270+
271+
protected override void Dispose(bool disposing)
272+
{
273+
if (disposing && components != null)
274+
{
275+
components.Dispose();
276+
}
277+
base.Dispose(disposing);
278+
}
279+
280+
private void InitializeComponent()
281+
{
282+
base.SuspendLayout();
283+
284+
button1 = new Button()
285+
{
286+
Location = new Point(197, 12),
287+
Name = "button1",
288+
Size = new Size(75, 46),
289+
TabIndex = 0,
290+
Text = "Hash",
291+
UseVisualStyleBackColor = true
292+
};
293+
294+
button1.Click += button1_Click;
295+
296+
textBox1 = new TextBox()
297+
{
298+
Location = new Point(12, 12),
299+
Name = "textBox1",
300+
Size = new Size(179, 20),
301+
TabIndex = 1
302+
};
303+
304+
textBox1.TextChanged += textBox1_TextChanged;
305+
306+
textBox2 = new TextBox()
307+
{
308+
Location = new Point(12, 38),
309+
Name = "textBox2",
310+
ReadOnly = true,
311+
Size = new Size(179, 20),
312+
TabIndex = 2
313+
};
314+
315+
base.Controls.Add(button1);
316+
base.Controls.Add(textBox1);
317+
base.Controls.Add(textBox2);
318+
319+
base.AutoScaleDimensions = new SizeF(6f, 13f);
320+
base.AutoScaleMode = AutoScaleMode.Font;
321+
base.ClientSize = new Size(284, 67);
322+
base.FormBorderStyle = FormBorderStyle.FixedToolWindow;
323+
base.StartPosition = FormStartPosition.CenterScreen;
324+
base.Name = "frmMain";
325+
Text = "Hash ident";
326+
base.ResumeLayout(false);
327+
base.PerformLayout();
328+
}
329+
}
330+
}

0 commit comments

Comments
 (0)