2016-07-18 14:00:53 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.SetupWizard
|
|
|
|
|
|
{
|
|
|
|
|
|
public class SyncingPrintersPage: WizardPage
|
|
|
|
|
|
{
|
2016-08-22 13:46:14 -07:00
|
|
|
|
TextWidget syncingDetails;
|
2016-07-18 14:00:53 -07:00
|
|
|
|
public SyncingPrintersPage()
|
2016-09-24 10:46:47 -07:00
|
|
|
|
: base("Close")
|
2016-07-18 14:00:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
TextWidget syncingText = new TextWidget("Syncing Profiles...".Localize(),textColor: ActiveTheme.Instance.PrimaryTextColor);
|
2016-09-02 15:28:19 -07:00
|
|
|
|
syncingDetails = new TextWidget("Retrieving sync information...".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10);
|
2016-08-22 13:46:14 -07:00
|
|
|
|
syncingDetails.AutoExpandBoundsToText = true;
|
2016-07-18 14:00:53 -07:00
|
|
|
|
contentRow.AddChild(syncingText);
|
2016-08-22 13:46:14 -07:00
|
|
|
|
contentRow.AddChild(syncingDetails);
|
|
|
|
|
|
Progress<SyncReportType> progress = new Progress<SyncReportType>(ReportProgress);
|
2016-07-18 14:00:53 -07:00
|
|
|
|
|
2016-10-30 09:03:56 -07:00
|
|
|
|
ApplicationController.SyncPrinterProfiles("SyncingPrintersPage.ctor()", progress).ContinueWith((task) =>
|
2016-07-18 14:00:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (!ProfileManager.Instance.ActiveProfiles.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
// Switch to setup wizard if no profiles exist
|
|
|
|
|
|
WizardWindow.ChangeToSetupPrinterForm();
|
|
|
|
|
|
}
|
2016-07-18 17:59:44 -07:00
|
|
|
|
else if (ProfileManager.Instance.ActiveProfiles.Count() == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Set as active printer
|
|
|
|
|
|
ActiveSliceSettings.SwitchToProfile(ProfileManager.Instance.ActiveProfiles.First().ID);
|
2016-12-07 14:53:48 -08:00
|
|
|
|
// only close the window if we are not switching to the setup printer form
|
|
|
|
|
|
UiThread.RunOnIdle(WizardWindow.Close);
|
2016-07-18 17:59:44 -07:00
|
|
|
|
}
|
2016-12-07 15:49:06 -08:00
|
|
|
|
else // multiple printers - close the window
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(WizardWindow.Close);
|
|
|
|
|
|
}
|
2016-07-18 14:00:53 -07:00
|
|
|
|
});
|
|
|
|
|
|
footerRow.AddChild(new HorizontalSpacer());
|
2016-11-30 13:31:19 -08:00
|
|
|
|
footerRow.AddChild(cancelButton);
|
2016-07-18 14:00:53 -07:00
|
|
|
|
}
|
2016-08-22 13:46:14 -07:00
|
|
|
|
|
|
|
|
|
|
private void ReportProgress(SyncReportType report)
|
|
|
|
|
|
{
|
|
|
|
|
|
syncingDetails.Text = report.actionLabel;
|
|
|
|
|
|
}
|
2016-07-18 14:00:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|