void ProgressUpdate(object sender, ProgressEventArgs e) { lock (SyncLock) { // keep all the message together ISyncItem syncItem = e.UserState as ISyncItem; if (e.ProgressPercentage % 10 == 0) { var line = string.Format("{0} ({1} of {2}) {3}%", syncItem.EpisodeTitle, DisplayFormatter.RenderFileSize(e.ItemsProcessed), DisplayFormatter.RenderFileSize(e.TotalItemsToProcess), e.ProgressPercentage); AddLineToOutput(line); AndroidApplication.Logger.Debug(() => line); } if (e.ProgressPercentage == 100) { number_of_files_downloaded++; AddLineToOutput($"Completed {number_of_files_downloaded} of {number_of_files_to_download} downloads"); } DisplayOutput(); } }
static void ProgressUpdate(object sender, ProgressEventArgs e) { lock (_synclock) { // keep all the message together ISyncItem syncItem = e.UserState as ISyncItem; if (e.ProgressPercentage % 10 == 0) { Console.WriteLine(string.Format("{0} ({1} of {2}) {3}%", syncItem.EpisodeTitle, DisplayFormatter.RenderFileSize(e.ItemsProcessed), DisplayFormatter.RenderFileSize(e.TotalItemsToProcess), e.ProgressPercentage)); } if (e.ProgressPercentage == 100) { _number_of_files_downloaded++; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Completed {0} of {1} downloads", _number_of_files_downloaded, _number_of_files_to_download); Console.ResetColor(); } if (IsDestinationDriveFull(_control.GetSourceRoot(), _control.GetFreeSpaceToLeaveOnDownload())) { if (_taskPool != null) { _taskPool.CancelAllTasks(); } } } }
protected void ProgressUpdate(object sender, ProgressEventArgs e) { lock (this) { // keep all the message together ISyncItem syncItem = e.UserState as ISyncItem; if (e.ProgressPercentage % 10 == 0) { Console.WriteLine(string.Format("{0} ({1} of {2}) {3}%", syncItem.EpisodeTitle, DisplayFormatter.RenderFileSize(e.ItemsProcessed), DisplayFormatter.RenderFileSize(e.TotalItemsToProcess), e.ProgressPercentage)); } } }
private void AddFileSystem(string absolutePath) { long freeBytes = FileSystemHelper.GetAvailableFileSystemSizeInBytes(absolutePath); long totalBytes = FileSystemHelper.GetTotalFileSystemSizeInBytes(absolutePath); long usedBytes = totalBytes - freeBytes; string[] freeSize = DisplayFormatter.RenderFileSize(freeBytes).Split(' '); string[] totalSize = DisplayFormatter.RenderFileSize(totalBytes).Split(' '); var view = DriveVolumeInfoViewFactory.GetNewView(ApplicationContext); view.Title = ConvertPathToTitle(absolutePath); view.SetSpace( Convert.ToInt32(ByteConverter.BytesToMegabytes(usedBytes)), Convert.ToInt32(ByteConverter.BytesToMegabytes(totalBytes)), freeSize[0], freeSize[1], totalSize[0], totalSize[1]); Observables?.AddInfoView?.Invoke(this, view.GetView()); }
void DownloadProgressUpdate(object sender, ProgressEventArgs e) { lock (MessageSyncLock) { ISyncItem syncItem = e.UserState as ISyncItem; if (e.ProgressPercentage % 10 == 0) { // only do every 10% var line = string.Format("{0} ({1} of {2}) {3}%", syncItem.EpisodeTitle, DisplayFormatter.RenderFileSize(e.ItemsProcessed), DisplayFormatter.RenderFileSize(e.TotalItemsToProcess), e.ProgressPercentage); Logger.Debug(() => line); Observables.UpdateItemProgress?.Invoke(this, Tuple.Create(syncItem, e.ProgressPercentage)); } if (IsDestinationDriveFull(ControlFile.GetSourceRoot(), ControlFile.GetFreeSpaceToLeaveOnDownload())) { TaskPool?.CancelAllTasks(); } } }
private ReadOnlyControlFile OpenControlFile(Android.Net.Uri uri) { try { ContentResolver resolver = Application.ContentResolver; var stream = resolver.OpenInputStream(uri); var xml = new XmlDocument(); xml.Load(stream); var control = new ReadOnlyControlFile(xml); var podcasts = control.GetPodcasts(); int count = 0; foreach (var item in podcasts) { count++; } NoOfFeeds = count; AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {control.GetSourceRoot()}"); AndroidApplication.Logger.Debug(() => $"MainActivity:Control Podcasts {count}"); SetTextViewText(Resource.Id.txtConfigFilePath, $"{uri.ToString()}"); freeBytesNet = GetFreeBytes(control.GetSourceRoot()); freeBytesAndroid = FileSystemHelper.GetAvailableFileSystemSizeInBytes(control.GetSourceRoot()); totalBytesAndroid = FileSystemHelper.GetTotalFileSystemSizeInBytes(control.GetSourceRoot()); var output = $"{count}, {control.GetSourceRoot()}\nFree space (Net): {DisplayFormatter.RenderFileSize(freeBytesNet)}\nFree/total space (Android): {DisplayFormatter.RenderFileSize(freeBytesAndroid)}/{DisplayFormatter.RenderFileSize(totalBytesAndroid)}"; SetTextViewText(Resource.Id.txtOutput, output); return(control); } catch (Exception ex) { AndroidApplication.Logger.LogException(() => $"MainActivity: OpenConfigFile", ex); SetTextViewText(Resource.Id.txtConfigFilePath, $"Error {ex.Message}"); return(null); } }
protected override void When() { _result = DisplayFormatter.RenderFileSize(4294967296); }
protected override void When() { _result = DisplayFormatter.RenderFileSize(3145728); }