diff --git a/MatterControlLib/Library/Widgets/InsertionGroupObject3D.cs b/MatterControlLib/Library/Widgets/InsertionGroupObject3D.cs index 2872d2e8c..063d155e9 100644 --- a/MatterControlLib/Library/Widgets/InsertionGroupObject3D.cs +++ b/MatterControlLib/Library/Widgets/InsertionGroupObject3D.cs @@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.Library this.scene = scene; this.view3DWidget = view3DWidget; - this.LoadingItemsTask = Task.Run((Func)(async () => + this.LoadingItemsTask = Task.Run(async () => { var offset = Matrix4X4.Identity; @@ -108,7 +108,7 @@ namespace MatterHackers.MatterControl.Library var aabb = loadedItem.GetAxisAlignedBoundingBox(); // lets move the cube to the center of the loaded thing - placeholderItem.Matrix *= Matrix4X4.CreateTranslation(-10 + aabb.XSize/2, 0, 0); + placeholderItem.Matrix *= Matrix4X4.CreateTranslation(-10 + aabb.XSize / 2, 0, 0); placeholderItem.Visible = false; @@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl.Library loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.MinXYZ.Z) * placeholderItem.Matrix; // check if the item has 0 height (it is probably an image) - if(loadedItem.ZSize() == 0) + if (loadedItem.ZSize() == 0) { // raise it up a bit so it is not z fighting with the bed loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1); @@ -148,7 +148,7 @@ namespace MatterHackers.MatterControl.Library this.Collapse(); this.Invalidate(InvalidateType.Children); - })); + }); } /// @@ -160,7 +160,7 @@ namespace MatterHackers.MatterControl.Library var loadedItems = this.Children; // If we only have one item it may be a mcx wrapper, collapse that first. - if(loadedItems.Count == 1) + if (loadedItems.Count == 1) { var first = loadedItems.First(); if (first.GetType() == typeof(Object3D) @@ -173,18 +173,20 @@ namespace MatterHackers.MatterControl.Library first.CollapseInto(list, false); }); } + loadedItems = this.Children; } - foreach(var item in loadedItems) + foreach (var item in loadedItems) { item.Matrix *= this.Matrix; } + view3DWidget.Scene.Children.Remove(this); if (layoutParts != null) { - List allBedItems = new List(view3DWidget.Scene.Children); + var allBedItems = new List(view3DWidget.Scene.Children); foreach (var item in loadedItems) { diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 7c5c17242..f44800a7a 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((Func)(async () => + await Task.Run(async () => { // Start index generation await HelpIndex.RebuildIndex(); - UiThread.RunOnIdle((Action)(() => + UiThread.RunOnIdle(() => { // Close popover popover.Close(); // Continue to original task ShowSearchPanel(); - })); - })); + }); + }); } catch { diff --git a/MatterControlLib/RootSystemWindow.cs b/MatterControlLib/RootSystemWindow.cs index 517ca7224..6aea2c4ff 100644 --- a/MatterControlLib/RootSystemWindow.cs +++ b/MatterControlLib/RootSystemWindow.cs @@ -263,10 +263,9 @@ 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((Action)(() => + UiThread.RunOnIdle(() => { - StyledMessageBox.ShowMessageBox( -(Action)((exitConfirmed) => + StyledMessageBox.ShowMessageBox(exitConfirmed => { // Record that the exitDialog has closed exitDialogOpen = false; @@ -285,18 +284,18 @@ namespace MatterHackers.MatterControl 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((Action)(async () => + UiThread.RunOnIdle(async () => { var application = ApplicationController.Instance; @@ -308,7 +307,7 @@ namespace MatterHackers.MatterControl application.Shutdown(); this.Close(); - })); + }); } } diff --git a/MatterControlLib/SetupWizard/DialogWindow.cs b/MatterControlLib/SetupWizard/DialogWindow.cs index 99396b8d3..93a71b9cc 100644 --- a/MatterControlLib/SetupWizard/DialogWindow.cs +++ b/MatterControlLib/SetupWizard/DialogWindow.cs @@ -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((EventHandler)((s,e) => + ApplicationController.Instance.DoneReloadingAll.RegisterEvent((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 @@ -260,7 +260,7 @@ namespace MatterHackers.MatterControl // remember the new content panel = newPanel; - }), ref unregisterEvents); + }, ref unregisterEvents); return panel; } diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index 7eeb391c0..139355574 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -824,9 +824,9 @@ namespace MatterHackers.MatterControl.Tests.Automation testMethod, maxTimeToRun, defaultTestImages, - closeWindow: (Action)(() => + closeWindow: () => { - foreach(var printer in ApplicationController.Instance.ActivePrinters) + foreach (var printer in ApplicationController.Instance.ActivePrinters) { if (printer.Connection.CommunicationState == CommunicationStates.Printing) { @@ -835,7 +835,7 @@ namespace MatterHackers.MatterControl.Tests.Automation } rootSystemWindow.Close(); - })); + }); } public static void LibraryEditSelectedItem(AutomationRunner testRunner)