do a new approach
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -29,8 +29,8 @@ namespace WalletWasabi.Fluent.Desktop
public static void Main(string[] args)
{
bool runGui = false;
- try
- {
+ // try
+ // {
Global = CreateGlobal();
Locator.CurrentMutable.RegisterConstant(Global);
@@ -55,17 +55,17 @@ namespace WalletWasabi.Fluent.Desktop
.AfterSetup(_ => AppMainAsync(args))
.StartWithClassicDesktopLifetime(args);
}
- }
- catch (Exception ex)
- {
- Logger.LogCritical(ex);
- Global.CrashReporter.SetException(ex);
- throw;
- }
- finally
- {
- DisposeAsync().GetAwaiter().GetResult();
- }
+ // }
+ // catch (Exception ex)
+ // {
+ // Logger.LogCritical(ex);
+ // Global.CrashReporter.SetException(ex);
+ // throw;
+ // }
+ // finally
+ // {
+ // DisposeAsync().GetAwaiter().GetResult();
+ // }
}
private static Global CreateGlobal()

MODIFY
WalletWasabi.Fluent/Controls/TagBox.xaml
WalletWasabi.Fluent/Controls/TagBox.xaml
<Style Selector="c|TagBox">
<Setter Property="Template">
<ControlTemplate>
- <Panel>
- <WrapPanel Name="PART_Container">
- <AutoCompleteBox Name="PART_InputBox" MinimumPrefixLength="{TemplateBinding MinimumPrefixLength}"
- Items="{TemplateBinding Suggestions}"/>
- </WrapPanel>
- </Panel>
+ <StackPanel>
+
+ <ItemsRepeater Items="{Binding CombinedContent}">
+ <ItemsRepeater.ItemTemplate>
+ <DataTemplate>
+ <ContentControl Content="{Binding .}" />
+
+ </DataTemplate>
+ </ItemsRepeater.ItemTemplate>
+ <ItemsRepeater.Layout>
+ <UniformGridLayout></UniformGridLayout>
+ </ItemsRepeater.Layout>
+ </ItemsRepeater>
+ <Button Command="{Binding AddTag}">Add</Button>
+ <Button Command="{Binding RemoveTag}">Sub</Button>
+ </StackPanel>
</ControlTemplate>
</Setter>
</Style>

MODIFY
WalletWasabi.Fluent/Controls/TagBox.xaml.cs
WalletWasabi.Fluent/Controls/TagBox.xaml.cs
-using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
using Avalonia;
-using Avalonia.Layout;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
+using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Threading;
+using DynamicData;
+using WalletWasabi.Fluent.ViewModels.TagsBox;
namespace WalletWasabi.Fluent.Controls
{
@@ -15,27 +18,28 @@ namespace WalletWasabi.Fluent.Controls
/// </summary>
public class TagBox : ContentControl
{
- public static readonly StyledProperty<int> MinimumPrefixLengthProperty =
- AvaloniaProperty.Register<TagBox, int>(nameof(MinimumPrefixLength));
-
- public int MinimumPrefixLength
- {
- get => GetValue(MinimumPrefixLengthProperty);
- set => SetValue(MinimumPrefixLengthProperty, value);
- }
-
- public static readonly StyledProperty<IEnumerable> SuggestionsProperty =
- AvaloniaProperty.Register<TagBox, IEnumerable>(nameof(Suggestions));
-
- public IEnumerable Suggestions
- {
- get => GetValue(SuggestionsProperty);
- set => SetValue(SuggestionsProperty, value);
- }
-
-
- private WrapPanel _wp;
- private AutoCompleteBox _tb;
+ // public static readonly StyledProperty<int> MinimumPrefixLengthProperty =
+ // AvaloniaProperty.Register<TagBox, int>(nameof(MinimumPrefixLength));
+ //
+ // public static readonly StyledProperty<IEnumerable> SuggestionsProperty =
+ // AvaloniaProperty.Register<TagBox, IEnumerable>(nameof(Suggestions));
+ //
+ // private AutoCompleteBox _tb;
+ //
+ //
+ // private WrapPanel _wp;
+ //
+ // public int MinimumPrefixLength
+ // {
+ // get => GetValue(MinimumPrefixLengthProperty);
+ // set => SetValue(MinimumPrefixLengthProperty, value);
+ // }
+ //
+ // public IEnumerable Suggestions
+ // {
+ // get => GetValue(SuggestionsProperty);
+ // set => SetValue(SuggestionsProperty, value);
+ // }
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change)
{
@@ -49,52 +53,86 @@ namespace WalletWasabi.Fluent.Controls
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
- _wp = e.NameScope.Find<WrapPanel>("PART_Container"); ;
- _tb = e.NameScope.Find<AutoCompleteBox>("PART_InputBox"); ;
- _tb.KeyUp += OnKeyPress;
- _tb.GetObservable<string>(TextBox.TextProperty).Subscribe(TextChanged);
- }
-
- private void TextChanged(string obj)
- {
- if (obj.Length > 1 && !string.IsNullOrEmpty(obj.Trim()) && obj.EndsWith(' '))
- {
- var index = _wp.Children.Count - 1;
-
- _wp.Children.Insert(index, GenerateTag(obj, index));
-
- Dispatcher.UIThread.InvokeAsync(() => { _tb.Text = string.Empty; });
- }
- }
-
- public IControl GenerateTag(string Text, int index) => new Border()
- {
- BorderThickness = new Thickness(1),
- Margin = new Thickness(5),
- Padding = new Thickness(5),
- BorderBrush = new SolidColorBrush(Colors.LightGreen),
- Child = new TextBlock()
- {
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- Text = Text.Trim()
- }
- };
+ // _wp = e.NameScope.Find<WrapPanel>("PART_Container");
+ ;
+ // var dt = new TagBoxViewModel();
+ // DataContext = dt;
+ // dt.AppendedObject = "Always at the end";
+ //
+ // dt.Tags = new ObservableCollection<object>();
+ //
+ // dt.Tags.AddRange(new List<object>
+ // {
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas"),
+ // new TagViewModel("asdasdas")
+ // });
+ //
+ //
+ // var b1 = e.NameScope.Find<Button>("PART_add");
+ //
+ // b1.Click += delegate { dt.Tags.Add(new TagViewModel("asdasdas")); };
+ //
+ // var b2 = e.NameScope.Find<Button>("PART_sub");
+ //
+ // b2.Click += delegate
+ // {
+ // if (dt.Tags.Count > 0)
+ // dt.Tags.Remove(dt.Tags.Last());
+ // };
- private void OnKeyPress(object? sender, KeyEventArgs e)
- {
- if (e.Key == Key.Back && _tb.Text.Length == 0 && _wp.Children.Count > 1)
- {
- _wp.Children.RemoveAt(_wp.Children.Count - 2);
+ // // _tb = e.NameScope.Find<AutoCompleteBox>("PART_InputBox"); ;
+ // // _tb.KeyUp += OnKeyPress;
+ // // _tb.GetObservable<string>(TextBox.TextProperty).Subscribe(TextChanged);
}
- else if (e.Key == Key.Enter && !string.IsNullOrEmpty(_tb.Text.Trim()))
- {
- var index = _wp.Children.Count - 1;
- _wp.Children.Insert(index, GenerateTag(_tb.Text, index));
+ // private void TextChanged(string obj)
+ // {
+ // if (obj.Length > 1 && !string.IsNullOrEmpty(obj.Trim()) && obj.EndsWith(' '))
+ // {
+ // var index = _wp.Children.Count - 1;
+ //
+ // _wp.Children.Insert(index, GenerateTag(obj, index));
+ //
+ // Dispatcher.UIThread.InvokeAsync(() => { _tb.Text = string.Empty; });
+ // }
+ // }
- Dispatcher.UIThread.InvokeAsync(() => { _tb.Text = string.Empty; });
- }
- }
+ // public IControl GenerateTag(string Text, int index)
+ // {
+ // return new Border
+ // {
+ // BorderThickness = new Thickness(1),
+ // Margin = new Thickness(5),
+ // Padding = new Thickness(5),
+ // BorderBrush = new SolidColorBrush(Colors.LightGreen),
+ // Child = new TextBlock
+ // {
+ // HorizontalAlignment = HorizontalAlignment.Center,
+ // VerticalAlignment = VerticalAlignment.Center,
+ // Text = Text.Trim()
+ // }
+ // };
+ // }
+ //
+ // private void OnKeyPress(object? sender, KeyEventArgs e)
+ // {
+ // if (e.Key == Key.Back && _tb.Text.Length == 0 && _wp.Children.Count > 1)
+ // {
+ // _wp.Children.RemoveAt(_wp.Children.Count - 2);
+ // }
+ // else if (e.Key == Key.Enter && !string.IsNullOrEmpty(_tb.Text.Trim()))
+ // {
+ // var index = _wp.Children.Count - 1;
+ //
+ // _wp.Children.Insert(index, GenerateTag(_tb.Text, index));
+ //
+ // Dispatcher.UIThread.InvokeAsync(() => { _tb.Text = string.Empty; });
+ // }
+ // }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
WalletWasabi.Fluent/ViewModels/RecoverWalletPageViewModel.cs
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using NBitcoin;
using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.TagsBox;
namespace WalletWasabi.Fluent.ViewModels
{
@@ -14,6 +15,8 @@ namespace WalletWasabi.Fluent.ViewModels
public override string IconName => "home_regular";
- public IEnumerable MnemonicSuggestions => new Mnemonic(Wordlist.English, WordCount.Twelve).WordList.GetWords();
+ public TagBoxViewModel RecoveryWordsTagBoxViewModel { get; } = new TagBoxViewModel();
+
+ public IEnumerable MnemonicSuggestions { get; } = new Mnemonic(Wordlist.English, WordCount.Twelve).WordList.GetWords();
}
}

ADD
WalletWasabi.Fluent/ViewModels/TagsBox/TagInputViewModel.cs
+using System.Collections;
+using ReactiveUI;
+using WalletWasabi.Gui.ViewModels;
+
+namespace WalletWasabi.Fluent.ViewModels.TagsBox
+{
+ public class TagInputViewModel : ViewModelBase
+ {
+ private readonly TagBoxViewModel _parent;
+ private IEnumerable _suggestions;
+
+ public IEnumerable Suggestions
+ {
+ get => _suggestions;
+ set => this.RaiseAndSetIfChanged(ref _suggestions, value);
+ }
+
+ public TagInputViewModel(TagBoxViewModel parent)
+ {
+ _parent = parent;
+ }
+ }
+}
\ No newline at end of file

ADD
WalletWasabi.Fluent/ViewModels/TagsBox/TagViewModel.cs
+using System;
+using ReactiveUI;
+using WalletWasabi.Gui.ViewModels;
+
+namespace WalletWasabi.Fluent.ViewModels.TagsBox
+{
+ public class TagViewModel : ViewModelBase
+ {
+ private readonly TagBoxViewModel _parent;
+
+ private string _tag;
+
+ public TagViewModel(TagBoxViewModel parent, string tag)
+ {
+ _parent = parent;
+ Tag = tag;
+ }
+
+ public string Tag
+ {
+ get => _tag;
+ set => this.RaiseAndSetIfChanged(ref _tag, value);
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
WalletWasabi.Fluent/Views/RecoveryPageView.axaml
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="WalletWasabi.Fluent.Views.RecoveryPageView">
<Panel>
- <c:TagBox Suggestions="{Binding MnemonicSuggestions}"/>
+ <c:TagBox DataContext="{Binding RecoveryWordsTagBoxViewModel}" />
</Panel>
</UserControl>

ADD
WalletWasabi.Fluent/Views/TagsBox/TagView.xaml
+<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:c="clr-namespace:WalletWasabi.Fluent.Controls"
+ mc:Ignorable="d"
+ x:Class="WalletWasabi.Fluent.Views.TagsBox.TagView">
+ <Border BorderBrush="Green" BorderThickness="1" Margin="5" CornerRadius="4">
+ <TextBlock Text="{Binding Tag}" Margin="5"/>
+ </Border>
+</UserControl>
\ No newline at end of file

ADD
WalletWasabi.Fluent/Views/TagsBox/TagView.xaml.cs
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace WalletWasabi.Fluent.Views.TagsBox
+{
+ public class TagView : UserControl
+ {
+ public TagView()
+ {
+ InitializeComponent();
+ }
+
+ private void InitializeComponent()
+ {
+ AvaloniaXamlLoader.Load(this);
+ }
+ }
+}
\ No newline at end of file

do a new approach