Exemplo n.º 1
0
        public static void WriteBar(PercentChangedEventArgs args)
        {
            StringBuilder output = new StringBuilder();
            int fillLen = 0;
            char filler = '#', spacer = ' ';

            output.Append(" ");
            for (int i = 0; i < 10; i++) {
                char c = i < args.Label.Length ? args.Label[i] : ' ';
                output.Append(c);
            }

            output.Append(" [");

            fillLen = Convert.ToInt32(((decimal)args.Percent / 100) * 60);

            for (int i = 0; i < 60; i++) {
                output.Append(i <= fillLen ? filler : spacer);
            }

            output.Append("] ");
            output.Append(args.Percent + "%");

            lock (__consoleWriteLock) {
                Console.Write("\r");
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Write(output.ToString());
                Console.ResetColor();
            }
        }
Exemplo n.º 2
0
        protected void RaisePercentChangedEvent(string label)
        {
            PercentChangedEventArgs args = new PercentChangedEventArgs();
            double percentComplete = (double)++doneItems / totalLoadingItems * 100;

            if (oldPercent != (int)percentComplete) {
                args.Percent = (int)percentComplete;
                args.Label = label;

                if (PercentChanged != null) {
                    PercentChanged(this, args);
                }
                oldPercent = (int)percentComplete;
            }
        }