终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Style3ArcConverter.cs 1.6 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Globalization;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Data;
  9. using System.Windows.Media;
  10. namespace BPASmartClient.SCADAControl.Converters
  11. {
  12. public class Style3ArcConverter :IMultiValueConverter
  13. {
  14. public object Convert(object[] values,Type targetType,object parameter,CultureInfo culture)
  15. {
  16. double value = (double)values[0];
  17. double thickness = (double)values[1];
  18. double radius = 40;
  19. double 周长 = Math.PI * (2 * radius - thickness) / thickness;
  20. double showPrecent = value / 100 * 周长;
  21. var converter = TypeDescriptor.GetConverter(typeof(DoubleCollection));
  22. return (DoubleCollection)converter.ConvertFrom($"{showPrecent} {周长}");
  23. }
  24. public object[] ConvertBack(object value,Type[] targetTypes,object parameter,CultureInfo culture)
  25. {
  26. throw new NotImplementedException();
  27. }
  28. }
  29. public class Style3DashConverter :IValueConverter
  30. {
  31. public object Convert(object value,Type targetType,object parameter,CultureInfo culture)
  32. {
  33. double v = (double)value;
  34. if (v == 0)
  35. {
  36. return PenLineCap.Flat;
  37. }
  38. else
  39. {
  40. return PenLineCap.Round;
  41. }
  42. }
  43. public object ConvertBack(object value,Type targetType,object parameter,CultureInfo culture)
  44. {
  45. throw new NotImplementedException();
  46. }
  47. }
  48. }