Item double click (run or open)
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
using FileTime.App.Core.ViewModels;
|
||||||
|
|
||||||
|
namespace FileTime.App.Core.UserCommand;
|
||||||
|
|
||||||
|
|
||||||
|
public class RunOrOpenCommand : IUserCommand
|
||||||
|
{
|
||||||
|
public IItemViewModel? Item { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class IdentifiableRunOrOpenCommand : RunOrOpenCommand, IIdentifiableUserCommand
|
||||||
|
{
|
||||||
|
public const string CommandName = "run_or_open";
|
||||||
|
public static IdentifiableRunOrOpenCommand Instance { get; } = new();
|
||||||
|
|
||||||
|
private IdentifiableRunOrOpenCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UserCommandID => CommandName;
|
||||||
|
|
||||||
|
public string Title => "Open or run";
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
namespace FileTime.App.Core.UserCommand;
|
|
||||||
|
|
||||||
public sealed class RunOrOpenCommand : IIdentifiableUserCommand
|
|
||||||
{
|
|
||||||
public const string CommandName = "run_or_open";
|
|
||||||
public static RunOrOpenCommand Instance { get; } = new();
|
|
||||||
|
|
||||||
private RunOrOpenCommand()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public string UserCommandID => CommandName;
|
|
||||||
|
|
||||||
public string Title => "Open or run";
|
|
||||||
}
|
|
||||||
@@ -89,14 +89,15 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunOrOpen()
|
private async Task RunOrOpen(RunOrOpenCommand command)
|
||||||
{
|
{
|
||||||
if (_currentSelectedItem?.Value is IContainerViewModel)
|
var item = command.Item ?? _currentSelectedItem?.Value;
|
||||||
|
if (item is IContainerViewModel)
|
||||||
{
|
{
|
||||||
await OpenSelected();
|
await OpenSelected();
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
_currentSelectedItem?.Value is IElementViewModel
|
item is IElementViewModel
|
||||||
{
|
{
|
||||||
Element: {NativePath: not null, Provider: ILocalContentProvider} localFile
|
Element: {NativePath: not null, Provider: ILocalContentProvider} localFile
|
||||||
}
|
}
|
||||||
@@ -344,7 +345,7 @@ public class NavigationUserCommandHandlerService : UserCommandHandlerServiceBase
|
|||||||
? (IContainer) await _timelessContentProvider.GetItemByFullNameAsync(fullName, PointInTime.Present)
|
? (IContainer) await _timelessContentProvider.GetItemByFullNameAsync(fullName, PointInTime.Present)
|
||||||
: _localContentProvider;
|
: _localContentProvider;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
var fullName = _currentLocation?.Value?.FullName?.Path ?? "unknown";
|
var fullName = _currentLocation?.Value?.FullName?.Path ?? "unknown";
|
||||||
_logger.LogError(ex, "Could not resolve container while switching to tab {TabNumber} to path {FullName}", number, fullName);
|
_logger.LogError(ex, "Could not resolve container while switching to tab {TabNumber} to path {FullName}", number, fullName);
|
||||||
|
|||||||
@@ -9,61 +9,6 @@ public class UserCommandHandlerService : IUserCommandHandlerService
|
|||||||
public UserCommandHandlerService(IServiceProvider serviceProvider)
|
public UserCommandHandlerService(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
_commandHandlers = new Lazy<IEnumerable<IUserCommandHandler>>(serviceProvider.GetServices<IUserCommandHandler>);
|
_commandHandlers = new Lazy<IEnumerable<IUserCommandHandler>>(serviceProvider.GetServices<IUserCommandHandler>);
|
||||||
|
|
||||||
//(Commands.AutoRefresh, ToggleAutoRefresh),
|
|
||||||
//(Commands.ChangeTimelineMode, ChangeTimelineMode),
|
|
||||||
//(Commands.CloseTab, CloseTab),
|
|
||||||
//(Commands.Compress, Compress),
|
|
||||||
//(Commands.Copy, Copy),
|
|
||||||
//(Commands.CopyHash, CopyHash),
|
|
||||||
//(Commands.CopyPath, CopyPath),
|
|
||||||
//(Commands.CreateContainer, CreateContainer),
|
|
||||||
//(Commands.CreateElement, CreateElement),
|
|
||||||
//(Commands.Cut, Cut),
|
|
||||||
//(Commands.Edit, Edit),
|
|
||||||
//(Commands.EnterRapidTravel, EnterRapidTravelMode),
|
|
||||||
//(Commands.FindByName, FindByName),
|
|
||||||
//(Commands.FindByNameRegex, FindByNameRegex),
|
|
||||||
//(Commands.GoToHome, GotToHome),
|
|
||||||
//(Commands.GoToPath, GoToContainer),
|
|
||||||
//(Commands.GoToProvider, GotToProvider),
|
|
||||||
//(Commands.GoToRoot, GotToRoot),
|
|
||||||
//(Commands.HardDelete, HardDelete),
|
|
||||||
//(Commands.Mark, MarkCurrentItem),
|
|
||||||
//(Commands.MoveCursorDownPage, MoveCursorDownPage),
|
|
||||||
//(Commands.MoveCursorUpPage, MoveCursorUpPage),
|
|
||||||
//(Commands.MoveToFirst, MoveToFirst),
|
|
||||||
//(Commands.MoveToLast, MoveToLast),
|
|
||||||
//(Commands.NextTimelineBlock, SelectNextTimelineBlock),
|
|
||||||
//(Commands.NextTimelineCommand, SelectNextTimelineCommand),
|
|
||||||
//(Commands.OpenInFileBrowser, OpenInDefaultFileExplorer),
|
|
||||||
//(Commands.OpenOrRun, OpenOrRun),
|
|
||||||
//(Commands.PasteMerge, PasteMerge),
|
|
||||||
//(Commands.PasteOverwrite, PasteOverwrite),
|
|
||||||
//(Commands.PasteSkip, PasteSkip),
|
|
||||||
//(Commands.PinFavorite, PinFavorite),
|
|
||||||
//(Commands.PreviousTimelineBlock, SelectPreviousTimelineBlock),
|
|
||||||
//(Commands.PreviousTimelineCommand, SelectPreviousTimelineCommand),
|
|
||||||
//(Commands.Refresh, RefreshCurrentLocation),
|
|
||||||
//(Commands.Rename, Rename),
|
|
||||||
//(Commands.RunCommand, RunCommandInContainer),
|
|
||||||
//(Commands.ScanContainerSize, ScanContainerSize),
|
|
||||||
//(Commands.ShowAllShotcut, ShowAllShortcut),
|
|
||||||
//(Commands.SoftDelete, SoftDelete),
|
|
||||||
//(Commands.SwitchToLastTab, async() => await SwitchToTab(-1)),
|
|
||||||
//(Commands.SwitchToTab1, async() => await SwitchToTab(1)),
|
|
||||||
//(Commands.SwitchToTab2, async() => await SwitchToTab(2)),
|
|
||||||
//(Commands.SwitchToTab3, async() => await SwitchToTab(3)),
|
|
||||||
//(Commands.SwitchToTab4, async() => await SwitchToTab(4)),
|
|
||||||
//(Commands.SwitchToTab5, async() => await SwitchToTab(5)),
|
|
||||||
//(Commands.SwitchToTab6, async() => await SwitchToTab(6)),
|
|
||||||
//(Commands.SwitchToTab7, async() => await SwitchToTab(7)),
|
|
||||||
//(Commands.SwitchToTab8, async() => await SwitchToTab(8)),
|
|
||||||
//(Commands.TimelinePause, PauseTimeline),
|
|
||||||
//(Commands.TimelineRefresh, RefreshTimeline),
|
|
||||||
//(Commands.TimelineStart, ContinueTimeline),
|
|
||||||
//(Commands.ToggleAdvancedIcons, ToggleAdvancedIcons),
|
|
||||||
//(Commands.ToggleHidden, ToggleHidden),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleCommandAsync(UserCommand.IUserCommand command)
|
public async Task HandleCommandAsync(UserCommand.IUserCommand command)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class DefaultIdentifiableCommandHandlerRegister : IStartupHandler
|
|||||||
AddUserCommand(PauseCommandSchedulerCommand.Instance);
|
AddUserCommand(PauseCommandSchedulerCommand.Instance);
|
||||||
AddUserCommand(RefreshCommand.Instance);
|
AddUserCommand(RefreshCommand.Instance);
|
||||||
AddUserCommand(RenameCommand.Instance);
|
AddUserCommand(RenameCommand.Instance);
|
||||||
AddUserCommand(RunOrOpenCommand.Instance);
|
AddUserCommand(IdentifiableRunOrOpenCommand.Instance);
|
||||||
AddUserCommand(ScanSizeCommand.Instance);
|
AddUserCommand(ScanSizeCommand.Instance);
|
||||||
AddUserCommand(StartCommandSchedulerCommand.Instance);
|
AddUserCommand(StartCommandSchedulerCommand.Instance);
|
||||||
AddUserCommand(SortItemsCommand.OrderByNameCommand);
|
AddUserCommand(SortItemsCommand.OrderByNameCommand);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public static class MainConfiguration
|
|||||||
new(RefreshCommand.CommandName, Key.R),
|
new(RefreshCommand.CommandName, Key.R),
|
||||||
new(RenameCommand.CommandName, Key.F2),
|
new(RenameCommand.CommandName, Key.F2),
|
||||||
new(RenameCommand.CommandName, new[] {Key.C, Key.W}),
|
new(RenameCommand.CommandName, new[] {Key.C, Key.W}),
|
||||||
new(RunOrOpenCommand.CommandName, Key.Enter),
|
new(IdentifiableRunOrOpenCommand.CommandName, Key.Enter),
|
||||||
//new CommandBindingConfiguration(ConfigCommand.RunCommand, new KeyConfig(Key.D4, shift: true)),
|
//new CommandBindingConfiguration(ConfigCommand.RunCommand, new KeyConfig(Key.D4, shift: true)),
|
||||||
//new CommandBindingConfiguration(ConfigCommand.ScanContainerSize, new[] { Key.C, Key.S }),
|
//new CommandBindingConfiguration(ConfigCommand.ScanContainerSize, new[] { Key.C, Key.S }),
|
||||||
//new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Key.F1),
|
//new CommandBindingConfiguration(ConfigCommand.ShowAllShortcut, Key.F1),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using FileTime.App.CommandPalette.Services;
|
using FileTime.App.CommandPalette.Services;
|
||||||
using FileTime.App.Core.Services;
|
using FileTime.App.Core.Services;
|
||||||
|
using FileTime.App.Core.ViewModels;
|
||||||
using FileTime.App.FrequencyNavigation.Services;
|
using FileTime.App.FrequencyNavigation.Services;
|
||||||
using FileTime.GuiApp.Services;
|
using FileTime.GuiApp.Services;
|
||||||
using FileTime.Providers.LocalAdmin;
|
using FileTime.Providers.LocalAdmin;
|
||||||
@@ -17,4 +18,5 @@ public interface IMainWindowViewModel : IMainWindowViewModelBase
|
|||||||
IRefreshSmoothnessCalculator RefreshSmoothnessCalculator { get; }
|
IRefreshSmoothnessCalculator RefreshSmoothnessCalculator { get; }
|
||||||
IAdminElevationManager AdminElevationManager { get; }
|
IAdminElevationManager AdminElevationManager { get; }
|
||||||
IClipboardService ClipboardService { get; }
|
IClipboardService ClipboardService { get; }
|
||||||
|
Task RunOrOpenItem(IItemViewModel itemViewModel);
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ using Avalonia.Input;
|
|||||||
using FileTime.App.CommandPalette.Services;
|
using FileTime.App.CommandPalette.Services;
|
||||||
using FileTime.App.Core.Services;
|
using FileTime.App.Core.Services;
|
||||||
using FileTime.App.Core.UserCommand;
|
using FileTime.App.Core.UserCommand;
|
||||||
|
using FileTime.App.Core.ViewModels;
|
||||||
using FileTime.App.FrequencyNavigation.Services;
|
using FileTime.App.FrequencyNavigation.Services;
|
||||||
using FileTime.Core.Models;
|
using FileTime.Core.Models;
|
||||||
using FileTime.Core.Timeline;
|
using FileTime.Core.Timeline;
|
||||||
@@ -77,6 +78,13 @@ public partial class MainWindowViewModel : IMainWindowViewModel
|
|||||||
new OpenContainerCommand(new AbsolutePath(_timelessContentProvider, resolvedContainer)));
|
new OpenContainerCommand(new AbsolutePath(_timelessContentProvider, resolvedContainer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task RunOrOpenItem(IItemViewModel itemViewModel) =>
|
||||||
|
await UserCommandHandlerService.HandleCommandAsync(
|
||||||
|
new RunOrOpenCommand
|
||||||
|
{
|
||||||
|
Item = itemViewModel
|
||||||
|
});
|
||||||
|
|
||||||
public async Task OnExit()
|
public async Task OnExit()
|
||||||
=> await _lifecycleService.ExitAsync();
|
=> await _lifecycleService.ExitAsync();
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,10 @@
|
|||||||
x:Name="CurrentItems">
|
x:Name="CurrentItems">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate x:DataType="corevm:IItemViewModel">
|
<DataTemplate x:DataType="corevm:IItemViewModel">
|
||||||
<local:ItemView HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" />
|
<local:ItemView
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
PointerPressed="Child_OnPointerPressed" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|||||||
@@ -184,4 +184,26 @@ public partial class MainWindow : Window, IUiAccessor
|
|||||||
public async Task InvokeOnUIThread(Func<Task> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
public async Task InvokeOnUIThread(Func<Task> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
||||||
|
|
||||||
public async Task<T> InvokeOnUIThread<T>(Func<Task<T>> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
public async Task<T> InvokeOnUIThread<T>(Func<Task<T>> func) => await Dispatcher.UIThread.InvokeAsync(func);
|
||||||
|
|
||||||
|
private async void Child_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e is {Handled: false, ClickCount: 2}
|
||||||
|
&& ViewModel != null
|
||||||
|
&& e.GetCurrentPoint(this).Properties.IsLeftButtonPressed
|
||||||
|
&& sender is StyledElement {DataContext: IItemViewModel itemViewModel})
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ViewModel.RunOrOpenItem(itemViewModel);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger?.LogError(
|
||||||
|
ex,
|
||||||
|
"Error while opening item {Item}",
|
||||||
|
itemViewModel.BaseItem?.FullName?.Path ?? itemViewModel.DisplayNameText
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user