feat: update to finish functionality, start to build theme.
This commit is contained in:
32
demo/Ursa.Demo/Converters/IconNameConverter.cs
Normal file
32
demo/Ursa.Demo/Converters/IconNameConverter.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Metadata;
|
||||
|
||||
namespace Ursa.Demo.Converters;
|
||||
|
||||
public class IconNameConverter: IValueConverter
|
||||
{
|
||||
[Content]
|
||||
public Dictionary<string, PathGeometry> Paths { get; set; } = new();
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is null) return null;
|
||||
if (value is string s)
|
||||
{
|
||||
return Paths.TryGetValue(s, out var path)? path: AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
return AvaloniaProperty.UnsetValue;
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user