コード例 #1
0
        public static T FindGridElement <T>(DependencyObject obj, bool failIfNothingFound = true) where T : DependencyObject
        {
            ObjectChecker <T> checker = new ObjectChecker <T>();

            DObjectChecker.CheckSubTree(obj, checker, failIfNothingFound);
            return((T)checker.Element);
        }
コード例 #2
0
        public static void CheckSubTree(DependencyObject dObject, DObjectChecker checker, bool failIfNothingFound)
        {
            VisualTreeEnumerator visualTreeEnumerator = new VisualTreeEnumerator(dObject);
            DependencyObjectCheckerEnumerator dObjectCheckerEnumerator = new DependencyObjectCheckerEnumerator(checker);

            dObjectCheckerEnumerator.MoveNext();
            while (visualTreeEnumerator.MoveNext())
            {
                if (dObjectCheckerEnumerator.Current.CheckElement(visualTreeEnumerator.Current, visualTreeEnumerator.Level))
                {
                    DObjectChecker parent = (DObjectChecker)dObjectCheckerEnumerator.CurrentParent;
                    if (parent != null)
                    {
                        Assert.IsTrue(IsParent(dObjectCheckerEnumerator.Current.Element, parent.Element));
                    }
                    if (!dObjectCheckerEnumerator.MoveNext())
                    {
                        checker.CheckLevels();
                        return;
                    }
                }
            }
            if (failIfNothingFound)
            {
                Assert.Fail("Element not found: " + dObjectCheckerEnumerator.Current);
            }
        }
コード例 #3
0
 public static void CheckNoSubTree(DependencyObject dObject, DObjectChecker checker)
 {
     try {
         CheckSubTree(dObject, checker);
     } catch {
         return;
     }
     Assert.Fail();
 }
コード例 #4
0
        public static T FindGridElement <T>(DependencyObject obj, DependencyProperty property, object value,
                                            bool exactType = false, bool onlyVisibleChildren = false, bool failIfNothingFound = true)
            where T : DependencyObject
        {
            ObjectChecker <T> checker
                = new ObjectChecker <T>(new DPropertyInfo(property, value), exactType, onlyVisibleChildren);

            DObjectChecker.CheckSubTree(obj, checker, failIfNothingFound);
            return((T)checker.Element);
        }
コード例 #5
0
 public static void CheckSubTree(DependencyObject dObject, DObjectChecker checker)
 {
     CheckSubTree(dObject, checker, true);
 }
コード例 #6
0
 public DependencyObjectCheckerEnumerator(DObjectChecker checker)
     : base(checker)
 {
 }
コード例 #7
0
 public DObjectChecker(Type dObjectType, DObjectChecker child)
     : this(dObjectType, new DObjectChecker[] { child })
 {
 }