Beispiel #1
0
        private void TopLevelForm_Load(object sender, EventArgs e)
        {
            Form f = sender as Form;

            Debug.Assert(f != null, "We should never wire up to anything that's not a form.");

            TabOrderManager tom = new TabOrderManager(f);

            // Add an override for everything with a tab scheme set EXCEPT for the form, which
            // serves as the root of the whole process.
            TabOrderManager.TabScheme formScheme         = TabOrderManager.TabScheme.None;
            IDictionaryEnumerator     extendeeEnumerator = extendees.GetEnumerator();

            while (extendeeEnumerator.MoveNext())
            {
                Control c = (Control)extendeeEnumerator.Key;
                TabOrderManager.TabScheme scheme = (TabOrderManager.TabScheme)extendeeEnumerator.Value;
                if (c == f)
                {
                    formScheme = scheme;
                }
                else
                {
                    tom.SetSchemeForControl(c, scheme);
                }
            }

            tom.SetTabOrder(formScheme);
        }
Beispiel #2
0
        /// <summary>
        /// Set the tab scheme to use on a given control
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public void SetTabScheme(Control c, TabOrderManager.TabScheme val)
        {
            if (val != TabOrderManager.TabScheme.None)
            {
                extendees[c] = val;

                if (topLevelForm == null)
                {
                    if (c.TopLevelControl != null)
                    {
                        // We're in luck.
                        // This is the form, or this control knows about it, so take the opportunity to grab it and wire up to its Load event.
                        topLevelForm = c.TopLevelControl as Form;
                        HookFormLoad();
                    }
                    else
                    {
                        // Set up to wait around until this control or one of its ancestors is added to the form's control hierarchy.
                        HookParentChangedEvents(c);
                    }
                }
            }
            else if (extendees.Contains(c))
            {
                extendees.Remove(c);

                // If we no longer have any extendees, we don't need to be wired up to the form load event.
                if (extendees.Count == 0)
                {
                    UnhookFormLoad();
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Create a tab scheme comparer that compares using the given scheme.
 /// </summary>
 /// <param name="scheme"></param>
 public TabSchemeComparer(TabOrderManager.TabScheme scheme)
 {
     _comparisonScheme = scheme;
 }
Beispiel #4
0
 /// <summary>
 /// Create a tab scheme comparer that compares using the given scheme.
 /// </summary>
 /// <param name="scheme"></param>
 public TabSchemeComparer(TabOrderManager.TabScheme scheme)
 {
     _comparisonScheme = scheme;
 }