Files
Tiago Conceição 9f7722d369 v3.7.0
- **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
2022-10-12 01:16:34 +01:00

171 lines
4.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.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using UVtools.Core.FileFormats;
namespace UVtools.Core.Objects;
public class MappedProcess : BindableBase
{
#region Constants
public const string DefaultArgument = "\"{0}\"";
#endregion
#region Members
private bool _isEnabled = true;
private string _applicationPath = null!;
private string? _name;
private string _arguments = DefaultArgument;
private string? _compatibleExtensions;
private bool _waitForExit;
#endregion
#region Properties
/// <summary>
/// Gets or sets if this device is enabled
/// </summary>
public bool IsEnabled
{
get => _isEnabled;
set => RaiseAndSetIfChanged(ref _isEnabled, value);
}
/// <summary>
/// Gets or sets the full path for the application
/// </summary>
public string ApplicationPath
{
get => _applicationPath;
set => RaiseAndSetIfChanged(ref _applicationPath, value);
}
/// <summary>
/// Gets or sets the path name alias
/// </summary>
public string? Name
{
get => _name;
set => RaiseAndSetIfChanged(ref _name, value);
}
/// <summary>
/// Gets or sets the arguments for the application
/// </summary>
public string Arguments
{
get => _arguments;
set => RaiseAndSetIfChanged(ref _arguments, value);
}
/// <summary>
/// Gets or sets the compatible extensions with this device.
/// Empty or null to be compatible with everything
/// </summary>
public string? CompatibleExtensions
{
get => _compatibleExtensions;
set => RaiseAndSetIfChanged(ref _compatibleExtensions, value);
}
public bool WaitForExit
{
get => _waitForExit;
set => RaiseAndSetIfChanged(ref _waitForExit, value);
}
#endregion
#region Constructors
public MappedProcess() { }
public MappedProcess(bool isEnabled, string applicationPath, string? name = null, string arguments = DefaultArgument)
{
_isEnabled = isEnabled;
_applicationPath = applicationPath;
if (string.IsNullOrWhiteSpace(name))
{
name = Path.GetFileNameWithoutExtension(applicationPath);
}
_name = name;
if (string.IsNullOrWhiteSpace(arguments))
{
arguments = DefaultArgument;
}
_arguments = arguments;
}
public MappedProcess(string applicationPath, string? name = null, string arguments = DefaultArgument) : this(true, applicationPath, name, arguments)
{ }
#endregion
#region Methods
public bool IsValid()
{
return File.Exists(_applicationPath);
}
public async Task StartProcess(FileFormat slicerFile, CancellationToken cancellationToken = default)
{
await StartProcess(slicerFile.FileFullPath!, cancellationToken);
}
public async Task StartProcess(string slicerFile, CancellationToken cancellationToken = default)
{
var arguments = string.IsNullOrWhiteSpace(_arguments) ? $"\"{slicerFile}\"" : string.Format(_arguments, slicerFile);
using var process = Process.Start(_applicationPath, arguments);
if (process is null) return;
if (_waitForExit)
{
await process.WaitForExitAsync(cancellationToken);
}
}
public override string ToString()
{
return $"{_applicationPath} {Arguments}";
}
protected bool Equals(MappedProcess other)
{
return _applicationPath == other._applicationPath && _name == other._name && _arguments == other._arguments && _compatibleExtensions == other._compatibleExtensions;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((MappedProcess)obj);
}
public override int GetHashCode()
{
return HashCode.Combine(_applicationPath, _name, _arguments, _compatibleExtensions);
}
public MappedProcess Clone()
{
return (MemberwiseClone() as MappedProcess)!;
}
#endregion
}