Beispiel #1
0
        public bool NumberSetting(int index, ConsoleKeyInfo key, int min, int max, int length, ref int val)
        {
            int oldval = val;

            if (Selected == index)
            {
                if (key.Key == ConsoleKey.Enter)
                {
                    if (this.fillBackround)
                    {
                        buffer.BackgroundColor = this.SelectedColor;
                    }
                    buffer.SetCursorPosition(this.X + width + 2, this.Y + Selected);
                    val = buffer.ReadNumberAlignRight(length, min, val.ToString());
                    buffer.ResetColor();
                }

                if (key.Key == ConsoleKey.RightArrow)
                {
                    val++;
                }
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    val--;
                }

                if (val == min - 1)
                {
                    val = max - 1;
                }
                if (val == max)
                {
                    val = min;
                }

                if (val >= max)
                {
                    val = max - 1;
                }
                if (val < min)
                {
                    val = min;
                }
            }

            return(oldval != val);
        }