mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
2c7ad09dc0
- (Change) `Layer.IsBottomLayer` no longer calculate the value using the position of the layer, a new property `IsBottomLayerByHeight` is now used to get that result - (Improvement) Tool - Double exposure: Increase the bottom layer count per cloned bottom layer - (Improvement) Calibration - Exposure time finder: Set the absolute bottom layer count accordingly when also testing for bottom time - (Improvement) Goo: Enforce Wait times or Light-off-delay flag based on property set - (Fix) AnyCubic and Goo: `PerLayerSetting` flag was set inverted causing printer not to follow layer settings when it should and also the otherwise (#689) - (Fix) Tool - Scripting: Prevent from reload UI multiple times when using profiles (#694)
128 lines
3.1 KiB
C#
128 lines
3.1 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.Linq;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.Core.Managers;
|
|
|
|
public class OperationSessionManager : IList<Operation>
|
|
{
|
|
#region Settings
|
|
|
|
//public static string FilePath;
|
|
#endregion
|
|
|
|
#region Singleton
|
|
|
|
private static readonly Lazy<OperationSessionManager> _instanceHolder =
|
|
new(() => new OperationSessionManager());
|
|
|
|
public static OperationSessionManager Instance => _instanceHolder.Value;
|
|
|
|
#endregion
|
|
|
|
#region Members
|
|
|
|
private readonly List<Operation> _operations = new();
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
private OperationSessionManager()
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public Operation? Find(Type type)
|
|
{
|
|
return this.FirstOrDefault(operation => operation.GetType() == type);
|
|
}
|
|
|
|
public Operation? Find(Operation fromOperation) => Find(fromOperation.GetType());
|
|
|
|
#endregion
|
|
|
|
#region List Implementation
|
|
public IEnumerator<Operation> GetEnumerator()
|
|
{
|
|
return _operations.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return ((IEnumerable) _operations).GetEnumerator();
|
|
}
|
|
|
|
public void Add(Operation item)
|
|
{
|
|
if (item is null) return;
|
|
_operations.RemoveAll(operation => operation.GetType() == item.GetType());
|
|
var operation = item.Clone();
|
|
operation.ClearPropertyChangedListeners();
|
|
operation.ClearROIandMasks();
|
|
operation.ImportedFrom = Operation.OperationImportFrom.Session;
|
|
_operations.Add(operation);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
_operations.Clear();
|
|
}
|
|
|
|
public bool Contains(Operation item)
|
|
{
|
|
return _operations.Contains(item);
|
|
}
|
|
|
|
public void CopyTo(Operation[] array, int arrayIndex)
|
|
{
|
|
_operations.CopyTo(array, arrayIndex);
|
|
}
|
|
|
|
public bool Remove(Operation item)
|
|
{
|
|
return _operations.Remove(item);
|
|
}
|
|
|
|
public int Count => _operations.Count;
|
|
|
|
public bool IsReadOnly => ((ICollection<Operation>) _operations).IsReadOnly;
|
|
|
|
public int IndexOf(Operation item)
|
|
{
|
|
return _operations.IndexOf(item);
|
|
}
|
|
|
|
public void Insert(int index, Operation item)
|
|
{
|
|
if (item is null) return;
|
|
_operations.RemoveAll(operation => operation.GetType() == item.GetType());
|
|
var operation = item.Clone();
|
|
operation.ClearPropertyChangedListeners();
|
|
operation.ClearROIandMasks();
|
|
operation.ImportedFrom = Operation.OperationImportFrom.Session;
|
|
_operations.Insert(index, operation);
|
|
}
|
|
|
|
public void RemoveAt(int index)
|
|
{
|
|
_operations.RemoveAt(index);
|
|
}
|
|
|
|
public Operation this[int index]
|
|
{
|
|
get => _operations[index];
|
|
set => _operations[index] = value;
|
|
}
|
|
#endregion
|
|
} |