Add option to show WizardWindow with active WizardPage instance
- Extract logic to find or create window to new function - GetWindow - Reuse GetWindow in Show<T> and new Show(WizardPage)
This commit is contained in:
parent
23092bec7d
commit
d3840bf98c
1 changed files with 27 additions and 14 deletions
|
|
@ -80,21 +80,16 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public static void Show<PanelType>(string uri, string title) where PanelType : WizardPage, new()
|
||||
{
|
||||
WizardWindow existingWindow;
|
||||
WizardWindow wizardWindow = GetWindow(uri);
|
||||
wizardWindow.Title = title;
|
||||
wizardWindow.ChangeToPage<PanelType>();
|
||||
}
|
||||
|
||||
if (allWindows.TryGetValue(uri, out existingWindow))
|
||||
{
|
||||
existingWindow.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
existingWindow = new WizardWindow();
|
||||
existingWindow.Closed += (s, e) => allWindows.Remove(uri);
|
||||
allWindows[uri] = existingWindow;
|
||||
}
|
||||
|
||||
existingWindow.Title = title;
|
||||
existingWindow.ChangeToPage<PanelType>();
|
||||
public static void Show(string uri, string title, WizardPage wizardPage)
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow(uri);
|
||||
wizardWindow.Title = title;
|
||||
wizardWindow.ChangeToPage(wizardPage);
|
||||
}
|
||||
|
||||
public static void Show(bool openToHome = false)
|
||||
|
|
@ -110,6 +105,24 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private static WizardWindow GetWindow(string uri)
|
||||
{
|
||||
WizardWindow wizardWindow;
|
||||
|
||||
if (allWindows.TryGetValue(uri, out wizardWindow))
|
||||
{
|
||||
wizardWindow.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
wizardWindow = new WizardWindow();
|
||||
wizardWindow.Closed += (s, e) => allWindows.Remove(uri);
|
||||
allWindows[uri] = wizardWindow;
|
||||
}
|
||||
|
||||
return wizardWindow;
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue