Example #1
0
        public static void DrawRectangle(this Screenbuffer buffer,
                                         RectangleDrawStyle drawStyle,
                                         int left,
                                         int top,
                                         int width,
                                         int height,
                                         ConsoleColor foreground = Screenbuffer.DEFAULT_FOREGROUND,
                                         ConsoleColor background = Screenbuffer.DEFAULT_BACKGROUND)
        {
            for (int i = 0; i < width; i++)
            {
                buffer.SetChar(left + i, top, _rectangleCharacters[drawStyle][0], foreground, background);
                buffer.SetChar(left + i, top + height - 1, _rectangleCharacters[drawStyle][1], foreground, background);
            }

            for (int i = 0; i < height; i++)
            {
                buffer.SetChar(left, top + i, _rectangleCharacters[drawStyle][2], foreground, background);
                buffer.SetChar(left + width - 1, top + i, _rectangleCharacters[drawStyle][3], foreground, background);
            }

            buffer.SetChar(left, top, _rectangleCharacters[drawStyle][4], foreground, background);
            buffer.SetChar(left + width - 1, top, _rectangleCharacters[drawStyle][5], foreground, background);
            buffer.SetChar(left + width - 1, top + height - 1, _rectangleCharacters[drawStyle][6], foreground, background);
            buffer.SetChar(left, top + height - 1, _rectangleCharacters[drawStyle][7], foreground, background);
        }
Example #2
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            buffer.DrawRectangle(RectangleDrawStyle.Single, Left, Top, Width, Height);

            string progressString = "";

            if (Value > Minimum)
            {
                var percentage = (int)Math.Round(((Width - 2.0) / (Maximum - Minimum)) * Value);
                progressString = string.Concat(Enumerable.Repeat((char)0x2588, percentage));
            }

            if (progressString.Length < Width - 2)
            {
                progressString += string.Concat(Enumerable.Repeat(' ', Width - 2 - progressString.Length));
            }

            buffer.DrawString(Left + 1, Top + 1, progressString, ConsoleColor.DarkBlue);

            var percentageString     = $"{Value}%";
            var percentageStringLeft = Left + 1 + ((Width - 2) / 2) - (percentageString.Length / 2);

            buffer.DrawString(percentageStringLeft, Top + 1, percentageString, ConsoleColor.White, ConsoleColor.DarkBlue);

            buffer.CommitTrackingData();
        }
Example #3
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            buffer.DrawRectangle(RectangleDrawStyle.Single, Left, Top, Width, Height);
            buffer.DrawString(Left + 1, Top + 1, Text);

            buffer.CommitTrackingData();
        }
Example #4
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            var stringToRender = $"{(Checked ? "[x]" : "[ ]")} {Text}";

            buffer.DrawString(Left, Top, stringToRender);

            buffer.CommitTrackingData();
        }
Example #5
0
        public override void Draw(Screenbuffer buffer)
        {
            var lines = GetLines();

            buffer.StartTrackingForObject(this);

            for (int i = 0; i < lines.Length; i++)
            {
                buffer.DrawString(Left, Top + i, lines[i], Foreground, Background);
            }

            buffer.CommitTrackingData();
        }
Example #6
0
        public static void DrawString(this Screenbuffer buffer,
                                      int left,
                                      int top,
                                      IEnumerable <char> str,
                                      ConsoleColor foreground = Screenbuffer.DEFAULT_FOREGROUND,
                                      ConsoleColor background = Screenbuffer.DEFAULT_BACKGROUND)
        {
            int i = 0;

            foreach (var chr in str)
            {
                buffer.SetChar(left + i++, top, chr, foreground, background);
            }
        }
Example #7
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            buffer.DrawRectangle(RectangleDrawStyle.Double, Left, Top, Width, Height);
            buffer.DrawString(Left + 1, Top + 1, "^v");

            var valueString = Value.ToString($"F{DecimalPlaces}");

            valueString += string.Concat(Enumerable.Repeat(' ', Width - valueString.Length - 5));

            buffer.DrawString(Left + 4, Top + 1, valueString, ConsoleColor.White);

            buffer.CommitTrackingData();
        }
Example #8
0
        public void Update(Screenbuffer buffer, bool force)
        {
            foreach (var control in Controls.Where(c => force || c.IsDirty))
            {
                if (control.IsVisible)
                {
                    control.Draw(buffer);
                }
                else
                {
                    buffer.DrawFill(' ', control.Left, control.Top, control.Width, control.Height);
                }

                control.IsDirty = false;
            }
        }
Example #9
0
        public static void DrawFill(this Screenbuffer buffer,
                                    char fillChar,
                                    int left,
                                    int top,
                                    int width,
                                    int height,
                                    ConsoleColor foreground = Screenbuffer.DEFAULT_FOREGROUND,
                                    ConsoleColor background = Screenbuffer.DEFAULT_BACKGROUND)
        {
            var line = string.Concat(Enumerable.Repeat(fillChar, width));

            for (int i = 0; i < height; i++)
            {
                buffer.DrawString(left, top + i, line, foreground, background);
            }
        }
Example #10
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            int numToDisplay = _height == -1 ? Items.Count
                                             : _height - 2;

            for (int i = 0; i < numToDisplay; i++)
            {
                if (i + _rowOffset <= Items.Count - 1)
                {
                    buffer.DrawString(Left + 1,
                                      Top + i + 1,
                                      FixItemStringLength("  " + Items[i + _rowOffset].ToString()),
                                      ConsoleColor.White,
                                      _selected.Contains(Items[i + _rowOffset]) ? ConsoleColor.DarkGray : Screenbuffer.DEFAULT_BACKGROUND);

                    if (_displayMarker && i + _rowOffset == _markerPosition)
                    {
                        buffer.SetChar(Left + 1,
                                       Top + 1 + _markerPosition - _rowOffset,
                                       '>',
                                       ConsoleColor.Magenta,
                                       _selected.Contains(Items[i + _rowOffset]) ? ConsoleColor.DarkGray : Screenbuffer.DEFAULT_BACKGROUND);
                    }
                }
                else
                {
                    break;
                }
            }

            buffer.DrawRectangle(RectangleDrawStyle.ShadedSingle, Left, Top, Width, Height);

            if (_rowOffset > 0)
            {
                buffer.SetChar(Left + Width - 1, Top + 1, '^', ConsoleColor.DarkGray, Screenbuffer.DEFAULT_BACKGROUND);
            }

            if (_height != -1 && Items.Count > _height - 2)
            {
                buffer.SetChar(Left + Width - 1, Top + Height - 2, 'v', ConsoleColor.DarkGray, Screenbuffer.DEFAULT_BACKGROUND);
            }

            buffer.CommitTrackingData();
        }
Example #11
0
        public override void Draw(Screenbuffer buffer)
        {
            buffer.StartTrackingForObject(this);

            buffer.DrawRectangle(RectangleDrawStyle.ShadedSingle, Left, Top, Width, Height);

            var stringToDraw = Text;

            if (stringToDraw.Length > Width - 2 + _scrollOffset + 1)
            {
                stringToDraw = stringToDraw.Substring(_scrollOffset + 1, Width - 2);
            }
            else if (_scrollOffset > 0)
            {
                stringToDraw = stringToDraw.Substring(_scrollOffset + 1);
            }

            buffer.DrawString(Left + 1, Top + 1, stringToDraw, ConsoleColor.White, ConsoleColor.Black);

            buffer.CommitTrackingData();
        }