stop if nothing found after first enumeration
MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/ConnectHardwareWalletViewModel.cs
@@ -13,10 +13,12 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
public class ConnectHardwareWalletViewModel : RoutableViewModel
{
private string _message;
- private bool _nothingShowUpMessageVisibility;
+ private bool _continueButtonEnable;
public ConnectHardwareWalletViewModel(string walletName, Network network, WalletManager walletManager)
{
+ IsBusy = true;
+
WalletName = walletName;
HardwareWalletOperations = new HardwareWalletOperations(walletManager, network);
@@ -32,13 +34,14 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
Navigate().Clear();
});
- _message = "";
- }
-
- public bool NothingShowUpMessageVisibility
+ NextCommand = ReactiveCommand.Create(() =>
{
- get => _nothingShowUpMessageVisibility;
- set => this.RaiseAndSetIfChanged(ref _nothingShowUpMessageVisibility, value);
+ HardwareWalletOperations.StartDetection();
+ ContinueButtonEnable = false;
+ Message = "";
+ });
+
+ _message = "";
}
public string WalletName { get; }
@@ -49,22 +52,32 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
set => this.RaiseAndSetIfChanged(ref _message, value);
}
+ public bool ContinueButtonEnable
+ {
+ get => _continueButtonEnable;
+ set => this.RaiseAndSetIfChanged(ref _continueButtonEnable, value);
+ }
+
public HardwareWalletOperations HardwareWalletOperations { get; }
- private void OnSearchingHasNoResult(object? sender, EventArgs e)
+ private void OnNoHardwareWalletFound(object? sender, EventArgs e)
{
- NothingShowUpMessageVisibility = true;
+ IsBusy = false;
+ ContinueButtonEnable = true;
+ Message = "Make sure your device is unlocked with PIN and plugged in then press Continue.";
+ Task.Run(() => HardwareWalletOperations.StopDetectionAsync());
+ HardwareWalletOperations.NoHardwareWalletFound -= OnNoHardwareWalletFound;
}
private void OnPassphraseNeeded(object sender, ElapsedEventArgs e)
{
- NothingShowUpMessageVisibility = false;
+ IsBusy = false;
Message = "Check your device and enter your passphrase.";
}
private void OnHardwareWalletsFound(object? sender, HwiEnumerateEntry[] devices)
{
- NothingShowUpMessageVisibility = false;
+ IsBusy = false;
if (devices.Length > 1)
{
@@ -118,15 +131,16 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
Message = "";
HardwareWalletOperations.HardwareWalletsFound += OnHardwareWalletsFound;
- HardwareWalletOperations.SearchingHasNoResult += OnSearchingHasNoResult;
+ HardwareWalletOperations.NoHardwareWalletFound += OnNoHardwareWalletFound;
HardwareWalletOperations.PassphraseTimer.Elapsed += OnPassphraseNeeded;
- disposable.Add(Disposable.Create(() =>
+ Disposable.Create(() =>
{
HardwareWalletOperations.HardwareWalletsFound -= OnHardwareWalletsFound;
- HardwareWalletOperations.SearchingHasNoResult -= OnSearchingHasNoResult;
+ HardwareWalletOperations.NoHardwareWalletFound -= OnNoHardwareWalletFound;
HardwareWalletOperations.PassphraseTimer.Elapsed -= OnPassphraseNeeded;
- }));
+ })
+ .DisposeWith(disposable);
}
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/DetectedHardwareWalletViewModel.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/DetectedHardwareWalletViewModel.cs
@@ -45,7 +45,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
try
{
await hardwareWalletOperations.GenerateWalletAsync(WalletName);
-
+ hardwareWalletOperations.Dispose();
Navigate().To(new AddedWalletPageViewModel(WalletName, Type));
}
catch(Exception ex)

MODIFY
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
WalletWasabi.Fluent/ViewModels/AddWallet/HardwareWallet/HardwareWalletOperations.cs
@@ -16,7 +16,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
public class HardwareWalletOperations : IDisposable
{
public event EventHandler<HwiEnumerateEntry[]>? HardwareWalletsFound;
- public event EventHandler? SearchingHasNoResult;
+ public event EventHandler? NoHardwareWalletFound;
public HardwareWalletOperations(WalletManager walletManager, Network network)
{
@@ -53,7 +53,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
{
if (wallets.Length == 0)
{
- SearchingHasNoResult?.Invoke(this, EventArgs.Empty);
+ NoHardwareWalletFound?.Invoke(this, EventArgs.Empty);
}
else
{
@@ -111,7 +111,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
}
}
- private async Task StopDetectionAsync()
+ public async Task StopDetectionAsync()
{
if (DetectionTask is { } task && DetectionCts is { } cts)
{
@@ -120,7 +120,7 @@ namespace WalletWasabi.Fluent.ViewModels.AddWallet.HardwareWallet
}
}
- private void StartDetection()
+ public void StartDetection()
{
if (DisposeCts is { } cts)
{

MODIFY
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/ConnectHardwareWalletView.axaml
WalletWasabi.Fluent/Views/AddWallet/HardwareWallet/ConnectHardwareWalletView.axaml
<c:ContentArea Title="Hardware Wallet"
Caption="Connect your hardware wallet to the PC"
EnableCancel="True" CancelContent="Cancel"
- EnableBack="True">
+ EnableBack="True"
+ EnableNext="{Binding ContinueButtonEnable}" NextContent="Continue"
+ IsBusy="{Binding IsBusy}">
<DockPanel LastChildFill="True">
<StackPanel DockPanel.Dock="Top" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0 20 0 0" Spacing="40" Orientation="Horizontal">
</StackPanel>
<Panel DockPanel.Dock="Bottom">
-
- <TextBlock Text="{Binding Message}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 0 200"/>
-
- <c:ProgressRing IsIndeterminate="True" VerticalAlignment="Center" HorizontalAlignment="Center" Height="100" Width="100" />
-
- <c:InfoMessage Classes="h8" Opacity="{Binding NothingShowUpMessageVisibility, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}" VerticalAlignment="Bottom" HorizontalAlignment="Left">
- <StackPanel>
- <TextBlock Text="Nothing showed up?"/>
- <TextBlock Text="Click on the link for more help."/>
- </StackPanel>
- </c:InfoMessage>
-
+ <TextBlock Text="{Binding Message}" HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" Margin="0 0 0 200"/>
+ <c:ProgressRing IsVisible="{Binding !ContinueButtonEnable}" IsIndeterminate="True" VerticalAlignment="Center" HorizontalAlignment="Center" Height="100" Width="100" />
<Button Content="More information and help with Hardware Wallets" Classes="h8 plain activeHyperLink" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="{DynamicResource SystemAccentColor}" />
</Panel>

stop if nothing found after first enumeration