Beispiel #1
0
        public Schnittstelle()
        {
            this.MyZustand = Schnittstelle.Zustand.KeinKampf;

            this.SuspendLayout();

            Konsole = new Konsole();
            SituationAuswahl = new SituationAuswahl(this);
            KampfBild = new KampfBild(this);
            Grafik = KampfBild.Grafik;
            SheduleText = new Label();
            SheduleText.AutoSize = true;
            ScrollSchedule = new ScrollBox(SheduleText);

            Timer = new Timer();
            Timer.Interval = 1000 / 60;
            Timer.Tick += (sender, e) => KampfBild.Mal();

            Controls.Add(ScrollSchedule);
            Controls.Add(KampfBild);
            Controls.Add(SituationAuswahl);
            Controls.Add(Konsole);

            this.ResumeLayout(false);
            this.ClientSize = new Size(1000, 1000);
            this.StartMenu = new StartMenu(this);
            this.ViewMenu = new ViewMenu(this);
            this.ZugMenu = new FigurZugMenu(this);
            this.MausZielMenu = new MausZielMenu(this);
            this.ShowMenu(StartMenu);
        }
Beispiel #2
0
        static void Init()
        {
            Konsole.Width  = 120;
            Konsole.Height = 30;
            Konsole.DisableResizing();


            // After the Cleaning, the app should have
            // already initialized essential variables.
            // Add with caution after this message.
            Konsole.Clear();

            Konsole.CursorY = 1;
            Konsole.CursorX = 2;
        }
Beispiel #3
0
        static void Start()
        {
            KBox b = new KBox();

            b.Title = " PopUp | MAIN MENU ";
            b.Text  = "                          " +
                      "                       " +
                      "[q][Enter] for [Q]uit." +
                      "                          " +
                      "[t][Enter] for [T]ool.";
            b.PosX   = 2;
            b.PosY   = 1;
            b.Width  = 48;
            b.Height = 6;

            KBox LeftResultBox = new KBox();

            LeftResultBox.Title           = "";
            LeftResultBox.Text            = " Welcome! Follow the menu above.";
            LeftResultBox.DarkColor       = Kolor.DARK_GREEN;
            LeftResultBox.LightColor      = Kolor.DARK_YELLOW;
            LeftResultBox.BackgroundColor = Kolor.YELLOW;
            LeftResultBox.Width           = 48;
            LeftResultBox.Height          = 2;
            //LeftResultBox.PosX = b.PosX + b.Width + 5;
            LeftResultBox.PosY = b.Height + b.PosY + LeftResultBox.Height + 2;


            LeftResultBox.Draw();
            b.Draw();

            string VALID_OPTIONS = "qt";
            string _Input        = "";

            while (!VALID_OPTIONS.Contains(_Input) || _Input == "")
            {
                _Input =
                    Konsole.AskLine(true, b.BotPosX, b.BotPosY,
                                    " >", Kolor.DARK_MAGENTA, Kolor.WHITE,
                                    Kolor.DARK_MAGENTA, Kolor.WHITE);

                Konsole.CursorX = b.PosX + b.Width + 6;
                Konsole.CursorY = 1;

                if (!VALID_OPTIONS.Contains(_Input) || _Input == "")
                {
                    LeftResultBox.Text = " <|º_º|> Invalid option.";
                }
                //Konsole.InLine("<|º_º|> Invalid option.", Kolor.DARK_GRAY);
                LeftResultBox.Draw();
                b.Draw();
            }


            switch (_Input.ToLower())
            {
            case "q":
                Konsole.Clear();
                Konsole.AskLine(false, 1, Konsole.Height - 2,
                                " > Press [ENTER] to exit the application.",
                                Kolor.CYAN, Kolor.DARK_MAGENTA, Kolor.DARK_MAGENTA, Kolor.DARK_MAGENTA);
                Environment.Exit(42);

                break;

            case "t":
                Konsole.Clear();
                Tool();
                break;
            }

            b = null;
        }
Beispiel #4
0
        private static async Task Main(string[] args)
        {
            //while (true)
            //{
            //    Konsole.PressAnyKey();
            //}



            Konsole.CrashOnEscapeKey = false;



            Console.WriteLine();
            var x = "123";

            Kl.Log($"Test ♦g{x}", ConsoleColor.Yellow);
            return;

            //string sss = Konsole.ReadString("Enter something: ", "abcd", 20, true);
            //Konsole.PressAnyKey(sss);
            //return;

            //var userName = Konsole.ReadString("Enter user name:", "").Trim();
            //if (string.IsNullOrWhiteSpace(userName))
            //{
            //    Konsole.PressAnyKey("You did not enter name");
            //    return;
            //}


            //while (true)
            //{
            //    //Konsole.WriteLine($"[{new KonsoleStringEdit {Prompt ="Введи строку:", DefaultValue = "Dефаульт", MaxLength = 15, EscapeBehavior = KonsoleStringEditEscapeBehavior.ReturnEmptystring}.ReadString()}]");
            //    var s = Konsole.ReadString("Enter something:", "something");
            //    Konsole.WriteLine($"[{s}]");
            //}


            var menu = new Menu("Main")
            {
                Items = new List <MenuItem>()
                {
                    new MenuItem()
                    {
                        Title  = "One",
                        Action = async() =>
                        {
                            var keepWaiting = true;

                            var t = new Timer {
                                Interval = 2000
                            };
                            t.Elapsed += (s1, e1) =>
                            {
                                Konsole.WriteLineAndLog("\n\nHello from timer... Press Z to stop waiting for events and return to menu");
                                Konsole.PurgeLog();
                                while (Console.KeyAvailable)
                                {
                                    var k = Console.ReadKey();
                                    if (k.KeyChar.ToString().ToLower() == "Z")
                                    {
                                        keepWaiting = false;
                                    }
                                }
                            };
                            t.Start();

                            Konsole.WriteLine("\nWaiting for events...");

                            while (keepWaiting)
                            {
                                Konsole.WriteLine("waiting.....");
                                Thread.Sleep(100);
                            }

                            //Konsole.PressAnyKey();
                        }
                    },
                    new MenuItem
                    {
                        Title = "Print object", Action = async() =>
                        {
                            var aPerson = new Person {
                                Name = "Wassily Pupeking", Age = 888, Details = new PersonDetails()
                                {
                                    Height = 123, SchoolName = "Asdfg", DetailedDetails = new DetailedDetails()
                                    {
                                        DetailOne = "One", DetailTwo = 2
                                    }
                                }
                            };
                            await Task.Run(() =>
                            {
                                Konsole.PrintObject(aPerson, nameof(aPerson));
                                Konsole.PressAnyKey();
                                Konsole.PurgeLog();
                            });
                        }
                    },
                    new MenuItem()
                    {
                        Title = "Print simple", Action = async() =>
                        {
                            var x = "test";
                            await Task.Run(() =>
                            {
                                Konsole.PrintObject(x, "X");

                                Konsole.PressAnyKey();
                            });
                        }
                    },
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem(),
                    new MenuItem()
                }
            };

            await menu.Loop();
        }
Beispiel #5
0
        /// <summary />
        public static CommandLine Parse(string[] args)
        {
            /*
             * Very crappy argument line parsing :p
             */
            CommandLine cl = new CommandLine();

            foreach (string arg in args)
            {
                if (arg.StartsWith("--assembly=") == true)
                {
                    cl.Assembly = arg.Substring("--assembly=".Length);
                    continue;
                }

                if (arg.StartsWith("--application=") == true)
                {
                    cl.Application = arg.Substring("--application=".Length);
                    continue;
                }

                if (arg.StartsWith("--namespace=") == true)
                {
                    cl.Namespace = arg.Substring("--namespace=".Length);
                    continue;
                }

                if (arg.StartsWith("--output=") == true)
                {
                    cl.Output = arg.Substring("--output=".Length);
                    continue;
                }

                if (arg == "--sync")
                {
                    cl.Sync = true;
                    continue;
                }

                if (arg == "--no-async")
                {
                    cl.Async = false;
                    continue;
                }
            }


            /*
             *
             */
            if (string.IsNullOrEmpty(cl.Assembly) == true)
            {
                Konsole.Fatal("err: Assembly is a required option");
                return(null);
            }

            if (string.IsNullOrEmpty(cl.Application) == true)
            {
                Konsole.Fatal("err: Application is a required option.");
                return(null);
            }

            if (string.IsNullOrEmpty(cl.Namespace) == true)
            {
                Konsole.Fatal("err: Namespace is a required option.");
                return(null);
            }

            if (string.IsNullOrEmpty(cl.Output) == true)
            {
                Konsole.Fatal("err: Output is a required option.");
                return(null);
            }

            return(cl);
        }