removing unnecessary casts

This commit is contained in:
LarsBrubaker 2019-07-06 08:00:03 -07:00 committed by jlewin
parent 2444fd0d9e
commit e602c7681d
5 changed files with 24 additions and 23 deletions

View file

@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.Library
this.scene = scene; this.scene = scene;
this.view3DWidget = view3DWidget; this.view3DWidget = view3DWidget;
this.LoadingItemsTask = Task.Run((Func<Task>)(async () => this.LoadingItemsTask = Task.Run(async () =>
{ {
var offset = Matrix4X4.Identity; var offset = Matrix4X4.Identity;
@ -108,7 +108,7 @@ namespace MatterHackers.MatterControl.Library
var aabb = loadedItem.GetAxisAlignedBoundingBox(); var aabb = loadedItem.GetAxisAlignedBoundingBox();
// lets move the cube to the center of the loaded thing // 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; 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; 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) // 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 // raise it up a bit so it is not z fighting with the bed
loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1); loadedItem.Matrix *= Matrix4X4.CreateTranslation(0, 0, .1);
@ -148,7 +148,7 @@ namespace MatterHackers.MatterControl.Library
this.Collapse(); this.Collapse();
this.Invalidate(InvalidateType.Children); this.Invalidate(InvalidateType.Children);
})); });
} }
/// <summary> /// <summary>
@ -160,7 +160,7 @@ namespace MatterHackers.MatterControl.Library
var loadedItems = this.Children; var loadedItems = this.Children;
// If we only have one item it may be a mcx wrapper, collapse that first. // 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(); var first = loadedItems.First();
if (first.GetType() == typeof(Object3D) if (first.GetType() == typeof(Object3D)
@ -173,18 +173,20 @@ namespace MatterHackers.MatterControl.Library
first.CollapseInto(list, false); first.CollapseInto(list, false);
}); });
} }
loadedItems = this.Children; loadedItems = this.Children;
} }
foreach(var item in loadedItems) foreach (var item in loadedItems)
{ {
item.Matrix *= this.Matrix; item.Matrix *= this.Matrix;
} }
view3DWidget.Scene.Children.Remove(this); view3DWidget.Scene.Children.Remove(this);
if (layoutParts != null) if (layoutParts != null)
{ {
List<IObject3D> allBedItems = new List<IObject3D>(view3DWidget.Scene.Children); var allBedItems = new List<IObject3D>(view3DWidget.Scene.Children);
foreach (var item in loadedItems) foreach (var item in loadedItems)
{ {

View file

@ -166,20 +166,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom) AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
}); });
await Task.Run((Func<Task>)(async () => await Task.Run(async () =>
{ {
// Start index generation // Start index generation
await HelpIndex.RebuildIndex(); await HelpIndex.RebuildIndex();
UiThread.RunOnIdle((Action)(() => UiThread.RunOnIdle(() =>
{ {
// Close popover // Close popover
popover.Close(); popover.Close();
// Continue to original task // Continue to original task
ShowSearchPanel(); ShowSearchPanel();
})); });
})); });
} }
catch catch
{ {

View file

@ -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 // 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; eventArgs.Cancel = true;
UiThread.RunOnIdle((Action)(() => UiThread.RunOnIdle(() =>
{ {
StyledMessageBox.ShowMessageBox( StyledMessageBox.ShowMessageBox(exitConfirmed =>
(Action<bool>)((exitConfirmed) =>
{ {
// Record that the exitDialog has closed // Record that the exitDialog has closed
exitDialogOpen = false; exitDialogOpen = false;
@ -285,18 +284,18 @@ namespace MatterHackers.MatterControl
this.Close(); this.Close();
} }
}), },
message, message,
caption, caption,
StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT); StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT);
})); });
} }
else if (!ApplicationController.Instance.ApplicationExiting) else if (!ApplicationController.Instance.ApplicationExiting)
{ {
// cancel the close so that we can save all our active work spaces // cancel the close so that we can save all our active work spaces
eventArgs.Cancel = true; eventArgs.Cancel = true;
UiThread.RunOnIdle((Action)(async () => UiThread.RunOnIdle(async () =>
{ {
var application = ApplicationController.Instance; var application = ApplicationController.Instance;
@ -308,7 +307,7 @@ namespace MatterHackers.MatterControl
application.Shutdown(); application.Shutdown();
this.Close(); this.Close();
})); });
} }
} }

View file

@ -237,7 +237,7 @@ namespace MatterHackers.MatterControl
this.ChangeToPage(panel); this.ChangeToPage(panel);
// in the event of a reload all make sure we rebuild the contents correctly // 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 // Normal theme references are safe to hold in widgets because they're rebuild on ReloadAll. DialogWindow
// survives and must refresh its reference on reload // survives and must refresh its reference on reload
@ -260,7 +260,7 @@ namespace MatterHackers.MatterControl
// remember the new content // remember the new content
panel = newPanel; panel = newPanel;
}), ref unregisterEvents); }, ref unregisterEvents);
return panel; return panel;
} }

View file

@ -824,9 +824,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
testMethod, testMethod,
maxTimeToRun, maxTimeToRun,
defaultTestImages, defaultTestImages,
closeWindow: (Action)(() => closeWindow: () =>
{ {
foreach(var printer in ApplicationController.Instance.ActivePrinters) foreach (var printer in ApplicationController.Instance.ActivePrinters)
{ {
if (printer.Connection.CommunicationState == CommunicationStates.Printing) if (printer.Connection.CommunicationState == CommunicationStates.Printing)
{ {
@ -835,7 +835,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
} }
rootSystemWindow.Close(); rootSystemWindow.Close();
})); });
} }
public static void LibraryEditSelectedItem(AutomationRunner testRunner) public static void LibraryEditSelectedItem(AutomationRunner testRunner)