patch for UI

This commit is contained in:
2022-06-02 13:48:56 +03:00
parent ab6f14e74c
commit 0d524cdf65
21 changed files with 265 additions and 359 deletions

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PluginManager.Others
{
@@ -14,17 +10,20 @@ namespace PluginManager.Others
/// </summary>
public class ProgressBar
{
public int Progress { get; set; }
public int Max { get; set; }
public string Message { get; set; }
public int Max { get; set; }
public string Message { get; set; }
public ConsoleColor Color { get; init; }
public ProgressBar(int max, string message)
{
Max = max;
Max = max;
Message = message;
var consoleColors = Enum.GetValues(typeof(ConsoleColor));
while ((Color = (ConsoleColor)consoleColors.GetValue(new Random().Next(consoleColors.Length))!) == ConsoleColor.White && Color != ConsoleColor.Black) ;
}
public async void Update(int progress, double speed = -1, string? unit = null)
public void Update(int progress, double speed = -1, string? unit = null)
{
//progress bar
@@ -39,8 +38,8 @@ namespace PluginManager.Others
for (int i = 0; i < onechunk * progress; i++)
{
Console.BackgroundColor = ConsoleColor.Green;
Console.CursorLeft = position++;
Console.BackgroundColor = this.Color;
Console.CursorLeft = position++;
Console.Write(" ");
}
@@ -130,11 +129,12 @@ namespace PluginManager.Others
ConsoleColor fg = Console.ForegroundColor;
Dictionary<string, ConsoleColor> colors = new Dictionary<string, ConsoleColor>()
{
{"&g", ConsoleColor.Green },
{"&b", ConsoleColor.Blue },
{"&r", ConsoleColor.Red },
{"&m", ConsoleColor.Magenta },
{"&c", fg }
{ "&g", ConsoleColor.Green },
{ "&b", ConsoleColor.Blue },
{ "&r", ConsoleColor.Red },
{ "&m", ConsoleColor.Magenta },
{ "&y", ConsoleColor.Yellow },
{ "&c", fg }
};
foreach (string word in words)
{
@@ -145,7 +145,9 @@ namespace PluginManager.Others
Console.ForegroundColor = colors[prefix];
}
string m = word.Replace("&g", "").Replace("&b", "").Replace("&r", "").Replace("&c", "").Replace("&m", "");
string m = word;
foreach (var key in colors.Keys) { m = m.Replace(key, ""); }
Console.Write(m + " ");
}
if (appendNewLine)