public int[] FindMessage(string message, bool ignoreCase) { // Break message into two parts. int[] index = { -1, -1 }; if (message.Length == 0) { return(index); } // Break a message into two major pieces: Family and Id/Level pair. string family = TcpIpMessageCode.GetFamily(message); string id = TcpIpMessageCode.GetId(message); string level = TcpIpMessageCode.GetLevel(message); string[] split = new string[2] { family, id + level }; if (split.Length > 0) { index[0] = Array.BinarySearch(internalNodes, new TreeNode(split[0]), new MessageComparer(ignoreCase)); if (index[0] >= 0) { TreeNode node = internalNodes[index[0]]; if (node.Nodes.Count > 0 && split.Length > 1) { index[1] = new ArrayList(node.Nodes).BinarySearch(new TreeNode(split[1]), new MessageComparer(ignoreCase)); } } } return(index); }
/// <summary> /// /// </summary> /// <param name="text"></param> public bool Lookup(string text) { bool duplicate = false; if (managerCM == null) { managerCM = new ManageCM(); } comboCode.Text = text.Trim(); object[] result = managerCM.GetMessageByName(release, comboCode.Text); if (result != null) { Message = new TcpIpMessageCode( result[0] is DBNull ? null : (string)result[0], result[2] is DBNull ? null : (string)result[2], result[3] is DBNull ? null : (string)result[3], result[4] is DBNull ? null : (string)result[4], result[5] is DBNull ? null : (string)result[5], result[6] is DBNull ? null : (string)result[6]); //Display(Message); } else { Message = null; } Display(Message); if (Message != null) { for (int i = 0; i < history.list.Items.Count; i++) { if (text.ToLower().Equals(history.list.Items[i].ToString().ToLower())) { duplicate = true; break; } } if (duplicate == false) { history.list.Items.Insert(0, text); if (history.list.Items.Count > 25) { history.list.Items.RemoveAt(25); } } } if (Message == null) { Beep(400, 125); return(false); } else { return(true); } }
void MessageCenter_OnMessageChanged(TcpIpMessageCode code) { }
public void Display(TcpIpMessageCode message) { Font fontHeader = new Font("Verdana", (float)8.25, FontStyle.Bold); Font fontText = new Font("Verdana", (float)8.25, FontStyle.Regular); if (message == null) { CenterEmptyMessage(); rtbMessage.Select(0, 0); // set cursor to beginning of text return; } rtbMessage.Clear(); rtbMessage.SelectionAlignment = HorizontalAlignment.Left; TcpIpMessageCode m = (TcpIpMessageCode)message; if (m.Level[0] == TcpIpMessageCode.INFORMATIONAL) { rtbMessage.SelectionColor = Color.Black; } else if (m.Level[0] == TcpIpMessageCode.WARNING) { rtbMessage.SelectionColor = Color.Blue; } else { rtbMessage.SelectionColor = Color.Red; } // Title rtbMessage.SelectionFont = fontHeader; rtbMessage.AppendText(m.Name + " " + TcpIpMessageCode.LevelFormatter(m.Level[0]) + "\n\n"); // Summary rtbMessage.SelectionFont = fontText; rtbMessage.SelectionColor = Color.Black; rtbMessage.AppendText(m.Summary + "\n\n"); // Details rtbMessage.SelectionFont = fontText; rtbMessage.SelectionColor = Color.Black; rtbMessage.AppendText(m.Detail + "\n\n"); if (m.SystemAction != null) { rtbMessage.SelectionFont = fontHeader; rtbMessage.AppendText("System Action:\n\n"); rtbMessage.SelectionFont = fontText; rtbMessage.SelectionIndent = 15; rtbMessage.AppendText(m.SystemAction + "\n\n"); rtbMessage.SelectionIndent = 0; } if (m.OperatorAction != null) { rtbMessage.SelectionFont = fontHeader; rtbMessage.AppendText("Operator Action:\n\n"); rtbMessage.SelectionFont = fontText; rtbMessage.SelectionIndent = 15; rtbMessage.AppendText(m.OperatorAction + "\n\n"); rtbMessage.SelectionIndent = 0; } if (m.AdministratorAction != null) { rtbMessage.SelectionFont = fontHeader; rtbMessage.AppendText("Administrator Action:\n\n"); rtbMessage.SelectionFont = fontText; rtbMessage.SelectionIndent = 15; rtbMessage.AppendText(m.AdministratorAction + "\n\n"); rtbMessage.SelectionIndent = 0; } rtbMessage.Select(0, 0); // set cursor to beginning of text }