mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
ea4f7e0400
- **UI:** - (Improvement) Layer navigation load time by parallel `Mat` to `Bitmap` conversion - (Improvement) Allow to show exceptions without the stack trace and detailed trigger action by using the `MessageExceiption` (#644) - (Improvement) Allow progress to have and display a detailed log (#644) - (Improvement) Convert format to another with multiple versions will now only show the possible versions for the extension - **Suggestion - Wait time before cure:** - (Improvement) Set the first wait time based on first valid layer mass rather than use the fixed limit - (Improvement) Set zero time to empty and dummy layers - (Improvement) When creating the dummy layer also increment the bottom layer count as the created layer count as one - **PCB Exposure:** - (Add) Excellon Drill Format (drl) to cut off holes (Implementation may lack some advanced features, please confirm the result) (#646) - (Fix) Arc (G03) with negative offsets (I-/J-) was not drawing the shape correctly - (Fix) Implement the rotation for the outline primitive (#645) - **File formats:** - (Improvement) Formats now sanitize the selected version before encode given the file extension, if version is out of range it will force the last known version - (Fix) CBDDLP: Remove a table from the file that might cause layer corruption - (Add) Operations - `AfterCompleteReport` property: Gets or sets an report to show to the user after complete the operation with success - (Improvement) Suggestion - Wait time after cure: Set zero time to empty and dummy layers - (Improvement) Slight improvement on the contour intersection check, yields better performance on resin and suction cup detection - (Improvement) Allow to trigger message boxes from operations and scripts (#644) - (Upgrade) .NET from 6.0.12 to 6.0.13
190 lines
5.6 KiB
C#
190 lines
5.6 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using Avalonia.Controls;
|
|
using Avalonia.Threading;
|
|
using MessageBox.Avalonia.Enums;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UVtools.Core.Suggestions;
|
|
using UVtools.WPF.Extensions;
|
|
using UVtools.WPF.Structures;
|
|
using UVtools.WPF.Windows;
|
|
|
|
namespace UVtools.WPF;
|
|
|
|
public partial class MainWindow
|
|
{
|
|
#region Members
|
|
|
|
private ListBox _suggestionsAvailableListBox;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
public Suggestion[] Suggestions
|
|
{
|
|
get => SuggestionManager.Instance.Suggestions;
|
|
set => SuggestionManager.Instance.Suggestions = value;
|
|
}
|
|
|
|
public RangeObservableCollection<Suggestion> SuggestionsAvailable { get; } = new();
|
|
public RangeObservableCollection<Suggestion> SuggestionsApplied { get; } = new();
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
public void InitSuggestions()
|
|
{
|
|
_suggestionsAvailableListBox = this.FindControl<ListBox>("SuggestionsAvailableListBox");
|
|
}
|
|
|
|
public void PopulateSuggestions(bool tryToAutoApply = true)
|
|
{
|
|
var suggestionsAvailable = new List<Suggestion>();
|
|
var suggestionsApplied = new List<Suggestion>();
|
|
byte autoApplied = 0;
|
|
foreach (var suggestion in Suggestions)
|
|
{
|
|
suggestion.SlicerFile = SlicerFile;
|
|
if(!suggestion.Enabled || !suggestion.IsAvailable) continue;
|
|
if (tryToAutoApply && suggestion.ExecuteIfAutoApply())
|
|
{
|
|
autoApplied++;
|
|
}
|
|
|
|
if(suggestion.IsApplied) suggestionsApplied.Add(suggestion);
|
|
else suggestionsAvailable.Add(suggestion);
|
|
}
|
|
|
|
SuggestionsAvailable.ReplaceCollection(suggestionsAvailable);
|
|
SuggestionsApplied.ReplaceCollection(suggestionsApplied);
|
|
|
|
if (autoApplied > 0)
|
|
{
|
|
CanSave = true;
|
|
ResetDataContext();
|
|
ForceUpdateActualLayer();
|
|
}
|
|
}
|
|
|
|
public async void ApplySuggestionsClicked()
|
|
{
|
|
if (!IsFileLoaded || _suggestionsAvailableListBox.SelectedItems.Count == 0) return;
|
|
var suggestions = _suggestionsAvailableListBox.SelectedItems.Cast<Suggestion>().Where(suggestion => !suggestion.IsInformativeOnly).ToArray();
|
|
if (suggestions.Length == 0) return;
|
|
var sb = new StringBuilder($"Are you sure you want to apply the following {suggestions.Length} suggestions?:\n\n");
|
|
|
|
foreach (var suggestion in suggestions)
|
|
{
|
|
sb.AppendLine(suggestion.ConfirmationMessage);
|
|
}
|
|
if (await this.MessageBoxQuestion(sb.ToString(), "Apply suggestions?") != ButtonResult.Yes) return;
|
|
|
|
IsGUIEnabled = false;
|
|
ShowProgressWindow($"Applying {suggestions.Length} suggestions", false);
|
|
|
|
var executed = await Task.Run(() =>
|
|
{
|
|
uint executed = 0;
|
|
|
|
try
|
|
{
|
|
foreach (var suggestion in suggestions)
|
|
{
|
|
if (suggestion.Execute(Progress))
|
|
{
|
|
executed++;
|
|
}
|
|
}
|
|
}
|
|
catch (OperationCanceledException)
|
|
{ }
|
|
catch (Exception ex)
|
|
{
|
|
Dispatcher.UIThread.InvokeAsync(async () => await this.MessageBoxError(ex.ToString(), "Error while applying a suggestion"));
|
|
}
|
|
|
|
return executed;
|
|
});
|
|
|
|
IsGUIEnabled = true;
|
|
|
|
|
|
|
|
if (executed > 0)
|
|
{
|
|
CanSave = true;
|
|
ResetDataContext();
|
|
ForceUpdateActualLayer();
|
|
}
|
|
|
|
PopulateSuggestions(false);
|
|
}
|
|
|
|
public async void ApplySuggestionClicked(Suggestion suggestion)
|
|
{
|
|
if (!IsFileLoaded || suggestion is null || suggestion.IsInformativeOnly) return;
|
|
|
|
if (await this.MessageBoxQuestion($"Are you sure you want to apply the following suggestion?:\n\n{suggestion.ConfirmationMessage}", "Apply the suggestion?") != ButtonResult.Yes) return;
|
|
|
|
|
|
IsGUIEnabled = false;
|
|
ShowProgressWindow(suggestion.Title, false);
|
|
|
|
var result = await Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
return suggestion.Execute(Progress);
|
|
}
|
|
catch (OperationCanceledException)
|
|
{
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Dispatcher.UIThread.InvokeAsync(async () => await this.MessageBoxError(ex.ToString(), $"{suggestion.Title} Error"));
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
IsGUIEnabled = true;
|
|
|
|
if (result)
|
|
{
|
|
CanSave = true;
|
|
ResetDataContext();
|
|
ForceUpdateActualLayer();
|
|
}
|
|
|
|
PopulateSuggestions(false);
|
|
}
|
|
|
|
public async void ConfigureSuggestionsClicked()
|
|
{
|
|
if (!IsFileLoaded || Suggestions.Length == 0) return;
|
|
var window = new SuggestionSettingsWindow();
|
|
await window.ShowDialog(this);
|
|
PopulateSuggestions(false);
|
|
}
|
|
|
|
public async void ConfigureSuggestionClicked(Suggestion suggestion)
|
|
{
|
|
if (!IsFileLoaded || Suggestions.Length == 0) return;
|
|
var window = new SuggestionSettingsWindow(suggestion);
|
|
await window.ShowDialog(this);
|
|
PopulateSuggestions(false);
|
|
}
|
|
|
|
#endregion
|
|
} |