Skip to content

Commit c2ecf73

Browse files
authored
Merge pull request #18 from thoblerone/master
Fixes Issue #17
2 parents f86be4f + 480412e commit c2ecf73

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CommonControls/DataTab.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CommonControls/DataTab.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ public ushort DataLength
5656
ushort rVal = 64;
5757
try
5858
{
59-
if (txtSize.Text.IndexOf("0x", 0, txtSize.Text.Length) == 0)
59+
if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
6060
{
6161
string str = txtSize.Text.Replace("0x", "");
6262
rVal = Convert.ToUInt16(str, 16);
6363
}
64-
rVal = Convert.ToUInt16(txtSize.Text);
64+
else
65+
rVal = Convert.ToUInt16(txtSize.Text);
6566
}
6667
catch (Exception)
6768
{
@@ -71,7 +72,13 @@ public ushort DataLength
7172
}
7273
set
7374
{
74-
txtSize.Text = Convert.ToString(value);
75+
if (txtSize.Text.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
76+
{
77+
// obey hex input
78+
txtSize.Text = "0x"+Convert.ToString(value, 16);
79+
}
80+
else
81+
txtSize.Text = Convert.ToString(value);
7582
}
7683
}
7784

0 commit comments

Comments
 (0)