public void GetNextControlComposite () { Form form = new Form (); form.ShowInTaskbar = false; ControlPoker a = new ControlPoker ("a"); ControlPoker b = new ControlPoker ("b"); ControlPoker c = new ControlPoker ("c"); form.Controls.Add (a); form.Controls.Add (b); b.Controls.Add (c); form.Show (); Assert.AreEqual (form.GetNextControl (a, true), b, "form-1"); Assert.AreEqual (form.GetNextControl (a, false), null, "form-2"); form.Dispose (); }
public void TestPublicMethods () { // Public Methods that force Handle creation: // - CreateGraphics () // - GetChildAtPoint () // - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created // - PointToClient () // - PointToScreen () // - RectangleToClient () // - RectangleToScreen () // - Select () // - Show (IWin32Window) // Notes: // - CreateControl does NOT force Handle creation! Form c = new Form (); c.BringToFront (); Assert.IsFalse (c.IsHandleCreated, "A1"); c.Contains (new Form ()); Assert.IsFalse (c.IsHandleCreated, "A2"); c.CreateControl (); Assert.IsFalse (c.IsHandleCreated, "A3"); c = new Form (); Graphics g = c.CreateGraphics (); g.Dispose (); Assert.IsTrue (c.IsHandleCreated, "A4"); c.Dispose (); c = new Form (); c.Dispose (); Assert.IsFalse (c.IsHandleCreated, "A5"); c = new Form (); // This is weird, it causes a form to appear that won't go away until you move the mouse over it, // but it doesn't create a handle?? //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.Dispose (); c = new Form (); c.GetContainerControl (); Assert.IsFalse (c.IsHandleCreated, "A11"); c.Dispose (); c = new Form (); c.GetNextControl (new Control (), true); Assert.IsFalse (c.IsHandleCreated, "A12"); c.GetPreferredSize (Size.Empty); Assert.IsFalse (c.IsHandleCreated, "A13"); 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.Dispose (); c = new Form (); c.PointToScreen (new Point (100, 100)); Assert.IsTrue (c.IsHandleCreated, "A19"); c.Dispose (); c = new Form (); //c.PreProcessControlMessage ??? //c.PreProcessMessage ??? c.RectangleToClient (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A20"); c.Dispose (); c = new Form (); c.RectangleToScreen (new Rectangle (0, 0, 100, 100)); Assert.IsTrue (c.IsHandleCreated, "A21"); c.Dispose (); c = new Form (); 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"); c.Scale (new SizeF (1.5f, 1.5f)); Assert.IsFalse (c.IsHandleCreated, "A33"); c.Select (); Assert.IsTrue (c.IsHandleCreated, "A34"); c.Dispose (); c = new Form (); 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"); // Form c.Activate (); Assert.IsFalse (c.IsHandleCreated, "F1"); c.AddOwnedForm (new Form ()); Assert.IsFalse (c.IsHandleCreated, "F2"); c.Close (); Assert.IsFalse (c.IsHandleCreated, "F3"); c.Hide (); Assert.IsFalse (c.IsHandleCreated, "F4"); c.LayoutMdi (MdiLayout.Cascade); Assert.IsFalse (c.IsHandleCreated, "F5"); #if !MONO c.PerformAutoScale (); Assert.IsFalse (c.IsHandleCreated, "F6"); #endif c.PerformLayout (); Assert.IsFalse (c.IsHandleCreated, "F7"); c.AddOwnedForm (new Form ()); c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]); Assert.IsFalse (c.IsHandleCreated, "F8"); c.ScrollControlIntoView (null); Assert.IsFalse (c.IsHandleCreated, "F9"); c.SetAutoScrollMargin (7, 13); Assert.IsFalse (c.IsHandleCreated, "F10"); c.SetDesktopBounds (-1, -1, 144, 169); Assert.IsFalse (c.IsHandleCreated, "F11"); c.SetDesktopLocation (7, 13); Assert.IsFalse (c.IsHandleCreated, "F12"); c = new Form (); c.Show (null); Assert.IsTrue (c.IsHandleCreated, "F13"); c.Close (); c = new Form (); //c.ShowDialog () c.ToString (); Assert.IsFalse (c.IsHandleCreated, "F14"); c.Validate (); Assert.IsFalse (c.IsHandleCreated, "F15"); #if !MONO c.ValidateChildren (); Assert.IsFalse (c.IsHandleCreated, "F16"); #endif c.Close (); }
public void GetNextControlFromTabControl2 () { Form form = new Form (); form.ShowInTaskbar = false; TabControl tab = new TabControl (); TabPage page1 = new TabPage ("page one"); page1.Controls.AddRange (flat_controls); TabPage page2 = new TabPage ("page two"); tab.TabPages.Add (page1); tab.TabPages.Add (page2); form.Controls.Add (tab); form.Show (); Assert.AreEqual (form.GetNextControl (null, true), tab, "form-1"); Assert.AreEqual (form.GetNextControl (null, false), page2, "form-2"); Assert.AreEqual (form.GetNextControl (tab, true), page1, "tab-1"); Assert.AreEqual (form.GetNextControl (tab, false), null, "tab-2"); Assert.AreEqual (form.GetNextControl (page1, true), flat_controls [0], "page-one-1"); Assert.AreEqual (form.GetNextControl (page1, false), tab, "page-one-2"); Assert.AreEqual (form.GetNextControl (page2, true), null, "page-two-1"); Assert.AreEqual (form.GetNextControl (page2, false), flat_controls [2], "page-two-2"); Assert.AreEqual (form.GetNextControl (flat_controls [0], false), page1, "form-ctrls-0-backward"); Assert.AreEqual (form.GetNextControl (flat_controls [2], true), page2, "form-ctrls-2-forward"); Assert.AreEqual (tab.GetNextControl (null, true), page1, "tab-null-forward"); Assert.AreEqual (tab.GetNextControl (page1, false), null, "tab-page1-backward"); Assert.AreEqual (tab.GetNextControl (flat_controls [0], false), page1, "tab-ctrls-0-backward"); Assert.AreEqual (tab.GetNextControl (flat_controls [2], true), page2, "tab-ctrls-2-forward"); Assert.AreEqual (page1.GetNextControl (flat_controls [0], true), flat_controls [1], "page1-ctrls-0-forward"); Assert.AreEqual (page1.GetNextControl (flat_controls [0], false), null, "page1-ctrls-0-backward"); Assert.AreEqual (page1.GetNextControl (flat_controls [1], true), flat_controls [2], "page1-ctrls-1-forward"); Assert.AreEqual (page1.GetNextControl (flat_controls [1], false), flat_controls [0], "page1-ctrls-1-backward"); Assert.AreEqual (page1.GetNextControl (flat_controls [2], true), null, "page1-ctrls-2-forward"); Assert.AreEqual (page1.GetNextControl (flat_controls [2], false), flat_controls [1],"page1-ctrls-2-backward"); form.Dispose (); }
public void GetNextControlDuplicateTabIndex () { Form form = new Form (); form.ShowInTaskbar = false; ControlPoker [] ctrls = new ControlPoker [5]; for (int i = 0; i < 5; i++) { ctrls [i] = new ControlPoker (); ctrls [i].TabIndex = i; ctrls [i].Text = "ctrl " + i; } ctrls [3].TabIndex = 2; form.Controls.AddRange (ctrls); form.Show (); Assert.AreEqual (form.GetNextControl (null, true), ctrls [0], "A1"); Assert.AreEqual (form.GetNextControl (null, false), ctrls [4], "A2"); Assert.AreEqual (form.GetNextControl (ctrls [0], true), ctrls [1], "A3"); Assert.AreEqual (form.GetNextControl (ctrls [0], false), null, "A4"); Assert.AreEqual (form.GetNextControl (ctrls [1], true), ctrls [2], "A5"); Assert.AreEqual (form.GetNextControl (ctrls [1], false), ctrls [0], "A6"); Assert.AreEqual (form.GetNextControl (ctrls [2], true), ctrls [3], "A7"); Assert.AreEqual (form.GetNextControl (ctrls [2], false), ctrls [1], "A8"); Assert.AreEqual (form.GetNextControl (ctrls [3], true), ctrls [4], "A9"); Assert.AreEqual (form.GetNextControl (ctrls [3], false), ctrls [2], "A10"); Assert.AreEqual (form.GetNextControl (ctrls [4], true), null, "A11"); Assert.AreEqual (form.GetNextControl (ctrls [4], false), ctrls [3], "A12"); form.Dispose (); }
public void GetNextGroupBoxControlFlat () { Form form = new Form (); form.ShowInTaskbar = false; GroupBoxPoker gbp = new GroupBoxPoker ("group-box"); gbp.Controls.AddRange (flat_controls); form.Controls.Add (gbp); form.Show (); Assert.AreEqual (form.GetNextControl (null, true), gbp, "form-1"); Assert.AreEqual (form.GetNextControl (null, false), flat_controls [2], "form-2"); Assert.AreEqual (form.GetNextControl (gbp, true), flat_controls [0], "gb-1"); Assert.AreEqual (form.GetNextControl (gbp, false), null, "gb-2"); Assert.AreEqual (gbp.GetNextControl (null, true), flat_controls [0], "gb-3"); Assert.AreEqual (gbp.GetNextControl (null, false), flat_controls [2], "gb-4"); Assert.AreEqual (gbp.GetNextControl (gbp, true), flat_controls [0], "gb-5"); Assert.AreEqual (gbp.GetNextControl (gbp, false), flat_controls [2], "gb-6"); Assert.AreEqual (form.GetNextControl (flat_controls [0], true), flat_controls [1], "form-ctrls-0-forward"); Assert.AreEqual (form.GetNextControl (flat_controls [0], false), gbp, "form-ctrls-0-backward"); Assert.AreEqual (form.GetNextControl (flat_controls [1], true), flat_controls [2], "form-ctrls-1-forward"); Assert.AreEqual (form.GetNextControl (flat_controls [1], false), flat_controls [0], "form-ctrls-1-backward"); Assert.AreEqual (form.GetNextControl (flat_controls [2], true), null, "form-ctrls-2-forward"); Assert.AreEqual (form.GetNextControl (flat_controls [2], false), flat_controls [1],"form-ctrls-2-backward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [0], true), flat_controls [1], "gbp-ctrls-0-forward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [0], false), null, "gbp-ctrls-0-backward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [1], true), flat_controls [2], "gbp-ctrls-1-forward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [1], false), flat_controls [0], "gbp-ctrls-1-backward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [2], true), null, "gbp-ctrls-2-forward"); Assert.AreEqual (gbp.GetNextControl (flat_controls [2], false), flat_controls [1],"gbp-ctrls-2-backward"); form.Dispose (); }
public void GetNextControlFromTabControl () { Form form = new Form (); form.ShowInTaskbar = false; TabControl tab = new TabControl (); TabPage page1 = new TabPage ("page one"); TabPage page2 = new TabPage ("page two"); tab.TabPages.Add (page1); tab.TabPages.Add (page2); form.Controls.Add (tab); form.Show (); Assert.AreEqual (form.GetNextControl (null, true), tab, "form-1"); Assert.AreEqual (form.GetNextControl (null, false), page2, "form-2"); Assert.AreEqual (form.GetNextControl (tab, true), page1, "tab-1"); Assert.AreEqual (form.GetNextControl (tab, false), null, "tab-2"); Assert.AreEqual (form.GetNextControl (page1, true), page2, "page-one-1"); Assert.AreEqual (form.GetNextControl (page1, false), tab, "page-one-2"); Assert.AreEqual (form.GetNextControl (page2, true), null, "page-two-1"); Assert.AreEqual (form.GetNextControl (page2, false), page1, "page-two-2"); form.Dispose (); }
public void GetNextControlFlat () { Form form = new Form (); form.ShowInTaskbar = false; form.Controls.AddRange (flat_controls); form.Show (); Assert.AreEqual (form.GetNextControl (null, true), flat_controls [0], "form-1"); Assert.AreEqual (form.GetNextControl (null, false), flat_controls [2], "form-2"); Assert.AreEqual (form.GetNextControl (flat_controls [0], true), flat_controls [1], "form-3"); Assert.AreEqual (form.GetNextControl (flat_controls [0], false), null, "form-4"); Assert.AreEqual (form.GetNextControl (flat_controls [1], true), flat_controls [2], "form-5"); Assert.AreEqual (form.GetNextControl (flat_controls [1], false), flat_controls [0], "form-6"); Assert.AreEqual (form.GetNextControl (flat_controls [2], true), null, "form-7"); Assert.AreEqual (form.GetNextControl (flat_controls [2], false), flat_controls [1],"form-8"); Assert.AreEqual (flat_controls [0].GetNextControl (null, true), null, "ctrls-0-1"); Assert.AreEqual (flat_controls [0].GetNextControl (null, false), null, "ctrls-0-2"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [0], true), null, "ctrls-0-3"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [0], false), null, "ctrls-0-4"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [1], true), null, "ctrls-0-5"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [1], false), null, "ctrls-0-6"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [2], true), null, "ctrls-0-7"); Assert.AreEqual (flat_controls [0].GetNextControl (flat_controls [2], false), null,"ctrls-0-8"); form.Dispose (); }
public void GetNextControl2FromForm () { Form form = new Form (); form.ShowInTaskbar = false; ContainerPoker con_a = new ContainerPoker ("container-a"); ContainerPoker con_b = new ContainerPoker ("container-b"); ContainerPoker con_c = new ContainerPoker ("container-c"); TestHelper.RemoveWarning (con_b, con_c); ControlPoker [] ctrls_a = new ControlPoker [] { new ControlPoker ("ctrls-a-0"), new ControlPoker ("ctrls-a-1"), new ControlPoker ("ctrls-a-2") }; ControlPoker ctrl_b = new ControlPoker ("ctrl-b"); con_a.Controls.AddRange (ctrls_a); form.Controls.Add (con_a); form.Controls.Add (ctrl_b); form.Show (); // top level movement, Assert.AreEqual (form.GetNextControl (null, true), con_a, "null-1"); Assert.AreEqual (form.GetNextControl (null, false), ctrl_b, "null-2"); Assert.AreEqual (form.GetNextControl (form, true), con_a, "form-1"); Assert.AreEqual (form.GetNextControl (form, false), ctrl_b, "form-2"); Assert.AreEqual (form.GetNextControl (con_a, true), ctrl_b, "con-a-1"); Assert.AreEqual (form.GetNextControl (con_a, false), null, "con-a-2"); Assert.AreEqual (form.GetNextControl (ctrl_b, true), null, "ctrl-b-1"); Assert.AreEqual (form.GetNextControl (ctrl_b, false), con_a, "ctrl-b-2"); Assert.AreEqual (form.GetNextControl (ctrls_a [0], true), ctrls_a [1], "ctrl-a-1"); Assert.AreEqual (form.GetNextControl (ctrls_a [0], false), con_a, "ctrl-a-2"); Assert.AreEqual (form.GetNextControl (ctrls_a [1], true), ctrls_a [2], "ctrl-a-1"); Assert.AreEqual (form.GetNextControl (ctrls_a [1], false), ctrls_a [0], "ctrl-a-2"); Assert.AreEqual (form.GetNextControl (ctrls_a [2], true), ctrl_b, "ctrl-a-1"); Assert.AreEqual (form.GetNextControl (ctrls_a [2], false), ctrls_a [1], "ctrl-a-2"); form.Dispose(); }
public void GetNextControlFromForm () { Form form = new Form (); form.ShowInTaskbar = false; ContainerPoker con_a = new ContainerPoker ("container-a"); ContainerPoker con_b = new ContainerPoker ("container-b"); ContainerPoker con_c = new ContainerPoker ("container-c"); ControlPoker [] ctrls_a = new ControlPoker [] { new ControlPoker (), new ControlPoker (), new ControlPoker () }; ControlPoker [] ctrls_b = new ControlPoker [] { new ControlPoker (), new ControlPoker (), new ControlPoker () }; ControlPoker [] ctrls_c = new ControlPoker [] { new ControlPoker (), new ControlPoker (), new ControlPoker () }; con_a.Controls.AddRange (ctrls_a); con_b.Controls.AddRange (ctrls_b); con_c.Controls.AddRange (ctrls_c); form.Controls.Add (con_a); form.Controls.Add (con_b); form.Controls.Add (con_c); form.Show (); // top level movement, Assert.AreEqual (form.GetNextControl (null, true), con_a, "null-1"); Assert.AreEqual (form.GetNextControl (null, false), con_c, "null-2"); Assert.AreEqual (form.GetNextControl (form, true), con_a, "form-1"); Assert.AreEqual (form.GetNextControl (form, false), con_c, "form-2"); Assert.AreEqual (form.GetNextControl (con_a, true), con_b, "container-1"); Assert.AreEqual (form.GetNextControl (con_a, false), null, "container-2"); Assert.AreEqual (form.GetNextControl (con_b, true), con_c, "container-3"); Assert.AreEqual (form.GetNextControl (con_b, false), con_a, "container-4"); Assert.AreEqual (form.GetNextControl (con_c, true), null, "container-5"); Assert.AreEqual (form.GetNextControl (con_c, false), con_b, "container-6"); Assert.AreEqual (form.GetNextControl (ctrls_a [0], true), ctrls_a [1], "ctrls-a-1"); Assert.AreEqual (form.GetNextControl (ctrls_a [0], false), con_a, "ctrls-a-2"); Assert.AreEqual (form.GetNextControl (ctrls_a [1], true), ctrls_a [2], "ctrls-a-3"); Assert.AreEqual (form.GetNextControl (ctrls_a [1], false), ctrls_a [0], "ctrls-a-4"); Assert.AreEqual (form.GetNextControl (ctrls_a [2], true), con_b, "ctrls-a-5"); Assert.AreEqual (form.GetNextControl (ctrls_a [2], false), ctrls_a [1], "ctrls-a-6"); Assert.AreEqual (form.GetNextControl (ctrls_b [0], true), ctrls_b [1], "ctrls-b-1"); Assert.AreEqual (form.GetNextControl (ctrls_b [0], false), con_b, "ctrls-b-2"); Assert.AreEqual (form.GetNextControl (ctrls_b [1], true), ctrls_b [2], "ctrls-b-3"); Assert.AreEqual (form.GetNextControl (ctrls_b [1], false), ctrls_b [0], "ctrls-b-4"); Assert.AreEqual (form.GetNextControl (ctrls_b [2], true), con_c, "ctrls-b-5"); Assert.AreEqual (form.GetNextControl (ctrls_b [2], false), ctrls_b [1], "ctrls-b-6"); Assert.AreEqual (form.GetNextControl (ctrls_c [0], true), ctrls_c [1], "ctrls-c-1"); Assert.AreEqual (form.GetNextControl (ctrls_c [0], false), con_c, "ctrls-c-2"); Assert.AreEqual (form.GetNextControl (ctrls_c [1], true), ctrls_c [2], "ctrls-c-3"); Assert.AreEqual (form.GetNextControl (ctrls_c [1], false), ctrls_c [0], "ctrls-c-4"); Assert.AreEqual (form.GetNextControl (ctrls_c [2], true), null, "ctrls-c-5"); Assert.AreEqual (form.GetNextControl (ctrls_c [2], false), ctrls_c [1], "ctrls-c-6"); form.Dispose (); }
public static void GetValue(Form form) { Control ctrl = null; while ((ctrl = form.GetNextControl(ctrl, true)) != null) Settings.GetValue(ctrl); }
public static void SetValue(Form form) { Control ctl = null; while ((ctl = form.GetNextControl(ctl, true)) != null) { SetValue(ctl); } }