using System;
|
using System.Collections.Generic;
|
using System.Globalization;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Data;
|
|
namespace HMI.Core
|
{
|
public class CustomFontSizeConverter : IValueConverter
|
{
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
{
|
if (parameter == null) return 15;
|
|
string[] ps = parameter.ToString().Split(',');
|
int size = int.Parse(ps[0]);
|
int baseSize = int.Parse(ps[1]);
|
if (value is double width)
|
{
|
return CountFontSize(size, width, baseSize);
|
}
|
return 15;
|
}
|
|
public static double CountFontSize(double size, double limit, double baseSize)
|
{
|
return size * limit / baseSize;
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
{
|
throw new NotImplementedException();
|
}
|
}
|
}
|