public void AddPacketsListView(string origin, string name, string id) { if (PacketsListView.InvokeRequired) { Invoke(new InsertIntoListDelegate(AddPacketsListView), origin, name, id); } else { var time = DateTime.Now.ToLongTimeString(); var rows = new[] { time, origin, id, name }; var listViewItem = new ListViewItem(rows); PacketsListView.Items.Add(listViewItem); switch (origin) { case "Client": PacketsListView.Items[PacketsListView.Items.Count - 1].ForeColor = ColorTranslator.FromHtml("#F16392"); break; case "Server": PacketsListView.Items[PacketsListView.Items.Count - 1].ForeColor = ColorTranslator.FromHtml("#9EC79D"); break; } PacketsListView.EnsureVisible(PacketsListView.Items.Count - 1); } }
private void Logger_OnLog(string log, LogMessageType logType) { Console.WriteLine(log); void LogCallback() { LogTextBox.SelectionStart = LogTextBox.Text.Length; LogTextBox.SelectionLength = 0; switch (logType) { case LogMessageType.Global: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#E9E9E9"); break; case LogMessageType.Team: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#FF006C"); break; case LogMessageType.Guild: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#975FFF"); break; case LogMessageType.Alliance: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#FFAD42"); break; case LogMessageType.Party: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#00E4FF"); break; case LogMessageType.Sales: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#B3783E"); break; case LogMessageType.Seek: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#E4A0D5"); break; case LogMessageType.Noob: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#D3AA07"); break; case LogMessageType.Admin: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#FF00FF"); break; case LogMessageType.Private: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#7EC3FF"); break; case LogMessageType.Info: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#46A324"); break; case LogMessageType.FightLog: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#9DFF00"); break; case LogMessageType.Public: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#EF3A3E"); break; case LogMessageType.Arena: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#F16392"); break; case LogMessageType.Community: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#9EC79D"); break; case LogMessageType.Sender: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#1B96FF"); break; case LogMessageType.Default: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#E8890D"); break; case LogMessageType.Divers: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#3498db"); break; default: LogTextBox.SelectionColor = ColorTranslator.FromHtml("#E8890D"); break; } var valueOrig = string.Empty; if (log.Contains("Received:") || log.Contains("Send")) { switch (log.Split(':')[0]) { case "Received": valueOrig = "Serveur"; break; case "Send": valueOrig = "Client"; break; } string[] row1 = { DateTime.Now.ToLongTimeString(), valueOrig, log.Split('(')[1].Split(')')[0], log.Split('-')[1].Replace(" ", "") }; var listViewItem = new ListViewItem(row1); PacketsListView.Items.Add(listViewItem); if (log.Contains("Send")) { PacketsListView.Items[PacketsListView.Items.Count - 1].ForeColor = ColorTranslator.FromHtml("#F16392"); } if (log.Contains("Received")) { PacketsListView.Items[PacketsListView.Items.Count - 1].ForeColor = ColorTranslator.FromHtml("#9EC79D"); } PacketsListView.EnsureVisible(PacketsListView.Items.Count - 1); } else if (log.Contains("NO HANDLER")) { NoHandlersListBox.Items.Add(log.Split(':')[1].Replace(" ", "")); } else { var text = $"[{DateTime.Now.ToLongTimeString()}] {log}"; LogTextBox.SelectedText = text + "\r\n"; LogTextBox.SelectionColor = LogTextBox.ForeColor; LogTextBox.ScrollToCaret(); } } LogTextBox.Invoke((Action)LogCallback); }