Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                if (args.Length == 1)
                {
                    switch (args[0])
                    {
                    case "listen":
                        Console.WriteLine("Pres any key to stop!");
                        using (MiniListener ml = new MiniListener(OnHaveFoundMini)) {
                            Console.ReadKey();
                        }
                        break;

                    default:
                        PrintHelp();
                        break;
                    }
                }
                else
                {
                    PrintHelp();
                }
            }
            else
            {
                Mini mini = new Mini(args[0]);
                switch (args[1])
                {
                case "slides":
                    string filename = args[2];
                    Pres   mp       = new Pres(filename);
                    mini.SendPresAsync(mp);
                    break;

                case "ncontrast":
                    int night_contrast = -1;
                    if (Int32.TryParse(args[2], out night_contrast))
                    {
                        if (night_contrast > 0)
                        {
                            mini.SendNightContrastAsync(night_contrast);
                        }
                    }
                    break;

                case "contrast":
                    int contrast = -1;
                    if (Int32.TryParse(args[2], out contrast))
                    {
                        if (contrast > 0)
                        {
                            mini.SendContrastAsync(contrast);
                        }
                    }
                    break;

                case "time":
                    mini.SendTimeAsync();
                    break;

                case "page":
                    int page = -1;
                    if (Int32.TryParse(args[2], out page))
                    {
                        if (page > 0)
                        {
                            mini.SendPageNrAsync(page);
                        }
                    }
                    break;

                case "standby":
                    string[] a = args[2].Split(",");
                    int      dh, dm, eh, em;
                    if (Int32.TryParse(a[0], out dh))
                    {
                        if (Int32.TryParse(a[1], out dm))
                        {
                            if (Int32.TryParse(a[2], out eh))
                            {
                                if (Int32.TryParse(a[3], out em))
                                {
                                    mini.SendStandbyTimeAsync(dh, dm, eh, em);
                                }
                            }
                        }
                    }
                    break;

                case "string":
                    mini.SendCustomStringAsync(args[2]);
                    break;

                case "message":
                    MessageRgb m = new MessageRgb(args[2], 2, 3, true);
                    mini.SendMessageAsync(m);
                    break;

                case "wificonf":
                    mini.SendWifiConfAsync(args[2]);
                    break;

                default:
                    Console.WriteLine("No such command!");
                    PrintHelp();
                    break;
                }
                mini.AwaitAllTasksFinished();
            }
        }