mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
331d37be7c
- **Settings:** - (Add) Remove source file after automatic conversion (#444) - (Add) Remove source file after manual conversion (#444) - (Add) **Average resin bottle cost:** The average cost per one resin bottle of 1000ml. Used to calculate the material cost when the file lacks that information. Use 0 to disable this feature and only show the cost if file have that information. If this value is changed, you need to reload the current file to update the cost. - (Change) Move "Expand and show tool descriptions by default" to From `General` to `Tools` tab (Setting will reset to default) - **File formats:** - (Add) Property `StartingMaterialMilliliters`: Gets the starting material milliliters when the file was loaded - (Add) Property `StartingMaterialCost`: Gets the starting material cost when the file was loaded - (Add) Property `MaterialMilliliterCost`: Gets the material cost per one milliliter - (Improvement) Update `MaterialCost` when `MaterialMilliliters` changes (#449) - **Raft relief:** - (Add) Linked lines: Remove the raft, keep supports and link them with lines - (Improvement) Change the supports detection parameters to be more effective and precise on detect the starting layer - (Fix) Brightness percentage not getting updated - (Fix) Remove anti-aliased edges from Tabs - (Improvement) Core: Minor clean-up - (Fix) Issue repair error when 'Auto repair layers and issues on file load' is enabled (#446) - (Fix) UI: Selecting a object with ROI when flip is verically, will cause 1px up-shift on the preview - (Fix) macOS permission error due loss of attributes on the build script, WSL have bug with mv, using ln&rm instead
120 lines
3.9 KiB
C#
120 lines
3.9 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 Emgu.CV.Cuda;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using UVtools.Core.Layers;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.Core;
|
|
|
|
public static class CoreSettings
|
|
{
|
|
#region Members
|
|
private static int _maxDegreeOfParallelism = -1;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum number of concurrent tasks enabled by this ParallelOptions instance.
|
|
/// Less or equal to 0 will set to auto number
|
|
/// 1 = Single thread
|
|
/// n = Multi threads
|
|
/// </summary>
|
|
public static int MaxDegreeOfParallelism
|
|
{
|
|
get => _maxDegreeOfParallelism;
|
|
set => _maxDegreeOfParallelism = value > 0 ? Math.Min(value, Environment.ProcessorCount) : -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> set
|
|
/// </summary>
|
|
public static ParallelOptions ParallelOptions => new() {MaxDegreeOfParallelism = _maxDegreeOfParallelism};
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> and the <see cref="CancellationToken"/> set
|
|
/// </summary>
|
|
public static ParallelOptions GetParallelOptions(CancellationToken token = default)
|
|
{
|
|
var options = ParallelOptions;
|
|
options.CancellationToken = token;
|
|
return options;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> and the <see cref="CancellationToken"/> set
|
|
/// </summary>
|
|
public static ParallelOptions GetParallelOptions(OperationProgress progress) => GetParallelOptions(progress.Token);
|
|
|
|
/// <summary>
|
|
/// Gets or sets if operations run via CUDA when possible
|
|
/// </summary>
|
|
public static bool EnableCuda { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets if we can use cuda on operations
|
|
/// </summary>
|
|
public static bool CanUseCuda => EnableCuda && CudaInvoke.HasCuda;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the default compression type for layers
|
|
/// </summary>
|
|
public static LayerCompressionCodec DefaultLayerCompressionCodec { get; set; } = LayerCompressionCodec.Png;
|
|
|
|
/// <summary>
|
|
/// <para>The average resin 1000ml bottle cost, to use when bottle cost is not available.</para>
|
|
/// <para>Use 0 to disable.</para>
|
|
/// </summary>
|
|
public static float AverageResin1000MlBottleCost = 60f;
|
|
|
|
/// <summary>
|
|
/// Gets the default folder to save the settings
|
|
/// </summary>
|
|
public static string DefaultSettingsFolder
|
|
{
|
|
get
|
|
{
|
|
var folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
var path = Path.Combine(folder, About.Software);
|
|
return path;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the default folder to save the settings
|
|
/// </summary>
|
|
public static string DefaultSettingsFolderAndEnsureCreation
|
|
{
|
|
get
|
|
{
|
|
var path = DefaultSettingsFolder;
|
|
try
|
|
{
|
|
if (!Directory.Exists(path))
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.WriteLine(e);
|
|
}
|
|
return path;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |