Possible commands, IsAlternative fix
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
namespace FileTime.App.Core.Models.Enums;
|
||||
|
||||
public enum ItemViewModelType
|
||||
{
|
||||
Main,
|
||||
SelectedChild,
|
||||
Parent
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IContainerSizeContainerViewModel : IItemViewModel, IInitable<IContainer, ITabViewModel>
|
||||
public interface IContainerSizeContainerViewModel : IItemViewModel, IInitable<IContainer, ITabViewModel, ItemViewModelType>
|
||||
{
|
||||
long Size { get; set; }
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IContainerViewModel : IItemViewModel, IInitable<IContainer, ITabViewModel>
|
||||
public interface IContainerViewModel : IItemViewModel, IInitable<IContainer, ITabViewModel, ItemViewModelType>
|
||||
{
|
||||
IContainer? Container { get; }
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IElementViewModel : IItemViewModel, IInitable<IElement, ITabViewModel>
|
||||
public interface IElementViewModel : IItemViewModel, IInitable<IElement, ITabViewModel, ItemViewModelType>
|
||||
{
|
||||
long? Size { get; set; }
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.Core.Models;
|
||||
using InitableService;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IFileViewModel : IElementViewModel, IInitable<IFileElement, ITabViewModel>
|
||||
public interface IFileViewModel : IElementViewModel, IInitable<IFileElement, ITabViewModel, ItemViewModelType>
|
||||
{
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using InitableService;
|
||||
|
||||
namespace FileTime.App.Core.ViewModels;
|
||||
|
||||
public interface IItemViewModel : IInitable<IItem, ITabViewModel>
|
||||
public interface IItemViewModel : IInitable<IItem, ITabViewModel, ItemViewModelType>
|
||||
{
|
||||
IItem? BaseItem { get; set; }
|
||||
IObservable<IReadOnlyList<ItemNamePart>>? DisplayName { get; set; }
|
||||
|
||||
@@ -22,6 +22,8 @@ public interface ITabViewModel : IInitable<ITab, int>
|
||||
BindedCollection<IItemViewModel>? SelectedsChildrenCollection { get; }
|
||||
BindedCollection<IItemViewModel>? ParentsChildrenCollection { get; }
|
||||
IObservable<IReadOnlyCollection<IItemViewModel>?> CurrentItemsCollectionObservable { get; }
|
||||
IObservable<IReadOnlyCollection<IItemViewModel>?> ParentsChildrenCollectionObservable { get; }
|
||||
IObservable<IReadOnlyCollection<IItemViewModel>?> SelectedsChildrenCollectionObservable { get; }
|
||||
void ClearMarkedItems();
|
||||
void RemoveMarkedItem(IAbsolutePath item);
|
||||
void AddMarkedItem(IAbsolutePath item);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using MvvmGen;
|
||||
@@ -10,12 +11,12 @@ public partial class ContainerSizeContainerViewModel : ItemViewModel, IContainer
|
||||
[Property]
|
||||
private long _size;
|
||||
|
||||
public ContainerSizeContainerViewModel(IItemNameConverterService _itemNameConverterService, IAppState _appState) : base(_itemNameConverterService, _appState)
|
||||
public ContainerSizeContainerViewModel(IItemNameConverterService itemNameConverterService, IAppState appState) : base(itemNameConverterService, appState)
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IContainer item, ITabViewModel parentTab)
|
||||
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IItem)item, parentTab);
|
||||
Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using MvvmGen;
|
||||
@@ -9,12 +10,12 @@ public partial class ContainerViewModel : ItemViewModel, IContainerViewModel
|
||||
{
|
||||
public IContainer? Container => BaseItem as IContainer;
|
||||
|
||||
public ContainerViewModel(IItemNameConverterService _itemNameConverterService, IAppState _appState) : base(_itemNameConverterService, _appState)
|
||||
public ContainerViewModel(IItemNameConverterService itemNameConverterService, IAppState appState) : base(itemNameConverterService, appState)
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IContainer item, ITabViewModel parentTab)
|
||||
public void Init(IContainer item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IItem)item, parentTab);
|
||||
Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using MvvmGen;
|
||||
@@ -10,12 +11,12 @@ public partial class ElementViewModel : ItemViewModel, IElementViewModel
|
||||
[Property]
|
||||
private long? _size;
|
||||
|
||||
public ElementViewModel(IItemNameConverterService _itemNameConverterService, IAppState _appState) : base(_itemNameConverterService, _appState)
|
||||
public ElementViewModel(IItemNameConverterService itemNameConverterService, IAppState appState) : base(itemNameConverterService, appState)
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IElement item, ITabViewModel parentTab)
|
||||
public void Init(IElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IItem)item, parentTab);
|
||||
Init((IItem)item, parentTab, itemViewModelType);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using MvvmGen;
|
||||
@@ -7,12 +8,12 @@ namespace FileTime.App.Core.ViewModels;
|
||||
[ViewModel(GenerateConstructor = false)]
|
||||
public partial class FileViewModel : ElementViewModel, IFileViewModel
|
||||
{
|
||||
public FileViewModel(IItemNameConverterService _itemNameConverterService, IAppState _appState) : base(_itemNameConverterService, _appState)
|
||||
public FileViewModel(IItemNameConverterService itemNameConverterService, IAppState appState) : base(itemNameConverterService, appState)
|
||||
{
|
||||
}
|
||||
|
||||
public void Init(IFileElement item, ITabViewModel parentTab)
|
||||
public void Init(IFileElement item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
Init((IElement)item, parentTab);
|
||||
Init((IElement)item, parentTab, itemViewModelType);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reactive.Linq;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Models;
|
||||
@@ -41,21 +42,29 @@ public abstract partial class ItemViewModel : IItemViewModel
|
||||
[Property]
|
||||
private IObservable<bool> _isAlternative;
|
||||
|
||||
public void Init(IItem item, ITabViewModel parentTab)
|
||||
public void Init(IItem item, ITabViewModel parentTab, ItemViewModelType itemViewModelType)
|
||||
{
|
||||
var sourceCollection = itemViewModelType switch
|
||||
{
|
||||
ItemViewModelType.Main => parentTab.CurrentItemsCollectionObservable,
|
||||
ItemViewModelType.Parent => parentTab.ParentsChildrenCollectionObservable,
|
||||
ItemViewModelType.SelectedChild => parentTab.SelectedsChildrenCollectionObservable,
|
||||
_ => throw new InvalidEnumArgumentException()
|
||||
};
|
||||
|
||||
BaseItem = item;
|
||||
DisplayName = _appState.SearchText.Select(s => _itemNameConverterService.GetDisplayName(item.DisplayName, s));
|
||||
DisplayNameText = item.DisplayName;
|
||||
IsMarked = parentTab.MarkedItems.ToCollection().Select(m => m.Any(i => i.Path.Path == item.FullName?.Path));
|
||||
IsSelected = parentTab.CurrentSelectedItem.Select(EqualsTo);
|
||||
IsAlternative = parentTab.CurrentItemsCollectionObservable.Select(c => c?.Index().FirstOrDefault(i => EqualsTo(i.Value)).Key % 2 == 0);
|
||||
IsAlternative = sourceCollection.Select(c => c?.Index().FirstOrDefault(i => EqualsTo(i.Value)).Key % 2 == 0);
|
||||
ViewMode = Observable.CombineLatest(IsMarked, IsSelected, IsAlternative, GenerateViewMode);
|
||||
Attributes = item.Attributes;
|
||||
CreatedAt = item.CreatedAt;
|
||||
}
|
||||
|
||||
private ItemViewMode GenerateViewMode(bool isMarked, bool isSelected, bool sAlternative)
|
||||
=> (isMarked, isSelected, sAlternative) switch
|
||||
private ItemViewMode GenerateViewMode(bool isMarked, bool isSelected, bool isAlternative)
|
||||
=> (isMarked, isSelected, isAlternative) switch
|
||||
{
|
||||
(true, true, _) => ItemViewMode.MarkedSelected,
|
||||
(true, false, true) => ItemViewMode.MarkedAlternative,
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Reactive.Linq;
|
||||
using DynamicData;
|
||||
using FileTime.App.Core.Extensions;
|
||||
using FileTime.App.Core.Models;
|
||||
using FileTime.App.Core.Models.Enums;
|
||||
using FileTime.App.Core.Services;
|
||||
using FileTime.Core.Models;
|
||||
using FileTime.Core.Services;
|
||||
@@ -35,15 +36,14 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
public IObservable<IObservable<IChangeSet<IItemViewModel>>?> ParentsChildren { get; private set; } = null!;
|
||||
|
||||
public IObservable<IReadOnlyCollection<IItemViewModel>?> CurrentItemsCollectionObservable { get; private set; } = null!;
|
||||
public IObservable<IReadOnlyCollection<IItemViewModel>?> ParentsChildrenCollectionObservable { get; private set; } = null!;
|
||||
public IObservable<IReadOnlyCollection<IItemViewModel>?> SelectedsChildrenCollectionObservable { get; private set; } = null!;
|
||||
|
||||
[Property]
|
||||
private BindedCollection<IItemViewModel>? _currentItemsCollection;
|
||||
[Property] private BindedCollection<IItemViewModel>? _currentItemsCollection;
|
||||
|
||||
[Property]
|
||||
private BindedCollection<IItemViewModel>? _parentsChildrenCollection;
|
||||
[Property] private BindedCollection<IItemViewModel>? _parentsChildrenCollection;
|
||||
|
||||
[Property]
|
||||
private BindedCollection<IItemViewModel>? _selectedsChildrenCollection;
|
||||
[Property] private BindedCollection<IItemViewModel>? _selectedsChildrenCollection;
|
||||
|
||||
public TabViewModel(
|
||||
IServiceProvider serviceProvider,
|
||||
@@ -67,7 +67,7 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
|
||||
CurrentLocation = tab.CurrentLocation.AsObservable();
|
||||
CurrentItems = tab.CurrentItems
|
||||
.Select(items => items?.Transform(MapItemToViewModel))
|
||||
.Select(items => items?.Transform(i => MapItemToViewModel(i, ItemViewModelType.Main)))
|
||||
.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
|
||||
.SubscribeOn(_rxSchedulerService.GetUIScheduler())
|
||||
.Publish(null)
|
||||
@@ -79,10 +79,11 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
tab.CurrentSelectedItem,
|
||||
(currentItems, currentSelectedItemPath) =>
|
||||
currentItems == null
|
||||
? Observable.Return((IItemViewModel?)null)
|
||||
? Observable.Return((IItemViewModel?) null)
|
||||
: currentItems
|
||||
.ToCollection()
|
||||
.Select(items => items.FirstOrDefault(i => i.BaseItem?.FullName == currentSelectedItemPath?.Path))
|
||||
.Select(items =>
|
||||
items.FirstOrDefault(i => i.BaseItem?.FullName == currentSelectedItemPath?.Path))
|
||||
)
|
||||
.Switch()
|
||||
.Publish(null)
|
||||
@@ -91,11 +92,9 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
SelectedsChildren = InitSelectedsChildren();
|
||||
ParentsChildren = InitParentsChildren();
|
||||
|
||||
CurrentItemsCollectionObservable = CurrentItems
|
||||
.Select(c => c != null ? c.ToCollection() : Observable.Return((IReadOnlyCollection<IItemViewModel>?)null))
|
||||
.Switch()
|
||||
.Publish(null)
|
||||
.RefCount();
|
||||
CurrentItemsCollectionObservable = InitAsd(CurrentItems);
|
||||
SelectedsChildrenCollectionObservable = InitAsd(SelectedsChildren);
|
||||
ParentsChildrenCollectionObservable = InitAsd(ParentsChildren);
|
||||
|
||||
CurrentItems.Subscribe(children =>
|
||||
{
|
||||
@@ -119,7 +118,8 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
|
||||
IObservable<IObservable<IChangeSet<IItemViewModel>>?> InitSelectedsChildren()
|
||||
{
|
||||
var currentSelectedItemThrottled = CurrentSelectedItem.Throttle(TimeSpan.FromMilliseconds(250)).Publish(null).RefCount();
|
||||
var currentSelectedItemThrottled =
|
||||
CurrentSelectedItem.Throttle(TimeSpan.FromMilliseconds(250)).Publish(null).RefCount();
|
||||
return Observable.Merge(
|
||||
currentSelectedItemThrottled
|
||||
.WhereNotNull()
|
||||
@@ -127,10 +127,12 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
.Where(c => c?.Container is not null)
|
||||
.Select(c => c.Container!.Items)
|
||||
.Switch()
|
||||
.Select(i => i?.TransformAsync(MapItem).Transform(MapItemToViewModel)),
|
||||
.Select(i =>
|
||||
i?.TransformAsync(MapItem)
|
||||
.Transform(i => MapItemToViewModel(i, ItemViewModelType.SelectedChild))),
|
||||
currentSelectedItemThrottled
|
||||
.Where(c => c is null || c is not IContainerViewModel)
|
||||
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?)null)
|
||||
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null)
|
||||
)
|
||||
.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
|
||||
.SubscribeOn(_rxSchedulerService.GetUIScheduler())
|
||||
@@ -149,43 +151,63 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
return Observable.Merge(
|
||||
parentThrottled
|
||||
.Where(p => p is not null)
|
||||
.Select(p => Observable.FromAsync(async () => (IContainer)await p!.ResolveAsync()))
|
||||
.Select(p => Observable.FromAsync(async () => (IContainer) await p!.ResolveAsync()))
|
||||
.Switch()
|
||||
.Select(p => p.Items)
|
||||
.Switch()
|
||||
.Select(items => items?.TransformAsync(MapItem).Transform(MapItemToViewModel)),
|
||||
.Select(items =>
|
||||
items?.TransformAsync(MapItem)
|
||||
.Transform(i => MapItemToViewModel(i, ItemViewModelType.Parent))),
|
||||
parentThrottled
|
||||
.Where(p => p is null)
|
||||
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?)null)
|
||||
.Select(_ => (IObservable<IChangeSet<IItemViewModel>>?) null)
|
||||
)
|
||||
.ObserveOn(_rxSchedulerService.GetWorkerScheduler())
|
||||
.SubscribeOn(_rxSchedulerService.GetUIScheduler())
|
||||
.Publish(null)
|
||||
.RefCount();
|
||||
}
|
||||
|
||||
IObservable<IReadOnlyCollection<IItemViewModel>?> InitAsd(
|
||||
IObservable<IObservable<IChangeSet<IItemViewModel>>?> source)
|
||||
{
|
||||
return source
|
||||
.Select(c =>
|
||||
c != null ? c.ToCollection() : Observable.Return((IReadOnlyCollection<IItemViewModel>?) null))
|
||||
.Switch()
|
||||
.Publish(null)
|
||||
.RefCount();
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<IItem> MapItem(IAbsolutePath item)
|
||||
=> await item.ResolveAsync(forceResolve: true, itemInitializationSettings: new ItemInitializationSettings(true));
|
||||
=> await item.ResolveAsync(forceResolve: true,
|
||||
itemInitializationSettings: new ItemInitializationSettings(true));
|
||||
|
||||
private IItemViewModel MapItemToViewModel(IItem item)
|
||||
private IItemViewModel MapItemToViewModel(IItem item, ItemViewModelType type)
|
||||
{
|
||||
if (item is IContainer container)
|
||||
{
|
||||
var containerViewModel = _serviceProvider.GetInitableResolver<IContainer, ITabViewModel>(container, this).GetRequiredService<IContainerViewModel>();
|
||||
var containerViewModel = _serviceProvider
|
||||
.GetInitableResolver<IContainer, ITabViewModel, ItemViewModelType>(container, this, type)
|
||||
.GetRequiredService<IContainerViewModel>();
|
||||
|
||||
return containerViewModel;
|
||||
}
|
||||
else if (item is IFileElement fileElement)
|
||||
{
|
||||
var fileViewModel = _serviceProvider.GetInitableResolver<IFileElement, ITabViewModel>(fileElement, this).GetRequiredService<IFileViewModel>();
|
||||
var fileViewModel = _serviceProvider
|
||||
.GetInitableResolver<IFileElement, ITabViewModel, ItemViewModelType>(fileElement, this, type)
|
||||
.GetRequiredService<IFileViewModel>();
|
||||
fileViewModel.Size = fileElement.Size;
|
||||
|
||||
return fileViewModel;
|
||||
}
|
||||
else if (item is IElement element)
|
||||
{
|
||||
var elementViewModel = _serviceProvider.GetInitableResolver<IElement, ITabViewModel>(element, this).GetRequiredService<IElementViewModel>();
|
||||
var elementViewModel = _serviceProvider
|
||||
.GetInitableResolver<IElement, ITabViewModel, ItemViewModelType>(element, this, type)
|
||||
.GetRequiredService<IElementViewModel>();
|
||||
|
||||
return elementViewModel;
|
||||
}
|
||||
@@ -237,9 +259,12 @@ public partial class TabViewModel : ITabViewModel, IDisposable
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
@@ -44,33 +44,39 @@
|
||||
</LinearGradientBrush>
|
||||
|
||||
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource AppBackgroundColor}" x:Key="AppBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource ContainerBackgroundColor}" x:Key="ContainerBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource TransparentContainerBackgroundColor}" x:Key="TransparentContainerBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource TransparentContainerBackgroundColor}"
|
||||
x:Key="TransparentContainerBackgroundBrush" />
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource ItemBackgroundColor}" x:Key="ItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AlternativeItemBackgroundColor}" x:Key="AlternativeItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AlternativeItemBackgroundColor}"
|
||||
x:Key="AlternativeItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource SelectedItemBackgroundColor}" x:Key="SelectedItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedItemBackgroundColor}" x:Key="MarkedItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedSelectedItemBackgroundColor}" x:Key="MarkedSelectedItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedAlternativeItemBackgroundColor}" x:Key="MarkedAlternativeItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedSelectedItemBackgroundColor}"
|
||||
x:Key="MarkedSelectedItemBackgroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedAlternativeItemBackgroundColor}"
|
||||
x:Key="MarkedAlternativeItemBackgroundBrush" />
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource ForegroundColor}" x:Key="ForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AccentColor}" x:Key="AccentBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AccentComplementColor}" x:Key="AccentComplementBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource LightForegroundColor}" x:Key="LightForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AlternativeItemForegroundColor}" x:Key="AlternativeItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource AlternativeItemForegroundColor}"
|
||||
x:Key="AlternativeItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource SelectedItemForegroundColor}" x:Key="SelectedItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedItemForegroundColor}" x:Key="MarkedItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedAlternativeItemForegroundColor}" x:Key="MarkedAlternativeItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedSelectedItemForegroundColor}" x:Key="MarkedSelectedItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedAlternativeItemForegroundColor}"
|
||||
x:Key="MarkedAlternativeItemForegroundBrush" />
|
||||
<SolidColorBrush Color="{DynamicResource MarkedSelectedItemForegroundColor}"
|
||||
x:Key="MarkedSelectedItemForegroundBrush" />
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource ErrorColor}" x:Key="ErrorBrush" />
|
||||
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource SelectedItemBackgroundColor}" x:Key="SystemControlHighlightListAccentLowBrush" />
|
||||
|
||||
<SolidColorBrush Color="{DynamicResource SelectedItemBackgroundColor}"
|
||||
x:Key="SystemControlHighlightListAccentLowBrush" />
|
||||
|
||||
|
||||
<converters:ItemViewModeToBrushConverter
|
||||
@@ -91,14 +97,17 @@
|
||||
x:Key="ItemViewModeToBackgroundConverter" />
|
||||
<converters:NamePartShrinkerConverter x:Key="NamePartShrinkerConverter" />
|
||||
<converters:ItemViewModelIsAttributeTypeConverter x:Key="ItemViewModelIsAttributeTypeConverter" />
|
||||
<converters:ItemViewModelIsAttributeTypeConverter Invert="true" x:Key="ItemViewModelIsNotAttributeTypeConverter" />
|
||||
<converters:ItemViewModelIsAttributeTypeConverter Invert="true"
|
||||
x:Key="ItemViewModelIsNotAttributeTypeConverter" />
|
||||
<converters:GetFileExtensionConverter x:Key="GetFileExtensionConverter" />
|
||||
<converters:FormatSizeConverter x:Key="FormatSizeConverter" />
|
||||
<converters:DateTimeConverter x:Key="DateTimeConverter" />
|
||||
<converters:SplitStringConverter x:Key="SplitStringConverter" />
|
||||
<converters:CompareConverter x:Key="EqualityConverter" />
|
||||
<converters:CompareConverter ComparisonCondition="{x:Static converters:ComparisonCondition.NotEqual}" x:Key="NotEqualsConverter" />
|
||||
<converters:CompareConverter ComparisonCondition="{x:Static converters:ComparisonCondition.NotEqual}"
|
||||
x:Key="NotEqualsConverter" />
|
||||
<converters:ExceptionToStringConverter x:Key="ExceptionToStringConverter" />
|
||||
<converters:CommandToCommandNameConverter x:Key="CommandToCommandNameConverter" />
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -182,4 +191,4 @@
|
||||
</Style.Animations>
|
||||
</Style>
|
||||
</Application.Styles>
|
||||
</Application>
|
||||
</Application>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Globalization;
|
||||
using Avalonia.Data.Converters;
|
||||
using FileTime.App.Core.Command;
|
||||
|
||||
namespace FileTime.GuiApp.Converters;
|
||||
|
||||
public class CommandToCommandNameConverter : IValueConverter
|
||||
{
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is not Commands command) return value;
|
||||
|
||||
//TODO: implement
|
||||
return command.ToString();
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ using MvvmGen;
|
||||
namespace FileTime.GuiApp.ViewModels;
|
||||
|
||||
[ViewModel]
|
||||
[Inject(typeof(IAppState), "_appState")]
|
||||
[Inject(typeof(IGuiAppState), "_appState")]
|
||||
[Inject(typeof(ILocalContentProvider), "_localContentProvider")]
|
||||
[Inject(typeof(IServiceProvider), PropertyName = "_serviceProvider")]
|
||||
[Inject(typeof(ILogger<MainWindowViewModel>), PropertyName = "_logger")]
|
||||
@@ -22,7 +22,7 @@ namespace FileTime.GuiApp.ViewModels;
|
||||
public partial class MainWindowViewModel : IMainWindowViewModelBase
|
||||
{
|
||||
public bool Loading => false;
|
||||
public IAppState AppState => _appState;
|
||||
public IGuiAppState AppState => _appState;
|
||||
public string Title { get; private set; }
|
||||
|
||||
partial void OnInitialize()
|
||||
@@ -30,7 +30,7 @@ public partial class MainWindowViewModel : IMainWindowViewModelBase
|
||||
_logger?.LogInformation($"Starting {nameof(MainWindowViewModel)} initialization...");
|
||||
|
||||
var version = Assembly.GetEntryAssembly()!.GetName().Version;
|
||||
var versionString = "Unknwon version";
|
||||
var versionString = "Unknown version";
|
||||
if (version != null)
|
||||
{
|
||||
versionString = $"{version.Major}.{version.Minor}.{version.Build}";
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
xmlns:local="using:FileTime.GuiApp.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:FileTime.GuiApp.ViewModels"
|
||||
xmlns:config="using:FileTime.GuiApp.Configuration"
|
||||
Title="FileTime"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
@@ -180,7 +181,8 @@
|
||||
Fill="{DynamicResource ContentSeparatorBrush}" />
|
||||
|
||||
<Grid Grid.Column="4">
|
||||
<Grid IsVisible="{Binding AppState.SelectedTab^.SelectedsChildrenCollection.Collection, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Grid
|
||||
IsVisible="{Binding AppState.SelectedTab^.SelectedsChildrenCollection.Collection, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<ListBox
|
||||
x:Name="ChildItems"
|
||||
x:CompileBindings="False"
|
||||
@@ -232,6 +234,42 @@
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="3">
|
||||
<Grid
|
||||
IsVisible="{Binding AppState.PossibleCommands.Count, Converter={StaticResource NotEqualsConverter}, ConverterParameter=0}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Rectangle
|
||||
Height="1"
|
||||
Margin="10,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
Fill="{DynamicResource ContentSeparatorBrush}" />
|
||||
|
||||
<ItemsRepeater
|
||||
Grid.Row="1"
|
||||
Items="{Binding AppState.PossibleCommands}">
|
||||
<ItemsRepeater.ItemTemplate>
|
||||
<DataTemplate x:DataType="config:CommandBindingConfiguration">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding KeysDisplayText}" />
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding Command, Converter={StaticResource CommandToCommandNameConverter}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsRepeater.ItemTemplate>
|
||||
</ItemsRepeater>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<!-- Borders -->
|
||||
|
||||
Reference in New Issue
Block a user