public bool IsControlEnabled(object control)
        {
            if (IsPartOfThisState(control))
            {
                return(true);
            }

            return(!_all.Contains(control));
        }
Beispiel #2
0
        public ControlSet Execute(ControlSet superSet)
        {
            Common.AddToLog("executing combinator: " + this.Type);

            ControlSet result = new ControlSet();

            switch (this.Type)
            {
            case CombinatorType.Descendant:
                //get descendants (children in visual-tree) of all controls in superset
                foreach (DependencyObject control in superSet)
                {
                    ControlSet controlSet = XamlQuery.All(control);
                    foreach (DependencyObject c in controlSet)
                    {
                        if (!result.Contains(c))
                        {
                            result.Add(c);
                        }
                    }
                }
                break;

            case CombinatorType.Child:
                //get children of all Panel controls in superset
                foreach (DependencyObject control in superSet)
                {
                    if (control is Panel)
                    {
                        result.AddRange(from child in ((Panel)control).Children select(DependencyObject) child);
                    }
                }
                break;

            case CombinatorType.Adjacent:
                //get children of all parent Panels of all controls in superset
                //if a parent is not a Panel, then it is ignored
                foreach (DependencyObject control in superSet)
                {
                    if (control is FrameworkElement)
                    {
                        DependencyObject parent = ((FrameworkElement)control).Parent;
                        if (parent is Panel)
                        {
                            result.AddRange(from child in ((Panel)parent).Children select(DependencyObject) child);
                        }
                    }
                }

                //include original controls also in result
                result.AddRange(superSet);
                Common.AddToLog("adj-superset-added");
                break;
            }

            //remove duplicate-controls
            ControlSet uniqueControls = new ControlSet();

            foreach (DependencyObject c in result)
            {
                if (!uniqueControls.Contains(c))
                {
                    uniqueControls.Add(c);
                }
            }

            return(uniqueControls);
        }
 public bool IsControlEnabled(object control)
 {
     return(_internalSet.Contains(control));
 }
 private bool IsPartOfThisState(object control)
 {
     return(_internalSet.Contains(control));
 }
Beispiel #5
0
        public ControlSet Execute(ControlSet superSet)
        {
            Common.AddToLog("executing combinator: " + this.Type);

            ControlSet result = new ControlSet();

            switch (this.Type)
            {
                case CombinatorType.Descendant:
                    //get descendants (children in visual-tree) of all controls in superset
                    foreach (DependencyObject control in superSet)
                    {
                        ControlSet controlSet = XamlQuery.All(control);
                        foreach (DependencyObject c in controlSet)
                        {
                            if (!result.Contains(c))
                            {
                                result.Add(c);
                            }
                        }
                    }
                    break;
                case CombinatorType.Child:
                    //get children of all Panel controls in superset
                    foreach (DependencyObject control in superSet)
                    {
                        if (control is Panel)
                        {
                            foreach (var child in ((Panel)control).Children)
                            {
                                result.Add((DependencyObject)child);
                            }
                        }
                    }
                    break;
                case CombinatorType.Adjacent:
                    //get children of all parent Panels of all controls in superset
                    //if a parent is not a Panel, then it is ignored
                    foreach (DependencyObject control in superSet)
                    {
                        if (control is FrameworkElement)
                        {
                            DependencyObject parent = ((FrameworkElement)control).Parent;
                            if (parent is Panel)
                            {
                                foreach (var child in ((Panel)control).Children)
                                {
                                    result.Add((DependencyObject)child);
                                }
                            }
                        }
                    }

                    //include original controls also in result
                    result.AddRange(superSet);
                    Common.AddToLog("adj-superset-added");
                    break;
            }

            //remove duplicate-controls
            ControlSet uniqueControls = new ControlSet();
            foreach (DependencyObject c in result)
            {
                if (!uniqueControls.Contains(c))
                {
                    uniqueControls.Add(c);
                }
            }

            return (uniqueControls);
        }