diff --git a/ActionBar/ActionBarPlus.cs b/ActionBar/ActionBarPlus.cs index 4bc8e7216..ab8afced3 100644 --- a/ActionBar/ActionBarPlus.cs +++ b/ActionBar/ActionBarPlus.cs @@ -61,9 +61,6 @@ namespace MatterHackers.MatterControl } this.AddChild(PrintStatusRow.Create(queueDataView)); this.Padding = new BorderDouble(bottom: 6); - - // Add Handlers - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); } public void ThemeChanged(object sender, EventArgs e) diff --git a/ActionBar/PrintActionRow.cs b/ActionBar/PrintActionRow.cs index 10759d871..e62925f39 100644 --- a/ActionBar/PrintActionRow.cs +++ b/ActionBar/PrintActionRow.cs @@ -289,7 +289,6 @@ namespace MatterHackers.MatterControl.ActionBar cancelConnectButton.Click += (sender, e) => { UiThread.RunOnIdle(CancelPrinting); }; reprintButton.Click += onReprintButton_Click; doneWithCurrentPartButton.Click += onDoneWithCurrentPartButton_Click; - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); } protected void DisableActiveButtons() diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 4ddd3c56a..1b9f115a0 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -253,11 +253,6 @@ namespace MatterHackers.MatterControl.ActionBar autoLevelButton.Cursor = Cursors.Hand; autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((sender, e) => - { - autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); - }, ref unregisterEvents); - PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); @@ -692,11 +687,6 @@ namespace MatterHackers.MatterControl.ActionBar autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize(); autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((sender, e) => - { - autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); - }, ref unregisterEvents); - PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent((sender, e) => { autoLevelButton.Visible = ActiveSliceSettings.Instance.GetValue(SettingsKey.print_leveling_enabled); diff --git a/ActionBar/PrinterConnectAndSelectControl.cs b/ActionBar/PrinterConnectAndSelectControl.cs index ade252546..800351cb7 100644 --- a/ActionBar/PrinterConnectAndSelectControl.cs +++ b/ActionBar/PrinterConnectAndSelectControl.cs @@ -199,7 +199,6 @@ namespace MatterHackers.MatterControl.ActionBar // Bind connect button states to active printer state this.SetConnectionButtonVisibleState(); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); } @@ -215,12 +214,6 @@ namespace MatterHackers.MatterControl.ActionBar PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(true); } - private void onActivePrinterChanged(object sender, EventArgs e) - { - connectPrinterButton.Enabled = ActiveSliceSettings.Instance.PrinterSelected; - editPrinterButton.Enabled = ActiveSliceSettings.Instance.PrinterSelected; - } - private void onConfirmStopPrint(bool messageBoxResponse) { if (messageBoxResponse) diff --git a/ActionBar/TemperatureWidgetBase.cs b/ActionBar/TemperatureWidgetBase.cs index 376c124b8..4578e5343 100644 --- a/ActionBar/TemperatureWidgetBase.cs +++ b/ActionBar/TemperatureWidgetBase.cs @@ -103,8 +103,6 @@ namespace MatterHackers.MatterControl.ActionBar this.AddChild(currentTempIndicator); this.AddChild(buttonContainer); - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); - this.MouseEnterBounds += onEnterBounds; this.MouseLeaveBounds += onLeaveBounds; this.preheatButton.Click += onPreheatButtonClick; diff --git a/ApplicationView/MenuRow/MenuOptionAction.cs b/ApplicationView/MenuRow/MenuOptionAction.cs index f7ee931cc..edd3f5ca7 100644 --- a/ApplicationView/MenuRow/MenuOptionAction.cs +++ b/ApplicationView/MenuRow/MenuOptionAction.cs @@ -20,7 +20,6 @@ namespace MatterHackers.MatterControl { Name = "Actions Menu"; - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => SetEnabledState(), ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((s,e) => SetEnabledState(), ref unregisterEvents); } diff --git a/ApplicationView/TouchscreenTabView.cs b/ApplicationView/TouchscreenTabView.cs index bdc777072..da38e7f75 100644 --- a/ApplicationView/TouchscreenTabView.cs +++ b/ApplicationView/TouchscreenTabView.cs @@ -202,8 +202,6 @@ namespace MatterHackers.MatterControl QueueData.Instance.ItemAdded.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); QueueData.Instance.ItemRemoved.RegisterEvent(NumQueueItemsChanged, ref unregisterEvents); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => ApplicationController.Instance.ReloadAdvancedControlsPanel(), ref unregisterEvents); - PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent((s, e) => { // ReloadPartPreview diff --git a/CustomWidgets/ExportPrintItemWindow.cs b/CustomWidgets/ExportPrintItemWindow.cs index b2c165ee4..ab03c58df 100644 --- a/CustomWidgets/ExportPrintItemWindow.cs +++ b/CustomWidgets/ExportPrintItemWindow.cs @@ -50,7 +50,6 @@ namespace MatterHackers.MatterControl this.Name = "Export Item Window"; CreateWindowContent(); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents); PrinterSettings.PrintLevelingEnabledChanged.RegisterEvent(ReloadAfterPrinterProfileChanged, ref unregisterEvents); } diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs index 47bcebe7a..866ca3025 100644 --- a/CustomWidgets/PartThumbnailWidget.cs +++ b/CustomWidgets/PartThumbnailWidget.cs @@ -126,7 +126,6 @@ namespace MatterHackers.MatterControl this.Click += DoOnMouseClick; this.MouseEnterBounds += onEnter; this.MouseLeaveBounds += onExit; - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); } private void DoOnMouseClick(object sender, EventArgs e) @@ -259,19 +258,6 @@ namespace MatterHackers.MatterControl } } - public void ThemeChanged(object sender, EventArgs e) - { - //Set background color to new theme - this.normalBackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; - this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; - - //Regenerate thumbnails - // The thumbnail color is currently white and does not change with this change. - // If we eventually change the thumbnail color with the theme we will need to change this. - //this.thumbNailHasBeenRequested = false; - this.Invalidate(); - } - private static ImageBuffer BuildImageFromMeshGroups(List loadedMeshGroups, string stlHashCode, Point2D size) { if (loadedMeshGroups != null diff --git a/CustomWidgets/PrintProgressBarWidget.cs b/CustomWidgets/PrintProgressBarWidget.cs index f6716ee30..0a629b67f 100644 --- a/CustomWidgets/PrintProgressBarWidget.cs +++ b/CustomWidgets/PrintProgressBarWidget.cs @@ -133,7 +133,6 @@ namespace MatterHackers.MatterControl PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(Instance_PrintItemChanged, ref unregisterEvents); - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); SetThemedColors(); UpdatePrintStatus(); diff --git a/History/PrintHistoryListItem.cs b/History/PrintHistoryListItem.cs index 9841bc712..e4b506316 100644 --- a/History/PrintHistoryListItem.cs +++ b/History/PrintHistoryListItem.cs @@ -304,7 +304,6 @@ namespace MatterHackers.MatterControl.PrintHistory private void AddHandlers() { - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); MouseEnterBounds += new EventHandler(HistoryItem_MouseEnterBounds); MouseLeaveBounds += new EventHandler(HistoryItem_MouseLeaveBounds); } diff --git a/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs index f7342955c..61f446c7f 100644 --- a/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs +++ b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs @@ -65,11 +65,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { ActiveSliceSettings.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent(CheckSettingChanged, ref unregisterEvents); -#if false - "extruder_offset", -#endif - - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => needToRecretaeBed = true, ref unregisterEvents); } private void CheckSettingChanged(object sender, EventArgs e) diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index c0eddb889..5068aed73 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -111,8 +111,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ActiveSliceSettings.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents); ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => ClearGCode(), ref unregisterEvents); - - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents); } private void CheckSettingChanged(object sender, EventArgs e) diff --git a/Queue/QueueDataWidget.cs b/Queue/QueueDataWidget.cs index dca5a5519..b4b77b32e 100644 --- a/Queue/QueueDataWidget.cs +++ b/Queue/QueueDataWidget.cs @@ -230,14 +230,6 @@ namespace MatterHackers.MatterControl.PrintQueue queueMenu = new QueueOptionsMenu(); queueMenuContainer.AddChild(queueMenu.MenuDropList); buttonPanel1.AddChild(queueMenuContainer); - - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) => - { - queueMenuContainer.RemoveAllChildren(); - // the printer changed reload the queueMenue - queueMenu = new QueueOptionsMenu(); - queueMenuContainer.AddChild(queueMenu.MenuDropList); - }, ref unregisterEvents); } allControls.AddChild(buttonPanel1); } diff --git a/Queue/QueueRowItem.cs b/Queue/QueueRowItem.cs index 34e9980d1..5c391e55c 100644 --- a/Queue/QueueRowItem.cs +++ b/Queue/QueueRowItem.cs @@ -266,7 +266,7 @@ namespace MatterHackers.MatterControl.PrintQueue this.AddChild(actionButtonContainer); - AddHandlers(); + PrintItemWrapper.SlicingOutputMessage += PrintItem_SlicingOutputMessage; } public override void OnClosed(EventArgs e) @@ -396,12 +396,6 @@ namespace MatterHackers.MatterControl.PrintQueue } } - private void AddHandlers() - { - ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents); - PrintItemWrapper.SlicingOutputMessage += PrintItem_SlicingOutputMessage; - } - private void ExportQueueItemWindow_Closed(object sender, EventArgs e) { this.exportingWindowIsOpen = false; diff --git a/SlicerConfiguration/SliceSettingsWidget.cs b/SlicerConfiguration/SliceSettingsWidget.cs index 913487cb8..81cabf353 100644 --- a/SlicerConfiguration/SliceSettingsWidget.cs +++ b/SlicerConfiguration/SliceSettingsWidget.cs @@ -205,7 +205,10 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } pageTopToBottomLayout.AddChild(topCategoryTabs); - AddHandlers(); + + PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); + PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); + SetVisibleControls(); // Make sure we are on the right tab when we create this view @@ -281,13 +284,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration private event EventHandler unregisterEvents; - private void AddHandlers() - { - PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); - ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(APP_onPrinterStatusChanged, ref unregisterEvents); - PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); - } - public override void OnClosed(EventArgs e) { unregisterEvents?.Invoke(this, null);