예제 #1
0
        internal Control GetFocussedChild()
        {
            // Look for any child with focus and keep going until we reach the bottom
            Control focussedChild = ChildrenInternal.FirstOrDefault(c => c.IsFocussed);

            if (focussedChild != null)
            {
                return(focussedChild.GetFocussedChild());
            }

            // We didn't find it so it must be us
            return(IsFocussed ? this : null);
        }
예제 #2
0
        /// <summary>
        /// Set focus down the hierarchy to be the current control
        /// </summary>
        /// <returns>
        /// True if focus has been set, false if it failed for some reason.
        /// </returns>
        public bool Focus()
        {
            // If no change, return
            if (IsFocussed && !ChildrenInternal.Any(c => c.IsFocussed))
            {
                return(true);
            }

            bool gotFocus = Focus(this);

            IsFocussed = gotFocus;
            return(gotFocus);
        }
예제 #3
0
 private void ChildrenOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.NewItems != null)
     {
         foreach (Control child in e.NewItems)
         {
             ChildrenInternal.Add(child);
             child.Parent = this;
         }
     }
     if (e.OldItems != null)
     {
         foreach (Control child in e.OldItems)
         {
             ChildrenInternal.Remove(child);
             RemoveLayoutInformationForChild(child);
             child.Parent = this;
         }
     }
 }