mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-14 20:36:19 +02:00
- **UI:**
- **Menu:**
- (Add) File - Open recent: Open any recent open file from a list
Shift + Click: Open file in a new window
Shift + Ctrl + Click: Remove file from recent list
Ctrl + Click: Purge non-existing files
- (Add) File - Send to: Copy the file directly to a removable drive (Windows only)
- **(Add) Layer navigation buttons:**
- SB: Navigate to the smallest bottom layer in mass
- LB: Navigate to the largest bottom layer in mass
- SN: Navigate to the smallest normal layer in mass
- LN: Navigate to the largest normal layer in mass
- (Add) Layer outline - Distance detection: Calculates the distance to the closest zero pixel for each pixel
- **Tools:**
- **Dynamic Lifts:**
- (Improvement) Select normal layers by default
- (Improvement) Hide light-off delay fields when the file format don't support them
- (Fix) Light-off delay fields was not hidding when set a mode that dont require the extra time fields
- **Exposure time finder:**
- (Fix) Fix the 'light-off delay' field not being show on files that support wait time before cure
- (Change) Field name 'Light-off delay' to 'Wait time before cure'
- (Add) Fade exposure time: The double exposure method clones the selected layer range and print the same layer twice with different exposure times and strategies
- (Add) Double exposure: The double exposure method clones the selected layer range and print the same layer twice with different exposure times and strategies
- (Add) Clone layers: Option to keep the same z position for the cloned layers instead of rebuild model height
- (Improvement) The layer range selector for normal and bottom layers now selects the correct range based on IsBottom property rather than layer index
- (Fix) The layer range selector was setting a very high last layer index when bottom layer count is 0
- (Fix) Pixel arithmetic: Threshold types "Otsu" and "Triangle" are flags to combine with other types, it will auto append the "Binnary" type
- (Add) Support for Encrypted CTB (read-only)
202 lines
4.9 KiB
C#
202 lines
4.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 System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
|
|
namespace UVtools.WPF.Structures
|
|
{
|
|
public class RecentFiles : IList<string>
|
|
{
|
|
#region Properties
|
|
/// <summary>
|
|
/// Default filepath for store
|
|
/// </summary>
|
|
private static string FilePath => Path.Combine(UserSettings.SettingsFolder, "recentfiles.dat");
|
|
|
|
private readonly List<string> _files = new();
|
|
|
|
public byte MaxEntries { get; set; } = 40;
|
|
|
|
#endregion
|
|
|
|
#region Singleton
|
|
|
|
private static Lazy<RecentFiles> _instanceHolder =
|
|
new(() => new RecentFiles());
|
|
|
|
/// <summary>
|
|
/// Instance of <see cref="UserSettings"/> (singleton)
|
|
/// </summary>
|
|
public static RecentFiles Instance => _instanceHolder.Value;
|
|
|
|
//public static List<Operation> Operations => _instance.Operations;
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
private RecentFiles()
|
|
{ }
|
|
|
|
#endregion
|
|
|
|
#region Static Methods
|
|
/// <summary>
|
|
/// Clear all files
|
|
/// </summary>
|
|
/// <param name="save">True to save settings on file, otherwise false</param>
|
|
public static void ClearFiles(bool save = true)
|
|
{
|
|
Instance.Clear();
|
|
if (save) Save();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Load settings from file
|
|
/// </summary>
|
|
public static void Load()
|
|
{
|
|
if (!File.Exists(FilePath))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Instance.Clear();
|
|
|
|
try
|
|
{
|
|
using var tr = new StreamReader(FilePath);
|
|
|
|
string path;
|
|
while ((path = tr.ReadLine()) is not null)
|
|
{
|
|
if(string.IsNullOrWhiteSpace(path)) continue;
|
|
|
|
try
|
|
{
|
|
Path.GetFullPath(path);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
Instance.Add(path);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save settings to file
|
|
/// </summary>
|
|
public static void Save()
|
|
{
|
|
try
|
|
{
|
|
using var tw = new StreamWriter(FilePath);
|
|
|
|
foreach (var file in Instance)
|
|
{
|
|
tw.WriteLine(file);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
|
|
public static int PurgenNonExistingFiles(bool save = true)
|
|
{
|
|
Load();
|
|
var count = Instance.RemoveAll(s => !File.Exists(s));
|
|
if(save && count > 0) Save();
|
|
return count;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region List Implementation
|
|
public IEnumerator<string> GetEnumerator()
|
|
{
|
|
return _files.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return ((IEnumerable)_files).GetEnumerator();
|
|
}
|
|
|
|
public void Add(string item)
|
|
{
|
|
_files.RemoveAll(s => s == item);
|
|
if (Count >= MaxEntries) return;
|
|
_files.Add(item);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
_files.Clear();
|
|
}
|
|
|
|
public bool Contains(string item)
|
|
{
|
|
return _files.Contains(item);
|
|
}
|
|
|
|
public void CopyTo(string[] array, int arrayIndex)
|
|
{
|
|
_files.CopyTo(array, arrayIndex);
|
|
}
|
|
|
|
public bool Remove(string item)
|
|
{
|
|
return _files.Remove(item);
|
|
}
|
|
|
|
public int Count => _files.Count;
|
|
|
|
public bool IsReadOnly => ((ICollection<string>)_files).IsReadOnly;
|
|
|
|
public int IndexOf(string item)
|
|
{
|
|
return _files.IndexOf(item);
|
|
}
|
|
|
|
public void Insert(int index, string item)
|
|
{
|
|
_files.RemoveAll(s => s == item);
|
|
_files.Insert(index, item);
|
|
while (Count > MaxEntries)
|
|
{
|
|
RemoveAt(Count-1);
|
|
}
|
|
}
|
|
|
|
public void RemoveAt(int index)
|
|
{
|
|
_files.RemoveAt(index);
|
|
}
|
|
|
|
public int RemoveAll(Predicate<string> match) => _files.RemoveAll(match);
|
|
|
|
public string this[int index]
|
|
{
|
|
get => _files[index];
|
|
set => _files[index] = value;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|