Move Bitcoin tab.
MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
@@ -21,15 +21,7 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
{
public class SettingsPageViewModel : NavBarItemViewModel
{
- private Network _network;
- private string _torSocks5EndPoint;
- private string _bitcoinP2PEndPoint;
- private string _localBitcoinCoreDataDir;
- private bool _useTor;
- private bool _startLocalBitcoinCoreOnStartup;
- private bool _stopLocalBitcoinCoreOnShutdown;
private bool _isModified;
- private bool _terminateTorOnExit;
private int _selectedTab;
private Global Global;
@@ -44,32 +36,23 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
GeneralTab = new GeneralTabViewModel(Global, config);
PrivacyTab = new PrivacyTabViewModel(config);
+ NetworkTab = new NetworkTabViewModel(config);
+ BitcoinTab = new BitcoinTabViewModel(config);
- this.ValidateProperty(x => x.TorSocks5EndPoint, ValidateTorSocks5EndPoint);
- this.ValidateProperty(x => x.BitcoinP2PEndPoint, ValidateBitcoinP2PEndPoint);
_selectedTab = 0;
- _network = config.Network;
- _torSocks5EndPoint = config.TorSocks5EndPoint.ToString(-1);
- UseTor = config.UseTor;
- TerminateTorOnExit = config.TerminateTorOnExit;
- StartLocalBitcoinCoreOnStartup = config.StartLocalBitcoinCoreOnStartup;
- StopLocalBitcoinCoreOnShutdown = config.StopLocalBitcoinCoreOnShutdown;
-
- _bitcoinP2PEndPoint = config.GetP2PEndpoint().ToString(defaultPort: -1);
- _localBitcoinCoreDataDir = config.LocalBitcoinCoreDataDir;
-
IsModified = !Global.Config.AreDeepEqual(config);
- this.WhenAnyValue(
- x => x.Network,
- x => x.UseTor,
- x => x.TerminateTorOnExit,
- x => x.StartLocalBitcoinCoreOnStartup,
- x => x.StopLocalBitcoinCoreOnShutdown)
- .ObserveOn(RxApp.TaskpoolScheduler)
- .Subscribe(_ => Save());
+ // TODO: trigger save
+ // this.WhenAnyValue(
+ // x => x.Network,
+ // x => x.UseTor,
+ // x => x.TerminateTorOnExit,
+ // x => x.StartLocalBitcoinCoreOnStartup,
+ // x => x.StopLocalBitcoinCoreOnShutdown)
+ // .ObserveOn(RxApp.TaskpoolScheduler)
+ // .Subscribe(_ => Save());
OpenConfigFileCommand = ReactiveCommand.CreateFromTask(OpenConfigFileAsync);
@@ -83,8 +66,10 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
}
public GeneralTabViewModel GeneralTab { get; }
-
public PrivacyTabViewModel PrivacyTab { get; }
+ public NetworkTabViewModel NetworkTab { get; }
+ public BitcoinTabViewModel BitcoinTab { get; }
+
private object ConfigLock { get; } = new object();
public ReactiveCommand<Unit, Unit> OpenConfigFileCommand { get; }
@@ -93,67 +78,12 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
public Version BitcoinCoreVersion => Constants.BitcoinCoreVersion;
- public IEnumerable<Network> Networks => new[]
- {
- Network.Main,
- Network.TestNet,
- Network.RegTest
- };
-
- public Network Network
- {
- get => _network;
- set => this.RaiseAndSetIfChanged(ref _network, value);
- }
-
- public string TorSocks5EndPoint
- {
- get => _torSocks5EndPoint;
- set => this.RaiseAndSetIfChanged(ref _torSocks5EndPoint, value);
- }
-
- public string BitcoinP2PEndPoint
- {
- get => _bitcoinP2PEndPoint;
- set => this.RaiseAndSetIfChanged(ref _bitcoinP2PEndPoint, value);
- }
-
- public string LocalBitcoinCoreDataDir
- {
- get => _localBitcoinCoreDataDir;
- set => this.RaiseAndSetIfChanged(ref _localBitcoinCoreDataDir, value);
- }
-
public bool IsModified
{
get => _isModified;
set => this.RaiseAndSetIfChanged(ref _isModified, value);
}
- public bool StartLocalBitcoinCoreOnStartup
- {
- get => _startLocalBitcoinCoreOnStartup;
- set => this.RaiseAndSetIfChanged(ref _startLocalBitcoinCoreOnStartup, value);
- }
-
- public bool StopLocalBitcoinCoreOnShutdown
- {
- get => _stopLocalBitcoinCoreOnShutdown;
- set => this.RaiseAndSetIfChanged(ref _stopLocalBitcoinCoreOnShutdown, value);
- }
-
- public bool UseTor
- {
- get => _useTor;
- set => this.RaiseAndSetIfChanged(ref _useTor, value);
- }
-
- public bool TerminateTorOnExit
- {
- get => _terminateTorOnExit;
- set => this.RaiseAndSetIfChanged(ref _terminateTorOnExit, value);
- }
-
public int SelectedTab
{
get => _selectedTab;
@@ -164,7 +94,7 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
private void Save()
{
- var network = Network;
+ var network = BitcoinTab.Network;
if (Validations.Any)
{
@@ -179,21 +109,21 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
lock (ConfigLock)
{
config.LoadFile();
- if (Network == config.Network)
+ if (BitcoinTab.Network == config.Network)
{
- if (EndPointParser.TryParse(TorSocks5EndPoint, Constants.DefaultTorSocksPort, out EndPoint torEp))
+ if (EndPointParser.TryParse(NetworkTab.TorSocks5EndPoint, Constants.DefaultTorSocksPort, out EndPoint torEp))
{
config.TorSocks5EndPoint = torEp;
}
- if (EndPointParser.TryParse(BitcoinP2PEndPoint, network.DefaultPort, out EndPoint p2PEp))
+ if (EndPointParser.TryParse(BitcoinTab.BitcoinP2PEndPoint, network.DefaultPort, out EndPoint p2PEp))
{
config.SetP2PEndpoint(p2PEp);
}
- config.UseTor = UseTor;
- config.TerminateTorOnExit = TerminateTorOnExit;
- config.StartLocalBitcoinCoreOnStartup = StartLocalBitcoinCoreOnStartup;
- config.StopLocalBitcoinCoreOnShutdown = StopLocalBitcoinCoreOnShutdown;
- config.LocalBitcoinCoreDataDir = Guard.Correct(LocalBitcoinCoreDataDir);
+ config.UseTor = NetworkTab.UseTor;
+ config.TerminateTorOnExit = NetworkTab.TerminateTorOnExit;
+ config.StartLocalBitcoinCoreOnStartup = BitcoinTab.StartLocalBitcoinCoreOnStartup;
+ config.StopLocalBitcoinCoreOnShutdown = BitcoinTab.StopLocalBitcoinCoreOnShutdown;
+ config.LocalBitcoinCoreDataDir = Guard.Correct(BitcoinTab.LocalBitcoinCoreDataDir);
config.DustThreshold = decimal.TryParse(GeneralTab.DustThreshold, out var threshold) ? Money.Coins(threshold) : Config.DefaultDustThreshold;
config.PrivacyLevelSome = PrivacyTab.MinimalPrivacyLevel;
config.PrivacyLevelStrong = PrivacyTab.StrongPrivacyLevel;
@@ -201,8 +131,8 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
}
else
{
- config.Network = Network;
- BitcoinP2PEndPoint = config.GetP2PEndpoint().ToString(defaultPort: -1);
+ config.Network = BitcoinTab.Network;
+ BitcoinTab.BitcoinP2PEndPoint = config.GetP2PEndpoint().ToString(defaultPort: -1);
}
config.ToFile();
IsModified = !Global.Config.AreDeepEqual(config);
@@ -214,22 +144,5 @@ namespace WalletWasabi.Fluent.ViewModels.Settings
{
await FileHelpers.OpenFileInTextEditorAsync(Global.Config.FilePath);
}
-
- private void ValidateTorSocks5EndPoint(IValidationErrors errors)
- => ValidateEndPoint(errors, TorSocks5EndPoint, Constants.DefaultTorSocksPort, whiteSpaceOk: true);
-
- private void ValidateBitcoinP2PEndPoint(IValidationErrors errors)
- => ValidateEndPoint(errors, BitcoinP2PEndPoint, Network.DefaultPort, whiteSpaceOk: true);
-
- private void ValidateEndPoint(IValidationErrors errors, string endPoint, int defaultPort, bool whiteSpaceOk)
- {
- if (!whiteSpaceOk || !string.IsNullOrWhiteSpace(endPoint))
- {
- if (!EndPointParser.TryParse(endPoint, defaultPort, out _))
- {
- errors.Add(ErrorSeverity.Error, "Invalid endpoint.");
- }
- }
- }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/Settings/GeneralSettingsView.xaml
WalletWasabi.Fluent/Views/Settings/GeneralSettingsView.xaml
xmlns:settings="clr-namespace:WalletWasabi.Fluent.ViewModels.Settings"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.Settings.GeneralSettingsView"
+ x:DataType="settings:SettingsPageViewModel"
DataContext="{Binding GeneralTab}">
- <!-- x:DataType="settings:SettingsPageViewModel" -->
<StackPanel Spacing="20" MinWidth="360" MaxWidth="650" HorizontalAlignment="Left" Orientation="Vertical">
<StackPanel.Styles>
<Style Selector="DockPanel > TextBlock">

MODIFY
WalletWasabi.Fluent/Views/Settings/NetworkSettingsView.xaml
WalletWasabi.Fluent/Views/Settings/NetworkSettingsView.xaml
xmlns:settings="clr-namespace:WalletWasabi.Fluent.ViewModels.Settings"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="settings:SettingsPageViewModel"
- x:Class="WalletWasabi.Fluent.Views.Settings.NetworkSettingsView">
+ x:Class="WalletWasabi.Fluent.Views.Settings.NetworkSettingsView"
+ DataContext="{Binding NetworkTab}">
<StackPanel Spacing="20" MinWidth="360" MaxWidth="650" HorizontalAlignment="Left" Orientation="Vertical">
<StackPanel.Styles>
<Style Selector="DockPanel > TextBlock">

MODIFY
WalletWasabi.Fluent/Views/Settings/PrivacySettingsView.xaml
WalletWasabi.Fluent/Views/Settings/PrivacySettingsView.xaml
xmlns:settings="clr-namespace:WalletWasabi.Fluent.ViewModels.Settings"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.Settings.PrivacySettingsView"
+ x:DataType="settings:SettingsPageViewModel"
DataContext="{Binding PrivacyTab}">
<StackPanel Spacing="20" MinWidth="360" MaxWidth="650" HorizontalAlignment="Left" Orientation="Vertical">
<StackPanel.Styles>

Move Bitcoin tab.