Permalink
Browse files

Merge pull request #2 from danwalmsley/features/Recovery-Wallet-AutoC…

…omplete

Fix caret positioning
  • Loading branch information...
lontivero committed Nov 6, 2018
2 parents b8a23c0 + 2d9572d commit afe735e2c93f1ae4f63c3b2fbad6dfa1036ae4d2

This file was deleted.

Oops, something went wrong.
@@ -12,10 +12,9 @@
</StackPanel>
<controls:ExtendedTextBox Text="{Binding WalletName}" Watermark="Wallet Name" UseFloatingWatermark="True" />
<TextBox Text="{Binding Password}" Watermark="Password" PasswordChar="*" UseFloatingWatermark="True" />
<controls:ExtendedTextBox Text="{Binding MnemonicWords}" Watermark="MnemonicWords" UseFloatingWatermark="True" >
<controls:ExtendedTextBox Text="{Binding MnemonicWords}" Watermark="MnemonicWords" UseFloatingWatermark="True" CaretIndex="{Binding CaretIndex, Mode=TwoWay}">
<i:Interaction.Behaviors>
<behaviors:MnemonicSuggestionBehavior SuggestionItems="{Binding Suggestions}" />
<behaviors:PutCursorAtEndTextBoxBehavior />
</i:Interaction.Behaviors>
</controls:ExtendedTextBox>
<ItemsControl Items="{Binding Suggestions}">
@@ -19,6 +19,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
{
internal class RecoverWalletViewModel : CategoryViewModel
{
private int _caretIndex;
private string _password;
private string _mnemonicWords;
private string _walletName;
@@ -28,6 +29,8 @@ internal class RecoverWalletViewModel : CategoryViewModel
public RecoverWalletViewModel(WalletManagerViewModel owner) : base("Recover Wallet")
{
MnemonicWords = "";
RecoverCommand = ReactiveCommand.Create(() =>
{
WalletName = Guard.Correct(WalletName);
@@ -81,6 +84,15 @@ public RecoverWalletViewModel(WalletManagerViewModel owner) : base("Recover Wall
}
}
});
this.WhenAnyValue(x => x.CaretIndex).Subscribe(_ =>
{
if(CaretIndex != MnemonicWords.Length)
{
CaretIndex = MnemonicWords.Length;
}
});
_suggestions = new ObservableCollection<MnemonicViewModel>();
}
@@ -120,6 +132,12 @@ public string ValidationMessage
set { this.RaiseAndSetIfChanged(ref _validationMessage, value); }
}
public int CaretIndex
{
get { return _caretIndex; }
set { this.RaiseAndSetIfChanged(ref _caretIndex, value); }
}
public ReactiveCommand RecoverCommand { get; }
public void OnTermsClicked()
@@ -142,7 +160,7 @@ public override void OnCategorySelected()
base.OnCategorySelected();
Password = null;
MnemonicWords = null;
MnemonicWords = "";
WalletName = Utils.GetNextWalletName();
TermsAccepted = false;
ValidationMessage = null;
@@ -176,8 +194,10 @@ public void OnAddWord(string word)
string[] words = MnemonicWords.Split(' ', StringSplitOptions.RemoveEmptyEntries);
words[words.Length-1] = word;
MnemonicWords = string.Join(' ', words) + " ";
Task.Delay(50).ContinueWith(x=>
Dispatcher.UIThread.InvokeAsync(()=>_suggestions.Clear()));
CaretIndex = MnemonicWords.Length;
Suggestions.Clear();
}
private static IEnumerable<string> EnglishWords = Wordlist.English.GetWords();

0 comments on commit afe735e

Please sign in to comment.