Move more input checker methods to AdminWindow
This commit is contained in:
@ -7,7 +7,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Elwig.Helpers {
|
||||
public static class Utils {
|
||||
@ -46,22 +45,36 @@ namespace Elwig.Helpers {
|
||||
return toggleButton?.Template.FindName("templateRoot", toggleButton) as Border;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> FindVisualChilds<T>(DependencyObject depObj) where T : DependencyObject {
|
||||
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj) where T : DependencyObject {
|
||||
if (depObj == null)
|
||||
yield return (T)Enumerable.Empty<T>();
|
||||
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++) {
|
||||
DependencyObject ithChild = VisualTreeHelper.GetChild(depObj, i);
|
||||
if (ithChild == null)
|
||||
foreach (var child in LogicalTreeHelper.GetChildren(depObj)) {
|
||||
if (child == null) {
|
||||
continue;
|
||||
if (ithChild is T t)
|
||||
} else if (child is T t) {
|
||||
yield return t;
|
||||
foreach (T childOfChild in FindVisualChilds<T>(ithChild))
|
||||
yield return childOfChild;
|
||||
} else if (child is DependencyObject childDepOpj) {
|
||||
foreach (T childOfChild in FindAllChildren<T>(childDepOpj)) {
|
||||
yield return childOfChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<T> FindVisualChilds<T>(DependencyObject depObj, IEnumerable<DependencyObject> exempt) where T : DependencyObject {
|
||||
return FindVisualChilds<T>(depObj).Where(c => !exempt.Contains(c));
|
||||
public static IEnumerable<T> FindAllChildren<T>(DependencyObject depObj, IEnumerable<DependencyObject> exempt) where T : DependencyObject {
|
||||
return FindAllChildren<T>(depObj).Where(c => !exempt.Contains(c));
|
||||
}
|
||||
|
||||
public static T? FindNextSibling<T>(Control me) where T : DependencyObject {
|
||||
var found = false;
|
||||
foreach (var child in LogicalTreeHelper.GetChildren(me.Parent)) {
|
||||
if (found && child is T c) {
|
||||
return c;
|
||||
} else if (child == me) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int Modulo(string a, int b) {
|
||||
|
Reference in New Issue
Block a user