25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

  1. using System;
  2. using System.Globalization;
  3. using System.Windows.Data;
  4. namespace BPA.UIControl.Converters
  5. {
  6. /// <summary>
  7. /// 是否为大弧形
  8. /// </summary>
  9. public class IsLargeArcConverter : IMultiValueConverter
  10. {
  11. /// <inheritdoc/>
  12. public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. if (values.Length < 3)
  15. {
  16. throw new ArgumentException("参数少于 3 个");
  17. }
  18. double value = System.Convert.ToDouble(values[0]);
  19. double min = System.Convert.ToDouble(values[1]);
  20. double max = System.Convert.ToDouble(values[2]);
  21. double percent = value / (max - min) > 1 ? 1 : value / (max - min);
  22. double angle = percent * 360;
  23. return angle > 180;
  24. }
  25. /// <inheritdoc/>
  26. public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
  27. {
  28. return null;
  29. }
  30. }
  31. }