Added Converter - currently not in use
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
|
||||||
|
namespace DelauneyTriangulation.Models;
|
||||||
|
|
||||||
|
public class Converters
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class EmptyStringIntConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public static readonly EmptyStringIntConverter Instance = new();
|
||||||
|
|
||||||
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => value?.ToString();
|
||||||
|
|
||||||
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
var s = value as string;
|
||||||
|
if (string.IsNullOrWhiteSpace(s)) return 0;
|
||||||
|
return int.TryParse(s, NumberStyles.Integer, culture, out var n) ? n : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user