diff --git a/MatterControl.Winforms/InspectForm.cs b/MatterControl.Winforms/InspectForm.cs index aeea318b8..1ebac80ed 100644 --- a/MatterControl.Winforms/InspectForm.cs +++ b/MatterControl.Winforms/InspectForm.cs @@ -360,7 +360,7 @@ namespace MatterHackers.MatterControl allowDisabledOrHidden: false); // If the context changed, update the UI - if (namedChildren.LastOrDefault()?.widget is GuiWidget firstUnderMouse + if (namedChildren.LastOrDefault()?.Widget is GuiWidget firstUnderMouse && firstUnderMouse != this.InspectedWidget) { this.InspectedWidget = firstUnderMouse; diff --git a/MatterControlLib/AboutPage/UpdateControlData.cs b/MatterControlLib/AboutPage/UpdateControlData.cs index 93a565817..df35b080b 100644 --- a/MatterControlLib/AboutPage/UpdateControlData.cs +++ b/MatterControlLib/AboutPage/UpdateControlData.cs @@ -411,7 +411,7 @@ namespace MatterHackers.MatterControl SystemWindow topSystemWindow = AppContext.RootSystemWindow; if (topSystemWindow != null) { - topSystemWindow.CloseOnIdle(); + topSystemWindow.Close(); return true; } #endif diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 6dc1c5bac..df3bedadf 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -2194,7 +2194,7 @@ namespace MatterHackers.MatterControl } catch (Exception ex) { - reloadingOverlay?.CloseOnIdle(); + reloadingOverlay?.Close(); UiThread.RunOnIdle(() => { @@ -3930,7 +3930,7 @@ Support and tutorials: ReportStartupProgress(0.02, "First draw->RunOnIdle"); //UiThread.RunOnIdle(() => - Task.Run(async () => + Task.Run((Func)(async () => { try { @@ -3952,7 +3952,7 @@ Support and tutorials: } catch (Exception ex) { - UiThread.RunOnIdle(() => + UiThread.RunOnIdle((Action)(() => { statusText.Visible = false; @@ -3988,11 +3988,11 @@ Support and tutorials: progressBar.Visible = false; progressPanel.AddChild(closeButton); - }); + })); } AppContext.IsLoading = false; - }); + })); } ReportStartupProgress(0, "ShowAsSystemWindow"); diff --git a/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs b/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs index 11854e2b0..3bf427f0c 100644 --- a/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs +++ b/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs @@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl saveButton.Click += (s,e) => { ApplicationController.Plugins.Save(); - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); }; this.AddPageAction(saveButton); diff --git a/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs b/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs index fa5124620..5ddbea63f 100644 --- a/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs +++ b/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs @@ -113,7 +113,7 @@ namespace MatterHackers.MatterControl var affirmativeButton = theme.CreateDialogButton(yesOk); affirmativeButton.Click += (s, e) => { - UiThread.RunOnIdle(this.DialogWindow.Close); + this.DialogWindow.Close(); // If applicable, invoke the callback responseCallback?.Invoke(true); diff --git a/MatterControlLib/CustomWidgets/DockingTabControl.cs b/MatterControlLib/CustomWidgets/DockingTabControl.cs index 2a981247a..526e6b01a 100644 --- a/MatterControlLib/CustomWidgets/DockingTabControl.cs +++ b/MatterControlLib/CustomWidgets/DockingTabControl.cs @@ -100,15 +100,16 @@ namespace MatterHackers.MatterControl.CustomWidgets public void RemovePage(string key, bool allowRebuild = true) { - foreach(var tab in allTabs) + foreach (var tab in allTabs) { - if(tab.key == key) + if (tab.key == key) { allTabs.Remove(tab); if (allowRebuild) { this.Rebuild(); } + return; } } @@ -153,7 +154,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { this.ControlIsPinned = !this.ControlIsPinned; this.printer.ViewState.DockWindowFloating = false; - UiThread.RunOnIdle(this.Rebuild); + this.Rebuild(); }; return pinTabButton; diff --git a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs index 23b1f3f49..6aeef6c5b 100644 --- a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs +++ b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs @@ -195,7 +195,7 @@ namespace MatterHackers.MatterControl DoExport(libraryItems, printer, activePlugin, centerOnBed, showInFolderAfterSave?.Checked == true); - this.Parent.CloseOnIdle(); + this.Parent.Close(); }; diff --git a/MatterControlLib/CustomWidgets/RadioImageWidget.cs b/MatterControlLib/CustomWidgets/RadioImageWidget.cs index 9a697029b..70f1d676e 100644 --- a/MatterControlLib/CustomWidgets/RadioImageWidget.cs +++ b/MatterControlLib/CustomWidgets/RadioImageWidget.cs @@ -39,7 +39,12 @@ namespace MatterHackers.MatterControl : base(label, textColor) { var imageWidget = new ImageWidget(image); - this.AddChild(imageWidget, this.Children.IndexOf(labelTextWidget)); + var index = 0; + this.Children.ReadOnly((list) => + { + index = list.IndexOf(labelTextWidget); + }); + this.AddChild(imageWidget, index); imageWidget.Margin = new BorderDouble(8, 5); labelTextWidget.Margin = new BorderDouble(8, 0); diff --git a/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs b/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs index 64738333e..dcaa14e15 100644 --- a/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs @@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; using System.Linq; +using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D.UndoCommands; diff --git a/MatterControlLib/EeProm/EePromMarlinWindow.cs b/MatterControlLib/EeProm/EePromMarlinWindow.cs index f27357050..633833850 100644 --- a/MatterControlLib/EeProm/EePromMarlinWindow.cs +++ b/MatterControlLib/EeProm/EePromMarlinWindow.cs @@ -157,12 +157,12 @@ namespace MatterHackers.MatterControl.EeProm // the bottom button bar var buttonSave = theme.CreateDialogButton("Save to EEProm".Localize()); - buttonSave.Click += (s, e) =>UiThread.RunOnIdle(() => + buttonSave.Click += (s, e) => { SaveSettingsToActive(); currentEePromSettings.SaveToEeProm(); this.DialogWindow.Close(); - }); + }; this.AddPageAction(buttonSave); var exportButton = theme.CreateDialogButton("Export".Localize()); diff --git a/MatterControlLib/EeProm/EePromRepetierWindow.cs b/MatterControlLib/EeProm/EePromRepetierWindow.cs index da7fd35b6..06cf12ea4 100644 --- a/MatterControlLib/EeProm/EePromRepetierWindow.cs +++ b/MatterControlLib/EeProm/EePromRepetierWindow.cs @@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.EeProm { if (!printer.Connection.IsConnected) { - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); } } } @@ -172,13 +172,11 @@ namespace MatterHackers.MatterControl.EeProm var buttonSave = theme.CreateDialogButton("Save To EEPROM".Localize()); buttonSave.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - currentEePromSettings.Save(printer.Connection); - currentEePromSettings.Clear(); - this.DialogWindow.Close(); - }); + currentEePromSettings.Save(printer.Connection); + currentEePromSettings.Clear(); + this.DialogWindow.Close(); }; + this.AddPageAction(buttonSave); var exportButton = theme.CreateDialogButton("Export".Localize()); diff --git a/MatterControlLib/Library/Widgets/ListView/LibraryListView.cs b/MatterControlLib/Library/Widgets/ListView/LibraryListView.cs index 67898fae0..fd5bded9e 100644 --- a/MatterControlLib/Library/Widgets/ListView/LibraryListView.cs +++ b/MatterControlLib/Library/Widgets/ListView/LibraryListView.cs @@ -548,11 +548,11 @@ namespace MatterHackers.MatterControl.CustomWidgets if (item.Enabled) { - item.Click += (s, e) => UiThread.RunOnIdle(() => + item.Click += (s, e) => { menu.Close(); menuAction.Action.Invoke(this.SelectedItems.Select(o => o.Model), this); - }); + }; } } } diff --git a/MatterControlLib/Library/Widgets/ListView/ListViewItemBase.cs b/MatterControlLib/Library/Widgets/ListView/ListViewItemBase.cs index a6715b17d..c2f7a5a9e 100644 --- a/MatterControlLib/Library/Widgets/ListView/ListViewItemBase.cs +++ b/MatterControlLib/Library/Widgets/ListView/ListViewItemBase.cs @@ -359,11 +359,11 @@ namespace MatterHackers.MatterControl.CustomWidgets else if (menuAction.IsEnabled(this.listViewItem.ListView.SelectedItems, this.listViewItem.ListView)) { var item = menu.CreateMenuItem(menuAction.Title, menuAction.Icon); - item.Click += (s, e) => UiThread.RunOnIdle(() => + item.Click += (s, e) => { menu.Close(); menuAction.Action.Invoke(this.listViewItem.ListView.SelectedItems.Select(o => o.Model), this.listViewItem.ListView); - }); + }; } } diff --git a/MatterControlLib/PartPreviewWindow/LibraryBrowserPage.cs b/MatterControlLib/PartPreviewWindow/LibraryBrowserPage.cs index cb57f6efc..93a7c19eb 100644 --- a/MatterControlLib/PartPreviewWindow/LibraryBrowserPage.cs +++ b/MatterControlLib/PartPreviewWindow/LibraryBrowserPage.cs @@ -91,7 +91,7 @@ namespace MatterHackers.MatterControl writableContainer); } - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); }; this.AddPageAction(acceptButton); diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 54c11b4ec..08472ee9f 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -166,20 +166,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }); - await Task.Run(async () => + await Task.Run((Func)(async () => { // Start index generation await HelpIndex.RebuildIndex(); - UiThread.RunOnIdle(() => + UiThread.RunOnIdle((Action)(() => { // Close popover popover.Close(); // Continue to original task ShowSearchPanel(); - }); - }); + })); + })); } catch { @@ -190,7 +190,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } else { - searchPanel?.CloseOnIdle(); + searchPanel?.Close(); searchPanelOpenOnMouseDown = false; } } diff --git a/MatterControlLib/PartPreviewWindow/MarkdownEditPage.cs b/MatterControlLib/PartPreviewWindow/MarkdownEditPage.cs index 29ea5e4bd..e8d56a390 100644 --- a/MatterControlLib/PartPreviewWindow/MarkdownEditPage.cs +++ b/MatterControlLib/PartPreviewWindow/MarkdownEditPage.cs @@ -114,7 +114,7 @@ namespace MatterHackers.MatterControl editWidget.Text.Replace("\n", "\\n"), userInitiated: true); - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); }; this.AddPageAction(saveButton); diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index fedd19d64..55c17712c 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -150,7 +150,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow tumbleCubeControl = view3DWidget.InteractionLayer.Children().FirstOrDefault(); - var position = view3DWidget.InteractionLayer.Children.IndexOf(trackball); + var position = 0; + view3DWidget.InteractionLayer.Children.ReadOnly((list) => + { + position = list.IndexOf(trackball); + }); gcodePanel = new GCodePanel(this, printer, sceneContext, theme) { @@ -311,11 +315,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Margin = new BorderDouble(10, 10, 0, 15) }; - unloadFilamentButton.Click += (s, e2) => UiThread.RunOnIdle(() => + unloadFilamentButton.Click += (s, e2) => { unloadFilamentButton.Parents().First().Close(); DialogWindow.Show(new UnloadFilamentWizard(printer, extruderIndex: 0)); - }); + }; theme.ApplyPrimaryActionStyle(unloadFilamentButton); diff --git a/MatterControlLib/PartPreviewWindow/ValueTag.cs b/MatterControlLib/PartPreviewWindow/ValueTag.cs index 3c5dcfbd4..b4bae233e 100644 --- a/MatterControlLib/PartPreviewWindow/ValueTag.cs +++ b/MatterControlLib/PartPreviewWindow/ValueTag.cs @@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return; } - var firstChild = this.Children[0]; + var firstChild = this.Children.FirstOrDefault(); var bounds = this.LocalBounds; // Get the first child bounds in our coords diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs index 3c4bd58cc..3015f029d 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs @@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow double blend = Easing.Cubic.In(ratio); box.Position = new VectorMath.Vector2(startX + (xdistance * blend), startY); - //Console.WriteLine("Ms: {0}, Ratio: {1}, Easing: {2}, Position: {3}", elapsedMs, ratio, blend, box.Position); + // Console.WriteLine("Ms: {0}, Ratio: {1}, Easing: {2}, Position: {3}", elapsedMs, ratio, blend, box.Position); box.Invalidate(); } else diff --git a/MatterControlLib/PrinterControls/ControlWidgets/WizardSummaryPage.cs b/MatterControlLib/PrinterControls/ControlWidgets/WizardSummaryPage.cs index e874a21aa..0d939b19c 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/WizardSummaryPage.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/WizardSummaryPage.cs @@ -40,7 +40,7 @@ namespace MatterHackers.MatterControl.PrinterControls protected override void OnCancel(out bool abortCancel) { - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); abortCancel = true; } } diff --git a/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs b/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs index 28321600a..596d06d48 100644 --- a/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs +++ b/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs @@ -136,7 +136,7 @@ namespace MatterHackers.MatterControl var savePresetsButton = theme.CreateDialogButton("Save".Localize()); savePresetsButton.Name = "Save Leveling Button"; - savePresetsButton.Click += (s, e) => UiThread.RunOnIdle(() => + savePresetsButton.Click += (s, e) => { PrintLevelingData newLevelingData = printer.Settings.Helpers.PrintLevelingData; @@ -147,7 +147,7 @@ namespace MatterHackers.MatterControl printer.Settings.Helpers.PrintLevelingData = newLevelingData; this.DialogWindow.Close(); - }); + }; this.AddPageAction(savePresetsButton); var exportButton = theme.CreateDialogButton("Export".Localize()); diff --git a/MatterControlLib/PrinterControls/MovementSpeedsPage.cs b/MatterControlLib/PrinterControls/MovementSpeedsPage.cs index 9263b8c44..9969f3fce 100644 --- a/MatterControlLib/PrinterControls/MovementSpeedsPage.cs +++ b/MatterControlLib/PrinterControls/MovementSpeedsPage.cs @@ -128,6 +128,7 @@ namespace MatterHackers.MatterControl { settingString.Append(","); } + first = false; settingString.Append(axisLabels[i]); @@ -147,7 +148,7 @@ namespace MatterHackers.MatterControl printer.Bed.GCodeRenderer?.Clear3DGCode(); } - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); }; this.AddPageAction(savePresetsButton); diff --git a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs index 908c53a65..707b6b061 100644 --- a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs +++ b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs @@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections // Construct buttons nextButton = theme.CreateDialogButton("Done".Localize()); - nextButton.Click += (s, e) => UiThread.RunOnIdle(Parent.Close); + nextButton.Click += (s, e) => Parent.Close(); nextButton.Visible = false; connectButton = theme.CreateDialogButton("Connect".Localize()); @@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections printerComPortError.Text = "Connection succeeded".Localize() + "!"; nextButton.Visible = true; connectButton.Visible = false; - UiThread.RunOnIdle(() => this?.Parent?.Close()); + this?.Parent?.Close(); } else if (printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect) { diff --git a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortOne.cs b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortOne.cs index 8cff94555..652abf812 100644 --- a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortOne.cs +++ b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortOne.cs @@ -119,21 +119,21 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections Margin = new BorderDouble(0, 8), TextColor = theme.TextColor }; - skipConnectionLink.Click += (s, e) => UiThread.RunOnIdle(() => + skipConnectionLink.Click += (s, e) => { printer.Connection.HaltConnectionThread(); Parent.Close(); - }); + }; container.AddChild(skipConnectionLink); contentRow.AddChild(container); - //Construct buttons + // Construct buttons var nextButton = theme.CreateDialogButton("Continue".Localize()); - nextButton.Click += (s, e) => UiThread.RunOnIdle(() => + nextButton.Click += (s, e) => { DialogWindow.ChangeToPage(new SetupStepComPortTwo(printer)); - }); + }; this.AddPageAction(nextButton); } diff --git a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs index 16858ba51..0a16d0909 100644 --- a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs +++ b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections //Construct buttons nextButton = theme.CreateDialogButton("Done".Localize()); - nextButton.Click += (s, e) => UiThread.RunOnIdle(Parent.Close); + nextButton.Click += (s, e) => Parent.Close(); nextButton.Visible = false; connectButton = theme.CreateDialogButton("Connect".Localize()); @@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections printerErrorMessage.Text = "Connection succeeded".Localize() + "!"; nextButton.Visible = true; connectButton.Visible = false; - UiThread.RunOnIdle(() => this?.Parent?.Close()); + this?.Parent?.Close(); } else if (printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect) { diff --git a/MatterControlLib/RootSystemWindow.cs b/MatterControlLib/RootSystemWindow.cs index e65f57715..517ca7224 100644 --- a/MatterControlLib/RootSystemWindow.cs +++ b/MatterControlLib/RootSystemWindow.cs @@ -263,10 +263,10 @@ namespace MatterHackers.MatterControl // We need to show an interactive dialog to determine if the original Close request should be honored, thus cancel the current Close request eventArgs.Cancel = true; - UiThread.RunOnIdle(() => + UiThread.RunOnIdle((Action)(() => { StyledMessageBox.ShowMessageBox( - (exitConfirmed) => +(Action)((exitConfirmed) => { // Record that the exitDialog has closed exitDialogOpen = false; @@ -283,20 +283,20 @@ namespace MatterHackers.MatterControl printer.Connection.Disable(); } - this.CloseOnIdle(); + this.Close(); } - }, + }), message, caption, StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT); - }); + })); } else if (!ApplicationController.Instance.ApplicationExiting) { // cancel the close so that we can save all our active work spaces eventArgs.Cancel = true; - UiThread.RunOnIdle(async () => + UiThread.RunOnIdle((Action)(async () => { var application = ApplicationController.Instance; @@ -307,8 +307,8 @@ namespace MatterHackers.MatterControl // Make sure we tell the Application Controller to shut down. This will release the slicing thread if running. application.Shutdown(); - this.CloseOnIdle(); - }); + this.Close(); + })); } } diff --git a/MatterControlLib/SetupWizard/DialogWindow.cs b/MatterControlLib/SetupWizard/DialogWindow.cs index a2b443ce5..fbb65ec95 100644 --- a/MatterControlLib/SetupWizard/DialogWindow.cs +++ b/MatterControlLib/SetupWizard/DialogWindow.cs @@ -203,7 +203,7 @@ namespace MatterHackers.MatterControl public virtual void ClosePage(bool allowAbort = true) { // Close this dialog window - this.CloseOnIdle(); + this.Close(); } public override void OnClosed(EventArgs e) @@ -237,7 +237,7 @@ namespace MatterHackers.MatterControl this.ChangeToPage(panel); // in the event of a reload all make sure we rebuild the contents correctly - ApplicationController.Instance.DoneReloadingAll.RegisterEvent((s,e) => + ApplicationController.Instance.DoneReloadingAll.RegisterEvent((EventHandler)((s,e) => { // Normal theme references are safe to hold in widgets because they're rebuild on ReloadAll. DialogWindow // survives and must refresh its reference on reload @@ -256,11 +256,11 @@ namespace MatterHackers.MatterControl DialogWindow = this }; this.AddChild(newPanel, thisIndex); - panel.CloseOnIdle(); + panel.Close(); // remember the new content panel = newPanel; - }, ref unregisterEvents); + }), ref unregisterEvents); return panel; } diff --git a/MatterControlLib/SetupWizard/ImportSettingsPage.cs b/MatterControlLib/SetupWizard/ImportSettingsPage.cs index 8e479da85..019e70198 100644 --- a/MatterControlLib/SetupWizard/ImportSettingsPage.cs +++ b/MatterControlLib/SetupWizard/ImportSettingsPage.cs @@ -55,11 +55,8 @@ namespace MatterHackers.MatterControl if (settingsToImport.QualityLayers.Count == 0 && settingsToImport.MaterialLayers.Count == 0) { // Only main setting so don't ask what to merge just do it. - UiThread.RunOnIdle(() => - { - DisplayFailedToImportMessage(settingsFilePath); - this.Parents().First().Close(); - }); + DisplayFailedToImportMessage(settingsFilePath); + this.Parents().First().Close(); } this.settingsFilePath = settingsFilePath; diff --git a/MatterControlLib/SetupWizard/InputBoxPage.cs b/MatterControlLib/SetupWizard/InputBoxPage.cs index 9b5b0742b..9f94cd569 100644 --- a/MatterControlLib/SetupWizard/InputBoxPage.cs +++ b/MatterControlLib/SetupWizard/InputBoxPage.cs @@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl if (!string.IsNullOrEmpty(newName)) { action.Invoke(newName); - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); } }; this.AddPageAction(actionButton); diff --git a/MatterControlLib/SetupWizard/LicenseAgreementPage.cs b/MatterControlLib/SetupWizard/LicenseAgreementPage.cs index 6cd9982db..c64caa263 100644 --- a/MatterControlLib/SetupWizard/LicenseAgreementPage.cs +++ b/MatterControlLib/SetupWizard/LicenseAgreementPage.cs @@ -72,7 +72,7 @@ public class LicenseAgreementPage : DialogPage protected override void OnCancel(out bool abortCancel) { // Exit if EULA is not accepted - UiThread.RunOnIdle(MatterHackers.MatterControl.AppContext.RootSystemWindow.Close); + MatterHackers.MatterControl.AppContext.RootSystemWindow.Close(); abortCancel = false; } diff --git a/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs b/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs index 5daab8111..190353bda 100644 --- a/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs +++ b/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl printerLoaded?.Invoke(printer); - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); } } @@ -102,7 +102,7 @@ namespace MatterHackers.MatterControl }); } - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); base.OnContinue(treeNode); } diff --git a/MatterControlLib/SetupWizard/PrinterProfileHistoryPage.cs b/MatterControlLib/SetupWizard/PrinterProfileHistoryPage.cs index 1cbf399ae..6bc1bbee1 100644 --- a/MatterControlLib/SetupWizard/PrinterProfileHistoryPage.cs +++ b/MatterControlLib/SetupWizard/PrinterProfileHistoryPage.cs @@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl.SetupWizard printer.SwapToSettings(printerSettings); } - UiThread.RunOnIdle(DialogWindow.Close); + DialogWindow.Close(); } }; this.AddPageAction(revertButton); diff --git a/MatterControlLib/SetupWizard/ProductTour.cs b/MatterControlLib/SetupWizard/ProductTour.cs index 97043a261..adafe8136 100644 --- a/MatterControlLib/SetupWizard/ProductTour.cs +++ b/MatterControlLib/SetupWizard/ProductTour.cs @@ -63,10 +63,10 @@ namespace MatterHackers.MatterControl.Tour // Filter to on-screen items var visibleTourItems = tourLocations.Where(t => { - var widget = visibleTourWidgets.FirstOrDefault(w => w.name == t.WidgetName && w.widget.ActuallyVisibleOnScreen()); + var widget = visibleTourWidgets.FirstOrDefault(w => w.Name == t.WidgetName && w.Widget.ActuallyVisibleOnScreen()); // Update widget reference on tour object - t.Widget = widget?.widget; + t.Widget = widget?.Widget; return widget != null; }); diff --git a/MatterControlLib/SetupWizard/StagedSetupWindow.cs b/MatterControlLib/SetupWizard/StagedSetupWindow.cs index a996467e0..810379a42 100644 --- a/MatterControlLib/SetupWizard/StagedSetupWindow.cs +++ b/MatterControlLib/SetupWizard/StagedSetupWindow.cs @@ -170,7 +170,7 @@ namespace MatterHackers.MatterControl ConditionalAbort("Are you sure you want to abort calibration?".Localize(), () => { closeConfirmed = true; - this.CloseOnIdle(); + this.Close(); }); } diff --git a/MatterControlLib/SetupWizard/TourPopover.cs b/MatterControlLib/SetupWizard/TourPopover.cs index 9c3f47ee1..3a1ddf39f 100644 --- a/MatterControlLib/SetupWizard/TourPopover.cs +++ b/MatterControlLib/SetupWizard/TourPopover.cs @@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.Tour closeButton.Margin = 0; closeButton.Click += (s, e) => { - this.Parent.CloseOnIdle(); + this.Parent.Close(); }; row.AddChild(closeButton); diff --git a/MatterControlLib/SetupWizard/WelcomePage.cs b/MatterControlLib/SetupWizard/WelcomePage.cs index d7fe889cc..c8caca959 100644 --- a/MatterControlLib/SetupWizard/WelcomePage.cs +++ b/MatterControlLib/SetupWizard/WelcomePage.cs @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.Tour nextButton.Name = "Next Button"; nextButton.Click += (s, e) => { - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); UiThread.RunOnIdle(ProductTour.StartTour); }; diff --git a/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs b/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs index c13e990fe..6ecd343b0 100644 --- a/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs +++ b/MatterControlLib/SlicerConfiguration/SlicePresetsWindow/SlicePresetsPage.cs @@ -75,35 +75,30 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var duplicateButton = theme.CreateDialogButton("Duplicate".Localize()); duplicateButton.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim(); - string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name))); + string sanitizedName = numberMatch.Replace(inlineNameEdit.Text, "").Trim(); + string newProfileName = agg_basics.GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name))); - var clonedLayer = presetsContext.PersistenceLayer.Clone(); - clonedLayer.Name = newProfileName; - presetsContext.PresetLayers.Add(clonedLayer); + var clonedLayer = presetsContext.PersistenceLayer.Clone(); + clonedLayer.Name = newProfileName; + presetsContext.PresetLayers.Add(clonedLayer); - presetsContext.SetAsActive(clonedLayer.LayerID); - presetsContext.PersistenceLayer = clonedLayer; + presetsContext.SetAsActive(clonedLayer.LayerID); + presetsContext.PersistenceLayer = clonedLayer; - sliceSettingsWidget.Close(); - sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer); - contentRow.AddChild(sliceSettingsWidget); + sliceSettingsWidget.Close(); + sliceSettingsWidget = CreateSliceSettingsWidget(printer, clonedLayer); + contentRow.AddChild(sliceSettingsWidget); - inlineNameEdit.Text = newProfileName; - }); + inlineNameEdit.Text = newProfileName; }; + this.AddPageAction(duplicateButton); var deleteButton = theme.CreateDialogButton("Delete".Localize()); deleteButton.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - presetsContext.DeleteLayer(); - this.DialogWindow.Close(); - }); + presetsContext.DeleteLayer(); + this.DialogWindow.Close(); }; this.AddPageAction(deleteButton); } diff --git a/MatterControlLib/SlicerConfiguration/UIFields/SurfacedEditorPage.cs b/MatterControlLib/SlicerConfiguration/UIFields/SurfacedEditorPage.cs index cd314a0ca..20667512f 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/SurfacedEditorPage.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/SurfacedEditorPage.cs @@ -141,7 +141,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { this.ValueChanged?.Invoke(this, null); - this.DialogWindow.CloseOnIdle(); + this.DialogWindow.Close(); }; this.AddPageAction(saveButton); } diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 48b38a00c..e87d2c150 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 48b38a00c1ce80ed5e4a2d80d30f23db2e2b181f +Subproject commit e87d2c150c1f410a6c360eecfd1a9bbdbfb72e58 diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index 8658e80a1..7eeb391c0 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -824,7 +824,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testMethod, maxTimeToRun, defaultTestImages, - closeWindow: () => + closeWindow: (Action)(() => { foreach(var printer in ApplicationController.Instance.ActivePrinters) { @@ -835,7 +835,7 @@ namespace MatterHackers.MatterControl.Tests.Automation } rootSystemWindow.Close(); - }); + })); } public static void LibraryEditSelectedItem(AutomationRunner testRunner)