Esempio n. 1
0
        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}");
            }
        }
Esempio n. 2
0
 private void WriteEmptyNotice()
 {
     VTConsole.WriteLine("no channel active", Color.Cyan);
     VTConsole.SetColorForeground(Color.White);
 }
Esempio n. 3
0
        private static void RandomColorsForever()
        {
            VTConsole.CursorSetBlinking(false);
            VTConsole.CursorSetVisibility(true);
            VTConsole.SetColorBackground(Color.Black);
            VTConsole.SetColorForeground(Color.White);

            Console.Clear();
            Console.SetCursorPosition(5, 8);
            VTConsole.Write("Hi there", Color.FromArgb(0, 255, 0));
            Console.SetCursorPosition(0, 0);

            int r = 0;
            int g = 0;
            int b = 0;

            //for (var column = 0; column < Console.BufferWidth; column++)
            while (!Console.KeyAvailable)
            {
                // Set column to random and row to 0
                var randomColumn = new Random().Next(0, Console.BufferWidth);
                Console.SetCursorPosition(randomColumn, 0);

                for (var row = 0; row < Console.WindowHeight - 1; row++)
                {
                    // Always move the cursor down
                    VTConsole.CursorMoveDown();

                    var percentageChance = new Random().Next(100);

                    //if (percentageChance == 50)
                    //{
                    //    VTConsole.CursorPosition(new Random().Next(1, Console.WindowHeight), new Random().Next(1, Console.WindowWidth - 1));
                    //    var datetimeString = DateTime.Now.ToString("hh:mm:ss");
                    //    VTConsole.Write(datetimeString, Color.Black);
                    //    VTConsole.CursorMoveLeft(datetimeString.Length);
                    //}

                    // Randomly print a new block colour
                    if (percentageChance < 40)
                    {
                        var random = new Random();
                        r = random.Next(255);
                        g = random.Next(255);
                        b = random.Next(255);

                        // Values will only ever be slightly over 255
                        if (r > 255)
                        {
                            r -= 255;
                        }
                        if (g > 255)
                        {
                            g -= 255;
                        }
                        if (b > 255)
                        {
                            b -= 255;
                        }

                        // Vibrant colours only
                        //bool vibrantColours = true;
                        //if (vibrantColours)
                        //{
                        //    // Make the lowest value = 0
                        //    if (r < g && r < b)
                        //        r = 0;
                        //    else if (g < r && g < b)
                        //        g = 0;
                        //    else if (b < g && b < r)
                        //        b = 0;
                        //}

                        //Debug.WriteLine($"r:{r} g:{g} b:{b}");

                        // vertical strip dark at the top
                        VTConsole.Write(" ", Color.Black, Color.FromArgb(Convert.ToInt32(r / 1.5), Convert.ToInt32(g / 1.5), Convert.ToInt32(b / 1.5)));
                        VTConsole.CursorMoveDown();
                        VTConsole.CursorMoveLeft();
                        VTConsole.Write(" ", Color.Black, Color.FromArgb(Convert.ToInt32(r / 1.2), Convert.ToInt32(g / 1.2), Convert.ToInt32(b / 1.2)));
                        VTConsole.CursorMoveDown();
                        VTConsole.CursorMoveLeft();
                        VTConsole.Write(" ", Color.Black, Color.FromArgb(r, g, b));


                        VTConsole.CursorMoveLeft();
                    }
                    else
                    {
                        VTConsole.Write(" ", Color.Black, Color.Black);
                        VTConsole.CursorMoveDown();
                        VTConsole.CursorMoveLeft();
                        VTConsole.Write(" ", Color.Black, Color.Black);
                        VTConsole.CursorMoveDown();
                        VTConsole.CursorMoveLeft();
                        VTConsole.Write(" ", Color.Black, Color.Black);


                        VTConsole.CursorMoveLeft();
                    }

                    //Thread.Sleep(5);
                }
            }
        }