Ensure printers can only be opened into a single tab
This commit is contained in:
parent
f4928a84bf
commit
66a1c5c0e4
3 changed files with 19 additions and 15 deletions
|
|
@ -2034,6 +2034,21 @@ namespace MatterHackers.MatterControl
|
|||
return null;
|
||||
}
|
||||
|
||||
public void OpenPrinter(PrinterInfo printerInfo)
|
||||
{
|
||||
if (this.ActivePrinters.FirstOrDefault(p => p.Settings.ID == printerInfo.ID) is PrinterConfig printer
|
||||
&& this.MainView.TabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerTabPage && printerTabPage.printer == printer) is ITab tab)
|
||||
{
|
||||
// Switch to existing printer tab
|
||||
this.MainView.TabControl.ActiveTab = tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Open new printer tab
|
||||
this.OpenEmptyPrinter(printerInfo.ID).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenWorkspace(PartWorkspace workspace)
|
||||
{
|
||||
this.OnWorkspacesChanged(
|
||||
|
|
|
|||
|
|
@ -103,17 +103,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
{
|
||||
if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo)
|
||||
{
|
||||
if (ApplicationController.Instance.ActivePrinters.FirstOrDefault(p => p.Settings.ID == printerInfo.ID) is PrinterConfig printer
|
||||
&& ApplicationController.Instance.MainView.TabControl.AllTabs.FirstOrDefault(t => t.TabContent is PrinterTabPage printerTabPage && printerTabPage.printer == printer) is ITab tab)
|
||||
{
|
||||
// Switch to existing printer tab
|
||||
ApplicationController.Instance.MainView.TabControl.ActiveTab = tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Open new printer tab
|
||||
ApplicationController.Instance.OpenEmptyPrinter(printerInfo.ID).ConfigureAwait(false);
|
||||
}
|
||||
ApplicationController.Instance.OpenPrinter(printerInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -129,12 +119,11 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
var menu = new PopupMenu(ApplicationController.Instance.MenuTheme);
|
||||
|
||||
var openMenuItem = menu.CreateMenuItem("Open".Localize());
|
||||
openMenuItem.Click += async (s2, e2) =>
|
||||
openMenuItem.Click += (s2, e2) =>
|
||||
{
|
||||
if (treeView?.SelectedNode.Tag is PrinterInfo printerInfo)
|
||||
{
|
||||
// Open printer
|
||||
await ApplicationController.Instance.OpenEmptyPrinter(printerInfo.ID);
|
||||
ApplicationController.Instance.OpenPrinter(printerInfo);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage
|
|||
};
|
||||
openButton.Click += (s, e) =>
|
||||
{
|
||||
ApplicationController.Instance.OpenEmptyPrinter(printerInfo.ID).ConfigureAwait(false);
|
||||
ApplicationController.Instance.OpenPrinter(printerInfo);
|
||||
};
|
||||
headingRow.AddChild(openButton);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue