From d4b471842b78a85295e754d79a37463cd8f0325c Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 14 Jul 2015 16:16:58 -0700 Subject: [PATCH] Made the GetPrintItemWrapperAsync take an optional ReportProgressRatio. Made it possible to show the wrapper loading progress. Made the ray trace images more white. --- CustomWidgets/ThumbnailTracer.cs | 2 +- Library/LibraryDataView.cs | 2 +- Library/LibraryRowItem.cs | 1 + Library/LibraryRowItemPart.cs | 20 ++++++++++++++++++- Library/Provider/LibraryProvider.cs | 2 +- Library/Provider/LibraryProviderFileSystem.cs | 2 +- Library/Provider/LibraryProviderSelector.cs | 2 +- Library/Provider/LibraryProviderSqlite.cs | 2 +- 8 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CustomWidgets/ThumbnailTracer.cs b/CustomWidgets/ThumbnailTracer.cs index ffd476256..d3ff385a5 100644 --- a/CustomWidgets/ThumbnailTracer.cs +++ b/CustomWidgets/ThumbnailTracer.cs @@ -323,7 +323,7 @@ namespace MatterHackers.RayTracer scene = new Scene(); scene.camera = new TrackBallCamera(trackballTumbleWidget); //scene.background = new Background(new RGBA_Floats(0.5, .5, .5), 0.4); - scene.background = new Background(new RGBA_Floats(0, 0, 0, 0), 0.4); + scene.background = new Background(new RGBA_Floats(1, 1, 1, 0), 0.6); AddTestMesh(loadedMeshGroups); diff --git a/Library/LibraryDataView.cs b/Library/LibraryDataView.cs index 7825c4245..c56484b93 100644 --- a/Library/LibraryDataView.cs +++ b/Library/LibraryDataView.cs @@ -261,7 +261,7 @@ namespace MatterHackers.MatterControl.PrintLibrary { if (SelectedIndex >= 0) { - return LibraryDataView.CurrentLibraryProvider.GetPrintItemWrapper(SelectedIndex); + return LibraryDataView.CurrentLibraryProvider.GetPrintItemWrapperAsync(SelectedIndex).Result; } else { diff --git a/Library/LibraryRowItem.cs b/Library/LibraryRowItem.cs index 9f69c16c0..e7be5c03b 100644 --- a/Library/LibraryRowItem.cs +++ b/Library/LibraryRowItem.cs @@ -213,6 +213,7 @@ namespace MatterHackers.MatterControl.PrintLibrary mainContainer.AddChild(rightButtonOverlay); } this.AddChild(mainContainer); + AddHandlers(); } diff --git a/Library/LibraryRowItemPart.cs b/Library/LibraryRowItemPart.cs index 6a81dcfad..fd4873081 100644 --- a/Library/LibraryRowItemPart.cs +++ b/Library/LibraryRowItemPart.cs @@ -62,6 +62,8 @@ namespace MatterHackers.MatterControl.PrintLibrary this.itemIndex = itemIndex; CreateGuiElements(); + + AddLoadingProgressBar(); } public override bool Protected @@ -76,12 +78,28 @@ namespace MatterHackers.MatterControl.PrintLibrary { if (printItemInstance == null) { - printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.itemIndex); + printItemInstance = await libraryProvider.GetPrintItemWrapperAsync(this.itemIndex, ReportProgressRatio); } return printItemInstance; } + void ReportProgressRatio(double progress0To1, string processingState, out bool continueProcessing) + { + continueProcessing = true; + processingProgressControl.RatioComplete = progress0To1; + } + + ProgressBar processingProgressControl; + private void AddLoadingProgressBar() + { + processingProgressControl = new ProgressBar(ActiveTheme.Instance.SecondaryAccentColor, 10, 5); + processingProgressControl.BorderColor = new RGBA_Bytes(); + processingProgressControl.VAnchor = VAnchor.ParentBottom; + processingProgressControl.HAnchor = HAnchor.ParentLeftRight; + this.AddChild(processingProgressControl); + } + public async override void AddToQueue() { // create a new item that will be only in the queue diff --git a/Library/Provider/LibraryProvider.cs b/Library/Provider/LibraryProvider.cs index c89eee0ce..ac1c2c6c5 100644 --- a/Library/Provider/LibraryProvider.cs +++ b/Library/Provider/LibraryProvider.cs @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider public abstract PrintItemCollection GetCollectionItem(int collectionIndex); - public abstract Task GetPrintItemWrapperAsync(int itemIndex); + public abstract Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null); public abstract LibraryProvider GetProviderForItem(PrintItemCollection collection); diff --git a/Library/Provider/LibraryProviderFileSystem.cs b/Library/Provider/LibraryProviderFileSystem.cs index 928125fc7..3b498dd1e 100644 --- a/Library/Provider/LibraryProviderFileSystem.cs +++ b/Library/Provider/LibraryProviderFileSystem.cs @@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return Path.GetFileName(currentDirectoryFiles[itemIndex]); } - public async override Task GetPrintItemWrapperAsync(int itemIndex) + public async override Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null) { string fileName = currentDirectoryFiles[itemIndex]; diff --git a/Library/Provider/LibraryProviderSelector.cs b/Library/Provider/LibraryProviderSelector.cs index a5bf33b67..cd23705d5 100644 --- a/Library/Provider/LibraryProviderSelector.cs +++ b/Library/Provider/LibraryProviderSelector.cs @@ -214,7 +214,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return new PrintItemCollection(provider.Name, provider.ProviderKey); } - public async override Task GetPrintItemWrapperAsync(int itemIndex) + public async override Task GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null) { 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 2d4f3dfbd..e885c10f1 100644 --- a/Library/Provider/LibraryProviderSqlite.cs +++ b/Library/Provider/LibraryProviderSqlite.cs @@ -306,7 +306,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider return childCollections[collectionIndex]; } - public async override Task GetPrintItemWrapperAsync(int index) + public async override Task GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null) { if (index >= 0 && index < printItems.Count) {