simplify lock screen logic and fix.
MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreenViewModelBase.cs
WalletWasabi.Gui/Controls/LockScreen/LockScreenViewModelBase.cs
+using System;
using ReactiveUI;
using System.Reactive.Disposables;
+using System.Reactive.Linq;
using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Gui.Controls.LockScreen
@@ -15,6 +17,11 @@ namespace WalletWasabi.Gui.Controls.LockScreen
_isLocked = true;
Disposables = new CompositeDisposable();
+
+ this.WhenAnyValue(x => x.IsLocked)
+ .Where(x => !x)
+ .Take(1)
+ .Subscribe(x => Close());
}
protected CompositeDisposable Disposables { get; }
@@ -28,7 +35,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
public bool IsLocked
{
get => _isLocked;
- private set => this.RaiseAndSetIfChanged(ref _isLocked, value);
+ set => this.RaiseAndSetIfChanged(ref _isLocked, value);
}
protected void Close()

MODIFY
WalletWasabi.Gui/Controls/LockScreen/WasabiLockScreenViewModelBase.cs
WalletWasabi.Gui/Controls/LockScreen/WasabiLockScreenViewModelBase.cs
@@ -7,20 +7,21 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
public abstract class WasabiLockScreenViewModelBase : LockScreenViewModelBase
{
- public WasabiLockScreenViewModelBase()
+ protected override void OnInitialize(CompositeDisposable disposables)
{
+ base.OnInitialize(disposables);
+
var global = Locator.Current.GetService<Global>();
- global.UiConfig
- .WhenAnyValue(x => x.LockScreenActive)
- .ObserveOn(RxApp.MainThreadScheduler)
- .BindTo(this, y => y.IsLocked)
- .DisposeWith(Disposables);
+ global.UiConfig.LockScreenActive = true;
+
+ Disposable.Create(() =>
+ {
+ var global = Locator.Current.GetService<Global>();
- this.WhenAnyValue(x => x.IsLocked)
- .ObserveOn(RxApp.MainThreadScheduler)
- .BindTo(global.UiConfig, y => y.LockScreenActive)
- .DisposeWith(Disposables);
+ global.UiConfig.LockScreenActive = false;
+ })
+ .DisposeWith(disposables);
}
}
}

MODIFY
WalletWasabi.Gui/MainWindow.xaml
WalletWasabi.Gui/MainWindow.xaml
UseLayoutRounding="True"
RenderOptions.BitmapInterpolationMode="HighQuality">
<cont:MetroWindow.TitleBarContent>
- <StackPanel Orientation="Horizontal" IsVisible="{Binding !LockScreen.IsLocked}">
+ <StackPanel Orientation="Horizontal" IsVisible="{Binding MenuVisible}">
<menu:MainMenuView DataContext="{Binding Shell.MainMenu}" Margin="4 0 0 0" Foreground="{DynamicResource ThemeForegroundBrush}" VerticalAlignment="Stretch" FontSize="13" />
</StackPanel>
</cont:MetroWindow.TitleBarContent>

MODIFY
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
@@ -30,6 +30,7 @@ namespace WalletWasabi.Gui.ViewModels
private LockScreenViewModelBase _lockScreen;
private volatile bool _disposedValue = false; // To detect redundant calls
private Stack<LockScreenViewModelBase> _lockScreens;
+ private bool _menuVisible;
public MainWindowViewModel()
{
@@ -39,6 +40,8 @@ namespace WalletWasabi.Gui.ViewModels
_lockScreens = new Stack<LockScreenViewModelBase>();
+ _menuVisible = true;
+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var uiConfig = global.UiConfig;
@@ -95,6 +98,12 @@ namespace WalletWasabi.Gui.ViewModels
private set => this.RaiseAndSetIfChanged(ref _lockScreen, value);
}
+ public bool MenuVisible
+ {
+ get { return _menuVisible; }
+ set { this.RaiseAndSetIfChanged(ref _menuVisible, value); }
+ }
+
public void PushLockScreen(LockScreenViewModelBase lockScreen)
{
if (LockScreen != null)
@@ -102,6 +111,7 @@ namespace WalletWasabi.Gui.ViewModels
_lockScreens.Push(LockScreen);
}
+ MenuVisible = false;
lockScreen.Initialize();
LockScreen = lockScreen;
}
@@ -119,6 +129,7 @@ namespace WalletWasabi.Gui.ViewModels
else
{
LockScreen = null;
+ MenuVisible = true;
}
}
}

simplify lock screen logic and fix.