Beispiel #1
0
        protected override void InputTemplate(FormRenderer formRenderer)
        {
            formRenderer.WriteMessage(_message);

            if (_defaultValue != null)
            {
                formRenderer.Write($"({(_defaultValue.Value ? "yes" : "no")}) ");
            }
            else
            {
                formRenderer.Write("(y/N) ");
            }

            if (_warning != null)
            {
                //  TODO ver el tema de que cuando borra el template (o sea todo lo que escribio) usa la pos del cursor actual
                //  entonces si agregue lineas, aparecen en el total pero el cursor es engañoso deberia guardar la pos
                //  de origen del template para saber exactamente desde donde borrar!!
                //
                //formRenderer.SaveCursor();
                formRenderer.WriteLine();
                formRenderer.Write(_warning, ConsoleColor.Red);
                //formRenderer.RestoreCursor();
            }
        }
Beispiel #2
0
        protected override void FinishTemplate(FormRenderer formRenderer, T result)
        {
            formRenderer.WriteFinishMessage(_message);

            if (result != null)
            {
                formRenderer.Write(result.ToString(), Prompt.ColorSchema.Answer);
            }
        }
Beispiel #3
0
        protected override void InputTemplate(FormRenderer formRenderer)
        {
            formRenderer.WriteMessage(_message);

            if (_defaultValue != null)
            {
                formRenderer.Write($"({_defaultValue}) ");
            }
        }
Beispiel #4
0
        protected override void InputTemplate(FormRenderer formRenderer)
        {
            formRenderer.WriteMessage(_message);
            formRenderer.Write(_selector.FilterTerm);

            if (string.IsNullOrEmpty(_selector.FilterTerm))
            {
                formRenderer.Write(" Hit space to select", Prompt.ColorSchema.Answer);
            }

            var subset = _selector.ToSubset();

            foreach (T item in subset)
            {
                var value = _valueSelector(item);

                formRenderer.WriteLine();

                if (_selector.IsSelected && EqualityComparer <T> .Default.Equals(item, _selector.SelectedItem))
                {
                    if (_selectedItems.Contains(item))
                    {
                        formRenderer.Write($"{Symbol.Selector} {Symbol.Selected} {value}", Prompt.ColorSchema.Select);
                    }
                    else
                    {
                        formRenderer.Write($"{Symbol.Selector} {Symbol.NotSelect} {value}", Prompt.ColorSchema.Select);
                    }
                }
                else
                {
                    if (_selectedItems.Contains(item))
                    {
                        formRenderer.Write($"  {Symbol.Selected} {value}", Prompt.ColorSchema.Select);
                    }
                    else
                    {
                        formRenderer.Write($"  {Symbol.NotSelect} {value}");
                    }
                }
            }
        }
Beispiel #5
0
        protected override void InputTemplate(FormRenderer formRenderer)
        {
            formRenderer.WriteMessage(_message);
            formRenderer.Write(_selector.FilterTerm);

            var subset = _selector.ToSubset();

            foreach (T item in subset)
            {
                var value = _valueSelector(item);

                formRenderer.WriteLine();

                if (_selector.IsSelected && EqualityComparer <T> .Default.Equals(item, _selector.SelectedItem))
                {
                    formRenderer.Write($"{Symbol.Selector} {value}", Prompt.ColorSchema.Select);
                }
                else
                {
                    formRenderer.Write($"  {value}");
                }
            }
        }
Beispiel #6
0
 protected override void FinishTemplate(FormRenderer formRenderer, IEnumerable <T> result)
 {
     formRenderer.WriteFinishMessage(_message);
     formRenderer.Write(result.Select(_valueSelector).Join(", "), Prompt.ColorSchema.Answer);
 }
Beispiel #7
0
 protected override void FinishTemplate(FormRenderer formRenderer, string result)
 {
     formRenderer.WriteFinishMessage(_message);
     formRenderer.Write(new string('*', _inputBuffer.Length), Prompt.ColorSchema.Answer);
 }
Beispiel #8
0
 protected override void InputTemplate(FormRenderer formRenderer)
 {
     formRenderer.WriteMessage(_message);
     formRenderer.Write(new string('*', _inputBuffer.Length));
 }
Beispiel #9
0
 protected override void FinishTemplate(FormRenderer formRenderer, bool result)
 {
     formRenderer.WriteFinishMessage(_message);
     formRenderer.Write(result ? "Yes" : "No", Prompt.ColorSchema.Answer);
 }
Beispiel #10
0
 protected FormBase(bool cursorVisible = true)
 {
     Renderer = new FormRenderer(cursorVisible);
 }
Beispiel #11
0
 protected virtual void FinishTemplate(FormRenderer formRenderer, T result)
 {
 }
Beispiel #12
0
 protected virtual void InputTemplate(FormRenderer formRenderer)
 {
 }
Beispiel #13
0
 protected override void FinishTemplate(FormRenderer formRenderer, T result)
 {
     formRenderer.WriteFinishMessage(_message);
     formRenderer.Write(_valueSelector(result), Prompt.ColorSchema.Answer);
 }