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.

89 lines
3.0 KiB

  1. using BPA.UIControl.Commons.KnownBoxes;
  2. using System.Windows;
  3. namespace BPA.UIControl
  4. {
  5. /// <summary>
  6. /// ProgressBar 帮助类
  7. /// </summary>
  8. public static class ProgressBarHelper
  9. {
  10. /// <summary>
  11. /// 厚度
  12. /// </summary>
  13. public static readonly DependencyProperty ThicknessProperty = DependencyProperty.RegisterAttached(
  14. "Thickness", typeof(double), typeof(ProgressBarHelper));
  15. /// <summary>
  16. /// Sets the thickness.
  17. /// </summary>
  18. /// <param name="element">The element.</param>
  19. /// <param name="value">The value.</param>
  20. public static void SetThickness(DependencyObject element, double value)
  21. {
  22. element.SetValue(ThicknessProperty, value);
  23. }
  24. /// <summary>
  25. /// Gets the thickness.
  26. /// </summary>
  27. /// <param name="element">The element.</param>
  28. /// <returns>A double.</returns>
  29. public static double GetThickness(DependencyObject element)
  30. {
  31. return (double)element.GetValue(ThicknessProperty);
  32. }
  33. /// <summary>
  34. /// 是否显示百分比
  35. /// </summary>
  36. public static readonly DependencyProperty ShowPercentProperty =
  37. DependencyProperty.RegisterAttached("ShowPercent", typeof(bool), typeof(ProgressBarHelper), new PropertyMetadata(BooleanBoxes.FalseBox));
  38. /// <summary>
  39. /// Gets the show percent.
  40. /// </summary>
  41. /// <param name="obj">The obj.</param>
  42. /// <returns>A bool.</returns>
  43. public static bool GetShowPercent(DependencyObject obj)
  44. {
  45. return (bool)obj.GetValue(ShowPercentProperty);
  46. }
  47. /// <summary>
  48. /// Sets the show percent.
  49. /// </summary>
  50. /// <param name="obj">The obj.</param>
  51. /// <param name="value">If true, value.</param>
  52. public static void SetShowPercent(DependencyObject obj, bool value)
  53. {
  54. obj.SetValue(ShowPercentProperty, BooleanBoxes.Box(value));
  55. }
  56. /// <summary>
  57. /// 不确定进度值
  58. /// </summary>
  59. public static readonly DependencyProperty IndeterminateValueProperty =
  60. DependencyProperty.RegisterAttached("IndeterminateValue", typeof(double), typeof(ProgressBarHelper));
  61. /// <summary>
  62. /// Gets the indeterminate value.
  63. /// </summary>
  64. /// <param name="obj">The obj.</param>
  65. /// <returns>A double.</returns>
  66. public static double GetIndeterminateValue(DependencyObject obj)
  67. {
  68. return (double)obj.GetValue(IndeterminateValueProperty);
  69. }
  70. /// <summary>
  71. /// Sets the indeterminate value.
  72. /// </summary>
  73. /// <param name="obj">The obj.</param>
  74. /// <param name="value">The value.</param>
  75. public static void SetIndeterminateValue(DependencyObject obj, double value)
  76. {
  77. obj.SetValue(IndeterminateValueProperty, value);
  78. }
  79. }
  80. }