Esempio n. 1
0
        /// <summary>
        /// Adds a new child control.
        /// </summary>
        /// <param name="ctrl">The child to add.</param>
        protected void AddChild(ZenControlBase ctrl)
        {
            // Make sure control is not already a child of me or someone else.
            if (zenChildren.Contains(ctrl))
            {
                if (ctrl.Parent != this)
                {
                    throw new InvalidOperationException("Control is already a child of a different parent.");
                }
                return;
            }
            // Make sure control was not a descendant of a different top-level form before.
            if (ctrl.parentForm != null && ctrl.parentForm != parentForm && parentForm != null)
            {
                throw new InvalidOperationException("Control cannot be added to the hierarchy of a different top-level form.");
            }
            // Set control's parent, add to my children
            ctrl.parent = this;
            if (parentForm != null)
            {
                ctrl.parentForm = parentForm;
            }
            zenChildren.Add(ctrl);
            // Own new control's WinForms controls.
            IEnumerable <Control> containedWinFormsControls = ctrl.GetWinFormsControlsRecursive();

            foreach (Control c in containedWinFormsControls)
            {
                AddWinFormsControl(c);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Removes a child control.
        /// </summary>
        /// <param name="ctrl">The child to remove.</param>
        protected void RemoveChild(ZenControlBase ctrl)
        {
            IEnumerable <Control> containedWinFormsControls = ctrl.GetWinFormsControlsRecursive();

            foreach (Control c in containedWinFormsControls)
            {
                RemoveWinFormsControl(c);
            }
            zenChildren.Remove(ctrl);
            ctrl.parent = null;
        }
Esempio n. 3
0
 /// <summary>
 /// Removes a child control.
 /// </summary>
 /// <param name="ctrl">The child to remove.</param>
 protected void RemoveChild(ZenControlBase ctrl)
 {
     IEnumerable<Control> containedWinFormsControls = ctrl.GetWinFormsControlsRecursive();
     foreach (Control c in containedWinFormsControls)
         RemoveWinFormsControl(c);
     zenChildren.Remove(ctrl);
     ctrl.parent = null;
 }
Esempio n. 4
0
 /// <summary>
 /// Adds a new child control.
 /// </summary>
 /// <param name="ctrl">The child to add.</param>
 protected void AddChild(ZenControlBase ctrl)
 {
     // Make sure control is not already a child of me or someone else.
     if (zenChildren.Contains(ctrl))
     {
         if (ctrl.Parent != this)
             throw new InvalidOperationException("Control is already a child of a different parent.");
         return;
     }
     // Make sure control was not a descendant of a different top-level form before.
     if (ctrl.parentForm != null && ctrl.parentForm != parentForm && parentForm != null)
         throw new InvalidOperationException("Control cannot be added to the hierarchy of a different top-level form.");
     // Set control's parent, add to my children
     ctrl.parent = this;
     if (parentForm != null) ctrl.parentForm = parentForm;
     zenChildren.Add(ctrl);
     // Own new control's WinForms controls.
     IEnumerable<Control> containedWinFormsControls = ctrl.GetWinFormsControlsRecursive();
     foreach (Control c in containedWinFormsControls)
         AddWinFormsControl(c);
 }