コード例 #1
0
        private void UpdateProgress()
        {
            Console.CursorVisible = false;
            var indentation    = new[] { new Indentation(this.ForeGroundColor, true) };
            var mainPercentage = this.Percentage;
            var cursorTop      = _originalCursorTop;

            Console.ForegroundColor = this.ForeGroundColor;

            void TopHalf()
            {
                ProgressBarTopHalf(mainPercentage,
                                   this.Options.ProgressCharacter,
                                   this.Options.BackgroundCharacter,
                                   this.Options.BackgroundColor,
                                   indentation,
                                   this.Options.ProgressBarOnBottom
                                   );
            }

            if (this.Options.ProgressBarOnBottom)
            {
                ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation, this.Options.ProgressBarOnBottom);
                Console.SetCursorPosition(0, ++cursorTop);
                TopHalf();
            }
            else
            {
                TopHalf();
                Console.SetCursorPosition(0, ++cursorTop);
                ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation, this.Options.ProgressBarOnBottom);
            }

            if (this.Options.EnableTaskBarProgress)
            {
                TaskbarProgress.SetValue(mainPercentage, 100);
            }

            DrawChildren(this.Children, indentation, ref cursorTop);

            ResetToBottom(ref cursorTop);

            Console.SetCursorPosition(0, _originalCursorTop);
            Console.ForegroundColor = _originalColor;

            if (!(mainPercentage >= 100))
            {
                return;
            }
            _timer?.Dispose();
            _timer = null;
        }
コード例 #2
0
        private void UpdateProgress()
        {
            var mainPercentage = this.Percentage;

            if (this.Options.EnableTaskBarProgress)
            {
                TaskbarProgress.SetValue(mainPercentage, 100);
            }

            // write queued console messages, displayprogress is signaled straight after but
            // just in case make sure we never write more then 5 in a display progress tick
            for (var i = 0; i < 5 && _stickyMessages.TryDequeue(out var m); i++)
            {
                WriteConsoleLine(m);
            }


            if (Console.IsOutputRedirected)
            {
                return;
            }

            Console.CursorVisible   = false;
            Console.ForegroundColor = this.ForegroundColor;

            GrowDrawingAreaBasedOnChildren();
            var cursorTop   = _originalCursorTop;
            var indentation = new[] { new Indentation(this.ForegroundColor, true) };

            void TopHalf()
            {
                ProgressBarTopHalf(mainPercentage,
                                   this.Options.ProgressCharacter,
                                   this.Options.BackgroundCharacter,
                                   this.Options.BackgroundColor,
                                   indentation,
                                   this.Options.ProgressBarOnBottom
                                   );
            }

            if (this.Options.ProgressBarOnBottom)
            {
                ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation,
                                      this.Options.ProgressBarOnBottom, Options.ShowEstimatedDuration, EstimatedDuration);
                Console.SetCursorPosition(0, ++cursorTop);
                TopHalf();
            }
            else
            {
                TopHalf();
                Console.SetCursorPosition(0, ++cursorTop);
                ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation,
                                      this.Options.ProgressBarOnBottom, Options.ShowEstimatedDuration, EstimatedDuration);
            }

            DrawChildren(this.Children, indentation, ref cursorTop);

            ResetToBottom(ref cursorTop);

            Console.SetCursorPosition(0, _originalCursorTop);
            Console.ForegroundColor = _originalColor;

            if (!(mainPercentage >= 100))
            {
                return;
            }
            _timer?.Dispose();
            _timer = null;
        }
コード例 #3
0
        protected override void DisplayProgress()
        {
            if (_isDisposed)
            {
                return;
            }

            Console.CursorVisible = false;
            var indentation    = new[] { new Indentation(this.ForeGroundColor, true) };
            var mainPercentage = this.Percentage;

            lock (Lock)
            {
                Console.ForegroundColor = this.ForeGroundColor;

                void TopHalf()
                {
                    ProgressBarTopHalf(mainPercentage,
                                       this.Options.ProgressCharacter,
                                       this.Options.BackgroundCharacter,
                                       this.Options.BackgroundColor,
                                       indentation,
                                       this.Options.ProgressBarOnBottom
                                       );
                }

                if (this.Options.ProgressBarOnBottom)
                {
                    Console.CursorLeft = 0;
                    ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation, this.Options.ProgressBarOnBottom);

                    if (!IsWindows)
                    {
                        Console.CursorTop = Console.CursorTop + 1;
                    }

                    Console.CursorLeft = 0;
                    TopHalf();
                }
                else
                {
                    Console.CursorLeft = 0;
                    TopHalf();
                    if (!IsWindows)
                    {
                        Console.CursorTop = Console.CursorTop + 1;
                    }

                    Console.CursorLeft = 0;
                    ProgressBarBottomHalf(mainPercentage, this._startDate, null, this.Message, indentation, this.Options.ProgressBarOnBottom);
                }

                if (this.Options.EnableTaskBarProgress)
                {
                    TaskbarProgress.SetValue(mainPercentage, 100);
                }

                DrawChildren(this.Children, indentation);

                ResetToBottom();

                Console.CursorLeft      = 0;
                Console.CursorTop       = _originalCursorTop;
                Console.ForegroundColor = _originalColor;

                if (!(mainPercentage >= 100))
                {
                    return;
                }
                _timer?.Dispose();
                _timer = null;
            }
        }