Show com port wizard on desktop when can't connect

Don't show com port wizard when setting up a printer
Moved onload code (first draw) to ApplicationController
getting android to have the same wizard logic as desktop
Refactored setup wizard
This commit is contained in:
Lars Brubaker 2016-07-21 13:49:22 -07:00
parent d2d315ff9f
commit e5c187c687
12 changed files with 89 additions and 75 deletions

View file

@ -436,11 +436,7 @@ namespace MatterHackers.MatterControl.ActionBar
{
if (ActiveSliceSettings.Instance == null)
{
#if __ANDROID__
WizardWindow.Show();
#else
PrinterActionRow.OpenConnectionWindow(true);
#endif
WizardWindow.ShowPrinterSetup();
}
else
{

View file

@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.ActionBar
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(ConnectToActivePrinter, ref staticUnregisterEvents);
}
WizardWindow.Show();
WizardWindow.ShowPrinterSetup();
}
public override void OnClosed(EventArgs e)
@ -143,7 +143,7 @@ namespace MatterHackers.MatterControl.ActionBar
Cursor = Cursors.Hand,
Margin = new BorderDouble(0, 6, rightMarginForWideScreenMode, 3)
};
printerSelector.AddPrinter += (s, e) => WizardWindow.Show();
printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup();
printerSelector.MinimumSize = new Vector2(printerSelector.MinimumSize.x, connectPrinterButton.MinimumSize.y);
printerSelectorAndEditButton.AddChild(printerSelector);

View file

@ -391,5 +391,43 @@ namespace MatterHackers.MatterControl
{
public bool IsAuthenticated { get; set; }
}
public void OnLoadActions()
{
ApplicationController.Instance.UserChanged();
if (false && UserSettings.Instance.get("SoftwareLicenseAccepted") != "true")
{
//UiThread.RunOnIdle(() => WizardWindow.Show<LicenseAgreementPage>("SoftwareLicense", "Software License Agreement"));
}
bool showAuthWindow = WizardWindow.ShouldShowAuthPanel?.Invoke() ?? false;
if (showAuthWindow)
{
//Launch window to prompt user to log in
UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup());
}
else
{ //If user in logged in sync before checking to prompt to create printer
ApplicationController.SyncPrinterProfiles().ContinueWith((task) =>
{
ApplicationController.Instance.ReloadAdvancedControlsPanel();
if (!ProfileManager.Instance.ActiveProfiles.Any())
{
// Start the setup wizard if no profiles exist
UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup());
}
});
}
if (ActiveSliceSettings.Instance.PrinterSelected
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.auto_connect))
{
UiThread.RunOnIdle(() =>
{
//PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
}, 2);
}
}
}
}

View file

@ -34,7 +34,7 @@ namespace MatterHackers.MatterControl
{
return new List<MenuItemAction>
{
new MenuItemAction("Add Printer".Localize(), () => WizardWindow.Show()),
new MenuItemAction("Add Printer".Localize(), () => WizardWindow.ShowPrinterSetup()),
new MenuItemAction("Add File To Queue".Localize(), importFile_Click),
new MenuItemAction("Redeem Design Code".Localize(), () => RedeemDesignCode?.Invoke(this, null)),
new MenuItemAction("Enter Share Code".Localize(), () => EnterShareCode?.Invoke(this, null)),

View file

@ -60,7 +60,8 @@ namespace MatterHackers.MatterControl
public static void GoToPrinterSettings(string widgetNameToHighlight)
{
if (PrinterConnectionAndCommunication.Instance?.ActivePrinter?.ID != null
&& ActiveSliceSettings.Instance.PrinterSelected)
&& ActiveSliceSettings.Instance.PrinterSelected
&& !WizardWindow.IsOpen("PrinterSetup"))
{
UiThread.RunOnIdle(() =>
{

View file

@ -1,5 +1,5 @@
/*
Copyright (c) 2014, Lars Brubaker, Kevin Pope
Copyright (c) 2016, Lars Brubaker, Kevin Pope
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -62,7 +62,6 @@ namespace MatterHackers.MatterControl
public class MatterControlApplication : SystemWindow
{
public static bool CameraPreviewActive = false;
public static Action AfterFirstDraw = null;
public bool RestartOnClose = false;
private static readonly Vector2 minSize = new Vector2(600, 600);
private static MatterControlApplication instance;
@ -694,7 +693,7 @@ namespace MatterHackers.MatterControl
TerminalWindow.ShowIfLeftOpen();
ApplicationController.Instance.UserChanged();
ApplicationController.Instance.OnLoadActions();
#if false
{
@ -713,32 +712,6 @@ namespace MatterHackers.MatterControl
}, 1);
}
#endif
AfterFirstDraw?.Invoke();
if (false && UserSettings.Instance.get("SoftwareLicenseAccepted") != "true")
{
UiThread.RunOnIdle(() => WizardWindow.Show<LicenseAgreementPage>("SoftwareLicense", "Software License Agreement"));
}
bool showAuthWindow = WizardWindow.ShouldShowAuthPanel?.Invoke() ?? false;
if (showAuthWindow)
{
//Launch window to prompt user to log in
UiThread.RunOnIdle(() => WizardWindow.Show());
}
else
{ //If user in logged in sync before checking to prompt to create printer
ApplicationController.SyncPrinterProfiles().ContinueWith((task) =>
{
ApplicationController.Instance.ReloadAdvancedControlsPanel();
if (!ProfileManager.Instance.ActiveProfiles.Any())
{
// Start the setup wizard if no profiles exist
UiThread.RunOnIdle(() => WizardWindow.Show());
}
});
}
}
//msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);

View file

@ -2327,7 +2327,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication
OnConnectionFailed(null);
UiNavigation.GoToPrinterSettings("com_port Edit Field");
#if !__ANDROID__
WizardWindow.ShowComPortSetup();
#endif
}
}

View file

@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
Button skipConnectionLink = linkButtonFactory.Generate(LocalizedString.Get("Skip Connection Setup"));
skipConnectionLink.Margin = new BorderDouble(0, 8);
skipConnectionLink.Click += new EventHandler(SkipConnectionLink_Click);
skipConnectionLink.Click += SkipConnectionLink_Click;
container.AddChild(printerMessageOne);
container.AddChild(printerMessageTwo);
@ -94,8 +94,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
private void SkipConnectionLink_Click(object sender, EventArgs mouseEvent)
{
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
Parent.Close();
UiThread.RunOnIdle(() => {
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
Parent.Close();
});
}
}
}

View file

@ -16,45 +16,19 @@ namespace MatterHackers.MatterControl
public static Func<bool> ShouldShowAuthPanel { get; set; }
public static Action ShowAuthDialog;
public static Action ChangeToAccountCreate;
private static WizardWindow wizardWindow = null;
private static Dictionary<string, WizardWindow> allWindows = new Dictionary<string, WizardWindow>();
private WizardWindow()
: base(500 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale)
{
this.AlwaysOnTopOfMain = true;
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
this.Padding = new BorderDouble(8);
this.ShowAsSystemWindow();
this.MinimumSize = new Vector2(350 * GuiWidget.DeviceScale, 400 * GuiWidget.DeviceScale);
}
private WizardWindow(bool openToHome = false)
: base(500 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale)
{
this.AlwaysOnTopOfMain = true;
AlwaysOnTopOfMain = true;
this.Title = "Setup Wizard".Localize();
// Todo - detect wifi connectivity
bool WifiDetected = MatterControlApplication.Instance.IsNetworkConnected();
if (!WifiDetected)
{
ChangeToPage<SetupWizardWifi>();
}
else
{
ChangeToSetupPrinterForm();
}
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
this.Padding = new BorderDouble(8);
this.ShowAsSystemWindow();
this.MinimumSize = new Vector2(350 * GuiWidget.DeviceScale, 400 * GuiWidget.DeviceScale);
}
public static void Close(string uri)
@ -81,19 +55,44 @@ namespace MatterHackers.MatterControl
wizardWindow.ChangeToPage(wizardPage);
}
public static void Show(bool openToHome = false)
public static void ShowPrinterSetup()
{
if (wizardWindow == null)
WizardWindow wizardWindow = GetWindow("PrinterSetup");
wizardWindow.Title = "Setup Wizard".Localize();
// Do the printer setup logic
// Todo - detect wifi connectivity
bool WifiDetected = MatterControlApplication.Instance.IsNetworkConnected();
if (!WifiDetected)
{
wizardWindow = new WizardWindow(openToHome);
wizardWindow.Closed += (s, e) => wizardWindow = null;
wizardWindow.ChangeToPage<SetupWizardWifi>();
}
else
{
wizardWindow.BringToFront();
wizardWindow.ChangeToSetupPrinterForm();
}
}
public static void ShowComPortSetup()
{
WizardWindow wizardWindow = GetWindow("PrinterSetup");
wizardWindow.Title = "Setup Wizard".Localize();
wizardWindow.ChangeToPage<SetupStepComPortOne>();
}
public static bool IsOpen(string uri)
{
WizardWindow wizardWindow;
if (allWindows.TryGetValue(uri, out wizardWindow))
{
return true;
}
return false;
}
private static WizardWindow GetWindow(string uri)
{
WizardWindow wizardWindow;

@ -1 +1 @@
Subproject commit 440bf80e81ee5767b75834feeaa638c3fc6f092b
Subproject commit 9ba3b557b51ef7e84ed6b64e49c8dac2f9b1bbf1

@ -1 +1 @@
Subproject commit 8bedcef1eab97b000e3d214366fb0fe1d587382a
Subproject commit 96e12d5bd3f5c1e04f6ce93eaa9ba85bd080c8d8

View file

@ -209,6 +209,9 @@
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>