Making the progress registration per item and more flexable.
This commit is contained in:
parent
a378551c69
commit
bc1f45f8b8
8 changed files with 40 additions and 11 deletions
|
|
@ -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<PrintItemWrapper> 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;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
|
||||
public abstract PrintItemCollection GetCollectionItem(int collectionIndex);
|
||||
|
||||
public abstract Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null);
|
||||
public abstract Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex);
|
||||
|
||||
// TODO: make this asnyc
|
||||
//public abstract Task<LibraryProvider> GetProviderForCollectionAsync(PrintItemCollection collection);
|
||||
|
|
@ -182,6 +182,30 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return GetProviderForCollection(GetCollectionItem(collectionIndex)).CollectionCount;
|
||||
}
|
||||
|
||||
protected Dictionary<int, ReportProgressRatio> itemReportProgressHandlers = new Dictionary<int, ReportProgressRatio>();
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return Path.GetFileName(currentDirectoryFiles[itemIndex]);
|
||||
}
|
||||
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null)
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex)
|
||||
{
|
||||
string fileName = currentDirectoryFiles[itemIndex];
|
||||
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return childCollections[collectionIndex];
|
||||
}
|
||||
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null)
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//return PrintHistoryData.Instance.GetPrintItemWrapper(index);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return childCollections[collectionIndex];
|
||||
}
|
||||
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null)
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index)
|
||||
{
|
||||
return QueueData.Instance.GetPrintItemWrapper(index);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return new PrintItemCollection(provider.Name, provider.ProviderKey);
|
||||
}
|
||||
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex, ReportProgressRatio reportProgress = null)
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int itemIndex)
|
||||
{
|
||||
throw new NotImplementedException("Print items are not allowed at the root level");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ namespace MatterHackers.MatterControl.PrintLibrary.Provider
|
|||
return childCollections[collectionIndex];
|
||||
}
|
||||
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index, ReportProgressRatio reportProgress = null)
|
||||
public async override Task<PrintItemWrapper> GetPrintItemWrapperAsync(int index)
|
||||
{
|
||||
if (index >= 0 && index < printItems.Count)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit be999d781e8ebc75a0bf2f4859573ba508122bd4
|
||||
Subproject commit 31f7c3892342e1d28f1ca357ceb65e8fb0cdc49d
|
||||
Loading…
Add table
Add a link
Reference in a new issue