终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Style3ArcConverter.cs 1.6 KiB

2 年之前
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.CustomResource.UserControls
  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. }