Revise WizardWindow api
- WizardPage instance should drive window namespace and title - Key open windows page initial WizardPage type
This commit is contained in:
parent
c27b6ec62d
commit
559c300cb4
32 changed files with 113 additions and 55 deletions
|
|
@ -109,7 +109,10 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
//Construct buttons
|
||||
troubleshootButton = whiteImageButtonFactory.Generate("Troubleshoot".Localize());
|
||||
troubleshootButton.Click += (s, e) => UiThread.RunOnIdle(WizardWindow.ChangeToPage<SetupWizardTroubleshooting>);
|
||||
troubleshootButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupWizardTroubleshooting>();
|
||||
});
|
||||
|
||||
retryButtonContainer = new FlowLayoutWidget()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ namespace MatterHackers.MatterControl
|
|||
public SetupOptionsPage()
|
||||
: base("Done")
|
||||
{
|
||||
this.WindowTitle = "Setup Wizard".Localize();
|
||||
|
||||
headerLabel.Text = "Setup Options".Localize();
|
||||
|
||||
contentRow.AddChild(new SetupPrinterView(this.textImageButtonFactory) { WizardPage = this });
|
||||
|
|
@ -102,7 +104,10 @@ namespace MatterHackers.MatterControl
|
|||
disconnectButton.Click += (sender, e) =>
|
||||
{
|
||||
PrinterConnection.Instance.Disable();
|
||||
UiThread.RunOnIdle(WizardPage.WizardWindow.ChangeToPage<SetupOptionsPage>);
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardPage.WizardWindow.ChangeToPage<SetupOptionsPage>();
|
||||
});
|
||||
};
|
||||
buttonContainer.AddChild(disconnectButton);
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ namespace MatterHackers.MatterControl
|
|||
public CopyGuestProfilesToUser()
|
||||
: base("Close", "Copy Printers to Account")
|
||||
{
|
||||
this.WindowTitle = "Copy Printers".Localize();
|
||||
|
||||
var scrollWindow = new ScrollableWidget()
|
||||
{
|
||||
AutoScroll = true,
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace MatterHackers.MatterControl
|
|||
public ExportSettingsPage() :
|
||||
base("Cancel", "Export As")
|
||||
{
|
||||
this.WindowTitle = "Export Settings".Localize();
|
||||
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
|
|
|
|||
|
|
@ -286,6 +286,8 @@ namespace MatterHackers.MatterControl
|
|||
public ImportSettingsPage() :
|
||||
base("Cancel", "Import Wizard")
|
||||
{
|
||||
this.WindowTitle = "Import Settings Page".Localize();
|
||||
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ public class LicenseAgreementPage : WizardPage
|
|||
{
|
||||
public LicenseAgreementPage()
|
||||
{
|
||||
this.WindowTitle = "Software License Agreement".Localize();
|
||||
|
||||
string eulaText = AggContext.StaticData.ReadAllText("MatterControl EULA.txt").Replace("\r\n", "\n");
|
||||
|
||||
var scrollable = new ScrollableWidget(true);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ namespace MatterHackers.MatterControl.SetupWizard
|
|||
public PrinterProfileHistoryPage()
|
||||
: base(unlocalizedTextForTitle: "Restore Settings")
|
||||
{
|
||||
this.WindowTitle = "Restore Settings".Localize();
|
||||
|
||||
scrollWindow = new ScrollableWidget()
|
||||
{
|
||||
AutoScroll = true,
|
||||
|
|
|
|||
|
|
@ -40,11 +40,16 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public SetupWizardTroubleshooting()
|
||||
{
|
||||
this.WindowTitle = "Troubleshooting".Localize();
|
||||
|
||||
RefreshStatus();
|
||||
|
||||
//Construct buttons
|
||||
cancelButton = whiteImageButtonFactory.Generate("Cancel".Localize());
|
||||
cancelButton.Click += (s, e) => UiThread.RunOnIdle(this.WizardWindow.ChangeToPage<AndroidConnectDevicePage>);
|
||||
cancelButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
this.WizardWindow.ChangeToPage<AndroidConnectDevicePage>();
|
||||
});
|
||||
|
||||
//Construct buttons
|
||||
nextButton = textImageButtonFactory.Generate("Continue".Localize());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ namespace MatterHackers.MatterControl.SetupWizard
|
|||
public SyncingPrintersPage()
|
||||
: base("Close")
|
||||
{
|
||||
this.WindowTitle = "Sync Printer Profiles Page".Localize();
|
||||
|
||||
TextWidget syncingText = new TextWidget("Syncing Profiles...".Localize(),textColor: ActiveTheme.Instance.PrimaryTextColor);
|
||||
syncingDetails = new TextWidget("Retrieving sync information...".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize:10);
|
||||
syncingDetails.AutoExpandBoundsToText = true;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ namespace MatterHackers.MatterControl
|
|||
this.AddChild(mainContainer);
|
||||
}
|
||||
|
||||
public string WindowTitle { get; set; }
|
||||
|
||||
public virtual void PageIsBecomingActive()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace MatterHackers.MatterControl
|
|||
public static Action ShowAuthDialog;
|
||||
public static Action ChangeToAccountCreate;
|
||||
|
||||
private static Dictionary<string, WizardWindow> allWindows = new Dictionary<string, WizardWindow>();
|
||||
private static Dictionary<Type, WizardWindow> allWindows = new Dictionary<Type, WizardWindow>();
|
||||
|
||||
private WizardWindow()
|
||||
: base(500 * GuiWidget.DeviceScale, 500 * GuiWidget.DeviceScale)
|
||||
|
|
@ -33,33 +33,33 @@ namespace MatterHackers.MatterControl
|
|||
this.ShowAsSystemWindow();
|
||||
}
|
||||
|
||||
public static void Close(string uri)
|
||||
public static void Close(Type type)
|
||||
{
|
||||
WizardWindow existingWindow;
|
||||
|
||||
if (allWindows.TryGetValue(uri, out existingWindow))
|
||||
if (allWindows.TryGetValue(type, out existingWindow))
|
||||
{
|
||||
existingWindow.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Show<PanelType>(string uri, string title) where PanelType : WizardPage, new()
|
||||
public static void Show<PanelType>() where PanelType : WizardPage, new()
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow(uri);
|
||||
wizardWindow.Title = title;
|
||||
wizardWindow.ChangeToPage<PanelType>();
|
||||
WizardWindow wizardWindow = GetWindow(typeof(PanelType));
|
||||
var newPanel = wizardWindow.ChangeToPage<PanelType>();
|
||||
wizardWindow.Title = newPanel.WindowTitle;
|
||||
}
|
||||
|
||||
public static void Show(string uri, string title, WizardPage wizardPage)
|
||||
public static void Show(WizardPage wizardPage)
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow(uri);
|
||||
wizardWindow.Title = title;
|
||||
WizardWindow wizardWindow = GetWindow(wizardPage.GetType());
|
||||
wizardWindow.Title = wizardPage.WindowTitle;
|
||||
wizardWindow.ChangeToPage(wizardPage);
|
||||
}
|
||||
|
||||
public static void ShowPrinterSetup(bool userRequestedNewPrinter = false)
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow("PrinterSetup");
|
||||
WizardWindow wizardWindow = GetWindow(typeof(SetupStepComPortOne));
|
||||
wizardWindow.Title = "Setup Wizard".Localize();
|
||||
|
||||
// Do the printer setup logic
|
||||
|
|
@ -77,17 +77,17 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public static void ShowComPortSetup()
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow("PrinterSetup");
|
||||
WizardWindow wizardWindow = GetWindow(typeof(SetupStepComPortOne));
|
||||
wizardWindow.Title = "Setup Wizard".Localize();
|
||||
|
||||
wizardWindow.ChangeToPage<SetupStepComPortOne>();
|
||||
}
|
||||
|
||||
public static bool IsOpen(string uri)
|
||||
public static bool IsOpen(Type type)
|
||||
{
|
||||
WizardWindow wizardWindow;
|
||||
|
||||
if (allWindows.TryGetValue(uri, out wizardWindow))
|
||||
if (allWindows.TryGetValue(type, out wizardWindow))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -95,19 +95,19 @@ namespace MatterHackers.MatterControl
|
|||
return false;
|
||||
}
|
||||
|
||||
private static WizardWindow GetWindow(string uri)
|
||||
private static WizardWindow GetWindow(Type type)
|
||||
{
|
||||
WizardWindow wizardWindow;
|
||||
|
||||
if (allWindows.TryGetValue(uri, out wizardWindow))
|
||||
if (allWindows.TryGetValue(type, out wizardWindow))
|
||||
{
|
||||
wizardWindow.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
wizardWindow = new WizardWindow();
|
||||
wizardWindow.Closed += (s, e) => allWindows.Remove(uri);
|
||||
allWindows[uri] = wizardWindow;
|
||||
wizardWindow.Closed += (s, e) => allWindows.Remove(type);
|
||||
allWindows[type] = wizardWindow;
|
||||
}
|
||||
|
||||
return wizardWindow;
|
||||
|
|
@ -166,7 +166,7 @@ namespace MatterHackers.MatterControl
|
|||
this.Invalidate();
|
||||
}
|
||||
|
||||
internal void ChangeToPage<PanelType>() where PanelType : WizardPage, new()
|
||||
internal WizardPage ChangeToPage<PanelType>() where PanelType : WizardPage, new()
|
||||
{
|
||||
PanelType panel = new PanelType();
|
||||
panel.WizardWindow = this;
|
||||
|
|
@ -189,6 +189,8 @@ namespace MatterHackers.MatterControl
|
|||
// remember the new content
|
||||
panel = newPanel;
|
||||
}, ref unregisterEvents);
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue