Skip to content

Commit f0f51f5

Browse files
Add a AutoCompleteBox to suggest words from word-list
1 parent 07e6a5f commit f0f51f5

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

Src/FinderOuter/ViewModels/MissingMnemonicViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public MissingMnemonicViewModel()
6161
}
6262

6363

64-
6564
public override string OptionName => "Missing Mnemonic";
6665
public override string Description => $"This option is useful for recovering mnemonics (seed phrases) that are " +
6766
$"missing some words. It supports both BIP39 and Electrum standards.{Environment.NewLine}" +
@@ -73,6 +72,13 @@ public MissingMnemonicViewModel()
7372

7473
private readonly MnemonicSearchSpace searchSpace = new();
7574

75+
private string[] _wl;
76+
public string[] WordList
77+
{
78+
get => _wl;
79+
set => this.RaiseAndSetIfChanged(ref _wl, value);
80+
}
81+
7682
public MnemonicSevice MnService { get; }
7783

7884
public IEnumerable<BIP0039.WordLists> WordListsList { get; }
@@ -136,6 +142,7 @@ private void Start()
136142

137143
if (IsProcessed)
138144
{
145+
WordList = searchSpace.allWords;
139146
allItems = new ObservableCollection<string>[searchSpace.MissCount];
140147
for (int i = 0; i < allItems.Length; i++)
141148
{

Src/FinderOuter/Views/MissingMnemonicView.axaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@
7474

7575
<Expander Header="Advanced (limit search space)" IsExpanded="False" Grid.Column="0" Grid.Row="3">
7676
<Grid ColumnDefinitions="auto,*,auto" RowDefinitions="auto,*">
77-
<Button Content="Start"
77+
<Grid ColumnDefinitions="auto,*" Grid.Column="0" Grid.Row="0">
78+
<Button Content="Start"
7879
Command="{Binding StartCommand}"
7980
Width="70"
80-
Grid.Column="0"
81-
Grid.Row="0"/>
81+
Grid.Column="0"/>
82+
<ToggleSwitch Name="InputTypeToggle"
83+
OffContent="Normal" OnContent="Auto Complete"
84+
Margin="10,0,0,0"
85+
Grid.Column="1"/>
86+
</Grid>
87+
8288
<Grid ColumnDefinitions="auto,*,auto" Margin="5,0,5,0" Grid.Column="1" Grid.Row="0">
8389
<Button Content="&#60;"
8490
Command="{Binding PreviousCommand}"
@@ -100,13 +106,33 @@
100106
<TextBlock Text="{Binding CurrentItems.Count}"/>
101107
</StackPanel>
102108

103-
<Grid ColumnDefinitions="*,*" RowDefinitions="*,*,*,*" Grid.Column="0" Grid.Row="1">
109+
<Grid ColumnDefinitions="*,auto" Width="268" Grid.Column="0" Grid.Row="1"
110+
IsVisible="{Binding ElementName=InputTypeToggle, Path=IsChecked}">
111+
<AutoCompleteBox Text="{Binding ToAdd}"
112+
Items="{Binding WordList}"
113+
IsEnabled="{Binding ElementName=InputTypeToggle, Path=IsChecked}"
114+
IsTextCompletionEnabled="True"
115+
FilterMode="Contains"
116+
MaxDropDownHeight="200"
117+
Height="45"
118+
VerticalAlignment="Top"
119+
Grid.Column="0"/>
120+
<Button Content="+" Command="{Binding AddExactCommand}"
121+
Margin="2,0,0,0" Width="45" Height="45"
122+
FontSize="20"
123+
VerticalAlignment="Top"
124+
Grid.Column="1"/>
125+
</Grid>
126+
127+
<Grid ColumnDefinitions="*,*" RowDefinitions="*,*,*,*" Grid.Column="0" Grid.Row="1"
128+
IsVisible="{Binding ElementName=InputTypeToggle, Path=!IsChecked}">
104129
<Grid.Styles>
105130
<Style Selector="Button">
106131
<Setter Property="Margin" Value="2"/>
107132
<Setter Property="Width" Value="130"/>
108133
</Style>
109134
</Grid.Styles>
135+
110136
<TextBox Text="{Binding ToAdd}" Grid.ColumnSpan="2" Grid.Row="0" MinHeight="30"/>
111137
<Button Content="Similar words" Command="{Binding AddSimilarCommand}" Grid.Column="0" Grid.Row="1"/>
112138
<Button Content="Exact word" Command="{Binding AddExactCommand}" Grid.Column="1" Grid.Row="1"/>

0 commit comments

Comments
 (0)