Upload FastSeekWpf/Converters.cs
Browse files- FastSeekWpf/Converters.cs +59 -0
FastSeekWpf/Converters.cs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using System.Globalization;
|
| 3 |
+
using System.Windows.Data;
|
| 4 |
+
using System.Windows.Media;
|
| 5 |
+
using FastSeekWpf.Core;
|
| 6 |
+
|
| 7 |
+
namespace FastSeekWpf;
|
| 8 |
+
|
| 9 |
+
public class KindToBadgeConverter : IValueConverter
|
| 10 |
+
{
|
| 11 |
+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
| 12 |
+
{
|
| 13 |
+
if (value is ResultKind kind)
|
| 14 |
+
{
|
| 15 |
+
var color = kind switch
|
| 16 |
+
{
|
| 17 |
+
ResultKind.App => Color.FromRgb(60, 200, 120),
|
| 18 |
+
ResultKind.Document => Color.FromRgb(240, 140, 60),
|
| 19 |
+
ResultKind.Image => Color.FromRgb(180, 80, 220),
|
| 20 |
+
ResultKind.Video => Color.FromRgb(220, 60, 80),
|
| 21 |
+
ResultKind.Audio => Color.FromRgb(60, 160, 240),
|
| 22 |
+
ResultKind.Archive => Color.FromRgb(200, 160, 40),
|
| 23 |
+
ResultKind.Folder => Color.FromRgb(80, 120, 220),
|
| 24 |
+
_ => Color.FromRgb(100, 100, 130)
|
| 25 |
+
};
|
| 26 |
+
return new SolidColorBrush(color);
|
| 27 |
+
}
|
| 28 |
+
return Brushes.Gray;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
| 32 |
+
=> throw new NotImplementedException();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
public class ColorToBrushConverter : IValueConverter
|
| 36 |
+
{
|
| 37 |
+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
| 38 |
+
{
|
| 39 |
+
if (value is Color c)
|
| 40 |
+
return new SolidColorBrush(c);
|
| 41 |
+
return Brushes.Gray;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
| 45 |
+
=> throw new NotImplementedException();
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
public class PathShortenerConverter : IValueConverter
|
| 49 |
+
{
|
| 50 |
+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
| 51 |
+
{
|
| 52 |
+
if (value is string path && path.Length > 75)
|
| 53 |
+
return "\u2026" + path[(path.Length - 73)..];
|
| 54 |
+
return value ?? "";
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
| 58 |
+
=> throw new NotImplementedException();
|
| 59 |
+
}
|