Move event registration to bottom of constructor
This commit is contained in:
parent
5cb1804f94
commit
efe22f8dfd
1 changed files with 35 additions and 35 deletions
|
|
@ -199,43 +199,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
tabControl.TabBar.ActionArea.AddChild(updateAvailableButton);
|
||||
|
||||
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
SetLinkButtonsVisibility(s, new StringEventArgs("Unknown"));
|
||||
}, ref unregisterEvents);
|
||||
|
||||
this.AddChild(tabControl);
|
||||
|
||||
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
if (e is StringEventArgs stringEvent
|
||||
&& stringEvent.Data == SettingsKey.printer_name
|
||||
&& printerTab != null)
|
||||
{
|
||||
printerTab.Text = activePrinter.Settings.GetValue(SettingsKey.printer_name);
|
||||
}
|
||||
|
||||
}, ref unregisterEvents);
|
||||
|
||||
ApplicationController.Instance.ActivePrinterChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
// If ActivePrinter has been nulled and a printer tab is open, close it
|
||||
var tab1 = tabControl.AllTabs.Skip(1).FirstOrDefault();
|
||||
if ((activePrinter == null || !activePrinter.Settings.PrinterSelected)
|
||||
&& tab1?.TabContent is PrinterTabPage)
|
||||
{
|
||||
tabControl.RemoveTab(tab1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CreatePrinterTab(activePrinter, theme);
|
||||
}
|
||||
}, ref unregisterEvents);
|
||||
|
||||
ApplicationController.Instance.NotifyPrintersTabRightElement(extensionArea);
|
||||
|
||||
// Add a tab for the current printer
|
||||
|
|
@ -292,6 +257,41 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.CreatePartTab("New Part", bed, theme);
|
||||
}
|
||||
|
||||
UpdateControlData.Instance.UpdateStatusChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
SetLinkButtonsVisibility(s, new StringEventArgs("Unknown"));
|
||||
}, ref unregisterEvents);
|
||||
|
||||
PrinterSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
if (e is StringEventArgs stringEvent
|
||||
&& stringEvent.Data == SettingsKey.printer_name
|
||||
&& printerTab != null)
|
||||
{
|
||||
printerTab.Text = activePrinter.Settings.GetValue(SettingsKey.printer_name);
|
||||
}
|
||||
|
||||
}, ref unregisterEvents);
|
||||
|
||||
ApplicationController.Instance.ActivePrinterChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
var activePrinter = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
// If ActivePrinter has been nulled and a printer tab is open, close it
|
||||
var tab1 = tabControl.AllTabs.Skip(1).FirstOrDefault();
|
||||
if ((activePrinter == null || !activePrinter.Settings.PrinterSelected)
|
||||
&& tab1?.TabContent is PrinterTabPage)
|
||||
{
|
||||
tabControl.RemoveTab(tab1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CreatePrinterTab(activePrinter, theme);
|
||||
}
|
||||
}, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public ChromeTabs TabControl => tabControl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue