diff --git a/Library/LibraryRowItemPart.cs b/Library/LibraryRowItemPart.cs index 5859abced..6b2a2639b 100644 --- a/Library/LibraryRowItemPart.cs +++ b/Library/LibraryRowItemPart.cs @@ -76,6 +76,8 @@ namespace MatterHackers.MatterControl.PrintLibrary CreateGuiElements(); AddLoadingProgressBar(); + + libraryProvider.RegisterForProgress(itemIndex, ReportProgressRatio); } public override bool Protected @@ -88,7 +90,7 @@ namespace MatterHackers.MatterControl.PrintLibrary public async Task GetPrintItemWrapperAsync() { - return await libraryProvider.GetPrintItemWrapperAsync(this.ItemIndex, ReportProgressRatio); + return await libraryProvider.GetPrintItemWrapperAsync(this.ItemIndex); } void ReportProgressRatio(double progress0To1, string processingState, out bool continueProcessing) @@ -106,10 +108,13 @@ namespace MatterHackers.MatterControl.PrintLibrary processingProgressControl.RatioComplete = progress0To1; } - ProgressBar processingProgressControl; + ProgressControl processingProgressControl; private void AddLoadingProgressBar() { - processingProgressControl = new ProgressBar(ActiveTheme.Instance.SecondaryAccentColor, (int)(100 * TextWidget.GlobalPointSizeScaleRatio), 5); + processingProgressControl = new ProgressControl("Downloading...", ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.SecondaryAccentColor, (int)(100 * TextWidget.GlobalPointSizeScaleRatio), 5) + { + PointSize = 8, + }; processingProgressControl.BackgroundColor = RGBA_Bytes.White; processingProgressControl.VAnchor = VAnchor.ParentBottom; processingProgressControl.HAnchor = HAnchor.ParentLeft; diff --git a/Library/Provider/LibraryProvider.cs b/Library/Provider/LibraryProvider.cs index a24e37314..33776bca3 100644 --- a/Library/Provider/LibraryProvider.cs +++ b/Library/Provider/LibraryProvider.cs @@ -149,7 +149,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public abstract PrintItemCollection GetCollectionItem(int collectionIndex); - public abstract Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null); + public abstract Task GetPrintItemWrapperAsync(int itemIndex); // TODO: make this asnyc //public abstract Task GetProviderForCollectionAsync(PrintItemCollection collection); @@ -182,7 +182,31 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return GetProviderForCollection(GetCollectionItem(collectionIndex)).CollectionCount; } - public virtual int GetCollectionItemCount(int collectionIndex) + protected Dictionary itemReportProgressHandlers = new Dictionary(); + + public void RegisterForProgress(int itemIndex, ReportProgressRatio reportProgress) + { + if (!itemReportProgressHandlers.ContainsKey(itemIndex)) + { + itemReportProgressHandlers.Add(itemIndex, reportProgress); + } + else + { + itemReportProgressHandlers[itemIndex] = reportProgress; + } + } + + protected ReportProgressRatio GetItemProgressHandler(int itemIndex) + { + if (!itemReportProgressHandlers.ContainsKey(itemIndex)) + { + return null; + } + + return itemReportProgressHandlers[itemIndex]; + } + + public virtual int GetCollectionItemCount(int collectionIndex) { return GetProviderForCollection(GetCollectionItem(collectionIndex)).ItemCount; } diff --git a/Library/Provider/LibraryProviderFileSystem.cs b/Library/Provider/LibraryProviderFileSystem.cs index 3165e1963..f69651986 100644 --- a/Library/Provider/LibraryProviderFileSystem.cs +++ b/Library/Provider/LibraryProviderFileSystem.cs @@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return Path.GetFileName(currentDirectoryFiles[itemIndex]); } - public async override Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null) + public async override Task GetPrintItemWrapperAsync(int itemIndex) { string fileName = currentDirectoryFiles[itemIndex]; diff --git a/Library/Provider/LibraryProviderHistory.cs b/Library/Provider/LibraryProviderHistory.cs index 06bbe9996..943c233f3 100644 --- a/Library/Provider/LibraryProviderHistory.cs +++ b/Library/Provider/LibraryProviderHistory.cs @@ -231,7 +231,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return childCollections[collectionIndex]; } - public async override Task GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null) + public async override Task GetPrintItemWrapperAsync(int index) { throw new NotImplementedException(); //return PrintHistoryData.Instance.GetPrintItemWrapper(index); diff --git a/Library/Provider/LibraryProviderQueue.cs b/Library/Provider/LibraryProviderQueue.cs index dddd2bd8f..32bfa1cbd 100644 --- a/Library/Provider/LibraryProviderQueue.cs +++ b/Library/Provider/LibraryProviderQueue.cs @@ -226,7 +226,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return childCollections[collectionIndex]; } - public async override Task GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null) + public async override Task GetPrintItemWrapperAsync(int index) { return QueueData.Instance.GetPrintItemWrapper(index); } diff --git a/Library/Provider/LibraryProviderSelector.cs b/Library/Provider/LibraryProviderSelector.cs index af3ba1070..e4fb387ed 100644 --- a/Library/Provider/LibraryProviderSelector.cs +++ b/Library/Provider/LibraryProviderSelector.cs @@ -253,7 +253,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return new PrintItemCollection(provider.Name, provider.ProviderKey); } - public async override Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null) + public async override Task GetPrintItemWrapperAsync(int itemIndex) { throw new NotImplementedException("Print items are not allowed at the root level"); } diff --git a/Library/Provider/LibraryProviderSqlite.cs b/Library/Provider/LibraryProviderSqlite.cs index 8434b9fbf..fc3e5d228 100644 --- a/Library/Provider/LibraryProviderSqlite.cs +++ b/Library/Provider/LibraryProviderSqlite.cs @@ -326,7 +326,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return childCollections[collectionIndex]; } - public async override Task GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null) + public async override Task GetPrintItemWrapperAsync(int index) { if (index >= 0 && index < printItems.Count) { diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index be999d781..31f7c3892 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit be999d781e8ebc75a0bf2f4859573ba508122bd4 +Subproject commit 31f7c3892342e1d28f1ca357ceb65e8fb0cdc49d