Add a converter that colors the border according to
aggregated error severities.
MODIFY
WalletWasabi.Gui/Controls/MultiTextBox.xaml
WalletWasabi.Gui/Controls/MultiTextBox.xaml
<Style Selector="controls|MultiTextBox:focus /template/ Border#border">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}" />
</Style>
- <Style Selector="controls|MultiTextBox:error /template/ Border#border">
- <Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}" />
- </Style>
</Styles>

MODIFY
WalletWasabi.Gui/Controls/TogglePasswordBox.xaml
WalletWasabi.Gui/Controls/TogglePasswordBox.xaml
<Style Selector="controls|TogglePasswordBox:focus /template/ Border#border">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}" />
</Style>
- <Style Selector="controls|TogglePasswordBox:error /template/ Border#border">
- <Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}" />
- </Style>
<Style Selector="controls|TogglePasswordBox">
<Setter Property="Cursor" Value="IBeam" />
</Style>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -1051,7 +1051,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
return ErrorDescriptors.Empty;
}
- return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Error, "Invalid address."));
+ return new ErrorDescriptors(new ErrorDescriptor(ErrorSeverity.Warning, "Invalid address."));
}
[ValidateMethod(nameof(ValidateAddress))]

ADD
WalletWasabi.Gui/Converters/ErrorDescriptorToBorderColorConverter.cs
+using Avalonia.Data.Converters;
+using Avalonia.Media;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using WalletWasabi.Models;
+
+namespace WalletWasabi.Gui.Converters
+{
+ public class ErrorDescriptorToBorderColorConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is ErrorDescriptors descriptors)
+ {
+ return GetColorFromDescriptors(descriptors);
+ }
+ else if (value is IEnumerable<Exception> exList)
+ {
+ return GetColorFromDescriptors(ErrorDescriptorsJsonConverter.ExceptionListToErrorDescriptor(exList));
+ }
+
+ return null;
+ }
+
+ private SolidColorBrush GetColorFromDescriptors(ErrorDescriptors descriptors)
+ {
+ if (!descriptors.HasErrors) return null;
+
+ var highPrioError = descriptors.OrderByDescending(p => p.Severity).Single();
+
+ if (ErrorSeverityColorConverter.ErrorSeverityColors.TryGetValue(highPrioError.Severity, out var brush))
+ {
+ return brush;
+ }
+ else
+ return null;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi.Gui/Converters/ErrorDescriptorsJsonConverter.cs
WalletWasabi.Gui/Converters/ErrorDescriptorsJsonConverter.cs
@@ -21,6 +21,14 @@ namespace WalletWasabi.Gui.Converters
}
if (value is IEnumerable<Exception> exList)
+ {
+ return ExceptionListToErrorDescriptor(exList);
+ }
+
+ return ErrorDescriptors.Empty;
+ }
+
+ internal static ErrorDescriptors ExceptionListToErrorDescriptor(IEnumerable<Exception> exList)
{
var errors = new ErrorDescriptors();
@@ -33,9 +41,6 @@ namespace WalletWasabi.Gui.Converters
return errors;
}
- return ErrorDescriptors.Empty;
- }
-
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;

MODIFY
WalletWasabi.Gui/Converters/ErrorSeverityColorConverter.cs
WalletWasabi.Gui/Converters/ErrorSeverityColorConverter.cs
@@ -9,7 +9,7 @@ namespace WalletWasabi.Gui.Converters
{
public class ErrorSeverityColorConverter : IValueConverter
{
- static Dictionary<ErrorSeverity, SolidColorBrush> ErrorSeverityColors = new Dictionary<ErrorSeverity, SolidColorBrush>
+ internal static Dictionary<ErrorSeverity, SolidColorBrush> ErrorSeverityColors = new Dictionary<ErrorSeverity, SolidColorBrush>
{
{ ErrorSeverity.Default, new SolidColorBrush(Colors.White)} ,
{ ErrorSeverity.Info, new SolidColorBrush(Colors.LightCyan)} ,

MODIFY
WalletWasabi.Gui/Styles/Styles.xaml
WalletWasabi.Gui/Styles/Styles.xaml
</FontFamily>
<converters:ErrorDescriptorsJsonConverter x:Key="ErrorDescriptorsJsonConverter" />
<converters:ErrorSeverityColorConverter x:Key="ErrorSeverityColorConverter" />
+ <converters:ErrorDescriptorToBorderColorConverter x:Key="ErrorDescriptorToBorderColorConverter" />
</Style.Resources>
</Style>
<Style Selector="shell|MetroWindow /template/ Button#minimiseButton">
</Setter>
</Style>
<Style Selector="TextBox:error /template/ Border#border">
- <Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" />
+ <Setter Property="BorderBrush" Value="{Binding $parent[TextBox].(DataValidationErrors.Errors), Converter={StaticResource ErrorDescriptorToBorderColorConverter}}" />
</Style>
<Style Selector="TextBox">
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />

MODIFY
WalletWasabi/Helpers/PasswordHelper.cs
WalletWasabi/Helpers/PasswordHelper.cs
@@ -156,6 +156,12 @@ namespace WalletWasabi.Helpers
if (IsTooLong(password, out _))
{
errors.Add(new ErrorDescriptor(ErrorSeverity.Warning, PasswordTooLongMessage));
+
+ // REMOVE AFTER TESTING!
+ errors.Add(new ErrorDescriptor(ErrorSeverity.Info, "Info Test"));
+ errors.Add(new ErrorDescriptor(ErrorSeverity.Warning, "Warning Test"));
+ errors.Add(new ErrorDescriptor(ErrorSeverity.Error, "Error Test"));
+
}
return errors;

Add a converter that colors the border according to
aggregated error severities.