Ejemplo n.º 1
0
 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;
     }
 }
Ejemplo n.º 2
0
 public void DisplayMsgTime(SharedAppObjs.MsgType msgType, string msg, string time)
 {
     dspMsgMutex.WaitOne();
     if (InvokeRequired)
     {
         try
         {
             BeginInvoke((Delegate)new DeviceForm.DisplayMsgTimeDelegate(DisplayMsgTime), msgType, msg, time);
         }
         catch { }
     }
     else
         msgLogForm.DisplayLogMsg(msgType, msg, time);
     dspMsgMutex.ReleaseMutex();
 }
Ejemplo n.º 3
0
 public void DisplayLogMsg(SharedAppObjs.MsgType msgType, string msg, string time)
 {
     dspMsgMutex.WaitOne();
     rtbUpdate = true;
     if (InvokeRequired)
     {
         try
         {
             BeginInvoke((Delegate)new MsgLogForm.DisplayLogMsgDelegate(DisplayLogMsg), (object)msgType, (object)msg, (object)time);
         }
         catch
         {
         }
     }
     else
     {
         string str1 = string.Empty;
         bool flag = false;
         string str2;
         switch (msgType)
         {
             case SharedAppObjs.MsgType.Incoming:
                 str2 = "<Rx> - ";
                 if (!tsmiDisplayRxPackets.Checked)
                 {
                     flag = true;
                     break;
                 }
                 else
                     break;
             case SharedAppObjs.MsgType.Outgoing:
                 str2 = "<Tx> - ";
                 if (!tsmiDisplayTxPackets.Checked)
                 {
                     flag = true;
                     break;
                 }
                 else
                     break;
             case SharedAppObjs.MsgType.Info:
                 str2 = "<Info> - ";
                 break;
             case SharedAppObjs.MsgType.Warning:
                 str2 = "<Warning> - ";
                 break;
             case SharedAppObjs.MsgType.Error:
                 str2 = "<Error> - ";
                 break;
             case SharedAppObjs.MsgType.RxDump:
                 str2 = "Dump(Rx):\n";
                 if (!tsmiDisplayRxDumps.Checked)
                 {
                     flag = true;
                     break;
                 }
                 else
                     break;
             case SharedAppObjs.MsgType.TxDump:
                 str2 = "Dump(Tx):\n";
                 if (!tsmiDisplayTxDumps.Checked)
                 {
                     flag = true;
                     break;
                 }
                 else
                     break;
             default:
                 str2 = "<Unknown> - ";
                 break;
         }
         if (!flag)
         {
             rtbMsgBox.SuspendLayout();
             try
             {
                 rtbMsgBox.SelectionStart = rtbMsgBox.TextLength;
                 rtbMsgBox.SelectionLength = 0;
                 if (msgType != SharedAppObjs.MsgType.RxDump && msgType != SharedAppObjs.MsgType.TxDump)
                 {
                     rtbMsgBox.SelectionColor = MessageColor[(int)msgType];
                     ++msgNumber;
                     string str3 = string.Empty;
                     string str4 = time != null ? time : DateTime.Now.ToString("hh:mm:ss.fff");
                     rtbMsgBox.AppendText("[" + msgNumber.ToString() + "] : " + str2 + str4 + "\n" + msg);
                 }
                 else
                 {
                     rtbMsgBox.SelectionColor = Color.Black;
                     rtbMsgBox.AppendText(str2 + msg + "\n");
                 }
                 if ((msgType == SharedAppObjs.MsgType.Incoming || msgType == SharedAppObjs.MsgType.Outgoing) && (msgType != SharedAppObjs.MsgType.Incoming || tsmiDisplayRxDumps.Checked))
                 {
                     if (msgType == SharedAppObjs.MsgType.Outgoing)
                     {
                         if (tsmiDisplayTxDumps.Checked)
                             goto label_26;
                     }
                     else
                         goto label_26;
                 }
                 rtbMsgBox.AppendText("------------------------------------------------------------------------------------------------------------------------\n");
             }
             catch
             {
             }
         label_26:
             rtbMsgBox.ResumeLayout();
         }
     }
     rtbUpdate = false;
     dspMsgMutex.ReleaseMutex();
 }
Ejemplo n.º 4
0
 public void DisplayMsg(SharedAppObjs.MsgType msgType, string msg)
 {
     if (InvokeRequired)
     {
         try
         {
             BeginInvoke((Delegate)new DeviceForm.DisplayMsgDelegate(DisplayMsg), msgType, msg);
         }
         catch { }
     }
     else
         msgLogForm.DisplayLogMsg(msgType, msg, null);
 }