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.view3DWidget = view3DWidget;
this.LoadingItemsTask = Task.Run((Func<Task>)(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);
}));
});
}
/// <summary>
@ -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<IObject3D> allBedItems = new List<IObject3D>(view3DWidget.Scene.Children);
var allBedItems = new List<IObject3D>(view3DWidget.Scene.Children);
foreach (var item in loadedItems)
{

View file

@ -166,20 +166,20 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom)
});
await Task.Run((Func<Task>)(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
{

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
eventArgs.Cancel = true;
UiThread.RunOnIdle((Action)(() =>
UiThread.RunOnIdle(() =>
{
StyledMessageBox.ShowMessageBox(
(Action<bool>)((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();
}));
});
}
}

View file

@ -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;
}

View file

@ -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)