Preview refactor, Console rename form
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using FileTime.Core.Interactions;
|
||||
using FileTime.Core.Models;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.App.Core.Interactions;
|
||||
|
||||
public partial class DoubleItemNamePartListPreview : IPreviewElement
|
||||
{
|
||||
[Notify] private List<ItemNamePart> _itemNameParts1 = new();
|
||||
[Notify] private List<ItemNamePart> _itemNameParts2 = new();
|
||||
public PreviewType PreviewType => PreviewType.DoubleItemNamePartList;
|
||||
object IPreviewElement.PreviewType => PreviewType;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using FileTime.Core.Interactions;
|
||||
|
||||
namespace FileTime.App.Core.Interactions;
|
||||
|
||||
public class DoubleTextListPreview : IPreviewElement
|
||||
{
|
||||
public ObservableCollection<DoubleTextPreview> Items { get; } = new();
|
||||
public PreviewType PreviewType { get; } = PreviewType.DoubleTextList;
|
||||
object IPreviewElement.PreviewType => PreviewType;
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
using System.Reactive.Subjects;
|
||||
using FileTime.Core.Interactions;
|
||||
using FileTime.Core.Models;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.App.Core.Interactions;
|
||||
|
||||
public class DoubleTextPreview : IPreviewElement
|
||||
public partial class DoubleTextPreview : IPreviewElement
|
||||
{
|
||||
public IObservable<List<ItemNamePart>> Text1 { get; init; } = new BehaviorSubject<List<ItemNamePart>>(new());
|
||||
public IObservable<List<ItemNamePart>> Text2 { get; init; } = new BehaviorSubject<List<ItemNamePart>>(new());
|
||||
|
||||
public PreviewType PreviewType => PreviewType.DoubleTextList;
|
||||
[Notify] private string _text1;
|
||||
[Notify] private string _text2;
|
||||
|
||||
public PreviewType PreviewType => PreviewType.DoubleText;
|
||||
object IPreviewElement.PreviewType => PreviewType;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using FileTime.Core.Interactions;
|
||||
|
||||
namespace FileTime.App.Core.Interactions;
|
||||
|
||||
public class PreviewList : IPreviewElement
|
||||
{
|
||||
public ObservableCollection<IPreviewElement> Items { get; } = new();
|
||||
public PreviewType PreviewType { get; } = PreviewType.PreviewList;
|
||||
object IPreviewElement.PreviewType => PreviewType;
|
||||
}
|
||||
@@ -3,5 +3,6 @@
|
||||
public enum PreviewType
|
||||
{
|
||||
DoubleText,
|
||||
DoubleTextList
|
||||
PreviewList,
|
||||
DoubleItemNamePartList
|
||||
}
|
||||
@@ -61,8 +61,9 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
|
||||
|
||||
public async Task HandleInputKey(GeneralKeyEventArgs args)
|
||||
{
|
||||
if (args.Key is not { } key) return;
|
||||
var keyWithModifiers = new KeyConfig(
|
||||
args.Key,
|
||||
key,
|
||||
shift: args.SpecialKeysStatus.IsShiftPressed,
|
||||
alt: args.SpecialKeysStatus.IsAltPressed,
|
||||
ctrl: args.SpecialKeysStatus.IsCtrlPressed);
|
||||
@@ -72,7 +73,7 @@ public class DefaultModeKeyInputHandler : IDefaultModeKeyInputHandler
|
||||
var selectedCommandBinding = _keyboardConfigurationService.UniversalCommandBindings.FirstOrDefault(c => c.Keys.AreKeysEqual(_appState.PreviousKeys));
|
||||
selectedCommandBinding ??= _keyboardConfigurationService.CommandBindings.FirstOrDefault(c => c.Keys.AreKeysEqual(_appState.PreviousKeys));
|
||||
|
||||
if (args.Key == Keys.Escape)
|
||||
if (key == Keys.Escape)
|
||||
{
|
||||
var doGeneralReset = _appState.PreviousKeys.Count > 1;
|
||||
|
||||
|
||||
@@ -54,9 +54,10 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
||||
|
||||
public async Task HandleInputKey(GeneralKeyEventArgs args)
|
||||
{
|
||||
var keyString = args.Key.Humanize();
|
||||
if (args.Key is not { } key) return;
|
||||
var keyString = key.Humanize();
|
||||
|
||||
if (args.Key == Keys.Escape)
|
||||
if (key == Keys.Escape)
|
||||
{
|
||||
args.Handled = true;
|
||||
if (_modalService.OpenModals.Count > 0)
|
||||
@@ -68,7 +69,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
||||
await CallCommandAsync(ExitRapidTravelCommand.Instance);
|
||||
}
|
||||
}
|
||||
else if (args.Key == Keys.Backspace)
|
||||
else if (key == Keys.Backspace)
|
||||
{
|
||||
if (_appState.RapidTravelText.Value!.Length > 0)
|
||||
{
|
||||
@@ -87,7 +88,7 @@ public class RapidTravelModeKeyInputHandler : IRapidTravelModeKeyInputHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
var currentKeyAsList = new List<KeyConfig> {new(args.Key)};
|
||||
var currentKeyAsList = new List<KeyConfig> {new(key)};
|
||||
var selectedCommandBinding = _keyboardConfigurationService.UniversalCommandBindings.FirstOrDefault(c => c.Keys.AreKeysEqual(currentKeyAsList));
|
||||
if (selectedCommandBinding != null)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
{
|
||||
list.AddRange(_markedItems.Value!);
|
||||
}
|
||||
else if(_currentSelectedItem?.Value?.BaseItem?.FullName is { } selectedItemName)
|
||||
else if (_currentSelectedItem?.Value?.BaseItem?.FullName is { } selectedItemName)
|
||||
{
|
||||
list.Add(selectedItemName);
|
||||
}
|
||||
@@ -217,12 +217,15 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
{
|
||||
BehaviorSubject<string> templateRegexValue = new(string.Empty);
|
||||
BehaviorSubject<string> newNameSchemaValue = new(string.Empty);
|
||||
List<IDisposable> subscriptions = new();
|
||||
|
||||
var itemsToRename = new List<FullName>(_markedItems.Value!);
|
||||
|
||||
var itemPreviews = itemsToRename
|
||||
.Select(item =>
|
||||
{
|
||||
var preview = new DoubleItemNamePartListPreview();
|
||||
|
||||
var originalName = item.GetName();
|
||||
|
||||
var decoratedOriginalName = templateRegexValue.Select(templateRegex =>
|
||||
@@ -284,17 +287,19 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
}
|
||||
);
|
||||
|
||||
var preview = new DoubleTextPreview
|
||||
{
|
||||
Text1 = decoratedOriginalName,
|
||||
Text2 = text2
|
||||
};
|
||||
subscriptions.Add(decoratedOriginalName.Subscribe(
|
||||
n => preview.ItemNameParts1 = n
|
||||
));
|
||||
subscriptions.Add(text2.Subscribe(
|
||||
n => preview.ItemNameParts2 = n
|
||||
));
|
||||
|
||||
return preview;
|
||||
}
|
||||
);
|
||||
|
||||
DoubleTextListPreview doubleTextListPreview = new();
|
||||
doubleTextListPreview.Items.AddRange(itemPreviews);
|
||||
PreviewList previewList = new();
|
||||
previewList.Items.AddRange(itemPreviews);
|
||||
|
||||
var templateRegex = new TextInputElement("Template regex", string.Empty,
|
||||
s => templateRegexValue.OnNext(s!));
|
||||
@@ -303,7 +308,7 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
|
||||
var success = await _userCommunicationService.ReadInputs(
|
||||
new[] {templateRegex, newNameSchema},
|
||||
new[] {doubleTextListPreview}
|
||||
new[] {previewList}
|
||||
);
|
||||
|
||||
if (success)
|
||||
@@ -338,6 +343,8 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
itemsToMove.AddRange(itemsToMoveWithPath);
|
||||
}
|
||||
}
|
||||
|
||||
subscriptions.ForEach(s => s.Dispose());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -460,6 +467,6 @@ public class ItemManipulationUserCommandHandlerService : UserCommandHandlerServi
|
||||
_selectedTab?.ClearMarkedItems();
|
||||
}
|
||||
|
||||
private async Task AddCommandAsync(ICommand command)
|
||||
private async Task AddCommandAsync(ICommand command)
|
||||
=> await _commandScheduler.AddCommand(command);
|
||||
}
|
||||
Reference in New Issue
Block a user