Added LockScreenViewModel and a Simple lock screen for debugging purposes.
MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml.cs
WalletWasabi.Gui/Controls/LockScreen/LockScreen.xaml.cs
@@ -11,6 +11,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
public LockScreen()
{
InitializeComponent();
+
}
private void InitializeComponent()

MODIFY
WalletWasabi.Gui/Controls/LockScreen/LockScreenImpl.cs
WalletWasabi.Gui/Controls/LockScreen/LockScreenImpl.cs
+using System;
+using Avalonia;
using Avalonia.Controls;
+using ReactiveUI;
namespace WalletWasabi.Gui.Controls.LockScreen
{
- internal class LockScreenImpl : UserControl
+ public abstract class LockScreenImpl : UserControl
{
- internal virtual void Reset()
+ private bool _isLocked;
+
+ public static readonly DirectProperty<LockScreenImpl, bool> IsLockedProperty =
+ AvaloniaProperty.RegisterDirect<LockScreenImpl, bool>(nameof(IsLocked),
+ o => o.IsLocked,
+ (o,v) => o.IsLocked = v);
+ public bool IsLocked
{
- IsHitTestVisible = true;
+ get => _isLocked;
+ set => SetAndRaise(IsLockedProperty, ref _isLocked, value);
}
}
}

MODIFY
WalletWasabi.Gui/Controls/LockScreen/SlideLock.xaml.cs
WalletWasabi.Gui/Controls/LockScreen/SlideLock.xaml.cs
@@ -68,6 +68,7 @@ namespace WalletWasabi.Gui.Controls.LockScreen
this.PseudoClasses.Add(":unlocked");
UnlockInProgress = false;
UnlockDone = true;
+ IsLocked = false;
return;
}
@@ -83,15 +84,6 @@ namespace WalletWasabi.Gui.Controls.LockScreen
}
}
- private new void Reset()
- {
- UnlockDone = false;
- UnlockInProgress = false;
- UserDragInProgress = false;
- Offset = 0;
- base.Reset();
- }
-
private void OnDragStarted(object sender, VectorEventArgs e)
{
UserDragInProgress = true;
@@ -114,5 +106,6 @@ namespace WalletWasabi.Gui.Controls.LockScreen
{
AvaloniaXamlLoader.Load(this);
}
+
}
}

MODIFY
WalletWasabi.Gui/MainWindow.xaml
WalletWasabi.Gui/MainWindow.xaml
<shell:ShellView DataContext="{Binding Shell}" />
</DockPanel>
<wasabi:ModalDialog DataContext="{Binding ModalDialog}" />
- <lockscreen:LockScreen/>
+ <lockscreen:LockScreen DataContext="{Binding LockScreen}"/>
</Grid>
</cont:MetroWindow>

MODIFY
WalletWasabi.Gui/Models/LockScreenType.cs
WalletWasabi.Gui/Models/LockScreenType.cs
@@ -9,7 +9,8 @@ namespace WalletWasabi.Gui.Models
/// </summary>
public enum LockScreenType
{
+ Simple,
SlideLock,
- PINLock
+ PINLock,
}
}
\ No newline at end of file

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

MODIFY
WalletWasabi.Gui/Shell/Commands/LockScreenCommands.cs
WalletWasabi.Gui/Shell/Commands/LockScreenCommands.cs
@@ -26,6 +26,7 @@ namespace WalletWasabi.Gui.Shell.Commands
"Lock Screen",
commandIconService.GetCompletionKindImage("Lock"),
lockScreen);
+
}
private void OnLockScreen()

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
@@ -21,7 +21,7 @@ namespace WalletWasabi.Gui
{
private bool? _lurkingWifeMode;
private bool? _lockScreenActive;
- private LockScreenType _lockScreenType;
+ private LockScreenType? _lockScreenType;
/// <inheritdoc />
public string FilePath { get; private set; }
@@ -60,7 +60,7 @@ namespace WalletWasabi.Gui
}
[JsonProperty(PropertyName = "LockScreenType")]
- public LockScreenType LockScreenType
+ public LockScreenType? LockScreenType
{
get => _lockScreenType;
set => this.RaiseAndSetIfChanged(ref _lockScreenType, value);
@@ -119,7 +119,7 @@ namespace WalletWasabi.Gui
LurkingWifeMode = false;
LockScreenActive = false;
LockScreenPinHash = "";
- LockScreenType = LockScreenType.SlideLock;
+ LockScreenType = Models.LockScreenType.SlideLock;
if (!File.Exists(FilePath))
{
@@ -145,6 +145,10 @@ namespace WalletWasabi.Gui
FeeDisplayFormat = config.FeeDisplayFormat ?? FeeDisplayFormat;
Autocopy = config.Autocopy ?? Autocopy;
LurkingWifeMode = config.LurkingWifeMode ?? LurkingWifeMode;
+ LockScreenActive = config.LockScreenActive ?? LockScreenActive;
+ LockScreenPinHash = config.LockScreenPinHash ?? LockScreenPinHash;
+ LockScreenType = config.LockScreenType ?? LockScreenType;
+
}
/// <inheritdoc />

ADD
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
+{
+ public class LockScreenViewModel : ViewModelBase
+ {
+ private CompositeDisposable Disposables { get; } = new CompositeDisposable();
+
+ public Global Global { get; }
+
+ private LockScreenImpl _activeLockScreen;
+
+ public LockScreenImpl ActiveLockScreen
+ {
+ get => _activeLockScreen;
+ set => this.RaiseAndSetIfChanged(ref _activeLockScreen, value);
+ }
+
+ public LockScreenViewModel(Global global)
+ {
+ Global = global;
+ }
+
+ public void Initialize()
+ {
+ Global.UiConfig.WhenAnyValue(x => x.LockScreenActive)
+ .Subscribe(OnLockScreenActiveChange)
+ .DisposeWith(Disposables);
+
+ Global.UiConfig.WhenAnyValue(x => x.LockScreenType)
+ .Subscribe(OnLockScreenTypeChange)
+ .DisposeWith(Disposables);
+
+ OnLockScreenTypeChange(Global.UiConfig.LockScreenType);
+
+ ActiveLockScreen.WhenAnyValue(x => x.IsLocked)
+ .Subscribe(ActiveLockScreenIsLockedChanged)
+ .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
+ }
+}

MODIFY
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
@@ -52,6 +52,14 @@ namespace WalletWasabi.Gui.ViewModels
internal set => this.RaiseAndSetIfChanged(ref _statusBar, value);
}
+ private LockScreenViewModel _lockScreen;
+
+ public LockScreenViewModel LockScreen
+ {
+ get => _lockScreen;
+ internal set => this.RaiseAndSetIfChanged(ref _lockScreen, value);
+ }
+
public MainWindowViewModel()
{
Shell = IoC.Get<IShell>();

Added LockScreenViewModel and a Simple lock screen for debugging purposes.