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;
|
2017-10-18 14:56:10 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
2016-07-18 14:00:53 -07:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2017-08-23 15:51:29 -07:00
|
|
|
|
this.WindowTitle = "Sync Printer Profiles Page".Localize();
|
|
|
|
|
|
|
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);
|
2017-10-25 01:57:45 -06:00
|
|
|
|
Progress<ProgressStatus> progress = new Progress<ProgressStatus>(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
|
2017-10-18 14:56:10 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2017-10-20 06:11:24 -07:00
|
|
|
|
this.WizardWindow.ChangeToPage(PrinterSetup.GetBestStartPage());
|
2017-10-18 14:56:10 -07:00
|
|
|
|
});
|
2016-07-18 14:00:53 -07:00
|
|
|
|
}
|
2016-07-18 17:59:44 -07:00
|
|
|
|
else if (ProfileManager.Instance.ActiveProfiles.Count() == 1)
|
|
|
|
|
|
{
|
2017-09-23 14:44:43 -07:00
|
|
|
|
// TODO: Investigate what this was doing and re-implement
|
|
|
|
|
|
//ActiveSliceSettings.ShowComPortConnectionHelp();
|
|
|
|
|
|
|
2016-07-18 17:59:44 -07:00
|
|
|
|
//Set as active printer
|
2017-09-23 14:44:43 -07:00
|
|
|
|
ProfileManager.SwitchToProfile(ProfileManager.Instance.ActiveProfiles.First().ID).ConfigureAwait(false);
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
|
}
|
2016-08-22 13:46:14 -07:00
|
|
|
|
|
2017-10-25 01:57:45 -06:00
|
|
|
|
private void ReportProgress(ProgressStatus report)
|
2016-08-22 13:46:14 -07:00
|
|
|
|
{
|
2017-10-25 01:57:45 -06:00
|
|
|
|
syncingDetails.Text = report.Status;
|
2016-08-22 13:46:14 -07:00
|
|
|
|
}
|
2016-07-18 14:00:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|