本文整理汇总了C#中System.Windows.Forms.Form.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Form.SetBounds方法的具体用法?C# Form.SetBounds怎么用?C# Form.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.SetBounds方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: trainingForm
private void trainingForm(int width, int height, Bitmap bitmapToRender, Form tempDisplay)
{
tempDisplay.SetBounds(10, 10, width + 360, height);
tempDisplay.BackgroundImage = bitmapToRender;
tempDisplay.BackgroundImageLayout = ImageLayout.Center;
enterTheLabel.SetBounds(0, 0, 900, 30);
segmentLabel.SetBounds(0, 30, 20, 20);
tempDisplay.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
Button submitLabel = new Button();
submitLabel.Text = "Submit";
submitLabel.SetBounds(2, 60, 60, 20);
Button skip = new Button();
skip.Text = "Skip";
skip.SetBounds(64, 60, 50, 20);
tempDisplay.Controls.Add(skip);
tempDisplay.Controls.Add(segmentLabel);
tempDisplay.Controls.Add(enterTheLabel);
tempDisplay.Controls.Add(submitLabel);
Point temp = new Point(3, 4);
tempDisplay.Location = new Point(100, 100);
submitLabel.Click += new System.EventHandler(submitLabel_click);
skip.Click += new System.EventHandler(skip_click);
tempDisplay.ShowDialog();
}
示例2: ReadForm
public bool ReadForm(Form form)
{
string s = ReadValue("Forms", form.Name);
if (convert.IsString(s))
{
string[] ts = s.Split(' ');
if (ts.Length == 4)
{
int[] v = new int[4];
int k = 0;
foreach (string t in ts)
if (Int32.TryParse(t, out v[k]))
k++;
else
break;
if (k == 4)
{
form.SetBounds(v[0], v[1], v[2], v[3]);
return true;
}
}
}
return false;
}
示例3: btnPeople_Click
void btnPeople_Click(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine(this.GetType().Attributes);
Form f = new Form();
Label lbl1, lbl2;
TextBox txt1, txt2;
f.Text = "WTF you are ?";
f.SetBounds(10, 10, 200, 140);
f.Controls.Add(lbl1 = new Label());
lbl1.SetBounds(5, 5, 185,18);
lbl1.Text = "firstname";
f.Controls.Add(txt1 = new TextBox());
txt1.SetBounds(5, 25, 185, 18);
f.Controls.Add(lbl2 = new Label());
lbl2.Text = "surname";
lbl2.SetBounds(5, 45, 185, 18);
f.Controls.Add(txt2 = new TextBox());
txt2.SetBounds(5, 65, 185, 18);
Button btn = new Button();
btn.SetBounds(5, 85, 185, 18);
btn.Text = "Add people";
f.Controls.Add(btn);
btn.Click += (object sender1, EventArgs e1) =>
{
this.chklistPeople.Items.Add(txt1.Text + " " + txt2.Text);
//this.Show();
//f.Close();
};
f.Show();
}
示例4: FormWindow
public static void FormWindow()
{
Form npcForm = new Form();
npcForm.ShowInTaskbar = false;
npcForm.Text = "NPCs"; //The text in the Title
npcForm.SetBounds(12, 12, 256, 256);
Button b1 = new Button();
b1.Text = "Lakitu";
npcForm.Controls.Add(b1);
b1.SetBounds(2, 2, 16, 16);
npcForm.Show();
}
示例5: Form_NPCs
public Form_NPCs()
{
Form npcForm = new Form();
npcForm.ShowInTaskbar = false;
npcForm.Text = "NPCs"; //The text in the Title
npcForm.SetBounds(12, 12, 256, 256);
Button b1 = new Button();
npcForm.Controls.Add(b1);
b1.Text = "b1";
b1.SetBounds(2, 2, 16, 16);
b1.Click += new System.EventHandler(b_click);
npcForm.Show();
}
示例6: TestPublicMethods
//.........这里部分代码省略.........
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");
示例7: LocateScreenCenter
/// <summary>
/// ��λ���ڵ���Ļ����,����ָ���Ĵ�С��ʾ
/// </summary>
/// <param name="form">����</param>
/// <param name="size">�µĴ�С</param>
public static void LocateScreenCenter(Form form, Size size)
{
if (form == null || form.IsDisposed)
return;
Screen primaryScreen = null;
if (form.Owner != null && !form.Owner.IsDisposed)
primaryScreen = Screen.FromControl(form.Owner);
if (primaryScreen == null)
primaryScreen = Screen.PrimaryScreen;
if (primaryScreen == null)
return;
Rectangle rect = primaryScreen.WorkingArea;
int width = form.Width;
int height = form.Height;
if (!size.IsEmpty)
{
width = (size.Width > rect.Width) ? rect.Width : size.Width;
height = (size.Height > rect.Height) ? rect.Height : size.Height;
}
int x = (rect.Width - width) / 2;
int y = (rect.Height - height) / 2;
form.SetBounds(x, y, width, height, BoundsSpecified.All);
}
示例8: LoadFormState
public void LoadFormState(Form form, string id)
{
try
{
id = "FormState." + id;
if (this.xml.GetNode(id + ".Width") == null)
return;
int x = Convert.ToInt32(this.xml[id + ".X"]);
int y = Convert.ToInt32(this.xml[id + ".Y"]);
int width = Convert.ToInt32(this.xml[id + ".Width"]);
int height = Convert.ToInt32(this.xml[id + ".Height"]);
form.StartPosition = FormStartPosition.Manual;
form.SetBounds(x, y, width, height);
form.WindowState = (FormWindowState)Enum.Parse(typeof(FormWindowState), this.xml[id + ".State"]);
}
catch
{
}
}
示例9: produceNewForm
private static void produceNewForm(Bitmap bitmapToRender, string displayLabel1, string displayLabel2)
{
Form tempDisplay = new Form();
Label labelLabel = new Label();
Label certaintyLabel1 = new Label();
Label displayLocation = new Label();
labelLabel.AutoSize = true;
certaintyLabel1.AutoSize = true;
displayLocation.AutoSize = true;
int width = bitmapToRender.Width;
int height = bitmapToRender.Height;
if(displayLabel1 != null)
labelLabel.Text = displayLabel1;
if (displayLabel2 != null)
certaintyLabel1.Text = displayLabel2;
labelLabel.Location = new System.Drawing.Point(6, 7);
certaintyLabel1.Location = new System.Drawing.Point(6, 66);
displayLocation.Location = new System.Drawing.Point(50, 7);
tempDisplay.Controls.Add(labelLabel);
tempDisplay.Controls.Add(certaintyLabel1);
tempDisplay.Controls.Add(displayLocation);
tempDisplay.SetBounds(10, 10, width, height);
tempDisplay.ClientSize = new System.Drawing.Size(150, 88);
tempDisplay.BackgroundImage = bitmapToRender;
tempDisplay.BackgroundImageLayout = ImageLayout.Center;
tempDisplay.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
tempDisplay.Location = new System.Drawing.Point(100, 100);
tempDisplay.ShowDialog();
}
示例10: takeScreenshot
public Bitmap takeScreenshot(Form owner, bool hideOwnerForm = true)
{
if (hideOwnerForm)
{
owner.Hide();
System.Threading.Thread.Sleep(500);
}
var bound = getScreenBounds();
using (var screenshot = takeScreenshot(bound))
{
using (var form = new Form())
{
// 背景(スクリーンショット画像)を表示するフォームを作成
form.SetBounds(bound.X, bound.Y, bound.Width, bound.Height);
form.Paint += (sender, e) =>
{
if (screenshot != null)
{
prevScreenshot_ = currentScreenshot_;
e.Graphics.DrawImage(currentScreenshot_, Point.Empty);
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, 0, 0, 0)), new Rectangle(0, 0, Width, Height));
}
};
form.StartPosition = FormStartPosition.Manual;
form.TopMost = true;
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.WindowState = FormWindowState.Normal;
form.Show();
form.Activate();
// キャプチャ範囲を表示するフォームを初期化
this.SetBounds(bound.X, bound.Y, bound.Width, bound.Height);
// キャプチャ
currentScreenshot_ = screenshot;
this.ShowDialog();
currentScreenshot_ = null;
if (hideOwnerForm)
{
owner.Show();
}
// ドラッグした範囲の画像を切り出す
if (start != null && end != null)
{
Rectangle rect = GetRectangle(start.Value, end.Value);
Bitmap bmp = new Bitmap(rect.Width, rect.Height, screenshot.PixelFormat);
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(screenshot, new Rectangle(0, 0, rect.Width, rect.Height), rect, GraphicsUnit.Pixel);
}
return bmp;
}
}
}
return null;
}
示例11: SetStartPosition
/// <summary>
/// 设置窗口的初始位置
/// </summary>
public static void SetStartPosition(Form currentForm)
{
Form owner = currentForm.Owner;
if (owner == null || owner.Name != "Main")
return;
// 窗体居中显示
currentForm.SetBounds((Screen.GetBounds(currentForm).Width / 2) - (currentForm.Width / 2),
(Screen.GetBounds(currentForm).Height / 2) - (currentForm.Height / 2), currentForm.Width, currentForm.Height, BoundsSpecified.Location);
}
示例12: RestoreFormPos
/// <summary>
/// RestoreFormPos(this, KeyName) - Restores a forms size and location from the registry
/// Use SaveFormPos(this, KeyName) to save a screens position
/// Note: Assume user has already done a SubKey() call to set the destination registry key
/// </summary>
/// <param name="form">Typically 'this' where this is a Form</param>
///
public void RestoreFormPos(Form form, String sKeyName)
{
int iLeft, iTop, iWidth, iHeight;
string sLeft, sTop, sWidth, sHeight;
if (String.IsNullOrEmpty(sKeyName))
sKeyName = form.Name;
sKeyName = sKeyName + ".";
//Maximized?
String state = this.ReadStr(sKeyName + "state", "");
if (state == "Maximized")
form.WindowState = FormWindowState.Maximized;
else if (state == "Minimized")
form.WindowState = FormWindowState.Minimized;
else
form.WindowState = FormWindowState.Normal;
//Read settings from registry
sLeft = this.ReadStr(sKeyName + "Left", "");
sTop = this.ReadStr(sKeyName + "Top", "");
sWidth = this.ReadStr(sKeyName + "Width", "");
sHeight = this.ReadStr(sKeyName + "Height", "");
//Str -> Int
iLeft = iTop = iWidth = iHeight = 0;
Boolean ok = int.TryParse(sLeft, NumberStyles.Integer, null, out iLeft);
ok = ok && int.TryParse(sTop, NumberStyles.Integer, null, out iTop);
ok = ok && int.TryParse(sWidth, NumberStyles.Integer, null, out iWidth);
ok = ok && int.TryParse(sHeight, NumberStyles.Integer, null, out iHeight);
if (ok)
ok = AreaOnScreen(iLeft, iTop, iWidth, iHeight);
//Restore to position read (since all read ok)
if (ok)
form.SetBounds(iLeft, iTop, iWidth, iHeight);
else // Center the Form on the user's screen
form.SetBounds((Screen.GetBounds(form).Width / 2) - (form.Width / 2),
(Screen.GetBounds(form).Height / 2) - (form.Height / 2),
form.Width, form.Height, BoundsSpecified.Location);
}
示例13: dgv_toets_CellDoubleClick
//student row ingedrukt(event)
private void dgv_toets_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
int row = e.RowIndex;
// checked of een rij met data is ingedrukt(invoegrow id is -1)
if (row >= 0)
{
//verkrijg id
int id = Convert.ToInt32(dgv_toets.Rows[row].Cells[0].Value);
//connect naar student sql
StudentSql.connect();
//checked of de student bestaat
if (StudentSql.studentExists(id))
{//open student overzicht voor deze student
Student student = StudentSql.getStudent(id);
Form form = new Form();
StudentView view = new StudentView(student, form);
form.SetBounds(form.Bounds.X + 100,form.Bounds.Y + 100, 1280, 800);
form.Show();
}
}
}