Beispiel #1
0
        public override bool SelectType(string prompt, Type[] available, out Type chosen)
        {
            var dlg = new ConsoleGuiBigListBox <Type>(prompt, "Ok", true, available.ToList(), null, true);

            if (dlg.ShowDialog())
            {
                chosen = dlg.Selected;
                return(true);
            }

            chosen = null;
            return(false);
        }
Beispiel #2
0
        public override bool SelectEnum(string prompt, Type enumType, out Enum chosen)
        {
            var dlg = new ConsoleGuiBigListBox <Enum>(prompt, "Ok", false, Enum.GetValues(enumType).Cast <Enum>().ToList(), null, false);

            if (dlg.ShowDialog())
            {
                chosen = dlg.Selected;
                return(true);
            }

            chosen = null;
            return(false);
        }
Beispiel #3
0
        public override bool YesNo(string text, string caption, out bool chosen)
        {
            var dlg = new ConsoleGuiBigListBox <bool>(text, "Ok", false, new List <bool>(new [] { true, false }), (b) => b ? "Yes" : "No", false);

            if (dlg.ShowDialog())
            {
                chosen = dlg.Selected;
                return(true);
            }

            chosen = false;
            return(false);
        }
        public override bool SelectType(DialogArgs args, Type[] available, out Type chosen)
        {
            var dlg = new ConsoleGuiBigListBox <Type>(args.WindowTitle, "Ok", true, available.ToList(), null, true);

            if (dlg.ShowDialog())
            {
                chosen = dlg.Selected;
                return(true);
            }

            chosen = null;
            return(false);
        }
        /// <inheritdoc/>
        public override bool SelectObject <T>(DialogArgs args, T[] available, out T selected)
        {
            if (args.AllowAutoSelect && available.Length == 1)
            {
                selected = available[0];
                return(true);
            }

            var dlg = new ConsoleGuiBigListBox <T>(args.WindowTitle, "Ok", true, available, t => t.ToString(), true);

            if (dlg.ShowDialog())
            {
                selected = dlg.Selected;
                return(true);
            }

            selected = default(T);
            return(false);
        }
Beispiel #6
0
        private void Run()
        {
            var commandInvoker = new CommandInvoker(_activator);

            commandInvoker.CommandImpossible += (o, e) => { _activator.Show("Command Impossible because:" + e.Command.ReasonCommandImpossible); };

            var commands = commandInvoker.GetSupportedCommands();

            var dlg = new ConsoleGuiBigListBox <Type>("Choose Command", "Run", true, commands.ToList(), (t) => BasicCommandExecution.GetCommandName(t.Name), false);

            if (dlg.ShowDialog())
            {
                try
                {
                    commandInvoker.ExecuteCommand(dlg.Selected, null);
                }
                catch (Exception exception)
                {
                    _activator.ShowException("Run Failed", exception);
                }
            }
        }