UI improvements
This commit is contained in:
@@ -7,39 +7,7 @@ namespace FileTime.Core.Components
|
||||
{
|
||||
private IItem? _currentSelectedItem;
|
||||
private IContainer _currentLocation;
|
||||
|
||||
/* public IContainer CurrentLocation
|
||||
{
|
||||
get => _currentLocation;
|
||||
private set
|
||||
{
|
||||
if (_currentLocation != value)
|
||||
{
|
||||
if (_currentLocation != null)
|
||||
{
|
||||
_currentLocation.Refreshed -= HandleCurrentLocationRefresh;
|
||||
}
|
||||
|
||||
_currentLocation = value;
|
||||
CurrentLocationChanged?.Invoke(this, EventArgs.Empty);
|
||||
CurrentSelectedItem = CurrentLocation.Items.Count > 0 ? CurrentLocation.Items[0] : null;
|
||||
_currentLocation.Refreshed += HandleCurrentLocationRefresh;
|
||||
}
|
||||
}
|
||||
}
|
||||
public IItem? CurrentSelectedItem
|
||||
{
|
||||
get => _currentSelectedItem;
|
||||
set
|
||||
{
|
||||
if (_currentSelectedItem != value && (_currentLocation.Items.Contains(value) || value == null))
|
||||
{
|
||||
_currentSelectedItem = value;
|
||||
CurrentSelectedIndex = GetItemIndex(value);
|
||||
CurrentSelectedItemChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
public int CurrentSelectedIndex { get; private set; }
|
||||
|
||||
public AsyncEventHandler CurrentLocationChanged = new();
|
||||
|
||||
25
src/Core/FileTime.Core/Extensions/ContainerExtensions.cs
Normal file
25
src/Core/FileTime.Core/Extensions/ContainerExtensions.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using FileTime.Core.Models;
|
||||
|
||||
namespace FileTime.Core.Extensions
|
||||
{
|
||||
public static class ContainerExtensions
|
||||
{
|
||||
public static async Task<IContainer> ToggleVirtualContainerInChain(this IContainer container, string filterName, Func<IContainer, Task<VirtualContainer>> generator)
|
||||
{
|
||||
if (container is VirtualContainer oldVirtualContainer)
|
||||
{
|
||||
return oldVirtualContainer.HasWithName(filterName)
|
||||
? await oldVirtualContainer.ExceptWithName(filterName)
|
||||
: await generator(container);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await generator(container);
|
||||
}
|
||||
}
|
||||
public static async Task<IContainer> WithoutVirtualContainer(this IContainer container, string filterName) =>
|
||||
container is VirtualContainer oldVirtualContainer
|
||||
? await oldVirtualContainer.ExceptWithName(filterName)
|
||||
: container;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ namespace FileTime.Core.Models
|
||||
|
||||
Task<bool> IsExists(string name);
|
||||
|
||||
Task<IContainer> Clone();
|
||||
|
||||
AsyncEventHandler Refreshed { get; }
|
||||
}
|
||||
}
|
||||
@@ -90,17 +90,20 @@ namespace FileTime.Core.Models
|
||||
|| (BaseContainer is VirtualContainer virtualContainer
|
||||
&& virtualContainer.HasWithName(name));
|
||||
|
||||
public IContainer ExceptWithName(string name)
|
||||
public async Task<IContainer> ExceptWithName(string name)
|
||||
{
|
||||
if (BaseContainer is VirtualContainer virtualBaseContainer && virtualBaseContainer.VirtualContainerName == name)
|
||||
{
|
||||
return new VirtualContainer(
|
||||
virtualBaseContainer.ExceptWithName(name),
|
||||
var newContainer = new VirtualContainer(
|
||||
await virtualBaseContainer.ExceptWithName(name),
|
||||
_containerTransformators,
|
||||
_elementTransformators,
|
||||
IsPermanent,
|
||||
IsTransitive,
|
||||
VirtualContainerName);
|
||||
|
||||
await newContainer.Init();
|
||||
return newContainer;
|
||||
}
|
||||
else if (VirtualContainerName == name)
|
||||
{
|
||||
@@ -145,5 +148,16 @@ namespace FileTime.Core.Models
|
||||
}
|
||||
|
||||
public async Task Delete() => await BaseContainer.Delete();
|
||||
public async Task<IContainer> Clone()
|
||||
{
|
||||
return new VirtualContainer(
|
||||
await BaseContainer.Clone(),
|
||||
_containerTransformators,
|
||||
_elementTransformators,
|
||||
IsPermanent,
|
||||
IsTransitive,
|
||||
VirtualContainerName
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,5 +50,7 @@ namespace FileTime.Core.Providers
|
||||
public Task<IReadOnlyList<IItem>?> GetItems(CancellationToken token = default) => Task.FromResult(_items);
|
||||
public Task<IReadOnlyList<IContainer>?> GetContainers(CancellationToken token = default) => Task.FromResult(_containers);
|
||||
public Task<IReadOnlyList<IElement>?> GetElements(CancellationToken token = default) => Task.FromResult(_elements);
|
||||
|
||||
public Task<IContainer> Clone() => Task.FromResult((IContainer)this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user