diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-09-12 22:25:44 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2020-09-12 22:25:44 +0300 |
commit | 12fc6dae7d1b3b471141ab2e070b460e7b1ad3e3 (patch) | |
tree | e3891f17a59991ef019b5e1ebe26e4300dbea85b /UVtools.GUI | |
parent | cd60296df39650a9f097ff62eff27d68f137fb6f (diff) |
Backup layers on operations
When a operation is cancelled affected layers will revert to the original form (#57)
Diffstat (limited to 'UVtools.GUI')
-rw-r--r-- | UVtools.GUI/FrmMain.cs | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs index 485ae7e..9ac592d 100644 --- a/UVtools.GUI/FrmMain.cs +++ b/UVtools.GUI/FrmMain.cs @@ -2048,10 +2048,9 @@ namespace UVtools.GUI { SavesCount++; menuFileSave.Enabled = false; + UpdateTitle(); } - UpdateTitle(); - return task.Result; } @@ -4175,63 +4174,70 @@ namespace UVtools.GUI var task = Task.Factory.StartNew(() => { + var backup = new Layer[baseOperation.LayerRangeCount]; + uint i = 0; + for (uint layerIndex = baseOperation.LayerIndexStart; layerIndex <= baseOperation.LayerIndexEnd; layerIndex++) + { + backup[i++] = SlicerFile[layerIndex].Clone(); + } + try { switch (baseOperation) { // Tools case OperationRepairLayers operation: - SlicerFile.LayerManager.RepairLayers(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.RepairLayers(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationMove operation: - SlicerFile.LayerManager.Move(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Move(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationResize operation: - SlicerFile.LayerManager.Resize(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Resize(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationFlip operation: - SlicerFile.LayerManager.Flip(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Flip(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationRotate operation: - SlicerFile.LayerManager.Rotate(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Rotate(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationSolidify operation: - SlicerFile.LayerManager.Solidify(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Solidify(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationMorph operation: - SlicerFile.LayerManager.Morph(operation, BorderType.Default, new MCvScalar(), FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Morph(operation, BorderType.Default, new MCvScalar(), FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationMask operation: - SlicerFile.LayerManager.Mask(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Mask(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationPixelDimming operation: - SlicerFile.LayerManager.PixelDimming(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.PixelDimming(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationThreshold operation: - SlicerFile.LayerManager.ThresholdPixels(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.ThresholdPixels(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationBlur operation: - SlicerFile.LayerManager.Blur(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Blur(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationChangeResolution operation: - SlicerFile.LayerManager.ChangeResolution(operation, FrmLoading.RestartProgress(false)); + SlicerFile.LayerManager.ChangeResolution(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationLayerReHeight operation: - SlicerFile.LayerManager.ReHeight(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.ReHeight(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationPattern operation: - SlicerFile.LayerManager.Pattern(operation, FrmLoading.RestartProgress()); + SlicerFile.LayerManager.Pattern(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; // Actions case OperationLayerImport operation: - SlicerFile.LayerManager.Import(operation, FrmLoading.RestartProgress(false)); + SlicerFile.LayerManager.Import(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationLayerClone operation: - SlicerFile.LayerManager.CloneLayer(operation, FrmLoading.RestartProgress(false)); + SlicerFile.LayerManager.CloneLayer(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; case OperationLayerRemove operation: - SlicerFile.LayerManager.RemoveLayers(operation, FrmLoading.RestartProgress(false)); + SlicerFile.LayerManager.RemoveLayers(operation, FrmLoading.RestartProgress(operation.CanCancel)); break; default: @@ -4240,7 +4246,11 @@ namespace UVtools.GUI } catch (OperationCanceledException) { - + i = 0; + for (uint layerIndex = baseOperation.LayerIndexStart; layerIndex <= baseOperation.LayerIndexEnd; layerIndex++) + { + SlicerFile[layerIndex] = backup[i++]; + } } catch (Exception ex) { |