diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index b2b865aac..953503066 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -181,7 +181,7 @@ namespace MatterHackers.MatterControl public static Func>> GetProfileHistory; public static Func> GetPrinterProfileAsync; - public static Func SyncPrinterProfiles; + public static Func,Task> SyncPrinterProfiles; public static Func> GetPublicProfileList; public static Func> DownloadPublicProfileAsync; @@ -510,7 +510,7 @@ namespace MatterHackers.MatterControl } else { - ApplicationController.SyncPrinterProfiles.Invoke().ContinueWith((task) => + ApplicationController.SyncPrinterProfiles.Invoke(null).ContinueWith((task) => { RunSetupIfRequired(); }); @@ -574,4 +574,10 @@ namespace MatterHackers.MatterControl PrintLibraryWidget.Reload(); } } + + public class SyncReportType + { + public string actionLabel; + public double percComplete; + } } \ No newline at end of file diff --git a/SettingsManagement/OemSettings.cs b/SettingsManagement/OemSettings.cs index 8062e507a..735c3c84c 100644 --- a/SettingsManagement/OemSettings.cs +++ b/SettingsManagement/OemSettings.cs @@ -155,7 +155,7 @@ namespace MatterHackers.MatterControl.SettingsManagement SetManufacturers(manufacturesList); } - public async Task ReloadOemProfiles() + public async Task ReloadOemProfiles(IProgress syncReport = null) { // In public builds this won't be assigned to and we should abort and exit early if (ApplicationController.GetPublicProfileList == null) @@ -176,16 +176,18 @@ namespace MatterHackers.MatterControl.SettingsManagement var manufactures = oemProfiles.Keys.ToDictionary(oem => oem); SetManufacturers(manufactures); - await DownloadMissingProfiles(); + await DownloadMissingProfiles(syncReport); } } - private async Task DownloadMissingProfiles() + private async Task DownloadMissingProfiles(IProgress syncReport) { string cacheDirectory = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles"); - + SyncReportType reportValue = new SyncReportType(); + int index = 0; foreach (string oem in OemProfiles.Keys) { + index++; foreach (string profileKey in OemProfiles[oem].Values) { string cacheKey = profileKey + ProfileManager.ProfileExtension; @@ -200,7 +202,14 @@ namespace MatterHackers.MatterControl.SettingsManagement { File.WriteAllText(cachePath, profileJson); } + if (syncReport != null) + { + reportValue.actionLabel = String.Format("Downloading public profiles for {0}...", oem); + reportValue.percComplete = (double)index / OemProfiles.Count; + syncReport.Report(reportValue); + } } + } } } diff --git a/SetupWizard/SyncingPrintersPage.cs b/SetupWizard/SyncingPrintersPage.cs index 8e196c9cc..821049b23 100644 --- a/SetupWizard/SyncingPrintersPage.cs +++ b/SetupWizard/SyncingPrintersPage.cs @@ -12,12 +12,17 @@ namespace MatterHackers.MatterControl.SetupWizard { public class SyncingPrintersPage: WizardPage { + TextWidget syncingDetails; public SyncingPrintersPage() { TextWidget syncingText = new TextWidget("Syncing Profiles...".Localize(),textColor: ActiveTheme.Instance.PrimaryTextColor); + syncingDetails = new TextWidget("Retreiving sync information...".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10); + syncingDetails.AutoExpandBoundsToText = true; contentRow.AddChild(syncingText); + contentRow.AddChild(syncingDetails); + Progress progress = new Progress(ReportProgress); - ApplicationController.SyncPrinterProfiles().ContinueWith((task) => + ApplicationController.SyncPrinterProfiles(progress).ContinueWith((task) => { if (!ProfileManager.Instance.ActiveProfiles.Any()) { @@ -34,5 +39,10 @@ namespace MatterHackers.MatterControl.SetupWizard footerRow.AddChild(new HorizontalSpacer()); footerRow.AddChild(cancelButton); } + + private void ReportProgress(SyncReportType report) + { + syncingDetails.Text = report.actionLabel; + } } } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 7b416302e..db851917f 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -5323,3 +5323,6 @@ Translated:When this is checked MatterControl will attempt to resume a print in English:Minimum Travel Requiring Retraction Translated:Minimum Travel Requiring Retraction +English:Retreiving sync information... +Translated:Retreiving sync information... +