From 4ff6c5cbb87fb7872f2106328e80b8ceee3809d7 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 18 Jul 2017 18:15:10 -0700 Subject: [PATCH] Convert from ReportProgressRatio to Action --- ApplicationView/ApplicationController.cs | 2 +- CustomWidgets/ExportPrintItemWindow.cs | 18 +++++------- .../ContentProviders/GCodeContentProvider.cs | 2 +- Library/ContentProviders/IContentProvider.cs | 2 +- .../ContentProviders/MeshContentProvider.cs | 2 +- Library/ExtensionMethods.cs | 3 +- Library/Interfaces/ILibraryContainerLink.cs | 4 +-- Library/Interfaces/ILibraryItem.cs | 6 ++-- Library/Providers/DynamicContainerLink.cs | 3 +- .../FileSystem/FileSystemContainer.cs | 3 +- .../FileSystem/FileSystemFileItem.cs | 5 ++-- Library/Providers/GeneratorItem.cs | 2 +- .../MatterControl/HistoryContainer.cs | 3 +- .../MatterControl/SqliteLibraryContainer.cs | 3 +- .../Providers/Zip/LocalZipContainerLink.cs | 6 ++-- Library/Providers/Zip/ZipMemoryItem.cs | 4 +-- Library/Widgets/ListView/ListViewItem.cs | 11 ++++---- .../GCode/GCodeMemoryFile.cs | 12 ++++---- PartPreviewWindow/CreateDiscreteMeshes.cs | 28 +++++++++---------- PartPreviewWindow/PlatingHelper.cs | 4 +-- .../View3D/DragDropLoadProgress.cs | 6 ++-- .../View3D/Gui3D/MoveInZControl.cs | 3 -- PartPreviewWindow/View3D/MeshViewerWidget.cs | 28 ++++++++----------- PartPreviewWindow/View3D/SceneActions.cs | 5 ++-- PartPreviewWindow/View3D/View3DWidget.cs | 13 ++++----- PartPreviewWindow/ViewGcodeBasic.cs | 6 ++-- Submodules/agg-sharp | 2 +- 27 files changed, 80 insertions(+), 106 deletions(-) diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index acafea501..c991d1d90 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl } } - public void LoadGCode(string filePath, CancellationToken cancellationToken, ReportProgressRatio<(double,string)> progressReporter) + public void LoadGCode(string filePath, CancellationToken cancellationToken, Action progressReporter) { this.LoadedGCode = GCodeMemoryFile.Load(filePath, cancellationToken, progressReporter); this.GCodeRenderer = new GCodeRenderer(loadedGCode); diff --git a/CustomWidgets/ExportPrintItemWindow.cs b/CustomWidgets/ExportPrintItemWindow.cs index 6a0b28d17..74853dbd6 100644 --- a/CustomWidgets/ExportPrintItemWindow.cs +++ b/CustomWidgets/ExportPrintItemWindow.cs @@ -1,10 +1,15 @@ -using MatterHackers.Agg; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using MatterHackers.Agg; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.GCodeVisualizer; using MatterHackers.Localizations; -using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrinterCommunication.Io; @@ -12,15 +17,6 @@ using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.Queue.OptionsMenu; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.PolygonMesh; -using MatterHackers.PolygonMesh.Processors; -using MatterHackers.VectorMath; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.IO; -using System.Threading.Tasks; -using System.Threading; namespace MatterHackers.MatterControl { diff --git a/Library/ContentProviders/GCodeContentProvider.cs b/Library/ContentProviders/GCodeContentProvider.cs index d4f9f4cfb..6f246282d 100644 --- a/Library/ContentProviders/GCodeContentProvider.cs +++ b/Library/ContentProviders/GCodeContentProvider.cs @@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl thumbnailImage = thumbIcon; } - public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter) + public ContentResult CreateItem(ILibraryItem item, Action reporter) { System.Diagnostics.Debugger.Break(); return null; diff --git a/Library/ContentProviders/IContentProvider.cs b/Library/ContentProviders/IContentProvider.cs index 72966243b..190761d63 100644 --- a/Library/ContentProviders/IContentProvider.cs +++ b/Library/ContentProviders/IContentProvider.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.Library public interface ISceneContentProvider : IContentProvider { // TODO: Needs to take a progress reporter that is used in the background task which creates the actual IObject3D mesh and children - ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter); + ContentResult CreateItem(ILibraryItem item, Action reporter); } public interface IPrintableContentProvider : IContentProvider diff --git a/Library/ContentProviders/MeshContentProvider.cs b/Library/ContentProviders/MeshContentProvider.cs index 072a3558e..53e5b120e 100644 --- a/Library/ContentProviders/MeshContentProvider.cs +++ b/Library/ContentProviders/MeshContentProvider.cs @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl private static readonly int MaxFileSize = (OsInformation.OperatingSystem == OSType.Android) ? tooBigAndroid : tooBigDesktop; private static readonly Point2D BigRenderSize = new Point2D(460, 460); - public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> progressReporter) + public ContentResult CreateItem(ILibraryItem item, Action progressReporter) { var sceneItem = new Object3D() { diff --git a/Library/ExtensionMethods.cs b/Library/ExtensionMethods.cs index a8c784881..3586d65cd 100644 --- a/Library/ExtensionMethods.cs +++ b/Library/ExtensionMethods.cs @@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Collections.Generic; -using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.UI; using MatterHackers.ImageProcessing; @@ -63,7 +62,7 @@ namespace MatterHackers.MatterControl.Library } } - public static ContentResult CreateContent(this ILibraryContentStream item, ReportProgressRatio<(double ratio, string state)> reporter = null) + public static ContentResult CreateContent(this ILibraryContentStream item, Action reporter = null) { var contentProvider = ApplicationController.Instance.Library.GetContentProvider(item) as ISceneContentProvider; return contentProvider?.CreateItem(item, reporter); diff --git a/Library/Interfaces/ILibraryContainerLink.cs b/Library/Interfaces/ILibraryContainerLink.cs index 7cad58def..e152fd26d 100644 --- a/Library/Interfaces/ILibraryContainerLink.cs +++ b/Library/Interfaces/ILibraryContainerLink.cs @@ -27,13 +27,13 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; using System.Threading.Tasks; -using MatterHackers.Agg; namespace MatterHackers.MatterControl.Library { public interface ILibraryContainerLink : ILibraryItem { - Task GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress); + Task GetContainer(Action reportProgress); } } diff --git a/Library/Interfaces/ILibraryItem.cs b/Library/Interfaces/ILibraryItem.cs index cdacfcd26..421d5e2d5 100644 --- a/Library/Interfaces/ILibraryItem.cs +++ b/Library/Interfaces/ILibraryItem.cs @@ -27,8 +27,8 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.DataConverters3D; namespace MatterHackers.MatterControl.Library @@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.Library { string ContentType { get; } string Category { get; } - Task GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress); + Task GetContent(Action reportProgress); void SetContent(IObject3D item); } @@ -58,6 +58,6 @@ namespace MatterHackers.MatterControl.Library string ContentType { get; } string FileName { get; } string AssetPath { get; } - Task GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress); + Task GetContentStream(Action progress); } } diff --git a/Library/Providers/DynamicContainerLink.cs b/Library/Providers/DynamicContainerLink.cs index a0a56b378..93b2977a9 100644 --- a/Library/Providers/DynamicContainerLink.cs +++ b/Library/Providers/DynamicContainerLink.cs @@ -29,7 +29,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.Image; namespace MatterHackers.MatterControl.Library @@ -56,7 +55,7 @@ namespace MatterHackers.MatterControl.Library public bool IsVisible => this.visibilityResolver(); - public Task GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContainer(Action reportProgress) { return Task.FromResult(this.containerCreator()); } diff --git a/Library/Providers/FileSystem/FileSystemContainer.cs b/Library/Providers/FileSystem/FileSystemContainer.cs index 0c1bfb6bd..1704e6003 100644 --- a/Library/Providers/FileSystem/FileSystemContainer.cs +++ b/Library/Providers/FileSystem/FileSystemContainer.cs @@ -33,7 +33,6 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; @@ -385,7 +384,7 @@ namespace MatterHackers.MatterControl.Library public bool UseIncrementedNameDuringTypeChange { get; set; } - public Task GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContainer(Action reportProgress) { return Task.FromResult( new FileSystemContainer(this.Path) diff --git a/Library/Providers/FileSystem/FileSystemFileItem.cs b/Library/Providers/FileSystem/FileSystemFileItem.cs index d33d5a804..49b3b5653 100644 --- a/Library/Providers/FileSystem/FileSystemFileItem.cs +++ b/Library/Providers/FileSystem/FileSystemFileItem.cs @@ -30,7 +30,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.IO; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.DataConverters3D; namespace MatterHackers.MatterControl.Library @@ -57,7 +56,7 @@ namespace MatterHackers.MatterControl.Library } } - public Task GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContentStream(Action reportProgress) { if (ApplicationController.Instance.IsLoadableFile(this.Path) && File.Exists(this.Path)) @@ -73,7 +72,7 @@ namespace MatterHackers.MatterControl.Library return Task.FromResult(null); } - public Task GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContent(Action reportProgress) { throw new NotImplementedException(); } diff --git a/Library/Providers/GeneratorItem.cs b/Library/Providers/GeneratorItem.cs index 4a0ef43f5..4557d27f9 100644 --- a/Library/Providers/GeneratorItem.cs +++ b/Library/Providers/GeneratorItem.cs @@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.Library /// public Func Collector { get; } - public Task GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress) => Task.FromResult(Collector?.Invoke()); + public Task GetContent(Action reportProgress) => Task.FromResult(Collector?.Invoke()); public void SetContent(IObject3D item) { diff --git a/Library/Providers/MatterControl/HistoryContainer.cs b/Library/Providers/MatterControl/HistoryContainer.cs index 87d1ee66f..58cd30e70 100644 --- a/Library/Providers/MatterControl/HistoryContainer.cs +++ b/Library/Providers/MatterControl/HistoryContainer.cs @@ -31,7 +31,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; @@ -64,7 +63,7 @@ namespace MatterHackers.MatterControl.Library public bool IsVisible => true; - public Task GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContentStream(Action reportProgress) { throw new NotImplementedException(); } diff --git a/Library/Providers/MatterControl/SqliteLibraryContainer.cs b/Library/Providers/MatterControl/SqliteLibraryContainer.cs index fcd6fcadb..29c5b4534 100644 --- a/Library/Providers/MatterControl/SqliteLibraryContainer.cs +++ b/Library/Providers/MatterControl/SqliteLibraryContainer.cs @@ -33,7 +33,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; @@ -343,7 +342,7 @@ namespace MatterHackers.MatterControl.Library public bool IsVisible { get; set; } = true; - public Task GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContainer(Action reportProgress) { return Task.FromResult( new SqliteLibraryContainer(this.ContainerID) diff --git a/Library/Providers/Zip/LocalZipContainerLink.cs b/Library/Providers/Zip/LocalZipContainerLink.cs index c8c9d6e43..38b77d9ba 100644 --- a/Library/Providers/Zip/LocalZipContainerLink.cs +++ b/Library/Providers/Zip/LocalZipContainerLink.cs @@ -27,12 +27,10 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System.Collections.Generic; +using System; using System.IO; -using System.IO.Compression; using System.Linq; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.Image; namespace MatterHackers.MatterControl.Library @@ -67,7 +65,7 @@ namespace MatterHackers.MatterControl.Library } } - public Task GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress) + public Task GetContainer(Action reportProgress) { return Task.FromResult(new ZipMemoryContainer(this.currentDirectory, this.Path)); } diff --git a/Library/Providers/Zip/ZipMemoryItem.cs b/Library/Providers/Zip/ZipMemoryItem.cs index 27afbe639..29e18b79b 100644 --- a/Library/Providers/Zip/ZipMemoryItem.cs +++ b/Library/Providers/Zip/ZipMemoryItem.cs @@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.Library /// public long FileSize { get; private set; } - public async Task GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress) + public async Task GetContentStream(Action reportProgress) { var memStream = await Task.Run(() => { @@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.Library } /* - public async Task GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress) + public async Task GetContent(Action reportProgress) { var streamAndLength = await GetContentStream(null); IObject3D object3D = Object3D.Load(streamAndLength.Stream, System.IO.Path.GetExtension(Name)); diff --git a/Library/Widgets/ListView/ListViewItem.cs b/Library/Widgets/ListView/ListViewItem.cs index 02f5c9abd..79bc533f9 100644 --- a/Library/Widgets/ListView/ListViewItem.cs +++ b/Library/Widgets/ListView/ListViewItem.cs @@ -28,7 +28,6 @@ either expressed or implied, of the FreeBSD Project. */ using System; -using System.Threading; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; @@ -48,18 +47,18 @@ namespace MatterHackers.MatterControl.CustomWidgets ProgressControl processingProgressControl; - internal void ProgressReporter((double progress0To1, string processingState) progress) + internal void ProgressReporter(double progress0To1, string processingState) { if (processingProgressControl == null) { return; } - processingProgressControl.Visible = progress.progress0To1 != 0; - processingProgressControl.RatioComplete = progress.progress0To1; - processingProgressControl.ProcessType = progress.processingState; + processingProgressControl.Visible = progress0To1 != 0; + processingProgressControl.RatioComplete = progress0To1; + processingProgressControl.ProcessType = processingState; - if (progress.progress0To1 == 1) + if (progress0To1 == 1) { EndProgress(); } diff --git a/MatterControl.Printing/GCode/GCodeMemoryFile.cs b/MatterControl.Printing/GCode/GCodeMemoryFile.cs index 8ef4b3fbb..8d0ff995c 100644 --- a/MatterControl.Printing/GCode/GCodeMemoryFile.cs +++ b/MatterControl.Printing/GCode/GCodeMemoryFile.cs @@ -113,7 +113,7 @@ namespace MatterHackers.GCodeVisualizer return ParseFileContents(gcodeContents, cancellationToken, null); } - public static GCodeMemoryFile Load(Stream fileStream, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter = null) + public static GCodeMemoryFile Load(Stream fileStream, CancellationToken cancellationToken, Action progressReporter = null) { try { @@ -130,7 +130,7 @@ namespace MatterHackers.GCodeVisualizer return null; } - public static GCodeMemoryFile Load(string filePath, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter) + public static GCodeMemoryFile Load(string filePath, CancellationToken cancellationToken, Action progressReporter) { if (Path.GetExtension(filePath).ToUpper() == ".GCODE") { @@ -180,7 +180,7 @@ namespace MatterHackers.GCodeVisualizer return crCount + 1; } - public static GCodeMemoryFile ParseFileContents(string gCodeString, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter) + public static GCodeMemoryFile ParseFileContents(string gCodeString, CancellationToken cancellationToken, Action progressReporter) { if (gCodeString == null) { @@ -259,7 +259,7 @@ namespace MatterHackers.GCodeVisualizer if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200) { - progressReporter(((double)lineIndex / crCount / 2, "")); + progressReporter((double)lineIndex / crCount / 2, ""); if (cancellationToken.IsCancellationRequested) { @@ -280,7 +280,7 @@ namespace MatterHackers.GCodeVisualizer return loadedGCodeFile; } - private void AnalyzeGCodeLines(CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> progressReporter) + private void AnalyzeGCodeLines(CancellationToken cancellationToken, Action progressReporter) { double feedRateMmPerMin = 0; Vector3 lastPrinterPosition = new Vector3(); @@ -334,7 +334,7 @@ namespace MatterHackers.GCodeVisualizer if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200) { - progressReporter((((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, "")); + progressReporter(((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, ""); if (cancellationToken.IsCancellationRequested) { return; diff --git a/PartPreviewWindow/CreateDiscreteMeshes.cs b/PartPreviewWindow/CreateDiscreteMeshes.cs index 7cc98b5c6..48390ccac 100644 --- a/PartPreviewWindow/CreateDiscreteMeshes.cs +++ b/PartPreviewWindow/CreateDiscreteMeshes.cs @@ -27,6 +27,10 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; using ClipperLib; using MatterHackers.Agg; using MatterHackers.Agg.Image; @@ -34,10 +38,6 @@ using MatterHackers.Agg.ImageProcessing; using MatterHackers.MarchingSquares; using MatterHackers.PolygonMesh; using MatterHackers.VectorMath; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; namespace MatterHackers.MatterControl { @@ -47,19 +47,19 @@ namespace MatterHackers.MatterControl public static class CreateDiscreteMeshes { - public static List SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> reportProgress) + public static List SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, CancellationToken cancellationToken, Action reportProgress) { List discreteMeshes = new List(); double ratioPerDiscreetMesh = 1.0 / meshGroupToSplit.Meshes.Count; double currentRatioDone = 0; foreach (Mesh mesh in meshGroupToSplit.Meshes) { - List discreteVolumes = SplitVolumesIntoMeshes(mesh, cancellationToken, ((double progress0To1, string processingState) progressIn) => + List discreteVolumes = SplitVolumesIntoMeshes(mesh, cancellationToken, (double progress0To1, string processingState) => { if (reportProgress != null) { - double progress = (currentRatioDone + ratioPerDiscreetMesh * progressIn.progress0To1); - reportProgress.Invoke((progress, "Split Into Meshes")); + double progress = (currentRatioDone + ratioPerDiscreetMesh * progress0To1); + reportProgress.Invoke(progress, "Split Into Meshes"); } }); discreteMeshes.AddRange(discreteVolumes); @@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl return discreteMeshes; } - public static List SplitVolumesIntoMeshes(Mesh meshToSplit, CancellationToken cancellationToken, ReportProgressRatio<(double ratio, string state)> reportProgress) + public static List SplitVolumesIntoMeshes(Mesh meshToSplit, CancellationToken cancellationToken, Action reportProgress) { List discreetVolumes = new List(); HashSet facesThatHaveBeenAdded = new HashSet(); @@ -125,14 +125,14 @@ namespace MatterHackers.MatterControl if (reportProgress != null) { double progress = faceIndex / (double)meshToSplit.Faces.Count; - reportProgress((progress, "Split Into Meshes")); + reportProgress(progress, "Split Into Meshes"); } } return discreetVolumes; } - public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, ReportProgressRatio<(double ratio, string state)> reportProgress) + public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, Action reportProgress) { // check if the part is bigger than the build plate (if it is we need to use that as our size) AxisAlignedBoundingBox partBounds = meshToSplit.GetAxisAlignedBoundingBox(); @@ -150,7 +150,7 @@ namespace MatterHackers.MatterControl PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partPlate.NewGraphics2D(), meshToSplit, renderOffset, scaleFactor, RGBA_Bytes.White); - reportProgress?.Invoke((.2, "")); + reportProgress?.Invoke(.2, ""); //ImageIO.SaveImageData("test part plate 0.png", partPlate); // expand the bounds a bit so that we can collect all the vertices and polygons within each bound @@ -188,7 +188,7 @@ namespace MatterHackers.MatterControl graphics2D.Render(PlatingHelper.PolygonToPathStorage(polygon), new RGBA_Bytes(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))); } - reportProgress?.Invoke((.5, "")); + reportProgress?.Invoke(.5, ""); //ImageIO.SaveImageData("test part plate 2.png", partPlate); @@ -233,7 +233,7 @@ namespace MatterHackers.MatterControl } } - reportProgress?.Invoke((.8, "")); + reportProgress?.Invoke(.8, ""); for (int i = 0; i < discreteMeshes.Count(); i++) { diff --git a/PartPreviewWindow/PlatingHelper.cs b/PartPreviewWindow/PlatingHelper.cs index be8d86de9..f1bd20ace 100644 --- a/PartPreviewWindow/PlatingHelper.cs +++ b/PartPreviewWindow/PlatingHelper.cs @@ -326,7 +326,7 @@ namespace MatterHackers.MatterControl } /* - public static void CreateITraceableForMeshGroup(List perMeshGroupInfo, List meshGroups, int meshGroupIndex, ReportProgressRatio<(double ratio, string state)> reportProgress) + public static void CreateITraceableForMeshGroup(List perMeshGroupInfo, List meshGroups, int meshGroupIndex, Action reportProgress) { if (meshGroups != null) { @@ -366,7 +366,7 @@ namespace MatterHackers.MatterControl return BoundingVolumeHierarchy.CreateNewHierachy(allPolys); } - private static List AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, ReportProgressRatio<(double ratio, string state)> reportProgress) + private static List AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, Action reportProgress) { var continueProcessing = new CancellationTokenSource(); diff --git a/PartPreviewWindow/View3D/DragDropLoadProgress.cs b/PartPreviewWindow/View3D/DragDropLoadProgress.cs index 7d9422e9a..abb570956 100644 --- a/PartPreviewWindow/View3D/DragDropLoadProgress.cs +++ b/PartPreviewWindow/View3D/DragDropLoadProgress.cs @@ -70,12 +70,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - public void ProgressReporter((double progress0To1, string processingState) progress) + public void ProgressReporter(double progress0To1, string processingState) { - progressBar.RatioComplete = progress.progress0To1; + progressBar.RatioComplete = progress0To1; view3DWidget?.Invalidate(); - if (progress.progress0To1 == 1) + if (progress0To1 == 1) { if (view3DWidget != null) { diff --git a/PartPreviewWindow/View3D/Gui3D/MoveInZControl.cs b/PartPreviewWindow/View3D/Gui3D/MoveInZControl.cs index b7ed8b40d..34705b7c0 100644 --- a/PartPreviewWindow/View3D/Gui3D/MoveInZControl.cs +++ b/PartPreviewWindow/View3D/Gui3D/MoveInZControl.cs @@ -32,13 +32,10 @@ using System.Collections.Generic; using System.IO; using System.Threading; using MatterHackers.Agg; -using MatterHackers.Agg.Image; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; -using MatterHackers.MatterControl; using MatterHackers.MatterControl.CustomWidgets; -using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MeshVisualizer; using MatterHackers.PolygonMesh; using MatterHackers.RayTracer; diff --git a/PartPreviewWindow/View3D/MeshViewerWidget.cs b/PartPreviewWindow/View3D/MeshViewerWidget.cs index b2c1df9b9..76faaf248 100644 --- a/PartPreviewWindow/View3D/MeshViewerWidget.cs +++ b/PartPreviewWindow/View3D/MeshViewerWidget.cs @@ -27,29 +27,23 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.OpenGlGui; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; +using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.PolygonMesh; -using MatterHackers.PolygonMesh.Processors; -using MatterHackers.RayTracer; -using MatterHackers.RayTracer.Traceable; using MatterHackers.RenderOpenGl; using MatterHackers.RenderOpenGl.OpenGl; using MatterHackers.VectorMath; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using System.Xml.Linq; -using System.Threading; -using MatterHackers.MatterControl.PartPreviewWindow; namespace MatterHackers.MeshVisualizer { @@ -593,18 +587,18 @@ namespace MatterHackers.MeshVisualizer partProcessingInfo.Visible = false; } - public void ReportProgress0to100((double progress0To1, string processingState) progress) + public void ReportProgress0to100(double progress0To1, string processingState) { UiThread.RunOnIdle(() => { - int percentComplete = (int)(progress.progress0To1 * 100); + int percentComplete = (int)(progress0To1 * 100); partProcessingInfo.centeredInfoText.Text = "{0} {1}%...".FormatWith(progressReportingPrimaryTask, percentComplete); partProcessingInfo.progressControl.PercentComplete = percentComplete; // Only assign to textbox if value passed through - if (progress.processingState != null) + if (processingState != null) { - partProcessingInfo.centeredInfoDescription.Text = progress.processingState; + partProcessingInfo.centeredInfoDescription.Text = processingState; } }); } diff --git a/PartPreviewWindow/View3D/SceneActions.cs b/PartPreviewWindow/View3D/SceneActions.cs index de12743a2..3df8446e7 100644 --- a/PartPreviewWindow/View3D/SceneActions.cs +++ b/PartPreviewWindow/View3D/SceneActions.cs @@ -32,7 +32,6 @@ using System.Globalization; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; @@ -62,9 +61,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow && !selectedItem.HasChildren && selectedItem.Mesh != null) { - var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, CancellationToken.None, ((double progress0To1, string processingState) progress) => + var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, CancellationToken.None, (double progress0To1, string processingState) => { - view3DWidget.ReportProgressChanged(progress.progress0To1 * .5, progress.processingState); + view3DWidget.ReportProgressChanged(progress0To1 * .5, processingState); }); if (discreetMeshes.Count == 1) diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 76ae10c4e..eae9ee420 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -46,7 +46,6 @@ using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; -using MatterHackers.MatterControl.ActionBar; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.Library; @@ -890,17 +889,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { sourceListItem.StartProgress(); - contentResult = DragSourceModel.CreateContent(((double progress0To1, string processingState) progress) => + contentResult = DragSourceModel.CreateContent((double ratio, string state) => { - sourceListItem.ProgressReporter(progress); - loadProgress.ProgressReporter(progress); + sourceListItem.ProgressReporter(ratio, state); + loadProgress.ProgressReporter(ratio, state); }); await contentResult.MeshLoaded; sourceListItem.EndProgress(); - loadProgress.ProgressReporter((1, "")); + loadProgress.ProgressReporter(1, ""); } return contentResult?.Object3D; @@ -1842,10 +1841,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { var libraryItem = new FileSystemFileItem(filePath); - var contentResult = libraryItem.CreateContent(((double progress0To1, string processingState) progress) => + var contentResult = libraryItem.CreateContent((double progress0To1, string processingState) => { double ratioAvailable = (ratioPerFile * .5); - double currentRatio = currentRatioDone + progress.progress0To1 * ratioAvailable; + double currentRatio = currentRatioDone + progress0To1 * ratioAvailable; ReportProgressChanged(currentRatio, progressMessage); }); diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index e51c55200..3e5f91ab7 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -29,8 +29,6 @@ either expressed or implied, of the FreeBSD Project. using System; using System.IO; -using System.Linq; -using System.Threading; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.GCodeVisualizer; @@ -174,9 +172,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - internal void LoadProgress_Changed((double progress0To1, string processingState) progress) + internal void LoadProgress_Changed(double progress0To1, string processingState) { - SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress.progress0To1 * 100)); + SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress0To1 * 100)); } private void SetProcessingMessage(string message) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0df89d544..0ae38f478 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0df89d544f83e0359fb512a4b83e1fc91c23890e +Subproject commit 0ae38f47898e67ca5d948fdfdf06877185caf159