Пример #1
0
        /// <summary>
        /// Initialize the popup
        /// </summary>
        public InstallFilterAddDialog() : base()
        {
            int l = GetLeft(),
                r = GetRight();
            int t = GetTop(),
                b = t + 4;

            SetDimensions(l, t, r, b);

            manualEntry = new ConsoleField(
                l + 2, b - 2, r - 2
                )
            {
                GhostText = () => "<Enter a filter>"
            };
            AddObject(manualEntry);
            manualEntry.AddTip("Enter", "Accept value");
            manualEntry.AddBinding(Keys.Enter, (object sender, ConsoleTheme theme) => {
                choice = manualEntry.Value;
                return(false);
            });

            AddTip("Esc", "Cancel");
            AddBinding(Keys.Escape, (object sender, ConsoleTheme theme) => {
                choice = null;
                return(false);
            });

            CenterHeader = () => "Add Filter";
        }
Пример #2
0
        /// <summary>
        /// Initialize the popup
        /// </summary>
        public CompatibleVersionDialog(IGame game) : base()
        {
            int l = GetLeft(),
                r = GetRight();
            int t = GetTop(),
                b = GetBottom();

            loadOptions(game);
            choices = new ConsoleListBox <GameVersion>(
                l + 2, t + 2, r - 2, b - 4,
                options,
                new List <ConsoleListBoxColumn <GameVersion> >()
            {
                new ConsoleListBoxColumn <GameVersion>()
                {
                    Header   = "Predefined Version",
                    Width    = r - l - 5,
                    Renderer = v => v.ToString(),
                    Comparer = (v1, v2) => v1.CompareTo(v2)
                }
            },
                0, 0, ListSortDirection.Descending
                );
            AddObject(choices);
            choices.AddTip("Enter", "Select version");
            choices.AddBinding(Keys.Enter, (object sender, ConsoleTheme theme) => {
                choice = choices.Selection;
                return(false);
            });

            manualEntry = new ConsoleField(
                l + 2, b - 2, r - 2
                )
            {
                GhostText = () => "<Enter a version>"
            };
            AddObject(manualEntry);
            manualEntry.AddTip("Enter", "Accept value", () => GameVersion.TryParse(manualEntry.Value, out choice));
            manualEntry.AddBinding(Keys.Enter, (object sender, ConsoleTheme theme) => {
                if (GameVersion.TryParse(manualEntry.Value, out choice))
                {
                    // Good value, done running
                    return(false);
                }
                else
                {
                    // Not valid, so they can't even see the key binding
                    return(true);
                }
            });

            AddTip("Esc", "Cancel");
            AddBinding(Keys.Escape, (object sender, ConsoleTheme theme) => {
                choice = null;
                return(false);
            });

            CenterHeader = () => "Select Compatible Version";
        }