SetBounds() public method

public SetBounds ( int x, int y, int width, int height ) : void
x int
y int
width int
height int
return void
Esempio n. 1
0
 public static void CallControlSetBounds(Control c, object[] obj)
 {
     if (obj.Length == 4)
     {
         c.SetBounds((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3]);
     }
     if (obj.Length == 5)
     {
         c.SetBounds((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3],
                     (BoundsSpecified)obj[4]);
     }
 }
Esempio n. 2
0
 public void ResetChildrenWidth(System.Windows.Forms.Control control, int width)
 {
     control.SetBounds(0, 0, width, 0, BoundsSpecified.Width);
     System.Windows.Forms.Control.ControlCollection children = control.Controls;
     for (int i = 0; i < children.Count; i++)
     {
         ResetChildrenWidth(children[i], width - control.Margin.Left - control.Margin.Right);
     }
 }
Esempio n. 3
0
 public Fenetre(Control control)
 {
     Control = control;
     Controls.Add(control);
     control.SetBounds(0, 0, control.Width, control.Height);
     InitializeComponent();
     this.Width = control.Width + 10;
     this.Height = control.Height + 30;
 }
Esempio n. 4
0
 private void PanelResize(object sender, EventArgs e)
 {
     if (panel.Controls.Count == 0)
     {
         return;
     }
     for (var i = 0; i < panel.Controls.Count; i++)
     {
         System.Windows.Forms.Control control = panel.Controls[i];
         var controlWidth = Math.Max(MinControlWidth, (panel.Width - Spacing - 20) / 2);
         var x            = ((i % 2 == 1) ? controlWidth + Spacing : 0) + panel.DisplayRectangle.X;
         var y            = (MinControlHeight + Spacing) * (i / 2) + panel.DisplayRectangle.Y;
         control.SetBounds(x, y, controlWidth, MinControlHeight);
     }
 }
Esempio n. 5
0
        private void InitializeAndShowStep(Control wizardstep)
        {
            wizardstep.SetBounds(0, 0, pnlMain.Width, pnlMain.Height);
            HideAllSteps();
            btnNext.Text = "&Next";

            switch (wizardstep.Name)
            {
                case "pnlStep_PivotalLogin":
                    {
                        break;
                    }
                case "pnlStep_PivotalDetails":
                    {
                        PopulatePivotalIterationsCombo();
                        PopulatePivotalProjectsCombo();
                        break;
                    }
                case "pnlStep_TFSLogins":
                    {
                        break;
                    }
                case "pnlStep_TFSDetails":
                    {
                        PopulateTfsIterationsCombo(cboTFSProjects.SelectedText);
                        break;
                    }
                case "pnlStep_Summary":
                    {
                        btnNext.Text = "&Finish";
                        break;
                    }
            }
            wizardstep.Show();
        }
Esempio n. 6
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");
		}
Esempio n. 7
0
        protected virtual void CommonEditorUse(Control ctl, Rectangle rectTarget) {

            Debug.WriteLineIf(CompModSwitches.DebugGridView.TraceVerbose,  "PropertyGridView:CommonEditorUse");
            Debug.WriteLineIf(GridViewDebugPaint.TraceVerbose,  "Showing common editors");

            Debug.Assert(ctl != null, "Null control passed to CommonEditorUse");

            Rectangle rectCur = ctl.Bounds;

            // the client rect minus the border line
            Rectangle clientRect = this.ClientRectangle;

            clientRect.Inflate(-1,-1);

            try {
                rectTarget = Rectangle.Intersect(clientRect, rectTarget);
                 //if (ctl is Button)
                 //   Debug.WriteStackTrace();


                if (!rectTarget.IsEmpty) {
                    if (!rectTarget.Equals(rectCur)) {
                        ctl.SetBounds(rectTarget.X,rectTarget.Y,
                                      rectTarget.Width,rectTarget.Height);
                    }
                    ctl.Visible = true;
                }
            }
            catch {
                rectTarget = Rectangle.Empty;
            }

            if (rectTarget.IsEmpty) {

                ctl.Visible = false;
            }

            currentEditor = ctl;

        }
Esempio n. 8
0
        void GUIContainer_PageEnter(object sender, PageChangedArgs args)
        {
            m_wrapper = new WizardSettingsWrapper(m_settings);
            m_backendOptions = m_wrapper.BackendSettings;

            //We inject a marker option here so the backend can make
            // intelligent testing based on the current action
            string marker;
            switch (m_wrapper.PrimayAction)
            {
                case WizardSettingsWrapper.MainAction.Add:
                    marker = "add";
                    break;
                case WizardSettingsWrapper.MainAction.Edit:
                    marker = "edit";
                    break;
                case WizardSettingsWrapper.MainAction.Restore:
                case WizardSettingsWrapper.MainAction.RestoreSetup:
                    marker = "restore";
                    break;
                default:
                    marker = "unknown";
                    break;
            }
            m_backendOptions[ACTION_MARKER] = marker;

            m_control = m_interface.GetControl(m_wrapper.ApplicationSettings, m_backendOptions);
            m_control.SetBounds(0, 0, this.Width, this.Height);
            m_control.Visible = true;
            this.Controls.Clear();
            this.Controls.Add(m_control);
        }
Esempio n. 9
0
		public void MethodSetBounds ()
		{
			Control myControl = new Control();
			myControl.SetBounds(10, 20, 30, 40);
			myControl.SetBounds(50, 60, 70, 70, BoundsSpecified.Location);

			Assert.AreEqual (new Rectangle (50, 60, 30, 40), myControl.Bounds, "A1");
		}
Esempio n. 10
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");
		}
 protected virtual void CommonEditorUse(Control ctl, Rectangle rectTarget)
 {
     Rectangle bounds = ctl.Bounds;
     Rectangle clientRectangle = base.ClientRectangle;
     clientRectangle.Inflate(-1, -1);
     try
     {
         rectTarget = Rectangle.Intersect(clientRectangle, rectTarget);
         if (!rectTarget.IsEmpty)
         {
             if (!rectTarget.Equals(bounds))
             {
                 ctl.SetBounds(rectTarget.X, rectTarget.Y, rectTarget.Width, rectTarget.Height);
             }
             ctl.Visible = true;
         }
     }
     catch
     {
         rectTarget = Rectangle.Empty;
     }
     if (rectTarget.IsEmpty)
     {
         ctl.Visible = false;
     }
     this.currentEditor = ctl;
 }
Esempio n. 12
0
	// Perform anchoring layouting.
	//
	// Some comments about this: we save the distance to the left, right, top and bottom
	// edge on each call to SetBoundsCore (except when we disabled this by setting the
	// updateDistances bool to false, which we only do in this function).
	//
	// This function then computes the positions/sizes of a control using these distances.
	// That's easier and more reliable way than trying to keep track of size changes and
	// then applying deltas.
	//
	// When no Left or Right AnchorStyle is given we need to center horizontally, and when
	// no Top or Bottom AnchorStyle is given we need to center vertically. This centering
	// seems to work like this: first we assume that the control plus its distances form a
	// a rectangle. Then we center /this/ rectangle and add distLeft or distTop to get the
	// location of the control.
	private void PerformAnchorLayout (Control child, Rectangle rect)
			{
				int x, y, w, h;
				AnchorStyles anchor = child.Anchor;
				
				x = child.left;
				y = child.top;
				w = child.width;
				h = child.height;
			
				if ((anchor & AnchorStyles.Right) != 0)
				{
					if ((anchor & AnchorStyles.Left) != 0)
					{
						x = child.distLeft;
						w = rect.Width - x - child.distRight;
						if (w < 0)
						{
							w = 0;
						}
					}
					else
					{
						x = rect.Width - w - child.distRight;
					}
				}
				else if ((anchor & AnchorStyles.Left) != 0)
				{
					x = child.distLeft;
				}
				else
				{
					x = ((rect.Width - (w + child.distLeft + child.distRight)) / 2) + child.distLeft;
				}
				
				if ((anchor & AnchorStyles.Bottom) != 0)
				{
					if ((anchor & AnchorStyles.Top) != 0)
					{
						y = child.distTop;
						h = rect.Height - y - child.distBottom;
						if (h < 0)
						{
							h = 0;
						}
					}
					else
					{
						y = rect.Height - h - child.distBottom;
					}
				}
				else if ((anchor & AnchorStyles.Top) != 0)
				{
					y = child.distTop;
				}
				else
				{
					y = ((rect.Height - (h + child.distTop + child.distBottom)) / 2) + child.distTop;
				}
				
				child.updateDistances = false;		
				child.SetBounds (x, y, w, h);
				child.updateDistances = true;
			}
Esempio n. 13
0
 /// <summary>
 /// The backend control was entered, probably user selected a backend
 /// </summary>
 void BackendRadioButtonClicked(object sender, EventArgs e)
 {
     if (!((RadioButton)sender).Checked) return;
     // Find the checked radio button and assign the GUI from the tag
     GuiControl = ((RadioButton)sender).Tag as Library.Interface.IGUIControl;
     // Show the new user interface
     GuiInterface = GuiControl.GetControl(new Dictionary<string, string>(), Row.GuiOptions);
     GuiInterface.SetBounds(0, 0, this.UIFPanel.Width, this.UIFPanel.Height);
     GuiInterface.Visible = true;
     this.UIFPanel.Controls.Clear();
     this.UIFPanel.Controls.Add(GuiInterface);
 }
Esempio n. 14
0
        // 通过触模柄调整控件大小
        //    0  1  2
        //  7      3
        //  6  5  4
        private void handle_MouseMove(object sender, MouseEventArgs e)
        {
            int l = _MControl.Left;
            int w = _MControl.Width;
            int t = _MControl.Top;
            int h = _MControl.Height;

            if (_dragging)
            {
                switch (((Label)sender).TabIndex)
                {
                //l算法:控件左边X坐标 + 鼠标在触模柄X坐标 < 控件左边X坐标 + 父控件宽度 - 控件大小 ?控件左边X坐标 + 鼠标在触模柄X坐标 :控件左边X坐标 + 父控件宽度 - 控件大小
                //t算法:
                //w算法:
                //h算法:
                case 0:     // _dragging top-left sizing box
                    l = _startl + e.X < _startl + _startw - MIN_SIZE ? _startl + e.X : _startl + _startw - MIN_SIZE;
                    t = _startt + e.Y < _startt + _starth - MIN_SIZE ? _startt + e.Y : _startt + _starth - MIN_SIZE;
                    w = _startl + _startw - _MControl.Left;
                    h = _startt + _starth - _MControl.Top;
                    break;

                case 1:     // _dragging top-center sizing box
                    t = _startt + e.Y < _startt + _starth - MIN_SIZE ? _startt + e.Y : _startt + _starth - MIN_SIZE;
                    h = _startt + _starth - _MControl.Top;
                    break;

                case 2:     // _dragging top-right sizing box
                    w = _startw + e.X > MIN_SIZE ? _startw + e.X : MIN_SIZE;
                    t = _startt + e.Y < _startt + _starth - MIN_SIZE ? _startt + e.Y : _startt + _starth - MIN_SIZE;
                    h = _startt + _starth - _MControl.Top;
                    break;

                case 3:     // _dragging right-middle sizing box
                    w = _startw + e.X > MIN_SIZE ? _startw + e.X : MIN_SIZE;
                    break;

                case 4:     // _dragging right-bottom sizing box
                    w = _startw + e.X > MIN_SIZE ? _startw + e.X : MIN_SIZE;
                    h = _starth + e.Y > MIN_SIZE ? _starth + e.Y : MIN_SIZE;
                    break;

                case 5:     // _dragging center-bottom sizing box
                    h = _starth + e.Y > MIN_SIZE ? _starth + e.Y : MIN_SIZE;
                    break;

                case 6:     // _dragging left-bottom sizing box
                    l = _startl + e.X < _startl + _startw - MIN_SIZE ? _startl + e.X : _startl + _startw - MIN_SIZE;
                    w = _startl + _startw - _MControl.Left;
                    h = _starth + e.Y > MIN_SIZE ? _starth + e.Y : MIN_SIZE;
                    break;

                case 7:     // _dragging left-middle sizing box
                    l = _startl + e.X < _startl + _startw - MIN_SIZE ? _startl + e.X : _startl + _startw - MIN_SIZE;
                    w = _startl + _startw - _MControl.Left;
                    break;
                }
                l = (l < 0) ? 0 : l;
                t = (t < 0) ? 0 : t;
                _MControl.SetBounds(l, t, w, h);
            }
        }
Esempio n. 15
0
		public void CreateGraphicsTest ()
		{
			Graphics g = null;
			Pen p = null;

			try {
				Control c = new Control ();
				c.SetBounds (0,0, 20, 20);
				g = c.CreateGraphics ();
				Assert.IsNotNull (g, "Graph1");
			} finally {
				if (p != null)
					p.Dispose ();
				if (g != null)
					g.Dispose ();
			}
		}
Esempio n. 16
0
        private static DialogResult InputBox(string title, string promptText, Control textBox, ref string value)
        {
            Form form = new Form();
            Label label = new Label();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(9, 20, 372, 13);
            textBox.SetBounds(12, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }
Esempio n. 17
0
		public void GetChildAtPointTest ()
		{
			Control c = null, d = null;
			TransparentControl e = null;

			try {
				c = new Control ();
				c.Name = "c1";
				c.SetBounds (0, 0, 100, 100);

				d = new Control ();
				d.Name = "d1";
				d.SetBounds (10, 10, 40, 40);
				c.Controls.Add (d);

				e = new TransparentControl ();
				e.Name = "e1";
				e.SetBounds (55, 55, 10, 10);

				Control l = c.GetChildAtPoint (new Point (15, 15));
				Assert.AreEqual (d.Name, l.Name, "Child1");
				Assert.IsFalse (e.Name == l.Name, "Child2");

				l = c.GetChildAtPoint (new Point (57, 57));
				Assert.AreEqual (null, l, "Child3");

				l = c.GetChildAtPoint (new Point (10, 10));
				Assert.AreEqual (d.Name, l.Name, "Child4");

				// GetChildAtPointSkip is not implemented and the following test is breaking for Net_2_0 profile
#if NET_2_0
				c.Controls.Add (e);
				e.Visible = false;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
				Assert.IsNull (l, "Child5");

				e.Visible = true;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Invisible);
				Assert.AreSame (e.Name, l.Name, "Child6");

				e.Enabled = false;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Disabled);
				Assert.IsNull (l, "Child7");

				e.Enabled = true;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Disabled);
				Assert.AreSame (e.Name, l.Name, "Child8");

				
				e.BackColor = Color.Transparent;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Transparent);
				Assert.IsNull (l, "Child9");

				e.BackColor = Color.Green;
				l = c.GetChildAtPoint (new Point (57, 57), GetChildAtPointSkip.Transparent);
				Assert.AreSame (e.Name, l.Name, "Child10");

#endif // NET_2_0
			} finally {
				if (c != null)
					c.Dispose ();
				if (d != null)
					d.Dispose ();
			}
		}
Esempio n. 18
0
		public static void CallControlSetBounds(Control c, object[] obj)
		{
			if(obj.Length == 4)
				c.SetBounds((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3]);
			if(obj.Length == 5)
				c.SetBounds((int)obj[0], (int)obj[1], (int)obj[2], (int)obj[3],
					(BoundsSpecified)obj[4]);
		}	
Esempio n. 19
0
        private void SlidePnl(Control pnl, int NewId)
        {
            if (NewId == PastId)
            {
                return;
            }
            pnlBase1.SetBounds(282, 0, 1, 1);
            pnlBase2.SetBounds(282, 10, 1, 1);
            pnlBase3.SetBounds(282, 20, 1, 1);
            pnlBase4.SetBounds(282, 30, 1, 1);
            pnlBase5.SetBounds(282, 40, 1, 1);
            if (NewId > PastId)
            {
                int temp = 60;
                for (int i = 0; i < 12; i++)
                {
                    pnl.SetBounds(temp -= 5, 0, 281, 400);
                    Application.DoEvents();
                    Thread.Sleep(5);
                }

            }
            else
            {
                int temp = -60;
                for (int i = 0; i < 12; i++)
                {
                    pnl.SetBounds(temp += 5, 0, 281, 400);
                    Application.DoEvents();
                    Thread.Sleep(5);
                }
            }
            PastId = NewId;
        }