本文整理汇总了C#中System.Windows.Forms.Control.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Control.SetBounds方法的具体用法?C# Control.SetBounds怎么用?C# Control.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.SetBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fenetre
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;
}
示例2: CallControlSetBounds
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]);
}
示例3: InputBox
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;
}
示例4: InitializeAndShowStep
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();
}
示例5: TestPublicMethods
//.........这里部分代码省略.........
// - 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");
}
示例6: CommonEditorUse
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;
}
示例7: GUIContainer_PageEnter
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);
}
示例8: MethodSetBounds
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");
}
示例9: GetChildAtPointTest
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 ();
}
}
示例10: CreateGraphicsTest
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 ();
}
}
示例11: RelationTest
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");
}
示例12: CommonEditorUse
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;
}
示例13: PerformAnchorLayout
// 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;
}
示例14: BackendRadioButtonClicked
/// <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);
}
示例15: SlidePnl
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;
}