DownloadPrinterProfile should return an instance of PrinterSettings

- Persistence of profile moves to caller
 - Rename to GetPrinterProfileAsync
 - Expose PrinterSettings.Save for use in external assemblies
 - Issue MatterHackers/MCCentral#227,  MatterHackers/MCCentral#242
This commit is contained in:
John Lewin 2016-07-28 09:38:03 -07:00
parent 48518f4314
commit 43e94f6ed4
4 changed files with 22 additions and 17 deletions

View file

@ -185,7 +185,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private string DocumentPath => ProfileManager.Instance.ProfilePath(this.ID);
internal void Save()
public void Save()
{
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
@ -325,12 +325,16 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
string profileToken = recentProfileHistoryItems.OrderByDescending(kvp => kvp.Key).FirstOrDefault().Value;
// Download the specified json profile
await ApplicationController.GetPrinterProfile(profile, profileToken);
// Update the active instance to the newly downloaded item
var printerProfile = ProfileManager.LoadProfile(profile.ID, false);
ActiveSliceSettings.RefreshActiveInstance(printerProfile);
// Download the specified json profile and persist and activate if successful
var printerProfile = await ApplicationController.GetPrinterProfileAsync(profile, profileToken);
if (printerProfile != null)
{
// Persist downloaded profile
printerProfile.Save();
// Update active instance without calling ReloadAll
ActiveSliceSettings.RefreshActiveInstance(printerProfile);
}
}
}