示例#1
0
        public int ReadFromOptions(string header, string prompt, string error, OptionsList options,
                                   bool optionToContinue = true)
        {
            PrintIfExists();
            WriteOptions(header, options, optionToContinue);
            int selection;
            var looped = false;

            do
            {
                if (looped)
                {
                    WriteAErrorLine(error);
                }
                selection = ReadAValidatedInt(prompt, error);
                looped    = true;
            } while (!options.IsValid(selection) && (optionToContinue && selection != options.ContinueOption));
            return(selection);
        }
示例#2
0
 // TODO: This function should be expanded, there should be an options class that can be created and validated against
 public void WriteOptions(string header, OptionsList options, bool optionToContinue = true)
 {
     HorizontalString();
     WriteAHeaderString(header, BoldColor);
     HorizontalString();
     for (var x = 0; x <= options.Count - 1; x++)
     {
         Write(RuleChar + " ", RuleOnColor);
         WriteBold((x + 1) + " ");
         Write(RuleChar + " ", RuleOffColor);
         WriteBold("\t" + options[x] + "\n");
     }
     if (optionToContinue)
     {
         Write(RuleChar + " ", RuleOnColor);
         WriteBold(options.ContinueOption + " ");
         Write(RuleChar + " ", RuleOffColor);
         Write("\t" + "To Continue" + "\n", SuccessColor);
     }
     HorizontalLine();
 }