Console Binary file preview

This commit is contained in:
2023-08-20 07:37:28 +02:00
parent 570ecd3f83
commit 845a37050f
23 changed files with 391 additions and 23 deletions

View File

@@ -22,7 +22,6 @@ public class CommandPaletteViewModel : FuzzyPanelViewModel<ICommandPaletteEntryV
IUserCommandHandlerService userCommandHandlerService,
ICommandKeysHelperService commandKeysHelperService,
ILogger<CommandPaletteViewModel> logger)
: base((a, b) => a.Identifier == b.Identifier)
{
_commandPaletteService = commandPaletteService;
_identifiableUserCommandService = identifiableUserCommandService;

View File

@@ -6,5 +6,6 @@ public interface IElementPreviewViewModel : IItemPreviewViewModel
{
ItemPreviewMode Mode { get; }
string TextContent { get; }
byte[] BinaryContent { get; }
string TextEncoding { get; }
}

View File

@@ -26,6 +26,7 @@ public partial class ElementPreviewViewModel : IElementPreviewViewModel, IAsyncI
public ItemPreviewMode Mode { get; private set; }
[Property] private string? _textContent;
[Property] private byte[]? _binaryContent;
[Property] private string? _textEncoding;
public string Name => PreviewName;
@@ -35,6 +36,7 @@ public partial class ElementPreviewViewModel : IElementPreviewViewModel, IAsyncI
try
{
var content = await element.Provider.GetContentAsync(element, MaxTextPreviewSize);
BinaryContent = content;
if (content is null)
{

View File

@@ -29,13 +29,20 @@ public abstract partial class FuzzyPanelViewModel<TItem> : IFuzzyPanelViewModel<
_searchText = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(SearchText)));
UpdateFilteredMatchesInternal();
UpdateFilteredMatches();
if (string.IsNullOrWhiteSpace(value))
{
SelectedItem = null;
}
else
{
UpdateSelectedItem();
}
}
}
private void UpdateFilteredMatchesInternal()
private void UpdateSelectedItem()
{
UpdateFilteredMatches();
if (SelectedItem != null && FilteredMatches.Contains(SelectedItem)) return;
SelectedItem = FilteredMatches.Count > 0