public void StepTest() { ConsoleProgressBar target = new ConsoleProgressBar(); // TODO: 初始化为适当的值 target.Step(); Assert.Inconclusive("无法验证不返回值的方法。"); }
// The IUser stuff is ONLY used by the mod download/install operations. /// <summary> /// Initialize the Screen /// </summary> /// <param name="descrip">Description of the task being done for the header</param> /// <param name="initMsg">Starting string to put in the progress bar</param> public ProgressScreen(string descrip, string initMsg = "") { // A nice frame to take up some of the blank space at the top AddObject(new ConsoleDoubleFrame( 1, 2, -1, -1, 8, () => "Progress", () => "Messages", // Cheating because our IUser handler needs a theme context th => { yesNoTheme = th; return(th.NormalFrameFg); } )); progress = new ConsoleProgressBar( 3, 5, -3, () => topMessage, () => percent ); messages = new ConsoleTextBox( 3, 10, -3, -3 ); AddObject(progress); AddObject(messages); topMessage = initMsg; taskDescription = descrip; }
public void Parse(TableCollection data, bool enableProgress = true) { ConsoleProgressBar progress = null; if (enableProgress) { progress = new ConsoleProgressBar(Console.CursorLeft, Console.CursorTop, 50, ProgressBarType.Character); } // 解析表 var i = 0; for (i = 0; i < data.Count;) { var table = data[i]; var meta_table = ParseTable(table); _tableNeedCheck.Add(meta_table); // 解析行 foreach (Column col in table.Columns) { ParseColumn(meta_table, col); } _config.Tables.Add(meta_table); // 打印进度 if (progress != null) { ProgressPrint(progress, ++i, data.Count + 1); } } // 打印进度 ProgressPrint(progress, ++i, data.Count + 1); }
public void ConsoleProgressBarConstructorTest1() { int iMaximumStep = 0; // TODO: 初始化为适当的值 ConsoleProgressBar target = new ConsoleProgressBar(iMaximumStep); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
public Installer(Repository repository) { _repo = repository; _dataDirectory = Path.Combine(_repo.DefaultDirectory, "Data"); _updateDirectory = Path.Combine(_repo.DefaultDirectory, "Updates"); _progressBar = new ConsoleProgressBar(false); }
private static void GetVatsimClientRecordsFromLines(string[] lines) { bool client_section = false; Console.Write("Processing Vatsim Client Records from File... "); using (var progress = new ConsoleProgressBar()) { int count = 0; int total = lines.Length; foreach (string line in lines) { if (!IgnoreThisLine(line)) { progress.Report((double)count++ / total); Thread.Sleep(20); if (line.StartsWith("!CLIENTS:")) { client_section = true; continue; } if (line.StartsWith("!SERVERS:") || line.StartsWith("!PREFILE:")) { client_section = false; return; } if (client_section) { CurrentVatsimData.VatsimClientRecords.Add(VatsimClientRecord.GetVatsimClientRecord(line)); } } } } Console.WriteLine("Done."); }
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); } } }
private static async Task ConsoleProgressBars() { var pb1 = new ConsoleProgressBar(); await TestProgressBar(pb1, 1); var pb2 = new ConsoleProgressBar { NumberOfBlocks = 18, StartBracket = string.Empty, EndBracket = string.Empty, CompletedBlock = "\u2022", IncompleteBlock = "·", AnimationSequence = ProgressAnimations.RotatingPipe }; await TestProgressBar(pb2, 2); var pb3 = new ConsoleProgressBar { DisplayBar = false, AnimationSequence = ProgressAnimations.RotatingTriangle }; await TestProgressBar(pb3, 3); }
// The IUser stuff is ONLY used by the mod download/install operations. /// <summary> /// Initialize the Screen /// </summary> /// <param name="taskDescription">Description of the task being done for the header</param> /// <param name="initMsg">Starting string to put in the progress bar</param> public ProgressScreen(string taskDescription, string initMsg = "") { // A nice frame to take up some of the blank space at the top AddObject(new ConsoleDoubleFrame( 1, 2, -1, -1, 8, () => "Progress", () => "Messages", () => ConsoleTheme.Current.NormalFrameFg )); progress = new ConsoleProgressBar( 3, 5, -3, () => topMessage, () => percent ); messages = new ConsoleTextBox( 3, 10, -3, -3 ); AddObject(progress); AddObject(messages); topMessage = initMsg; LeftHeader = () => $"CKAN {Meta.GetVersion()}"; CenterHeader = () => taskDescription; }
private static async Task ConsoleProgressBars() { var pb1 = new ConsoleProgressBar { ForegroundColor = ConsoleColor.Cyan }; await TestProgressBar(pb1, 1); var pb2 = new ConsoleProgressBar { NumberOfBlocks = 30, ForegroundColor = ConsoleColor.Cyan, StartBracket = string.Empty, EndBracket = string.Empty, CompletedBlock = "\u2022", IncompleteBlock = "·", AnimationSequence = UniversalProgressAnimations.Default }; await TestProgressBar(pb2, 2); var pb3 = new ConsoleProgressBar { DisplayBars = false, AnimationSequence = UniversalProgressAnimations.RotatingTriangle, ForegroundColor = ConsoleColor.Cyan }; await TestProgressBar(pb3, 3); }
public void Unpack(string hFilePath, string unpackPath) { using (BinaryReader binaryReader = new BinaryReader((Stream) new FileStream(this.getPath(Path.GetDirectoryName(hFilePath), Path.GetFileNameWithoutExtension(hFilePath) + ".~p"), FileMode.Open))) { ConsoleProgressBar consoleProgressBar = new ConsoleProgressBar(this.header.Header.FileCount); try { consoleProgressBar.Start(); foreach (FileIndex file in this.header.Files) { binaryReader.BaseStream.Seek(file.Offset, SeekOrigin.Begin); consoleProgressBar.PerformStep(); Directory.CreateDirectory(Path.GetDirectoryName(this.getPath(unpackPath, file.GetFilePath()))); using (MemoryStream memoryStream = new MemoryStream()) { using (ZOutputStream zoutputStream = new ZOutputStream((Stream)memoryStream)) { if (file.IsCompressed()) { zoutputStream.Write(binaryReader.ReadBytes(file.Size), 0, file.Size); } else { memoryStream.Write(binaryReader.ReadBytes(file.Size), 0, file.Size); } memoryStream.Seek(0L, SeekOrigin.Begin); if ((long)file.ContentSize < memoryStream.Length) { using (BinaryWriter binaryWriter = new BinaryWriter((Stream) new FileStream(this.getPath(unpackPath, file.GetFilePath() + ".header"), FileMode.Create))) { byte[] buffer = new byte[memoryStream.Length - (long)file.ContentSize]; memoryStream.Read(buffer, 0, buffer.Length); binaryWriter.Write(buffer); } } using (BinaryWriter binaryWriter = new BinaryWriter((Stream) new FileStream(this.getPath(unpackPath, file.GetFilePath()), FileMode.Create))) { int contentSize = file.ContentSize; if (file.FileType.HasSizeHeader) { contentSize -= 4; } byte[] buffer = new byte[contentSize]; if (file.FileType.HasSizeHeader) { memoryStream.Read(buffer, 0, 4); } memoryStream.Read(buffer, 0, contentSize); binaryWriter.Write(buffer); } } } } } finally { consoleProgressBar.End(); } } }
private static void sshCp_OnTransferEnd(string src, string dst, int transferredBytes, int totalBytes, string message) { if (progressBar != null) { progressBar.Update(transferredBytes, totalBytes, message); progressBar = null; } }
private void AnimateProgressBar(CmdExecutorProgress o) { var duration = DurationFactory.FromMilliseconds(250); DoubleAnimation doubleAnimation = new DoubleAnimation(o.Percentage, duration); ConsoleProgressBar.BeginAnimation(RangeBase.ValueProperty, doubleAnimation); ConsoleProgressBar.Value = o.Percentage; }
private static void sshCp_OnTransferStart(string src, string dst, int transferredBytes, int totalBytes, string message) { Console.WriteLine(); progressBar = new ConsoleProgressBar(); StringBuilder temp = progressBar.Update(transferredBytes, totalBytes, message); traceHandler(temp.ToString()); }
public void MaximumStepTest() { ConsoleProgressBar target = new ConsoleProgressBar(); // TODO: 初始化为适当的值 int actual; actual = target.MaximumStep; Assert.Inconclusive("验证此测试方法的正确性。"); }
public void IndicatingPosTest() { ConsoleProgressBar target = new ConsoleProgressBar(); // TODO: 初始化为适当的值 int actual; actual = target.IndicatingPos; Assert.Inconclusive("验证此测试方法的正确性。"); }
public void BeginStepTest() { ConsoleProgressBar target = new ConsoleProgressBar(); // TODO: 初始化为适当的值 string strBeginString = string.Empty; // TODO: 初始化为适当的值 target.BeginStep(strBeginString); Assert.Inconclusive("无法验证不返回值的方法。"); }
private void ResetProgressBar() { //Avoids animating the progressbar when its value is reset to zero. ConsoleProgressBar.BeginAnimation(RangeBase.ValueProperty, null); ConsoleProgressBar.Value = 0.0; //06b025 ConsoleProgressBar.Foreground = ResourceUtils.DefaultProgressBarColor; }
private static void sshCp_OnTransferEnd(string src, string dst, int transferredBytes, int totalBytes, string message) { if (progressBar != null) { StringBuilder temp = progressBar.Update(transferredBytes, totalBytes, message); traceHandler(temp.ToString()); progressBar = null; } }
public FileDownloader(Repository repository, List <FileObject> files) { Files = files; BasePath = repository.DefaultDirectory; Progress = new ConsoleProgressBar(true, Files.Count); Client = new WebClient(); Client.DownloadProgressChanged += DownloadProgressChanged; Client.DownloadFileCompleted += DownloadFileCompleted; }
private static void PrintProgressBar(int gen, int genmax) { StringBuilder sb = new StringBuilder(); sb.Append("\r"); ConsoleProgressBar.BuildProgressBar(sb, 50, gen, genmax); sb.Append(" Gen: "); sb.Append(gen); Console.Write(sb.ToString()); Console.Out.Flush(); }
private static void Main(string[] args) { Console.WriteLine("console progress bar test.."); // 单线程单任务 var pBar = new ConsoleProgressBar("s1").Show(); for (int i = 0; i <= 100; i++) { Thread.Sleep(25); pBar.UpdateProgress(i); } // 单线程多个任务 var pBars = new ConsoleProgressBar[9]; for (int i = 0; i < pBars.Length; i++) { pBars[i] = new ConsoleProgressBar($"task{i + 1}").Show(); } for (int i = 0; i <= 100; i++) { Thread.Sleep(25); for (int j = 0; j < pBars.Length; j++) { pBars[j].UpdateProgress(i); } } // 多线程多任务 // 有问题 orz for (int i = 0; i < 9; i++) { var thread = new Thread(new ThreadStart(delegate() { var threadName = Thread.CurrentThread.Name; var pBar = new ConsoleProgressBar(threadName).Show(); for (int i = 0; i <= 100; i++) { Thread.Sleep(25); pBar.UpdateProgress(i); } })); thread.Name = $"Thread{i + 1}"; thread.Start(); } // wait for exit Console.ReadKey(); }
public EtLogger(ConsoleProgressBar progressBar) { LoggerConfiguration loggerConfiguration = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.File("ET_Tool.log", restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Debug, rollingInterval: RollingInterval.Hour, rollOnFileSizeLimit: true) .WriteTo.ColoredConsole(restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information); this._slogger = loggerConfiguration.CreateLogger(); this._progressBar = progressBar; }
/// <summary> /// Run through the list of clients to parse out ATC and Pilots /// </summary> public void ProcessVatsimClientRecords() { // are there any clients to process? if(VatsimClientRecords != null && VatsimClientRecords.Count > 0) { Console.Write("Writing Vatsim Objects to Database... "); // progress bar using(var progress = new ConsoleProgressBar()) { // get total count int count = 0; int total = VatsimClientRecords.Count; try { foreach (VatsimClientRecord record in VatsimClientRecords) { progress.Report((double)count++ / total); Thread.Sleep(20); switch(record.Clienttype) { case "ATC": VatsimDbHelper.UpdateOrCreateATCAsync(record.GetVatsimClientATCFromRecord()); break; case "PILOT": // only process IFR flights if(IFRONLY) { // check to see that this pilot has an IFR Plan Active if(IFRFlightPlanActive(record)) { VatsimDbHelper.UpdateOrCreatePilotAsync(record.GetVatsimClientPilotFromRecord()); VatsimDbHelper.UpdateOrCreateFlightAsync(record.GetVatsimClientPlannedFlightFromRecord()); VatsimDbHelper.CreatePositionAsync(record.GetVatsimClientPilotSnapshotFromRecord()); } } break; } } } catch(Exception exp) { Console.WriteLine($"{exp.Message}"); } } Console.WriteLine("Done."); } }
static bool Generate(string input_path, string output_path) { var is_file = Path.HasExtension(input_path); string[] input_file_paths = null; if (is_file) { input_file_paths = new string[] { input_path }; } else { input_file_paths = Directory.GetFiles(input_path, "*.cs"); if (input_file_paths.Length == 0) { Print("指定目录下没有任何cs文件!", 3); return(false); } } EnsurePath(output_path); ConsoleProgressBar progress = GetProgressBar(); try { for (int i = 0; i < input_file_paths.Length; i++) { InnerGenerate(input_file_paths[i], output_path); if (progress != null) { // 打印进度 ProgressPrint(progress, (i + 1), input_file_paths.Length); } } } catch (GeneratorParseException ex) { Print(ex.Message, 3); return(false); } catch (Exception ex) { Print(ex.Message, 3); return(false); } return(true); }
/// <inheritdoc cref="IConsoleLogger.ReportProgress"/> public virtual void ReportProgress(int max, int current, string message) { if (ProgressBarDisplayMode == ConsoleProgressBarDisplayMode.Off) { return; } if (_console.IsOutputRedirected) { // cannot use the progress bar Debug(FormatLogMessageProgressAsText(max, current, message)); return; } try { if (_progressBar == null) { _progressBar = new ConsoleProgressBar(_console, max, message) { ClearProgressBarOnStop = ProgressBarDisplayMode == ConsoleProgressBarDisplayMode.On, TextColor = ProgressTextColor, BackgroundCharacter = ProgressBackgroundCharacter, ForegroundCharacter = ProgressForegroundCharacter, BackgroundColor = ProgressBackgroundColor, ForegroundColor = ProgressForegroundColor, ForegroundColorDone = ProgressForegroundColorDone, ForegroundColorUncomplete = ProgressForegroundColorUncomplete, MaximumRefreshRateInMilliseconds = ProgressMaximumRefreshRateInMilliseconds, MinimumRefreshRateInMilliseconds = ProgressMinimumRefreshRateInMilliseconds, }; } if (!_progressBar.IsRunning) { base.WriteResultOnNewLine(null); } if (max > 0 && max != _progressBar.MaxTicks) { _progressBar.MaxTicks = max; } _progressBar.Tick(current, message); if (max == current) { StopProgressBar(); } } catch (Exception) { // ignored } }
public static ProgressBar GetProgressBar(ProgressBarConfig config) { CheckConfig(config); ProgressBar pb = null; switch (config.PBType) { case ProgressBarType.Console: pb = new ConsoleProgressBar(config); break; case ProgressBarType.Gui: break; } return(pb); }
private static async Task TestProgressBar(ConsoleProgressBar progress, int num) { Console.Write($"{num}. Performing some task... "); using (progress) { for (var i = 0; i <= 150; i++) { progress.Report((double)i / 150); await Task.Delay(20); } progress.Report(1); await Task.Delay(200); } Console.WriteLine(); }
public static void OutputModel(SQLMetaData config, bool enableProgress = true) { var path = Path.Combine(_basePath, "Model"); Directory.CreateDirectory(path); ConsoleProgressBar progress = null; if (enableProgress) { progress = GetProgressBar(); } var sb = new StringBuilder(); var g = new ModelGenerator(config); // 解析 for (int i = 0; i < config.Tables.Count; i++) { var table = config.Tables[i]; if (config.ExceptTables.Contains(table.Name)) { continue; } sb.Append(config.Model_HeaderNote); sb.Append(string.Join(Environment.NewLine, config.Model_Using)); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(config.Model_Namespace); sb.AppendLine("{"); sb.AppendLine(g.Get_Class(table.Name)); sb.AppendLine("}"); File.AppendAllText(Path.Combine(path, string.Format("{0}.cs", table.Name)), sb.ToString()); sb.Clear(); if (progress != null) { // 打印进度 ProgressPrint(progress, (i + 1), config.Tables.Count); } } // 拷贝公用文件到指定目录 DirHelper.CopyDirectory(Path.Combine("CopyFiles", "Model"), path); }
public void TestIProgressBarInterface() { IProgressBar cpb = new ConsoleProgressBar(); IFileCopier pfc = new ProgressFileCopier(cpb); double percent = default; string progressBar = default; bool complete = default; cpb.ProgressChanged += (percentage, bar) => { percent = percentage; progressBar = bar; }; cpb.Completed += delegate { complete = true; }; pfc.Copy(SRC_PATH, DST_PATH, true); Assert.AreEqual(percent, 1); Assert.AreEqual(progressBar, "[==========]"); Assert.AreEqual(complete, true); }
private static void sshCp_OnTransferStart(string src, string dst, int transferredBytes, int totalBytes, string message) { Console.WriteLine(); progressBar = new ConsoleProgressBar(); progressBar.Update(transferredBytes, totalBytes, message); }