diff --git a/Src/FinderOuter/ViewModels/MissingBase58ViewModel.cs b/Src/FinderOuter/ViewModels/MissingBase58ViewModel.cs index 82e9af3..0490c59 100644 --- a/Src/FinderOuter/ViewModels/MissingBase58ViewModel.cs +++ b/Src/FinderOuter/ViewModels/MissingBase58ViewModel.cs @@ -31,8 +31,10 @@ public MissingBase58ViewModel(Settings settings) searchSpace = new(); IObservable isFindEnabled = this.WhenAnyValue( - x => x.Input, x => x.SelectedMissingChar, - x => x.Result.CurrentState, (b58, c, state) => + x => x.Input, + x => x.SelectedMissingChar, + x => x.Result.CurrentState, + (b58, c, state) => !string.IsNullOrEmpty(b58) && InputService.IsMissingCharValid(c) && state != State.Working); @@ -56,6 +58,8 @@ public MissingBase58ViewModel(Settings settings) AddNumberCommand = ReactiveCommand.Create(AddNumber, canAdd); AddExactCommand = ReactiveCommand.Create(AddExact, canAdd); AddSimilarCommand = ReactiveCommand.Create(AddSimilar, canAdd); + + CopyCommand = ReactiveCommand.Create(Copy, isFindEnabled); } @@ -93,6 +97,7 @@ public Base58Type SelectedInputType private void Start() { + CopiedList = Array.Empty(); isChanged = false; Index = 0; Max = 0; diff --git a/Src/FinderOuter/ViewModels/OptionVmBase.cs b/Src/FinderOuter/ViewModels/OptionVmBase.cs index a1fa403..6134235 100644 --- a/Src/FinderOuter/ViewModels/OptionVmBase.cs +++ b/Src/FinderOuter/ViewModels/OptionVmBase.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Linq; namespace FinderOuter.ViewModels { @@ -41,6 +42,9 @@ public OptionVmBase(IReport report, IWindowManager winMan) : base(winMan) PreviousCommand = ReactiveCommand.Create(Previous, isPrevEnabled); RemoveSelectedCommand = ReactiveCommand.Create(RemoveSelected, canRemove); ClearAllCommand = ReactiveCommand.Create(ClearAll, canAdd); + + IObservable canPaste = this.WhenAnyValue(x => x.CopiedList, (item) => item != null && item.Length > 0); + PasteCommand = ReactiveCommand.Create(Paste, canPaste); } @@ -97,6 +101,44 @@ public DescriptiveItem SelectedCompareInputType public FontFamily CjkFont => FontFamily.Parse("Microsoft YaHei,Simsun,苹方-简,宋体-简"); + public IReactiveCommand CopyCommand { get; protected set; } + public IReactiveCommand PasteCommand { get; protected set; } + + private string[] _copied = Array.Empty(); + public string[] CopiedList + { + get => _copied; + set => this.RaiseAndSetIfChanged(ref _copied, value); + } + + public void Copy() + { + if (CurrentItems is not null) + { + CopiedList = CurrentItems.ToArray(); + } + } + + public void Paste(bool replace) + { + if (CurrentItems is not null) + { + if (replace) + { + CurrentItems.Clear(); + } + + foreach (var item in CopiedList) + { + if (!CurrentItems.Contains(item)) + { + CurrentItems.Add(item); + } + } + } + } + + protected ObservableCollection[] allItems = []; private ObservableCollection _items; diff --git a/Src/FinderOuter/Views/MissingBase58View.axaml b/Src/FinderOuter/Views/MissingBase58View.axaml index 223575f..1821200 100644 --- a/Src/FinderOuter/Views/MissingBase58View.axaml +++ b/Src/FinderOuter/Views/MissingBase58View.axaml @@ -7,7 +7,7 @@ x:CompileBindings="True" x:DataType="vm:MissingBase58ViewModel" x:Class="FinderOuter.Views.MissingBase58View"> - + @@ -84,14 +84,31 @@