Contains() public method

public Contains ( Control ctl ) : bool
ctl Control
return bool
Ejemplo n.º 1
0
        internal void ChildControlRemoved(Control control)
        {
            ContainerControl top_container = FindForm();

            if (top_container == null)
            {
                top_container = this;
            }

            // Remove controls -as well as any sub control- that was in the pending validation chain
            ArrayList pending_validation_chain = top_container.pending_validation_chain;

            if (pending_validation_chain != null)
            {
                RemoveChildrenFromValidation(pending_validation_chain, control);

                if (pending_validation_chain.Count == 0)
                {
                    top_container.pending_validation_chain = null;
                }
            }

            if (control == active_control || control.Contains(active_control))
            {
                SelectNextControl(this, true, true, true, true);
                if (control == active_control || control.Contains(active_control))
                {
                    active_control = null;
                }
            }
        }
Ejemplo n.º 2
0
        /// <devdoc>
        ///     Cleans up form state after a control has been removed.
        ///     Package scope for Control
        /// </devdoc>
        /// <internalonly/>
        internal virtual void AfterControlRemoved(Control control)
        {
            if (control == activeControl || control.Contains(activeControl))
            {
                // REGISB: this branch never seems to be reached.
                //         leaving it intact to be on the safe side
                bool selected = SelectNextControl(control, true, true, true, true);
                if (selected)
                {
                    FocusActiveControlInternal();
                }
            }
            else if (activeControl == null && ParentInternal != null)
            {
                // The last control of an active container was removed. Focus needs to be given to the next
                // control in the Form.
                ContainerControl cc = ParentInternal.GetContainerControlInternal() as ContainerControl;
                if (cc != null && cc.ActiveControl == this)
                {
                    Form f = FindFormInternal();
                    if (f != null)
                    {
                        f.SelectNextControl(this, true, true, true, true);
                    }
                }
            }

            if (control == unvalidatedControl || control.Contains(unvalidatedControl))
            {
                unvalidatedControl = null;
            }
        }
Ejemplo n.º 3
0
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            Control c = e.Control;

            if (c == activeControl || c.Contains(activeControl))
            {
                SetActiveControlInternal(null);
            }
            if (c == unvalidatedControl || c.Contains(unvalidatedControl))
            {
                unvalidatedControl = null;
            }

            base.OnControlRemoved(e);
        }
Ejemplo n.º 4
0
        protected override void OnControlRemoved(ControlEventArgs e)
        {
            Control control = e.Control;

            // Make sure the unvalidated control and active control are cleaned up.
            if (control == unvalidatedControl || control.Contains(unvalidatedControl))
            {
                unvalidatedControl = null;
            }
            if (control == activeControl || control.Contains(activeControl))
            {
                ActiveControl = null;
            }
            base.OnControlRemoved(e);
        }
Ejemplo n.º 5
0
 public static void displayFormOnPanel(Control.ControlCollection control, Form newForm)
 {
     bool isExist = control.Contains(newForm);
     if (isExist == false)
     {
         newForm.TopLevel = false;    //设置为非顶级窗体
         newForm.FormBorderStyle = FormBorderStyle.None;       //设置窗体为非边框样式
         newForm.Dock = System.Windows.Forms.DockStyle.Fill;   //设置样式是否填充整个PANEL
         control.Add(newForm);      //添加窗体
         newForm.Show();
     }
     newForm.BringToFront();
 }
Ejemplo n.º 6
0
        // Brubbel
        internal virtual void AfterControlRemoved(Control control)
        {
            // Select next control, if control was active and removed.
            if (control == activeControl || control.Contains(activeControl))
            {
                if (base.SelectNextControl(control, true, true, true, true))
                {
                    this.SetFocus(activeControl);
                }
                else
                {
                    this.SetActiveControl(null);
                }
            }
            else if ((this.activeControl == null) && (this.Parent != null))
            {
                ContainerControl container = Parent.GetContainerControl() as ContainerControl;
                if (null != container && container.ActiveControl == this)
                {
                    Form form = base.FindForm();
                    if (null != form)
                    {
                        form.SelectNextControl(this, true, true, true, true);
                    }
                }
            }
            else
            {
            }

            // Make sure the unvalidated control and active control are cleaned up.
            if (control == unvalidatedControl || control.Contains(unvalidatedControl))
            {
                unvalidatedControl = null;
            }
        }
Ejemplo n.º 7
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateControl ()
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			Control c = new Control ();
			
			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			c.Contains (new Control ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			c.CreateControl ();
			Assert.IsTrue (c.IsHandleCreated, "A3");
			c = new Control ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c = new Control ();
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Control ();
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.GetContainerControl ();
			c = new Control ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c = new Control ();
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c = new Control ();
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c = new Control ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c = new Control ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
			c.Select ();
			Assert.IsFalse (c.IsHandleCreated, "A34");
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
		}
Ejemplo n.º 8
0
		internal void ChildControlRemoved (Control control)
		{
			ContainerControl top_container = FindForm ();
			if (top_container == null)
				top_container = this;

			// Remove controls -as well as any sub control- that was in the pending validation chain
			ArrayList pending_validation_chain = top_container.pending_validation_chain;
			if (pending_validation_chain != null) {
				RemoveChildrenFromValidation (pending_validation_chain, control);

				if (pending_validation_chain.Count == 0)
					top_container.pending_validation_chain = null;
			}

			if (control == active_control || control.Contains (active_control)) {
				SelectNextControl (this, true, true, true, true);
				if (control == active_control || control.Contains (active_control)) {
					active_control = null;
				}
			}
		}
 public virtual bool CanParent(Control control)
 {
     return !control.Contains(this.Control);
 }
	// Brubbel
	internal virtual void AfterControlRemoved(Control control)
	{
		// Select next control, if control was active and removed.
		if (control == activeControl || control.Contains(activeControl))
		{
			if( base.SelectNextControl( control, true, true, true, true ) ) {
				this.SetFocus( activeControl );
			}
			else {
				this.SetActiveControl( null );
			}
		}
		else if( (this.activeControl == null) && (this.Parent != null) ) {
			ContainerControl container = Parent.GetContainerControl() as ContainerControl;
			if( null != container && container.ActiveControl == this ) {
				Form form = base.FindForm();
				if( null != form ) {
					form.SelectNextControl( this, true, true, true, true );
				}
				
			}
		}
		else {
		}
		
		// Make sure the unvalidated control and active control are cleaned up.
		if (control == unvalidatedControl || control.Contains(unvalidatedControl))
		{
			unvalidatedControl = null;
		}
	}
Ejemplo n.º 11
0
 public static object CallControlContains(Control c, object[] obj)
 {
     return(c.Contains((Control)(obj[0])));
 }
Ejemplo n.º 12
0
        static void AddtoPanel(Control pControlToAdd, Control pContainerControl)
        {

            if (!pContainerControl.Contains(pControlToAdd))
            {
                pContainerControl.Controls.Add(pControlToAdd);
                pControlToAdd.Dock = DockStyle.Fill;
                //pContainerControl.Controls.Clear();

            }
            pControlToAdd.Dock = DockStyle.Fill;
            pControlToAdd.BringToFront();
        }
Ejemplo n.º 13
0
		public override bool CanParent(Control control)
		{
			if(control.Contains(this.Control))
				return false;
			if(this.IsDockableWindow && !(control is PanelDockContainer))
				return false;
			return base.CanParent(control);
		}
Ejemplo n.º 14
0
		// If the control is not already parented return true
		//
		public virtual bool CanParent (Control control)
		{
			if (control != null)
				return !control.Contains (this.Control);

			return false;
		}
Ejemplo n.º 15
0
		public void RelationTest() {
			Control c1;
			Control c2;

			c1 = new Control();
			c2 = new Control();

			Assert.AreEqual(true , c1.Visible , "Rel1");
			Assert.AreEqual(false, c1.Contains(c2) , "Rel2");
			Assert.AreEqual("System.Windows.Forms.Control", c1.ToString() , "Rel3");

			c1.Controls.Add(c2);
			Assert.AreEqual(true , c2.Visible , "Rel4");
			Assert.AreEqual(true, c1.Contains(c2) , "Rel5");

			c1.Anchor = AnchorStyles.Top;
			c1.SuspendLayout ();
			c1.Anchor = AnchorStyles.Left ;
			c1.ResumeLayout ();
			Assert.AreEqual(AnchorStyles.Left , c1.Anchor, "Rel6");

			c1.SetBounds(10, 20, 30, 40) ;
			Assert.AreEqual(new Rectangle(10, 20, 30, 40), c1.Bounds, "Rel7");

			Assert.AreEqual(c1, c2.Parent, "Rel8");
		}
        /// <devdoc>
        ///     Cleans up form state after a control has been removed.
        ///     Package scope for Control
        /// </devdoc>
        /// <internalonly/>
        internal virtual void AfterControlRemoved(Control control, Control oldParent) {
            ContainerControl cc;
            Debug.Assert(control != null);
            Debug.WriteLineIf(Control.FocusTracing.TraceVerbose, "ContainerControl::AfterControlRemoved(" + control.Name + ") - " + this.Name);
            if (control == activeControl || control.Contains(activeControl)) {
                bool selected;
                // SECREVIEW : Note that a function overriding "protected virtual void Control::Select(bool directed, bool forward)"
                //             called by SelectNextControl will be able to set the focus to any control.
                //             This is also enabled by the ModifyFocus.Assert inside Control::SelectNextIfFocused.
                IntSecurity.ModifyFocus.Assert ();
                try
                {
                    selected = SelectNextControl(control, true, true, true, true);
                }
                finally
                {
                    CodeAccessPermission.RevertAssert ();
                }
                if (selected && this.activeControl != control)
                {
                    FocusActiveControlInternal();
                }
                else
                {
                    SetActiveControlInternal(null);
                }
            }
            else if (activeControl == null && ParentInternal != null)
            {
                // The last control of an active container was removed. Focus needs to be given to the next
                // control in the Form.
                cc = ParentInternal.GetContainerControlInternal() as ContainerControl;
                if (cc != null && cc.ActiveControl == this)
                {
                    Form f = FindFormInternal();
                    if (f != null)
                    {
                        // SECREVIEW : Same comment as above.
                        IntSecurity.ModifyFocus.Assert ();
                        try
                        {
                            f.SelectNextControl(this, true, true, true, true);
                        }
                        finally
                        {
                            CodeAccessPermission.RevertAssert();
                        }
                    }
                }
            }

            // VSWhidbey#262686: Two controls in UserControls that don't take focus via UI can have bad behavior if ...
            // VSWhidbey#537131: 
            // When a control is removed from a container, not only do we need to clear the unvalidatedControl of that 
            // container potentially, but the unvalidatedControl of all its container parents, up the chain, needs to
            // now point to the old parent of the disappearing control.
            cc = this;
            while (cc != null) {
                Control parent = cc.ParentInternal;
                if (parent == null) {
                    break;
                }
                else {
                    cc = parent.GetContainerControlInternal() as ContainerControl;
                }
                if (cc != null &&
                    cc.unvalidatedControl != null &&
                    (cc.unvalidatedControl == control || control.Contains(cc.unvalidatedControl)))
                {
                    cc.unvalidatedControl = oldParent;
                }
            }

            if (control == unvalidatedControl || control.Contains(unvalidatedControl)) {
                unvalidatedControl = null;
            }
        }
Ejemplo n.º 17
0
		public void ContainsTest ()
		{
			Control t = new Control ();
			Control s = new Control ();

			t.Controls.Add (s);

			Assert.AreEqual (true, t.Contains (s), "Con1");
			Assert.AreEqual (false, s.Contains (t), "Con2");
			Assert.AreEqual (false, s.Contains (null), "Con3");
			Assert.AreEqual (false, t.Contains (new Control ()), "Con4");
		}
Ejemplo n.º 18
0
		public static object CallControlContains(Control c, object[] obj)
		{
			return c.Contains((Control)(obj[0]));
		}
 internal virtual void AfterControlRemoved(Control control, Control oldParent)
 {
     ContainerControl containerControlInternal;
     if ((control == this.activeControl) || control.Contains(this.activeControl))
     {
         bool flag;
         System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
         try
         {
             flag = base.SelectNextControl(control, true, true, true, true);
         }
         finally
         {
             CodeAccessPermission.RevertAssert();
         }
         if (flag)
         {
             this.FocusActiveControlInternal();
         }
         else
         {
             this.SetActiveControlInternal(null);
         }
     }
     else if ((this.activeControl == null) && (this.ParentInternal != null))
     {
         containerControlInternal = this.ParentInternal.GetContainerControlInternal() as ContainerControl;
         if ((containerControlInternal != null) && (containerControlInternal.ActiveControl == this))
         {
             Form form = base.FindFormInternal();
             if (form != null)
             {
                 System.Windows.Forms.IntSecurity.ModifyFocus.Assert();
                 try
                 {
                     form.SelectNextControl(this, true, true, true, true);
                 }
                 finally
                 {
                     CodeAccessPermission.RevertAssert();
                 }
             }
         }
     }
     containerControlInternal = this;
     while (containerControlInternal != null)
     {
         Control parentInternal = containerControlInternal.ParentInternal;
         if (parentInternal == null)
         {
             break;
         }
         containerControlInternal = parentInternal.GetContainerControlInternal() as ContainerControl;
         if (((containerControlInternal != null) && (containerControlInternal.unvalidatedControl != null)) && ((containerControlInternal.unvalidatedControl == control) || control.Contains(containerControlInternal.unvalidatedControl)))
         {
             containerControlInternal.unvalidatedControl = oldParent;
         }
     }
     if ((control == this.unvalidatedControl) || control.Contains(this.unvalidatedControl))
     {
         this.unvalidatedControl = null;
     }
 }