2025-05-30 15:42:59 +08:00
|
|
|
|
using System.Windows.Data;
|
2025-05-28 23:19:00 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Serein.Workbench.Converters
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 画布拉动范围距离计算器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class RightThumbPositionConverter : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is double width)
|
|
|
|
|
|
return width - 10; // Adjust for Thumb width
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 画布拉动范围距离计算器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class BottomThumbPositionConverter : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is double height)
|
|
|
|
|
|
return height - 10; // Adjust for Thumb height
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 画布拉动范围距离计算器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class VerticalCenterThumbPositionConverter : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is double height)
|
|
|
|
|
|
return height / 2 - 5; // Centering Thumb vertically
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 画布拉动范围距离计算器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class HorizontalCenterThumbPositionConverter : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value is double width)
|
|
|
|
|
|
return width / 2 - 5; // Centering Thumb horizontally
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|