Fix lock screen persistence.
MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
@@ -187,6 +187,9 @@ namespace WalletWasabi.Gui
{
MainWindowViewModel.Instance.WindowState = WindowState.Maximized;
}
+
+ MainWindowViewModel.Instance.LockScreen.Initialize();
+
DisplayWalletManager();
}
catch (Exception ex)

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -22,7 +22,6 @@ namespace WalletWasabi.Gui
#pragma warning restore IDE1006 // Naming Styles
{
StatusBarViewModel statusBar = null;
- LockScreenViewModel lockScreen = null;
bool runGui = false;
try
@@ -47,13 +46,11 @@ namespace WalletWasabi.Gui
MainWindowViewModel.Instance.Global = Global;
statusBar = new StatusBarViewModel(Global);
MainWindowViewModel.Instance.StatusBar = statusBar;
- lockScreen = new LockScreenViewModel(Global);
- MainWindowViewModel.Instance.LockScreen = lockScreen;
+ MainWindowViewModel.Instance.LockScreen = new LockScreenViewModel(Global);
await Global.InitializeNoWalletAsync();
statusBar.Initialize(Global.Nodes.ConnectedNodes, Global.Synchronizer, Global.UpdateChecker);
- lockScreen.Initialize();
if (Global.Network != Network.Main)
{

MODIFY
WalletWasabi.Gui/ViewModels/LockScreenViewModel.cs
WalletWasabi.Gui/ViewModels/LockScreenViewModel.cs
-using Avalonia.Threading;
-using AvalonStudio.Extensibility;
-using AvalonStudio.Shell;
-using NBitcoin.Protocol;
-using Nito.AsyncEx;
using ReactiveUI;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.IO;
-using System.Linq;
-using System.Reactive;
using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using System.Runtime.InteropServices;
-using System.Threading;
-using System.Threading.Tasks;
-using WalletWasabi.Gui.Controls.LockScreen;
-using WalletWasabi.Gui.Converters;
-using WalletWasabi.Gui.Dialogs;
using WalletWasabi.Gui.Models;
-using WalletWasabi.Gui.Tabs;
-using WalletWasabi.Helpers;
-using WalletWasabi.Models;
-using WalletWasabi.Services;
-using WalletWasabi.Stores;
namespace WalletWasabi.Gui.ViewModels
{
@@ -33,93 +10,38 @@ namespace WalletWasabi.Gui.ViewModels
public Global Global { get; }
- private LockScreenImpl _activeLockScreen;
+ public LockScreenViewModel(Global global)
+ {
+ Global = global;
+ }
- public LockScreenImpl ActiveLockScreen
+ private LockScreenType _lockScreenType;
+ public LockScreenType ActiveLockScreen
{
- get => _activeLockScreen;
- set => this.RaiseAndSetIfChanged(ref _activeLockScreen, value);
+ get => _lockScreenType;
+ set => this.RaiseAndSetIfChanged(ref _lockScreenType, value);
}
- public LockScreenViewModel(Global global)
+ private bool _isLocked;
+ public bool IsLocked
{
- Global = global;
+ get => _isLocked;
+ set => this.RaiseAndSetIfChanged(ref _isLocked, value);
}
public void Initialize()
{
- OnLockScreenTypeChange(Global.UiConfig.LockScreenType);
-
Global.UiConfig.WhenAnyValue(x => x.LockScreenActive)
- .Subscribe(OnLockScreenActiveChange)
+ .BindTo(this, y => y.IsLocked)
.DisposeWith(Disposables);
- Global.UiConfig.WhenAnyValue(x => x.LockScreenType)
- .Subscribe(OnLockScreenTypeChange)
+ this.WhenAnyValue(x => x.IsLocked)
+ .BindTo(Global.UiConfig, y => y.LockScreenActive)
.DisposeWith(Disposables);
- ActiveLockScreen.WhenAnyValue(x => x.IsLocked)
- .Subscribe(ActiveLockScreenIsLockedChanged)
+ Global.UiConfig.WhenAnyValue(x => x.LockScreenType)
+ .BindTo(this, y => y.ActiveLockScreen)
.DisposeWith(Disposables);
}
-
- private void ActiveLockScreenIsLockedChanged(bool obj)
- {
- if (Global.UiConfig.LockScreenActive != obj)
- Global.UiConfig.LockScreenActive = obj;
- }
-
- // Registers oncoming changes from settings
- private void OnLockScreenActiveChange(bool? obj)
- {
- if (ActiveLockScreen is null)
- return;
-
- if (ActiveLockScreen.IsLocked != obj)
- ActiveLockScreen.IsLocked = obj ?? false;
- }
-
- private void OnLockScreenTypeChange(LockScreenType? obj)
- {
- switch (obj)
- {
- case LockScreenType.Simple:
- ActiveLockScreen = new SimpleLock();
- break;
- case LockScreenType.SlideLock:
- ActiveLockScreen = new SlideLock();
- break;
- case LockScreenType.PINLock:
-
- break;
- }
-
- }
-
-
- #region IDisposable Support
-
- private volatile bool _disposedValue = false; // To detect redundant calls
-
- protected virtual void Dispose(bool disposing)
- {
- if (!_disposedValue)
- {
- if (disposing)
- {
- Disposables?.Dispose();
- }
-
- _disposedValue = true;
- }
- }
-
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
- Dispose(true);
- }
-
- #endregion IDisposable Support
}
}
\ No newline at end of file

Fix lock screen persistence.