Fixes, UI improvements
child container, preview, etc
This commit is contained in:
@@ -33,7 +33,7 @@ namespace FileTime.Avalonia.Application
|
||||
private ContainerViewModel _currentLocation;
|
||||
|
||||
[Property]
|
||||
private ContainerViewModel _childContainer;
|
||||
private ContainerViewModel? _childContainer;
|
||||
|
||||
[Property]
|
||||
private int _tabNumber;
|
||||
@@ -51,16 +51,16 @@ namespace FileTime.Avalonia.Application
|
||||
{
|
||||
if (!_updateFromCode && value != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
/*try
|
||||
{*/
|
||||
/*var task = SetSelectedItemAsync(value, true);
|
||||
Task.WaitAll(new Task[] { task }, 100);*/
|
||||
SetSelectedItemAsync(value, true);
|
||||
}
|
||||
/*}
|
||||
catch
|
||||
{
|
||||
//TODO: Debug, linux start after restore 3 tabs
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,23 +74,10 @@ namespace FileTime.Avalonia.Application
|
||||
{
|
||||
_selectedItem = value;
|
||||
|
||||
if (value is ElementViewModel elementViewModel)
|
||||
{
|
||||
var elementPreview = new ElementPreviewViewModel();
|
||||
await elementPreview.Init(elementViewModel.Element);
|
||||
ElementPreview = elementPreview;
|
||||
}
|
||||
else
|
||||
{
|
||||
ElementPreview = null;
|
||||
}
|
||||
|
||||
if (await Tab.SetCurrentSelectedItem(SelectedItem?.Item, fromDataBinding))
|
||||
{
|
||||
await Tab.SetCurrentSelectedItem(SelectedItem?.Item, fromDataBinding);
|
||||
OnPropertyChanged(nameof(SelectedItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnInitialize()
|
||||
{
|
||||
@@ -161,17 +148,18 @@ namespace FileTime.Avalonia.Application
|
||||
|
||||
public async Task UpdateCurrentSelectedItem(CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tabCurrentSelectenItem = await Tab.GetCurrentSelectedItem();
|
||||
/*try
|
||||
{*/
|
||||
|
||||
if (token.IsCancellationRequested) return;
|
||||
|
||||
var tabCurrentSelectenItem = await Tab.GetCurrentSelectedItem();
|
||||
ContainerViewModel? newChildContainer = null;
|
||||
|
||||
IItemViewModel? currentSelectenItem = null;
|
||||
if (tabCurrentSelectenItem == null)
|
||||
{
|
||||
await SetSelectedItemAsync(null);
|
||||
ChildContainer = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -179,22 +167,49 @@ namespace FileTime.Avalonia.Application
|
||||
if (currentSelectenItem is ContainerViewModel currentSelectedContainer)
|
||||
{
|
||||
await SetSelectedItemAsync(currentSelectedContainer);
|
||||
ChildContainer = currentSelectedContainer;
|
||||
newChildContainer = currentSelectedContainer;
|
||||
}
|
||||
else if (currentSelectenItem is ElementViewModel element)
|
||||
{
|
||||
await SetSelectedItemAsync(element);
|
||||
ChildContainer = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
await SetSelectedItemAsync(null);
|
||||
ChildContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
await UpdateParents(token);
|
||||
|
||||
var start = DateTime.Now;
|
||||
while (true)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
if (token.IsCancellationRequested) return;
|
||||
if ((DateTime.Now - start).Milliseconds > 500) break;
|
||||
}
|
||||
|
||||
ChildContainer = newChildContainer;
|
||||
|
||||
if (currentSelectenItem is ElementViewModel elementViewModel)
|
||||
{
|
||||
var elementPreview = new ElementPreviewViewModel();
|
||||
await elementPreview.Init(elementViewModel.Element);
|
||||
ElementPreview = elementPreview;
|
||||
}
|
||||
else
|
||||
{
|
||||
ElementPreview = null;
|
||||
}
|
||||
/*}
|
||||
catch
|
||||
{
|
||||
//INFO collection modified exception on: currentSelectenItem = (await _currentLocation.GetItems()).FirstOrDefault(i => i.Item.Name == tabCurrentSelectenItem.Name);
|
||||
//TODO: handle or error message
|
||||
}*/
|
||||
|
||||
async Task UpdateParents(CancellationToken token = default)
|
||||
{
|
||||
var items = await _currentLocation.GetItems(token);
|
||||
if (items?.Count > 0)
|
||||
{
|
||||
@@ -244,11 +259,6 @@ namespace FileTime.Avalonia.Application
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
//INFO collection modified exception on: currentSelectenItem = (await _currentLocation.GetItems()).FirstOrDefault(i => i.Item.Name == tabCurrentSelectenItem.Name);
|
||||
//TODO: handle or error message
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetCurrentSelectedItem(IItem newItem)
|
||||
@@ -269,9 +279,12 @@ namespace FileTime.Avalonia.Application
|
||||
}
|
||||
catch
|
||||
{
|
||||
_updateFromCode = false;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_updateFromCode = false;
|
||||
}
|
||||
}
|
||||
|
||||
private CancellationToken CancelAndGenerateNextMovementToken()
|
||||
|
||||
@@ -80,9 +80,9 @@ namespace FileTime.Avalonia.Services
|
||||
else if (selectedCommandBinding != null)
|
||||
{
|
||||
setHandled(true);
|
||||
await _commandHandlerService.HandleCommandAsync(selectedCommandBinding.Command);
|
||||
_appState.PreviousKeys.Clear();
|
||||
_appState.PossibleCommands = new();
|
||||
await _commandHandlerService.HandleCommandAsync(selectedCommandBinding.Command);
|
||||
}
|
||||
else if (_keysToSkip.Any(k => AreKeysEqual(k, _appState.PreviousKeys)))
|
||||
{
|
||||
@@ -99,6 +99,7 @@ namespace FileTime.Avalonia.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
setHandled(true);
|
||||
var possibleCommands = _keyboardConfigurationService.AllShortcut.Where(c => AreKeysEqual(c.Keys[0], keyWithModifiers)).ToList();
|
||||
|
||||
if (possibleCommands.Count == 0)
|
||||
@@ -110,7 +111,6 @@ namespace FileTime.Avalonia.Services
|
||||
{
|
||||
_appState.PossibleCommands = possibleCommands;
|
||||
}
|
||||
setHandled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -67,71 +67,6 @@ namespace FileTime.Avalonia.ViewModels
|
||||
|
||||
public List<ItemNamePart> DisplayName => ItemNameConverterService.GetDisplayName(this);
|
||||
|
||||
/*[Obsolete($"This property is for databinding only, use {nameof(GetContainers)} method instead.")]
|
||||
public ObservableCollection<ContainerViewModel> Containers
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_isInitialized) Task.Run(Refresh).Wait();
|
||||
}
|
||||
catch(Exception e) { }
|
||||
return _containers;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _containers)
|
||||
{
|
||||
_containers = value;
|
||||
OnPropertyChanged(nameof(Containers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete($"This property is for databinding only, use {nameof(GetElements)} method instead.")]
|
||||
public ObservableCollection<ElementViewModel> Elements
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_isInitialized) Task.Run(Refresh).Wait();
|
||||
}
|
||||
catch(Exception e) { }
|
||||
return _elements;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _elements)
|
||||
{
|
||||
_elements = value;
|
||||
OnPropertyChanged(nameof(Elements));
|
||||
}
|
||||
}
|
||||
}
|
||||
[Obsolete($"This property is for databinding only, use {nameof(GetItems)} method instead.")]
|
||||
public ObservableCollection<IItemViewModel> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_isInitialized) Task.Run(Refresh).Wait();
|
||||
}
|
||||
catch(Exception e) { }
|
||||
return _items;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != _items)
|
||||
{
|
||||
_items = value;
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public Task Containers => GetContainers();
|
||||
public Task Elements => GetElements();
|
||||
public Task Items => GetItems();
|
||||
|
||||
@@ -248,9 +248,10 @@
|
||||
AutoScrollToSelectedItem="True"
|
||||
IsTabStop="True"
|
||||
Items="{Binding AppState.SelectedTab.CurrentLocation.Items^}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Hidden"
|
||||
SelectedItem="{Binding AppState.SelectedTab.SelectedItem, Mode=TwoWay}"
|
||||
SelectionChanged="OnCurrentItemsSelectionChanged"
|
||||
Classes="ContentListView">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -154,5 +154,11 @@ namespace FileTime.Avalonia.Views
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCurrentItemsSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var listBox = this.FindControl<ListBox>("CurrentItems");
|
||||
listBox.ScrollIntoView(listBox.SelectedIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user