ValueExtension.cs 853 B

12345678910111213141516171819202122
  1. using System.Windows;
  2. using HandyControl.Expression.Drawing;
  3. namespace HandyControl.Tools.Extension;
  4. public static class ValueExtension
  5. {
  6. public static Thickness Add(this Thickness a, Thickness b) => new(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom);
  7. public static bool IsZero(this Thickness thickness) =>
  8. MathHelper.IsZero(thickness.Left)
  9. && MathHelper.IsZero(thickness.Top)
  10. && MathHelper.IsZero(thickness.Right)
  11. && MathHelper.IsZero(thickness.Bottom);
  12. public static bool IsUniform(this Thickness thickness) =>
  13. MathHelper.AreClose(thickness.Left, thickness.Top)
  14. && MathHelper.AreClose(thickness.Left, thickness.Right)
  15. && MathHelper.AreClose(thickness.Left, thickness.Bottom);
  16. public static bool IsNaN(this double value) => double.IsNaN(value);
  17. }