mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-03-03 00:00:55 +08:00
28 lines
777 B
C#
28 lines
777 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using Avalonia;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Metadata;
|
|
|
|
namespace Semi.Avalonia.Demo.Converters;
|
|
|
|
public class FileIconConverter : IMultiValueConverter
|
|
{
|
|
[Content] public IDictionary<string, object?> Items { get; } = new Dictionary<string, object?>();
|
|
|
|
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (values[0] is bool isDirectory && values[1] is bool isOpen)
|
|
{
|
|
if (!isDirectory)
|
|
{
|
|
return Items["file"];
|
|
}
|
|
|
|
return isOpen ? Items["folderOpen"] : Items["folderClosed"];
|
|
}
|
|
|
|
return AvaloniaProperty.UnsetValue;
|
|
}
|
|
} |