Clipboard

This commit is contained in:
2022-05-07 18:58:12 +02:00
parent 60ab58659e
commit b161ded92e
16 changed files with 214 additions and 33 deletions

View File

@@ -0,0 +1,51 @@
using FileTime.Core.Command;
using FileTime.Core.Models;
namespace FileTime.App.Core.Services
{
public class ClipboardService : IClipboardService
{
private List<IAbsolutePath> _content;
public IReadOnlyList<IAbsolutePath> Content { get; private set; }
public Type? CommandType { get; private set; }
public ClipboardService()
{
_content = new List<IAbsolutePath>();
Content = _content.AsReadOnly();
}
public void AddContent(IAbsolutePath absolutePath)
{
foreach (var content in _content)
{
if (content.Equals(absolutePath)) return;
}
_content.Add(absolutePath);
}
public void RemoveContent(IAbsolutePath absolutePath)
{
for (var i = 0; i < _content.Count; i++)
{
if (_content[i].Equals(absolutePath))
{
_content.RemoveAt(i--);
}
}
}
public void Clear()
{
_content = new List<IAbsolutePath>();
Content = _content.AsReadOnly();
CommandType = null;
}
public void SetCommand<T>() where T : ITransportationCommand
{
CommandType = typeof(T);
}
}
}