-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68f3f01
commit 49e9a41
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// WatchOnlyBitcoinWallet | ||
// Copyright (c) 2016 Coding Enthusiast | ||
// Distributed under the MIT software license, see the accompanying | ||
// file LICENCE or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
using Autarkysoft.Bitcoin; | ||
using Autarkysoft.Bitcoin.Encoders; | ||
using WatchOnlyBitcoinWallet.MVVM; | ||
|
||
namespace WatchOnlyBitcoinWallet.ViewModels | ||
{ | ||
public class AddEditViewModel : ViewModelBase | ||
{ | ||
public AddEditViewModel() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
|
||
public AddEditViewModel(string addr, string tag) | ||
{ | ||
// Set fields since we don't want to change IsChanged to true. | ||
_addr = addr; | ||
_tag = tag; | ||
|
||
OkCommand = new(Ok); | ||
CancelCommand = new(Cancel); | ||
} | ||
|
||
|
||
public bool IsChanged { get; private set; } = false; | ||
|
||
private string _addr; | ||
public string AddressString | ||
{ | ||
get => _addr; | ||
set | ||
{ | ||
if (SetField(ref _addr, value)) | ||
{ | ||
IsChanged = true; | ||
} | ||
} | ||
} | ||
|
||
private string _tag; | ||
public string Tag | ||
{ | ||
get => _tag; | ||
set | ||
{ | ||
if (SetField(ref _tag, value)) | ||
{ | ||
IsChanged = true; | ||
} | ||
} | ||
} | ||
|
||
private string _error = string.Empty; | ||
public string Error | ||
{ | ||
get => _error; | ||
set => SetField(ref _error, value); | ||
} | ||
|
||
|
||
public BindableCommand OkCommand { get; } | ||
private void Ok() | ||
{ | ||
AddressType type = Address.GetAddressType(AddressString, NetworkType.MainNet); | ||
if (type is AddressType.Unknown or AddressType.Invalid) | ||
{ | ||
Error = "Invalid address type."; | ||
} | ||
else | ||
{ | ||
RaiseCloseEvent(); | ||
} | ||
} | ||
|
||
public BindableCommand CancelCommand { get; } | ||
private void Cancel() | ||
{ | ||
IsChanged = false; | ||
RaiseCloseEvent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:vm="using:WatchOnlyBitcoinWallet.ViewModels" | ||
mc:Ignorable="d" | ||
x:Class="WatchOnlyBitcoinWallet.Views.AddEditView" | ||
Height="110" Width="480" | ||
FontSize="14"> | ||
|
||
<Design.DataContext> | ||
<vm:AboutViewModel/> | ||
</Design.DataContext> | ||
|
||
<Grid ColumnDefinitions="400,*" RowDefinitions="auto,auto,*"> | ||
<TextBox Text="{Binding AddressString}" | ||
Watermark="Enter a valid bitcoin address" | ||
Margin="2" | ||
Grid.Column="0" Grid.Row="0"/> | ||
<TextBox Text="{Binding Tag}" | ||
Watermark="[Optional] Enter a name for this address" | ||
Margin="2" | ||
Grid.Column="0" Grid.Row="1"/> | ||
<TextBlock Text="{Binding Error}" | ||
Grid.Column="0" Grid.Row="2"/> | ||
|
||
<Button Content="OK" | ||
Command="{Binding OkCommand}" | ||
HorizontalContentAlignment="Center" | ||
IsDefault="True" | ||
Width="65" | ||
Grid.Column="1" Grid.Row="0"/> | ||
<Button Content="Cancel" | ||
Command="{Binding CancelCommand}" | ||
HorizontalContentAlignment="Center" | ||
IsCancel="True" | ||
Width="65" | ||
Grid.Column="1" Grid.Row="1"/> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// WatchOnlyBitcoinWallet | ||
// Copyright (c) 2016 Coding Enthusiast | ||
// Distributed under the MIT software license, see the accompanying | ||
// file LICENCE or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
using Avalonia.Controls; | ||
|
||
namespace WatchOnlyBitcoinWallet.Views | ||
{ | ||
public partial class AddEditView : UserControl | ||
{ | ||
public AddEditView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |