Revise close on printer change logic
- Issue MatterHackers/MCCentral#4305 Multiple printer tabs appear
This commit is contained in:
parent
5ca295385e
commit
4abc1de7c6
1 changed files with 10 additions and 11 deletions
|
|
@ -328,21 +328,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
// If ActivePrinter has been nulled and a printer tab is open, close it
|
||||
var tab1 = tabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage);
|
||||
if ((activePrinter == null || !activePrinter.Settings.PrinterSelected)
|
||||
&& tab1 != null)
|
||||
// Close existing printer tabs
|
||||
if (tabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage) is ITab tab
|
||||
&& tab.TabContent is PrinterTabPage printerPage
|
||||
&& (activePrinter == null || printerPage.printer != activePrinter))
|
||||
{
|
||||
tabControl.RemoveTab(tab1);
|
||||
tabControl.RemoveTab(tab);
|
||||
}
|
||||
else
|
||||
|
||||
if (activePrinter.Settings.PrinterSelected)
|
||||
{
|
||||
if (activePrinter.Settings.PrinterSelected)
|
||||
{
|
||||
// Create and switch to new printer tab
|
||||
tabControl.ActiveTab = this.CreatePrinterTab(activePrinter, theme);
|
||||
}
|
||||
// Create and switch to new printer tab
|
||||
tabControl.ActiveTab = this.CreatePrinterTab(activePrinter, theme);
|
||||
}
|
||||
|
||||
|
||||
tabControl.RefreshTabPointers();
|
||||
}, ref unregisterEvents);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue