private void UpdateDisplay() { WriteHeader(); if (ChannelData.Count == 0) { WriteEmptyNotice(); } foreach (var entry in ChannelData.OrderBy(x => x.Key)) { var id = entry.Key; var kv = entry.Value; string inout; switch (GetValueOrDefault(kv, "direction")) { case "incoming": inout = "-[in]->"; break; case "outgoing": inout = "<-[out]"; break; default: inout = "<-[?]->"; break; } var ystatus = GetValueOrDefault(kv, "ysm_status"); if (ystatus == "hungup" && GetValueOrDefault(kv, "status") != "answered") { ystatus = GetValueOrDefault(kv, "status"); } switch (ystatus) { case "rejected": VTConsole.SetColorForeground(Color.Yellow); VTConsole.SetColorBackground(Color.Red); break; case "ringing": VTConsole.SetColorForeground(Color.Yellow); VTConsole.SetColorBackground(Color.Black); break; case "answered": VTConsole.SetColorForeground(Color.Green); VTConsole.SetColorBackground(Color.Black); break; case "hungup": VTConsole.SetColorForeground(Color.White); VTConsole.SetColorBackground(Color.Blue); break; default: VTConsole.SetColorForeground(Color.White); VTConsole.SetColorBackground(Color.Black); break; } var status = ystatus; if (kv.ContainsKey("reason")) { status += ": " + kv["reason"]; } if (kv.ContainsKey("cause_sip")) { status += $" SIP {kv["cause_sip"]}/{GetValueOrDefault(kv, "reason_sip")}"; } Console.WriteLine($"{id,-10} {inout} {GetValueOrDefault(kv, "caller"),10} -> {GetValueOrDefault(kv, "called"),-10} | {GetValueOrDefault(kv, "address")} {status}"); VTConsole.EraseInLine(); } foreach (var value in FlashMessages.Values) { var level = value.Item1; var msg = value.Item2; switch (level) { case "info": VTConsole.SetColorForeground(Color.Yellow); VTConsole.SetColorBackground(Color.Black); break; case "notice": VTConsole.SetColorForeground(Color.Black); VTConsole.SetColorBackground(Color.Cyan); break; case "warning": VTConsole.SetColorForeground(Color.Black); VTConsole.SetColorBackground(Color.Red); break; case "error": VTConsole.SetColorForeground(Color.Red); VTConsole.SetColorBackground(Color.Black); break; default: VTConsole.SetColorForeground(Color.Cyan); VTConsole.SetColorBackground(Color.Black); break; } Console.WriteLine($"[{level}] {msg}"); } }