Help, key bindings

This commit is contained in:
2022-02-02 21:50:10 +01:00
parent f40c84a123
commit ee0c6f7a0b
5 changed files with 520 additions and 427 deletions

View File

@@ -59,6 +59,24 @@ namespace FileTime.App.Core.Tab
}
}
public async Task ClearMarkedItems(IContainer container)
{
if (_markedItems.ContainsKey(container))
{
var markedItems = _markedItems[container];
for (var i = 0; i < markedItems.Count; i++)
{
await ItemUnmarked.InvokeAsync(this, markedItems[i]);
markedItems.RemoveAt(i--);
}
}
}
public async Task ClearCurrentMarkedItems()
{
await ClearMarkedItems(await Tab.GetCurrentLocation());
}
public bool ContainsMarkedItem(IContainer container, AbsolutePath path)
{
if (!_markedItems.ContainsKey(container)) return false;

View File

@@ -11,6 +11,7 @@
<ResourceDictionary>
<Color x:Key="AppBackgroundColor">#073642</Color>
<Color x:Key="ContainerBackgroundColor">#083e4c</Color>
<Color x:Key="TransparentContainerBackgroundColor">#D0083e4c</Color>
<Color x:Key="ItemBackgroundColor">#00000000</Color>
<Color x:Key="AlternativeItemBackgroundColor">#10000000</Color>
@@ -44,6 +45,9 @@
<SolidColorBrush
x:Key="ContainerBackgroundBrush"
Color="{DynamicResource ContainerBackgroundColor}" />
<SolidColorBrush
x:Key="TransparentContainerBackgroundBrush"
Color="{DynamicResource TransparentContainerBackgroundColor}" />
<SolidColorBrush
x:Key="ItemBackgroundBrush"

View File

@@ -54,7 +54,7 @@ namespace FileTime.Avalonia.Command
bool ctrlOrAlt = (key.Ctrl ?? false) || (key.Alt ?? false);
if (ctrlOrAlt && currentText.Last() != ' ') s += " ";
if (ctrlOrAlt && currentText.Length > 0 && currentText.Last() != ' ') s += " ";
if (key.Ctrl ?? false) s += "CTRL+";
if (key.Alt ?? false) s += "ALT+";
@@ -69,7 +69,7 @@ namespace FileTime.Avalonia.Command
{
var s = "";
if (currentText.Last() != ' ' && !wasCtrlOrAlt) s += " ";
if (currentText.Length > 0 && currentText.Last() != ' ' && !wasCtrlOrAlt) s += " ";
s += key.Key.ToString();
if (!wasCtrlOrAlt) s += " ";

View File

@@ -73,6 +73,12 @@ namespace FileTime.Avalonia.ViewModels
[Property]
private ObservableCollection<string> _popupTexts = new ObservableCollection<string>();
[Property]
private bool _showAllShortcut;
[Property]
private List<CommandBinding> _allShortcut;
public ObservableCollection<ParallelCommandsViewModel> TimelineCommands { get; } = new();
async partial void OnInitialize()
@@ -95,6 +101,8 @@ namespace FileTime.Avalonia.ViewModels
_keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(Key.PageUp) });
_keysToSkip.Add(new KeyWithModifiers[] { new KeyWithModifiers(Key.F4, alt: true) });
AllShortcut = _commandBindings.Concat(_universalCommandBindings).ToList();
var tab = new Tab();
await tab.Init(LocalContentProvider);
@@ -428,6 +436,7 @@ namespace FileTime.Avalonia.ViewModels
{
_clipboard.AddContent(selectedItem);
}
await AppState.SelectedTab.TabState.ClearCurrentMarkedItems();
}
else
{
@@ -647,6 +656,12 @@ namespace FileTime.Avalonia.ViewModels
return Task.CompletedTask;
}
private Task ShowAllShortcut2()
{
ShowAllShortcut = true;
return Task.CompletedTask;
}
[Command]
public async void ProcessInputs()
{
@@ -707,6 +722,7 @@ namespace FileTime.Avalonia.ViewModels
if (key == Key.Escape)
{
ShowAllShortcut = false;
_previousKeys.Clear();
PossibleCommands = new();
}
@@ -749,9 +765,16 @@ namespace FileTime.Avalonia.ViewModels
var updateRapidTravelFilter = false;
if (key == Key.Escape)
{
if (ShowAllShortcut)
{
ShowAllShortcut = false;
}
else
{
await ExitRapidTravelMode();
}
}
else if (key == Key.Back)
{
if (AppState.RapidTravelText.Length > 0)
@@ -888,6 +911,11 @@ namespace FileTime.Avalonia.ViewModels
FileTime.App.Core.Command.Commands.CreateContainer,
new KeyWithModifiers[]{new KeyWithModifiers(Key.C),new KeyWithModifiers(Key.C)},
CreateContainer),
new CommandBinding(
"create container",
FileTime.App.Core.Command.Commands.CreateContainer,
new KeyWithModifiers[]{new KeyWithModifiers(Key.F7)},
CreateContainer),
new CommandBinding(
"create element",
FileTime.App.Core.Command.Commands.CreateElement,
@@ -1008,6 +1036,11 @@ namespace FileTime.Avalonia.ViewModels
FileTime.App.Core.Command.Commands.Rename,
new KeyWithModifiers[]{new KeyWithModifiers(Key.C),new KeyWithModifiers(Key.W)},
Rename),
new CommandBinding(
"rename",
FileTime.App.Core.Command.Commands.Rename,
new KeyWithModifiers[]{new KeyWithModifiers(Key.F2)},
Rename),
new CommandBinding(
"timeline pause",
FileTime.App.Core.Command.Commands.Dummy,
@@ -1028,6 +1061,11 @@ namespace FileTime.Avalonia.ViewModels
FileTime.App.Core.Command.Commands.Refresh,
new KeyWithModifiers[]{new KeyWithModifiers(Key.R)},
RefreshCurrentLocation),
new CommandBinding(
"refresh",
FileTime.App.Core.Command.Commands.Refresh,
new KeyWithModifiers[]{new KeyWithModifiers(Key.F5)},
RefreshCurrentLocation),
new CommandBinding(
"go to",
FileTime.App.Core.Command.Commands.Dummy,
@@ -1038,6 +1076,11 @@ namespace FileTime.Avalonia.ViewModels
FileTime.App.Core.Command.Commands.Dummy,
new KeyWithModifiers[] { new KeyWithModifiers(Key.Z), new KeyWithModifiers(Key.I) },
ToggleAdvancedIcons),
new CommandBinding(
"show all shortcut",
FileTime.App.Core.Command.Commands.Dummy,
new KeyWithModifiers[] { new KeyWithModifiers(Key.F1) },
ShowAllShortcut2),
};
var universalCommandBindings = new List<CommandBinding>()
{

View File

@@ -18,6 +18,7 @@
x:Name="RootContainer"
Background="{DynamicResource AppBackgroundBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="250" />
<ColumnDefinition Width="*" />
@@ -470,10 +471,10 @@
VerticalAlignment="Center"
Fill="{DynamicResource ContentSeparatorBrush}" />
<ItemsControl
<ItemsRepeater
Grid.Row="1"
Items="{Binding PossibleCommands}">
<ItemsControl.ItemTemplate>
<ItemsRepeater.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
@@ -481,14 +482,41 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding KeysDisplayText}" />
<TextBlock Grid.Column="1" Text="{Binding Name}" />
</Grid>
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
</Grid>
</Grid>
</Grid>
</Grid>
<Border Background="{DynamicResource TransparentContainerBackgroundBrush}" Margin="20" HorizontalAlignment="Center" IsVisible="{Binding ShowAllShortcut}">
<Grid RowDefinitions="Auto, *" Margin="30,10">
<TextBlock Text="Shortcuts" Margin="0,0,0,20"/>
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled">
<ItemsControl
Items="{Binding AllShortcut}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,10,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding KeysDisplayText}" />
<TextBlock Grid.Column="1" Text="{Binding Name}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
</Window>