Changed ReportPregress delegate to have touple and use CancellationTokenSource

This commit is contained in:
Lars Brubaker 2017-06-30 16:09:31 -07:00
parent f7b5ea9386
commit 1a9ebebaed
30 changed files with 104 additions and 91 deletions

View file

@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl
thumbnailImage = thumbIcon;
}
public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio reporter)
public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter)
{
System.Diagnostics.Debugger.Break();
return null;

View file

@ -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 reporter);
ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> reporter);
}
public interface IPrintableContentProvider : IContentProvider

View file

@ -56,7 +56,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 progressReporter)
public ContentResult CreateItem(ILibraryItem item, ReportProgressRatio<(double ratio, string state)> progressReporter)
{
var sceneItem = new Object3D()
{

View file

@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.Library
}
}
public static ContentResult CreateContent(this ILibraryContentStream item, ReportProgressRatio reporter = null)
public static ContentResult CreateContent(this ILibraryContentStream item, ReportProgressRatio<(double ratio, string state)> reporter = null)
{
var contentProvider = ApplicationController.Instance.Library.GetContentProvider(item) as ISceneContentProvider;
return contentProvider?.CreateItem(item, reporter);

View file

@ -34,6 +34,6 @@ namespace MatterHackers.MatterControl.Library
{
public interface ILibraryContainerLink : ILibraryItem
{
Task<ILibraryContainer> GetContainer(ReportProgressRatio reportProgress);
Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress);
}
}

View file

@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.Library
{
string ContentType { get; }
string Category { get; }
Task<IObject3D> GetContent(ReportProgressRatio reportProgress);
Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress);
void SetContent(IObject3D item);
}
@ -58,6 +58,6 @@ namespace MatterHackers.MatterControl.Library
string ContentType { get; }
string FileName { get; }
string AssetPath { get; }
Task<StreamAndLength> GetContentStream(ReportProgressRatio reportProgress);
Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress);
}
}

View file

@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.Library
public bool IsVisible => this.visibilityResolver();
public Task<ILibraryContainer> GetContainer(ReportProgressRatio reportProgress)
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
return Task.FromResult(this.containerCreator());
}

View file

@ -385,7 +385,7 @@ namespace MatterHackers.MatterControl.Library
public bool UseIncrementedNameDuringTypeChange { get; set; }
public Task<ILibraryContainer> GetContainer(ReportProgressRatio reportProgress)
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
return Task.FromResult<ILibraryContainer>(
new FileSystemContainer(this.Path)

View file

@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.Library
}
}
public Task<StreamAndLength> GetContentStream(ReportProgressRatio reportProgress)
public Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
if (ApplicationController.Instance.IsLoadableFile(this.Path)
&& File.Exists(this.Path))
@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.Library
return Task.FromResult<StreamAndLength>(null);
}
public Task<IObject3D> GetContent(ReportProgressRatio reportProgress)
public Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
throw new NotImplementedException();
}

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.Library
/// </summary>
public Func<IObject3D> Collector { get; }
public Task<IObject3D> GetContent(ReportProgressRatio reportProgress) => Task.FromResult(Collector?.Invoke());
public Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress) => Task.FromResult(Collector?.Invoke());
public void SetContent(IObject3D item)
{

View file

@ -64,7 +64,7 @@ namespace MatterHackers.MatterControl.Library
public bool IsVisible => true;
public Task<StreamAndLength> GetContentStream(ReportProgressRatio reportProgress)
public Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
throw new NotImplementedException();
}

View file

@ -342,7 +342,7 @@ namespace MatterHackers.MatterControl.Library
public bool IsVisible { get; set; } = true;
public Task<ILibraryContainer> GetContainer(ReportProgressRatio reportProgress)
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
return Task.FromResult<ILibraryContainer>(
new SqliteLibraryContainer(this.ContainerID)

View file

@ -67,7 +67,7 @@ namespace MatterHackers.MatterControl.Library
}
}
public Task<ILibraryContainer> GetContainer(ReportProgressRatio reportProgress)
public Task<ILibraryContainer> GetContainer(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
return Task.FromResult<ILibraryContainer>(new ZipMemoryContainer(this.currentDirectory, this.Path));
}

View file

@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.Library
/// </summary>
public long FileSize { get; private set; }
public async Task<StreamAndLength> GetContentStream(ReportProgressRatio reportProgress)
public async Task<StreamAndLength> GetContentStream(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
var memStream = await Task.Run(() =>
{
@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.Library
}
/*
public async Task<IObject3D> GetContent(ReportProgressRatio reportProgress)
public async Task<IObject3D> GetContent(ReportProgressRatio<(double ratio, string state)> reportProgress)
{
var streamAndLength = await GetContentStream(null);
IObject3D object3D = Object3D.Load(streamAndLength.Stream, System.IO.Path.GetExtension(Name));

View file

@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Threading;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
@ -47,20 +48,18 @@ namespace MatterHackers.MatterControl.CustomWidgets
ProgressControl processingProgressControl;
internal void ProgressReporter(double progress0To1, string processingState, out bool continueProcessing)
internal void ProgressReporter((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing)
{
continueProcessing = true;
if (processingProgressControl == null)
{
return;
}
processingProgressControl.Visible = progress0To1 != 0;
processingProgressControl.RatioComplete = progress0To1;
processingProgressControl.ProcessType = processingState;
processingProgressControl.Visible = progress.progress0To1 != 0;
processingProgressControl.RatioComplete = progress.progress0To1;
processingProgressControl.ProcessType = progress.processingState;
if (progress0To1 == 1)
if (progress.progress0To1 == 1)
{
EndProgress();
}

View file

@ -33,6 +33,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using MatterHackers.Agg;
using MatterHackers.VectorMath;
@ -125,7 +126,7 @@ namespace MatterHackers.GCodeVisualizer
return loadedGCode;
}
public static async Task<GCodeMemoryFile> LoadInBackground(string fileName, ReportProgressRatio progressReporter)
public static async Task<GCodeMemoryFile> LoadInBackground(string fileName, ReportProgressRatio<(double ratio, string state)> progressReporter)
{
if (Path.GetExtension(fileName).ToUpper() == ".GCODE")
{
@ -198,7 +199,7 @@ namespace MatterHackers.GCodeVisualizer
return crCount + 1;
}
public static GCodeMemoryFile ParseFileContents(string gCodeString, ReportProgressRatio progressReporter)
public static GCodeMemoryFile ParseFileContents(string gCodeString, ReportProgressRatio<(double ratio, string state)> progressReporter)
{
if (gCodeString == null)
{
@ -277,8 +278,9 @@ namespace MatterHackers.GCodeVisualizer
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)
{
progressReporter((double)lineIndex / crCount / 2, "", out bool continueProcessing);
if (!continueProcessing)
var continueProcessing = new CancellationTokenSource();
progressReporter(((double)lineIndex / crCount / 2, ""), continueProcessing);
if (continueProcessing.IsCancellationRequested)
{
return null;
}
@ -297,7 +299,7 @@ namespace MatterHackers.GCodeVisualizer
return loadedGCodeFile;
}
private void AnalyzeGCodeLines(ReportProgressRatio progressReporter)
private void AnalyzeGCodeLines(ReportProgressRatio<(double ratio, string state)> progressReporter)
{
double feedRateMmPerMin = 0;
Vector3 lastPrinterPosition = new Vector3();
@ -351,8 +353,9 @@ namespace MatterHackers.GCodeVisualizer
if (progressReporter != null && maxProgressReport.ElapsedMilliseconds > 200)
{
progressReporter(((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, "", out bool continueProcessing);
if (!continueProcessing)
var continueProcessing = new CancellationTokenSource();
progressReporter((((double) lineIndex / GCodeCommandQueue.Count / 2) + .5, ""), continueProcessing);
if (continueProcessing.IsCancellationRequested)
{
return;
}

View file

@ -34,6 +34,9 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@ -58,5 +61,8 @@
<Name>VectorMath</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.ValueTuple" version="4.3.1" targetFramework="net461" />
</packages>

View file

@ -427,8 +427,8 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Net.Http" />
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />

View file

@ -37,6 +37,7 @@ using MatterHackers.VectorMath;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace MatterHackers.MatterControl
{
@ -46,23 +47,19 @@ namespace MatterHackers.MatterControl
public static class CreateDiscreteMeshes
{
public static List<Mesh> SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, ReportProgressRatio reportProgress)
public static List<Mesh> SplitConnectedIntoMeshes(MeshGroup meshGroupToSplit, ReportProgressRatio<(double ratio, string state)> reportProgress)
{
List<Mesh> discreteMeshes = new List<Mesh>();
double ratioPerDiscreetMesh = 1.0 / meshGroupToSplit.Meshes.Count;
double currentRatioDone = 0;
foreach (Mesh mesh in meshGroupToSplit.Meshes)
{
List<Mesh> discreteVolumes = SplitVolumesIntoMeshes(mesh, (double progress0To1, string processingState, out bool continueProcessing) =>
List<Mesh> discreteVolumes = SplitVolumesIntoMeshes(mesh, ((double progress0To1, string processingState) progressIn, CancellationTokenSource continueProcessing) =>
{
if (reportProgress != null)
{
double progress = (currentRatioDone + ratioPerDiscreetMesh * progress0To1);
reportProgress(progress, "Split Into Meshes", out continueProcessing);
}
else
{
continueProcessing = true;
double progress = (currentRatioDone + ratioPerDiscreetMesh * progressIn.progress0To1);
reportProgress((progress, "Split Into Meshes"), continueProcessing);
}
});
discreteMeshes.AddRange(discreteVolumes);
@ -73,7 +70,7 @@ namespace MatterHackers.MatterControl
return discreteMeshes;
}
public static List<Mesh> SplitVolumesIntoMeshes(Mesh meshToSplit, ReportProgressRatio reportProgress)
public static List<Mesh> SplitVolumesIntoMeshes(Mesh meshToSplit, ReportProgressRatio<(double ratio, string state)> reportProgress)
{
List<Mesh> discreetVolumes = new List<Mesh>();
HashSet<Face> facesThatHaveBeenAdded = new HashSet<Face>();
@ -127,15 +124,15 @@ namespace MatterHackers.MatterControl
if (reportProgress != null)
{
double progress = faceIndex / (double)meshToSplit.Faces.Count;
bool continueProcessing;
reportProgress(progress, "Split Into Meshes", out continueProcessing);
var continueProcessing = new CancellationTokenSource();
reportProgress((progress, "Split Into Meshes"), continueProcessing);
}
}
return discreetVolumes;
}
public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, ReportProgressRatio reportProgress)
public static Mesh[] SplitIntoMeshesOnOrthographicZ(Mesh meshToSplit, Vector3 buildVolume, ReportProgressRatio<(double ratio, string state)> 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();
@ -153,10 +150,10 @@ namespace MatterHackers.MatterControl
PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partPlate.NewGraphics2D(), meshToSplit, renderOffset, scaleFactor, RGBA_Bytes.White);
bool continueProcessin = true;
var continueProcessin = new CancellationTokenSource();
if (reportProgress != null)
{
reportProgress(.2, "", out continueProcessin);
reportProgress((.2, ""), continueProcessin);
}
//ImageIO.SaveImageData("test part plate 0.png", partPlate);
@ -196,7 +193,7 @@ namespace MatterHackers.MatterControl
}
if (reportProgress != null)
{
reportProgress(.5, "", out continueProcessin);
reportProgress((.5, ""), continueProcessin);
}
//ImageIO.SaveImageData("test part plate 2.png", partPlate);
@ -243,7 +240,7 @@ namespace MatterHackers.MatterControl
if (reportProgress != null)
{
reportProgress(.8, "", out continueProcessin);
reportProgress((.8, ""), continueProcessin);
}
for (int i = 0; i < discreteMeshes.Count(); i++)

View file

@ -86,12 +86,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private GCodeFile loadedGCode => printer.BedPlate.LoadedGCode;
private ReportProgressRatio progressReporter;
private ReportProgressRatio<(double ratio, string state)> progressReporter;
private View3DConfig options;
private PrinterConfig printer;
public GCode2DWidget(Vector2 gridSizeMm, Vector2 gridCenterMm, ReportProgressRatio progressReporter)
public GCode2DWidget(Vector2 gridSizeMm, Vector2 gridCenterMm, ReportProgressRatio<(double ratio, string state)> progressReporter)
{
options = ApplicationController.Instance.Options.View3D;

View file

@ -327,7 +327,7 @@ namespace MatterHackers.MatterControl
}
/*
public static void CreateITraceableForMeshGroup(List<PlatingMeshGroupData> perMeshGroupInfo, List<MeshGroup> meshGroups, int meshGroupIndex, ReportProgressRatio reportProgress)
public static void CreateITraceableForMeshGroup(List<PlatingMeshGroupData> perMeshGroupInfo, List<MeshGroup> meshGroups, int meshGroupIndex, ReportProgressRatio<(double ratio, string state)> reportProgress)
{
if (meshGroups != null)
{
@ -348,8 +348,8 @@ namespace MatterHackers.MatterControl
needUpdateTitle = true;
if (reportProgress != null)
{
bool continueProcessing;
reportProgress(currentAction / (double)totalActionCount, "Creating Trace Group", out continueProcessing);
var continueProcessing = new CancellationTokenSource();
reportProgress(currentAction / (double)totalActionCount, "Creating Trace Group", continueProcessing);
}
// only allow limited recursion to speed this up building this data
@ -367,9 +367,9 @@ namespace MatterHackers.MatterControl
return BoundingVolumeHierarchy.CreateNewHierachy(allPolys);
}
private static List<IPrimitive> AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, ReportProgressRatio reportProgress)
private static List<IPrimitive> AddTraceDataForMesh(Mesh mesh, int totalActionCount, ref int currentAction, ref bool needToUpdateProgressReport, ReportProgressRatio<(double ratio, string state)> reportProgress)
{
bool continueProcessing;
var continueProcessing = new CancellationTokenSource();
List<IPrimitive> allPolys = new List<IPrimitive>();
List<Vector3> positions = new List<Vector3>();
@ -403,7 +403,7 @@ namespace MatterHackers.MatterControl
{
if ((currentAction % 256) == 0 || needToUpdateProgressReport)
{
reportProgress(currentAction / (double)totalActionCount, "Creating Trace Polygons", out continueProcessing);
reportProgress(currentAction / (double)totalActionCount, "Creating Trace Polygons", continueProcessing);
needToUpdateProgressReport = false;
}
currentAction++;

View file

@ -48,6 +48,7 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Threading;
namespace MatterHackers.MeshVisualizer
{
@ -751,27 +752,23 @@ namespace MatterHackers.MeshVisualizer
partProcessingInfo.Visible = false;
}
public void ReportProgress0to100(double progress0To1, string processingState, out bool continueProcessing)
public void ReportProgress0to100((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing)
{
if (this.HasBeenClosed)
{
continueProcessing = false;
}
else
{
continueProcessing = true;
continueProcessing.Cancel();
}
UiThread.RunOnIdle(() =>
{
int percentComplete = (int)(progress0To1 * 100);
int percentComplete = (int)(progress.progress0To1 * 100);
partProcessingInfo.centeredInfoText.Text = "{0} {1}%...".FormatWith(progressReportingPrimaryTask, percentComplete);
partProcessingInfo.progressControl.PercentComplete = percentComplete;
// Only assign to textbox if value passed through
if (processingState != null)
if (progress.processingState != null)
{
partProcessingInfo.centeredInfoDescription.Text = processingState;
partProcessingInfo.centeredInfoDescription.Text = progress.processingState;
}
});
}

View file

@ -32,6 +32,7 @@ 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;
@ -61,9 +62,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
&& !selectedItem.HasChildren
&& selectedItem.Mesh != null)
{
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, (double progress0To1, string processingState, out bool continueProcessing) =>
var discreetMeshes = CreateDiscreteMeshes.SplitVolumesIntoMeshes(Scene.SelectedItem.Mesh, ((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing) =>
{
view3DWidget.ReportProgressChanged(progress0To1 * .5, processingState, out continueProcessing);
view3DWidget.ReportProgressChanged(progress.progress0To1 * .5, progress.processingState, continueProcessing);
});
if (discreetMeshes.Count == 1)
@ -194,9 +195,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
for (int i = 0; i < MeshGroups.Count; i++)
{
// create the selection info
PlatingHelper.CreateITraceableForMeshGroup(MeshGroups, i, (double progress0To1, string processingState, out bool continueProcessing) =>
PlatingHelper.CreateITraceableForMeshGroup(MeshGroups, i, (double progress0To1, string processingState, CancellationTokenSource continueProcessing) =>
{
ReportProgressChanged(progress0To1, processingState, out continueProcessing);
ReportProgressChanged(progress0To1, processingState, continueProcessing);
});
currentRatioDone += ratioPerMeshGroup;

View file

@ -145,11 +145,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
}
public void ProgressReporter(double progress0To1, string processingState, out bool continueProcessing)
public void ProgressReporter((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing)
{
continueProcessing = true;
progressBar.RatioComplete = progress0To1;
if (progress0To1 == 1)
progressBar.RatioComplete = progress.progress0To1;
if (progress.progress0To1 == 1)
{
if (view3DWidget != null)
{
@ -988,17 +987,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
sourceListItem.StartProgress();
contentResult = DragSourceModel.CreateContent((double progress0To1, string processingState, out bool continueProcessing) =>
contentResult = DragSourceModel.CreateContent(((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing) =>
{
sourceListItem.ProgressReporter(progress0To1, processingState, out continueProcessing);
loadProgress.ProgressReporter(progress0To1, processingState, out continueProcessing);
sourceListItem.ProgressReporter(progress, continueProcessing);
loadProgress.ProgressReporter(progress, continueProcessing);
});
await contentResult.MeshLoaded;
sourceListItem.EndProgress();
loadProgress.ProgressReporter(1, "", out bool continuex);
loadProgress.ProgressReporter((1, ""), new CancellationTokenSource());
}
return contentResult?.Object3D;
@ -1679,11 +1678,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
private void ReportProgressChanged(double progress0To1, string processingState)
{
bool continueProcessing;
ReportProgressChanged(progress0To1, processingState, out continueProcessing);
var continueProcessing = new CancellationTokenSource();
ReportProgressChanged(progress0To1, processingState, continueProcessing);
}
internal void ReportProgressChanged(double progress0To1, string processingState, out bool continueProcessing)
internal void ReportProgressChanged(double progress0To1, string processingState, CancellationTokenSource continueProcessing)
{
if (!timeSinceReported.IsRunning || timeSinceReported.ElapsedMilliseconds > 100
|| processingState != processingProgressControl.ProgressMessage)
@ -1695,7 +1694,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
});
timeSinceReported.Restart();
}
continueProcessing = true;
}
public async Task ClearBedAndLoadPrintItemWrapper(PrintItemWrapper newPrintItem, bool switchToEditingMode = false)
@ -1933,11 +1931,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
{
var libraryItem = new FileSystemFileItem(filePath);
var contentResult = libraryItem.CreateContent((double progress0To1, string processingState, out bool continueProcessing) =>
var contentResult = libraryItem.CreateContent(((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing) =>
{
double ratioAvailable = (ratioPerFile * .5);
double currentRatio = currentRatioDone + progress0To1 * ratioAvailable;
ReportProgressChanged(currentRatio, progressMessage, out continueProcessing);
double currentRatio = currentRatioDone + progress.progress0To1 * ratioAvailable;
ReportProgressChanged(currentRatio, progressMessage, continueProcessing);
});
contentResult?.MeshLoaded.ContinueWith((task) =>
@ -2321,7 +2319,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// TODO: Why were we recreating GLData on edit?
//bool continueProcessing2;
//ReportProgressChanged(1, "Creating GL Data", out continueProcessing2);
//ReportProgressChanged(1, "Creating GL Data", continueProcessing2);
//meshViewerWidget.CreateGlDataForMeshes(Scene.Children);
});

View file

@ -30,6 +30,7 @@ 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;
@ -594,10 +595,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
SetSyncToPrintVisibility();
}
private void LoadProgress_Changed(double progress0To1, string processingState, out bool continueProcessing)
private void LoadProgress_Changed((double progress0To1, string processingState) progress, CancellationTokenSource continueProcessing)
{
SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress0To1 * 100));
continueProcessing = !this.HasBeenClosed;
SetProcessingMessage(string.Format("{0} {1:0}%...", gcodeLoading, progress.progress0To1 * 100));
if(this.HasBeenClosed)
{
continueProcessing.Cancel();
}
}
private GuiWidget CreateGCodeViewWidget(string pathAndFileName)

@ -1 +1 @@
Subproject commit c8047868bac1cc6fecf77aaf871c241a48481789
Subproject commit 88107bb816ab25de37b338cb6a0b24511f51f56c

View file

@ -47,6 +47,9 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ValueTuple, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.XML" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>

View file

@ -4,4 +4,5 @@
<package id="NUnit" version="3.5.0" targetFramework="net45" />
<package id="NUnit.ApplicationDomain" version="10.2.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.7.0" targetFramework="net45" />
<package id="System.ValueTuple" version="4.3.1" targetFramework="net461" />
</packages>

View file

@ -2,5 +2,5 @@
<packages>
<package id="Mindscape.Raygun4Net" version="5.4.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.3.1" targetFramework="net461" />
</packages>