This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -0,0 +1,31 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace WPFDark.Controls.Converters
{
public class BoolInverseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is null)
return Binding.DoNothing;
if (value is bool b)
return b == false;
return Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is null)
return Binding.DoNothing;
if (value is bool b)
return b == false;
return Binding.DoNothing;
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace WPFDark.Controls.Converters
{
public class DoubleColorToBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is DoubleColor item))
return null!;
return Caches.GetSolidColorBrush(item.ByteColor);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Jewelry.Collections;
using WPFDark.Internals;
namespace WPFDark.Controls.Converters
{
public class IndentToMarginConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var thickness = new Thickness(0);
if (values is null)
return thickness;
if (!(values[0] is TreeViewItem item))
return thickness;
var length = 19.0;
if (values.Length == 2)
if (values[1] is double v)
length = v;
var k = length * item.GetDepth();
// ReSharper disable once CompareOfFloatsByEqualityOperator
if (k == 0)
return thickness;
if (_thicknessCache.TryGetValue(k, out var result) == false)
{
result = new Thickness(k, 0, 0, 0);
_thicknessCache.Add(k, result);
}
return result;
}
private static readonly LruCache<double, object> _thicknessCache = new LruCache<double, object>(8);
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using WPFDark.Internals;
namespace WPFDark.Controls.Converters
{
public class TreeListViewItemMarginConverter : IValueConverter
{
public double Length { get; set; }
public bool IsFirstColumn { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is TreeViewItem item))
return new Thickness(0);
var right = Length * (item.GetDepth() + 1.0);
var left = IsFirstColumn ? -6.0 : right * -1.0;
return new Thickness(left, 0, right, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}