mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
9f7722d369
- **File formats:** - (Add) `TransitionLayerCount` modifier to: Chitubox Zip, CWS, JXS, OSLA, PW*, UVJ, ZCodex, ZCode - (Add) Utility methods for transition layers calculation/parse - (Improvement) Calculate and set `TransitionLayerCount` property in file decode based on layer exposure time configuration - **GCode:** - (Improvement) GCode: Able to parse layer image file with appended numbers on the filename (Afecting CWS) (#577) - (Fix) Bad parsing of the file when it comes from Lychee or NovaMaker slicer (Afecting CWS) - (Fix) Incorrect parse of "Wait time before cure" from layers when printer require wait sync moves (Afecting CWS) - **Tools:** - (Add) External tests: The Complete Resin 3D Printing Settings Guide for Beginners - (Add) External tests: 9 settings for faster printing - (Improvement) Fade exposure time: Set `TransitionLayerCount` property with the affected layer count - **Suggestions:** - (Add) Transition layers: If you are printing flat on the build plate your model will print better when using a smooth transition exposure time instead of a harsh variation, resulting in reduced layer line effect and avoid possible problems due the large exposure difference. This is not so important when your model print raised under a raft/supports unaffected by the bottom exposure, in that case, it's fine to ignore this. - (Add) Model position: Printing on a corner will reduce the FEP stretch forces when detaching from the model during a lift sequence, benefits are: Reduced lift height and faster printing, less stretch, less FEP marks, better FEP lifespan, easier to peel, less prone to failure and use the screen pixels more evenly. If the model is too large to fit within the margin(s) on the screen, it will attempt to center it on that same axis to avoid touching on screen edge(s) and to give a sane margin from it. - **Status bar:** - (Add) Transition layers: 0/-0.00s - (Improvement) Change "Layer Height: 0.000mm" to "Layers: count @ 0.000mm" - (Improvement) Change "Bottom layers: 0" to "Bottom layers: 0/0.000mm" - (Change) Show user informative message about CTB Encrypted file format once per ten file loads - (Upgrade) .NET from 6.0.9 to 6.0.10 - (Fix) Windows MSI installation not upgrading well when downgrade libraries
200 lines
5.5 KiB
C#
200 lines
5.5 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 System;
|
|
using System.ComponentModel;
|
|
using System.Xml.Serialization;
|
|
using UVtools.Core.FileFormats;
|
|
using UVtools.Core.Objects;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.Core.Suggestions;
|
|
|
|
public abstract class Suggestion : BindableBase
|
|
{
|
|
#region Enums
|
|
public enum SuggestionApplyWhen : byte
|
|
{
|
|
[Description("Outside limits: Applies when the recommended value does not meet the current limit criteria")]
|
|
OutsideLimits,
|
|
|
|
[Description("Different: Applies when the recommended value is different from the current")]
|
|
Different,
|
|
}
|
|
#endregion
|
|
|
|
#region Members
|
|
|
|
protected FileFormat _slicerFile = null!;
|
|
protected bool _enabled = true;
|
|
protected bool _autoApply;
|
|
protected SuggestionApplyWhen _applyWhen = SuggestionApplyWhen.OutsideLimits;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the <see cref="FileFormat"/>
|
|
/// </summary>
|
|
[XmlIgnore]
|
|
public FileFormat SlicerFile
|
|
{
|
|
get => _slicerFile;
|
|
set
|
|
{
|
|
if (ReferenceEquals(_slicerFile, value)) return;
|
|
_slicerFile = value;
|
|
RaisePropertyChanged();
|
|
RaisePropertyChanged(nameof(IsAvailable));
|
|
RaisePropertyChanged(nameof(IsApplied));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets if this suggestion is enabled
|
|
/// </summary>
|
|
public bool Enabled
|
|
{
|
|
get => _enabled;
|
|
set => RaiseAndSetIfChanged(ref _enabled, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets if this suggestion can be auto applied once file load
|
|
/// </summary>
|
|
public bool AutoApply
|
|
{
|
|
get => _autoApply;
|
|
set => RaiseAndSetIfChanged(ref _autoApply, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets when to apply the suggestion
|
|
/// </summary>
|
|
public SuggestionApplyWhen ApplyWhen
|
|
{
|
|
get => _applyWhen;
|
|
set => RaiseAndSetIfChanged(ref _applyWhen, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets if this suggestion is informative only and contain no actions to execute
|
|
/// </summary>
|
|
public virtual bool IsInformativeOnly => false;
|
|
|
|
/// <summary>
|
|
/// Gets if this suggestion is available given the <see cref="SlicerFile"/>
|
|
/// </summary>
|
|
public virtual bool IsAvailable => true;
|
|
|
|
/// <summary>
|
|
/// Gets if this suggestion is already applied given the <see cref="SlicerFile"/>
|
|
/// </summary>
|
|
public abstract bool IsApplied { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the title for this suggestion
|
|
/// </summary>
|
|
public abstract string Title { get; }
|
|
|
|
public abstract string Description { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the message for this suggestion
|
|
/// </summary>
|
|
public abstract string Message { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the tooltip message
|
|
/// </summary>
|
|
public virtual string ToolTip => Description;
|
|
|
|
public virtual string? InformationUrl => null;
|
|
|
|
/// <summary>
|
|
/// Gets the confirmation message before apply the suggestion
|
|
/// </summary>
|
|
public virtual string? ConfirmationMessage => null;
|
|
|
|
|
|
public string GlobalAppliedMessage => $"✓ {Title}";
|
|
public string GlobalNotAppliedMessage => $"⚠ {Title}";
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public void RefreshNotifyAll()
|
|
{
|
|
RaisePropertyChanged(nameof(IsAvailable));
|
|
RaisePropertyChanged(nameof(IsApplied));
|
|
RefreshNotifyMessage();
|
|
}
|
|
|
|
public void RefreshNotifyMessage()
|
|
{
|
|
RaisePropertyChanged(nameof(Message));
|
|
RaisePropertyChanged(nameof(ToolTip));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validates the settings and return a string message if got any error
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public virtual string? Validate() => null;
|
|
|
|
/// <summary>
|
|
/// Executes and applies the suggestion
|
|
/// </summary>
|
|
/// <param name="progress"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
protected virtual bool ExecuteInternally(OperationProgress progress)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Executes and applies the suggestion
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <exception cref="InvalidOperationException"></exception>
|
|
public bool Execute(OperationProgress? progress = null)
|
|
{
|
|
if (_slicerFile is null) throw new InvalidOperationException($"The suggestion '{Title}' can't execute due the lacking of a file parent.");
|
|
if (!Enabled || !IsAvailable || IsApplied || IsInformativeOnly || SlicerFile.LayerCount == 0) return false;
|
|
|
|
progress ??= new OperationProgress();
|
|
progress.Title = $"Applying suggestion: {Title}";
|
|
|
|
var result = ExecuteInternally(progress);
|
|
|
|
RaisePropertyChanged(nameof(IsApplied));
|
|
RefreshNotifyMessage();
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Executes only if this suggestion is marked with <see cref="AutoApply"/> as true
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool ExecuteIfAutoApply()
|
|
{
|
|
return _autoApply && Execute();
|
|
}
|
|
|
|
public Suggestion Clone()
|
|
{
|
|
return (MemberwiseClone() as Suggestion)!;
|
|
}
|
|
#endregion
|
|
|
|
|
|
} |