ProgressBar3/Program.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ConsoleGraphics;

namespace ProgressBar3
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var progressBar = new ConsoleProgressBar(totalUnitsOfWork: 3500))
            {
                for (uint i = 0; i < 3500; ++i)
                {
                    progressBar.Draw(i + 1);
                    Thread.Sleep(1);
                }
            }

            using (var progressBar = new ConsoleProgressBar(
                totalUnitsOfWork: 2000,
                startingPosition: 3,
                widthInCharacters: 48,
                completedColor: ConsoleColor.DarkBlue,
                remainingColor: ConsoleColor.DarkGray))
            {
                for (uint i = 0; i < 2000; ++i)
                {
                    progressBar.Draw(i + 1);
                    Thread.Sleep(1);
                }
            }
        }
    }
}

namespace ConsoleGraphics
{
    public class ConsoleProgressBar : IDisposable
    {
        private const char ProgressBlockCharacter = ' ';
        private readonly float _unitsOfWorkPerProgressBlock;
        private readonly bool _originalCursorVisible;

        /// <summary>
        /// Color for completed portion of progress bar.
        /// </summary>
        public ConsoleColor CompletedColor { get; private set; }

        /// <summary>
        /// Color for incomplete portion of progress bar.
        /// </summary>
        public ConsoleColor RemainingColor { get; private set; }

        /// <summary>
        /// Progress bar starting position.
后面还有 103 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。