Synchronize the Net40
This commit is contained in:
1 parent
b3c3173c46
commit
ab6e2efe21
87 files changed
+2743
-349
No files matched your search
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
public static class EnumerableExtension
|
||||
{
|
||||
public static IEnumerable<TSource> Do<TSource>(this IEnumerable<TSource> source, Action<TSource> predicate)
|
||||
{
|
||||
var enumerable = source as IList<TSource> ?? source.ToList();
|
||||
foreach (var item in enumerable)
|
||||
{
|
||||
predicate.Invoke(item);
|
||||
}
|
||||
|
||||
return enumerable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,41 @@
|
||||
/// <summary>
|
||||
/// 验证帮助类
|
||||
/// </summary>
|
||||
internal class ValidateHelper
|
||||
public class ValidateHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否在浮点数范围内
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
internal static bool IsInRangeOfDouble(object value)
|
||||
public static bool IsInRangeOfDouble(object value)
|
||||
{
|
||||
var v = (double)value;
|
||||
return !(double.IsNaN(v) || double.IsInfinity(v));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在正浮点数范围内
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="includeZero"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInRangeOfPosDouble(object value, bool includeZero = false)
|
||||
{
|
||||
var v = (double)value;
|
||||
return !(double.IsNaN(v) || double.IsInfinity(v)) && (includeZero ? v >= 0 : v > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在正浮点数范围内
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="includeZero"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsInRangeOfNegDouble(object value, bool includeZero = false)
|
||||
{
|
||||
var v = (double)value;
|
||||
return !(double.IsNaN(v) || double.IsInfinity(v)) && (includeZero ? v <= 0 : v < 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ using System.Windows.Media;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
internal class VisualHelper
|
||||
public class VisualHelper
|
||||
{
|
||||
public static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName)
|
||||
internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject dependencyObject, string groupName)
|
||||
{
|
||||
var root = GetImplementationRoot(dependencyObject);
|
||||
if (root == null)
|
||||
@@ -20,11 +20,13 @@ namespace HandyControl.Tools
|
||||
.FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
|
||||
}
|
||||
|
||||
public static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject)
|
||||
internal static FrameworkElement GetImplementationRoot(DependencyObject dependencyObject)
|
||||
{
|
||||
return 1 == VisualTreeHelper.GetChildrenCount(dependencyObject)
|
||||
? VisualTreeHelper.GetChild(dependencyObject, 0) as FrameworkElement
|
||||
: null;
|
||||
}
|
||||
|
||||
public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user