Files
UVtools/UVtools.WPF/Controls/Tools/ToolControl.axaml.cs
T
Tiago Conceição 6dc26f7434 v3.8.0
- **File formats:**
  - (Add) Property: DisplayTotalOnTime
  - (Add) Property: DisplayTotalOffTime
  - (Add) SL1File Property: high_viscosity_tilt_time
- **Tools**
  - **I printed this file**
    - (Add) Display on time for the print information
    - (Improvement) Labels on numeric box
    - (Improvement) Show print time label formatted as hh:mm:ss
  - **PCB Exposure:**
    - (Improvement) Increase "Exposure time" maximum from 200s to 1000s (#592)
    - (Fix) Set `BottomLightHeight` to 0
    - (Fix) Set `TransitionLayerCount` to 0
- **Issues:**
  - (Improvement) Overhang detection by using a dynamic cross kernel
  - (Improvement) Bring back the discard logic of "false-positive" islands based on overhang detection but improve the threshold of the detection to be safer (#591, #591)
- **PrusaSlicer:**
  - (Change) Elegoo Mars 2 to use file version 4
  - (Change) Elegoo Mars 2 Pro to use file version 4
- (Add) Status bar: On and Off time (hh:mm:ss) as tooltip in the Print time label
- (Improvement) When any of libcvextern dependencies are missing, it try to show the missing libraries in the error message (Linux only)
- (Improvement) Auto-upgrade procedure for non-Windows systems
- (Improvement) macOS arm64 (M1/M2) can now run natively if installed via the auto installer script
- (Fix) Error on Mat cache manager when file have only one layer
- (Fix) Suggestion "Transition layer count" shows as never applied when using with file formats that use in-firmware transition layers
- (Upgrade) openCV from 4.5.4 to 4.6.0
  - Custom library is now built to strip unused dependencies and reduce library size
- (Remove) arch and rhel packages in favor of a generic linux
2022-10-30 00:52:49 +01:00

115 lines
3.2 KiB
C#

using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using UVtools.Core.Objects;
using UVtools.Core.Operations;
using UVtools.WPF.Extensions;
using UVtools.WPF.Windows;
namespace UVtools.WPF.Controls.Tools;
public class ToolControl : UserControlEx
{
private Operation _baseOperation;
public Operation BaseOperation
{
get => _baseOperation;
set
{
bool wasNullBefore = _baseOperation is null;
_baseOperation = value;
_baseOperation.SlicerFile = SlicerFile;
RaisePropertyChanged();
if (!wasNullBefore)
{
Callback(ToolWindow.Callbacks.Loaded);
}
if (DataContext is null) return;
ResetDataContext();
}
}
public ToolWindow ParentWindow { get; set; } = null;
public bool CanRun { get; set; } = true;
public ToolControl()
{
InitializeComponent();
}
public ToolControl(Operation operation)
{
BaseOperation = operation;
if (!ValidateSpawn()) return;
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public bool ValidateSpawn()
{
if (Design.IsDesignMode) return true;
if(_baseOperation is null)
{
App.MainWindow.MessageBoxInfo("The operation does not contain a valid configuration.\n" +
"Please contact the support/developer.", BaseOperation.NotSupportedTitle).ConfigureAwait(false);
CanRun = false;
return false;
}
if (!_baseOperation.ValidateSpawn(out var message))
{
App.MainWindow.MessageBoxInfo(message, BaseOperation.NotSupportedTitle).ConfigureAwait(false);
CanRun = false;
return false;
}
return true;
}
public virtual void Callback(ToolWindow.Callbacks callback) { }
public virtual bool UpdateOperation() => true;
/*public virtual void SetOperation(Operation operation)
{
BaseOperation = operation;
ResetDataContext();
}*/
/// <summary>
/// Validates if is safe to continue with operation
/// </summary>
/// <returns></returns>
public virtual async Task<bool> ValidateForm()
{
if (BaseOperation is null) return true;
if (!UpdateOperation()) return false;
return await ValidateFormFromString(BaseOperation.Validate());
}
/// <summary>
/// Validates if is safe to continue with operation, if not shows a message box with the error
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public async Task<bool> ValidateFormFromString(string text)
{
if (string.IsNullOrEmpty(text)) return true;
await ParentWindow.MessageBoxError(text);
return false;
}
/// <summary>
/// Validates if is safe to continue with operation, if not shows a message box with the error
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public async Task<bool> ValidateFormFromString(ValueDescription text) => await ValidateFormFromString(text?.ToString());
}