public string HexStr2UserDefinedStr(string msg, SharedAppObjs.StringType strType)
{
string str = string.Empty;
try
{
if (msg == null)
return "";
msg = msg.Trim();
string[] strArray = msg.Split(m_sp_colon);
uint num = 0U;
if (strType == SharedAppObjs.StringType.HEX)
str = msg;
else if (strType == SharedAppObjs.StringType.DEC)
{
if (strArray.Length <= 4)
{
for (int index = 0; index < strArray.Length; ++index)
try
{
num += (uint)Convert.ToByte(strArray[index], 16) << (8 * index);
}
catch (Exception ex)
{
m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Cannot Convert The Value Into Decimal.\n\n{0}\n", ex.Message));
}
str = str + string.Format("{0:D} ", num);
}
else
m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, "Cannot Convert The Value Into Decimal.\n");
}
else if (strType == SharedAppObjs.StringType.ASCII)
{
for (uint index = 0U; (long)index < (long)strArray.Length; ++index)
try
{
char ch = Convert.ToChar(Convert.ToByte(strArray[index], 16));
str = str + string.Format("{0:S} ", ch.ToString());
}
catch (Exception ex)
{
m_msgBox.UserMsgBox(SharedObjects.MainWin, MsgBox.MsgTypes.Error, string.Format("Can Not Convert The Value Into ASCII.\n\n{0}\n", ex.Message));
}
}
else
str = msg;
return str.Trim();
}
catch
{
return str;
}
}