diff options
author | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-03-28 06:26:01 +0300 |
---|---|---|
committer | Tiago Conceição <Tiago_caza@hotmail.com> | 2021-03-28 06:26:01 +0300 |
commit | 1e9bbf9562357f1c53db91f0148cfc01e9db2d62 (patch) | |
tree | ca763c375807ae8243c23438aac301d90f8046d5 /UVtools.WPF | |
parent | 2231fdaca309cec03bb02e59a52ed6685a906cf4 (diff) |
v2.7.2v2.7.2
* **Core:**
* Fix some improper locks for progress counter and change to Interlocked instead
* Fix a bug when chaging layer count by remove or add layers it will malform the file after save and crash the program with some tools and/or clipboard
* Fix when a operation fails by other reason different from cancelation it was not restoring the backup
* When manually delete/fix issues it will also backup the layers
* **LayerManager:**
* LayerManager is now readonly and no longer used to transpose layers, each FileFormat have now a unique `LayerManager` instance which is set on the generic constructor
* Implemented `List<Layer>` methods to easy modify the layers array
* Changing the `Layers` instance will now recompute some properties, call the properties rebuild and forced sanitize of the structure
* Better reallocation methods
* **Clipboard Manager:**
* Add the hability to do full backups, they will be marked with an asterisk (*) at clipboard items list
* When a partial backup is made and it backups all the layers it will be converted to full backup
* Clipboard can now restore a snapshot directly with `RestoreSnapshot`
* Prevent restore the initial backup upon file load and when clearing the clipboard
* Clip's that change the layer count will perform a full backup and also do a fail-safe backup behind if previous clip is not a full backup
* **Pixel dimming:**
* Allow to load an image file as a pattern (Do not use very large files or it will take much time to dump the data into the textbox)
* Empty lines on patterns will be discarded and not trigger validation error
Diffstat (limited to 'UVtools.WPF')
-rw-r--r-- | UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml | 37 | ||||
-rw-r--r-- | UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml.cs | 13 | ||||
-rw-r--r-- | UVtools.WPF/MainWindow.Issues.cs | 14 | ||||
-rw-r--r-- | UVtools.WPF/MainWindow.PixelEditor.cs | 10 | ||||
-rw-r--r-- | UVtools.WPF/MainWindow.axaml.cs | 13 | ||||
-rw-r--r-- | UVtools.WPF/UVtools.WPF.csproj | 2 |
6 files changed, 67 insertions, 22 deletions
diff --git a/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml b/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml index 8ec27a5..6128e4f 100644 --- a/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml +++ b/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml @@ -68,28 +68,43 @@ </StackPanel> <Grid - RowDefinitions="200,10,Auto" - ColumnDefinitions="450,10,450" - > + RowDefinitions="Auto,200,10,Auto" + ColumnDefinitions="450,10,450"> + + <Button Grid.Row="0" Grid.Column="0" + Content="Load pattern from image" + HorizontalContentAlignment="Center" + VerticalAlignment="Stretch" + HorizontalAlignment="Stretch" + Command="{Binding LoadPatternFromImage}" + CommandParameter="False"/> + <TextBox + Grid.Row="1" Grid.Column="0" AcceptsReturn="True" Watermark="Pattern" UseFloatingWatermark="True" TextWrapping="NoWrap" - Text="{Binding Operation.PatternText}" - /> + Text="{Binding Operation.PatternText}"/> + + <Button Grid.Row="0" Grid.Column="2" + Content="Load alternate pattern from image" + HorizontalContentAlignment="Center" + VerticalAlignment="Stretch" + HorizontalAlignment="Stretch" + Command="{Binding LoadPatternFromImage}" + CommandParameter="True"/> <TextBox - Grid.Column="2" + Grid.Row="1" Grid.Column="2" AcceptsReturn="True" Watermark="Alternate pattern (Optional)" UseFloatingWatermark="True" TextWrapping="NoWrap" - Text="{Binding Operation.AlternatePatternText}" - /> + Text="{Binding Operation.AlternatePatternText}"/> <Border - Grid.Row="3" - BorderBrush="LightGray" + Grid.Row="3" Grid.Column="0" + BorderBrush="LightGray" BorderThickness="1" Padding="5" > @@ -195,7 +210,7 @@ </Border> <Border - Grid.Row="2" + Grid.Row="3" Grid.Column="2" BorderBrush="LightGray" BorderThickness="1" diff --git a/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml.cs b/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml.cs index 4d09bb6..2d32651 100644 --- a/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml.cs +++ b/UVtools.WPF/Controls/Tools/ToolPixelDimmingControl.axaml.cs @@ -1,4 +1,5 @@ using System; +using Avalonia.Controls; using Avalonia.Markup.Xaml; using Emgu.CV; using UVtools.Core.Extensions; @@ -23,7 +24,17 @@ namespace UVtools.WPF.Controls.Tools { AvaloniaXamlLoader.Load(this); } - + public async void LoadPatternFromImage(bool isAlternatePattern = false) + { + var dialog = new OpenFileDialog + { + AllowMultiple = false, + Filters = Helpers.ImagesFileFilter, + }; + var files = await dialog.ShowAsync(ParentWindow); + if (files is null || files.Length == 0) return; + Operation.LoadPatternFromImage(files[0], isAlternatePattern); + } } } diff --git a/UVtools.WPF/MainWindow.Issues.cs b/UVtools.WPF/MainWindow.Issues.cs index 2971ea6..5e9c513 100644 --- a/UVtools.WPF/MainWindow.Issues.cs +++ b/UVtools.WPF/MainWindow.Issues.cs @@ -111,7 +111,9 @@ namespace UVtools.WPF IsGUIEnabled = false; - + + Clipboard.Snapshot(); + var task = await Task.Factory.StartNew(() => { ShowProgressWindow("Removing selected issues"); @@ -160,7 +162,7 @@ namespace UVtools.WPF } } - progress++; + progress.LockAndIncrement(); }); if (layersRemove.Count > 0) @@ -181,7 +183,11 @@ namespace UVtools.WPF IsGUIEnabled = true; - if (!task) return; + if (!task) + { + Clipboard.RestoreSnapshot(); + return; + } var whiteListLayers = new List<uint>(); @@ -207,6 +213,8 @@ namespace UVtools.WPF } + Clipboard.Clip($"Manually removed {issueRemoveList.Count} issues"); + Issues.RemoveMany(issueRemoveList); if (layersRemove.Count > 0) diff --git a/UVtools.WPF/MainWindow.PixelEditor.cs b/UVtools.WPF/MainWindow.PixelEditor.cs index ea23b9a..e7984cd 100644 --- a/UVtools.WPF/MainWindow.PixelEditor.cs +++ b/UVtools.WPF/MainWindow.PixelEditor.cs @@ -387,6 +387,7 @@ namespace UVtools.WPF try { SlicerFile.LayerManager.DrawModifications(Drawings, ProgressWindow.RestartProgress()); + return true; } catch (OperationCanceledException) { @@ -405,11 +406,18 @@ namespace UVtools.WPF IsGUIEnabled = true; + if (!task.Result) + { + Clipboard.RestoreSnapshot(); + ShowLayer(); + return; + } + Clipboard.Clip($"Draw {Drawings.Count} modifications"); if (Settings.PixelEditor.PartialUpdateIslandsOnEditing) { - List<uint> whiteListLayers = new List<uint>(); + List<uint> whiteListLayers = new(); foreach (var item in Drawings) { /*if (item.OperationType != PixelOperation.PixelOperationType.Drawing && diff --git a/UVtools.WPF/MainWindow.axaml.cs b/UVtools.WPF/MainWindow.axaml.cs index bc680e6..6512bea 100644 --- a/UVtools.WPF/MainWindow.axaml.cs +++ b/UVtools.WPF/MainWindow.axaml.cs @@ -1060,7 +1060,7 @@ namespace UVtools.WPF } } - ClipboardManager.Instance.Init(SlicerFile); + Clipboard.Init(SlicerFile); if (SlicerFile is not ImageFile) { @@ -1466,11 +1466,11 @@ namespace UVtools.WPF IsGUIEnabled = false; - LayerManager backup = null; + Clipboard.Snapshot(); + var result = await Task.Factory.StartNew(() => { ShowProgressWindow(baseOperation.ProgressTitle); - backup = SlicerFile.LayerManager.Clone(); try { @@ -1478,7 +1478,6 @@ namespace UVtools.WPF } catch (OperationCanceledException) { - SlicerFile.LayerManager = backup; } catch (Exception ex) { @@ -1494,7 +1493,7 @@ namespace UVtools.WPF if (result) { - ClipboardManager.Instance.Clip(baseOperation, backup); + Clipboard.Clip(baseOperation); ShowLayer(); RefreshProperties(); @@ -1510,6 +1509,10 @@ namespace UVtools.WPF break; } } + else + { + Clipboard.RestoreSnapshot(); + } if (baseOperation.Tag is not null) { diff --git a/UVtools.WPF/UVtools.WPF.csproj b/UVtools.WPF/UVtools.WPF.csproj index f6ff058..bd98a45 100644 --- a/UVtools.WPF/UVtools.WPF.csproj +++ b/UVtools.WPF/UVtools.WPF.csproj @@ -12,7 +12,7 @@ <PackageLicenseFile>LICENSE</PackageLicenseFile> <RepositoryUrl>https://github.com/sn4k3/UVtools</RepositoryUrl> <RepositoryType>Git</RepositoryType> - <Version>2.7.1</Version> + <Version>2.7.2</Version> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |