本文整理汇总了C#中System.Windows.Forms.Button.SetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetBounds方法的具体用法?C# Button.SetBounds怎么用?C# Button.SetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Button
的用法示例。
在下文中一共展示了Button.SetBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FixControlSizes
private static void FixControlSizes(Label label, TextBox textBox, Button buttonOk, Button buttonCancel)
{
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
}
示例2: Show
/// <summary>
/// Shows a dialog box with a property grid.
/// </summary>
/// <param name="title"></param>
/// <param name="value"></param>
/// <returns></returns>
public static DialogResult Show(string title, ref Entity_cl value)
{
Form mForm = new Form();
PropertyGrid mPropertyGrid = new PropertyGrid();
Button mOKButton = new Button();
mForm.Text = title + " Properties";
mPropertyGrid.SelectedObject = value;
mOKButton.Text = "OK";
mOKButton.DialogResult = DialogResult.OK;
mForm.ClientSize = new Size(320, 320);
mPropertyGrid.SetBounds(4, 4, mForm.ClientSize.Width - 4, mForm.ClientSize.Height - 40);
mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, mForm.ClientSize.Height - 36, 64, 22);
mPropertyGrid.Anchor = AnchorStyles.Top;
mOKButton.Anchor = AnchorStyles.Bottom;
mForm.Controls.AddRange(new Control[] { mPropertyGrid, mOKButton });
mForm.FormBorderStyle = FormBorderStyle.FixedSingle;
mForm.StartPosition = FormStartPosition.CenterScreen;
mForm.MinimizeBox = false;
mForm.MaximizeBox = false;
mForm.AcceptButton = mOKButton;
DialogResult dialogResult = mForm.ShowDialog();
return dialogResult;
}
示例3: Show
/// <summary>
/// Shows a dialog box with an input field.
/// </summary>
/// <param name="title"></param>
/// <param name="prompt"></param>
/// <param name="value"></param>
/// <returns></returns>
public static DialogResult Show(string title, string prompt, ref string value)
{
Form mForm = new Form();
Label mLabel = new Label();
TextBox mTextBox = new TextBox();
Button mOKButton = new Button();
mForm.Text = title;
mLabel.Text = prompt;
mTextBox.Text = value;
mOKButton.Text = "OK";
mOKButton.DialogResult = DialogResult.OK;
mForm.ClientSize = new Size(240, 80);
mLabel.SetBounds(4, 4, mForm.ClientSize.Width-8, 22);
mTextBox.SetBounds(32, 26, mForm.ClientSize.Width - 64, 24);
mOKButton.SetBounds(mForm.ClientSize.Width / 2 - 32, 54, 64, 22);
mLabel.AutoSize = true;
mTextBox.Anchor = AnchorStyles.Bottom;
mOKButton.Anchor = AnchorStyles.Bottom;
mForm.Controls.AddRange(new Control[] { mLabel, mTextBox, mOKButton });
mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
mForm.StartPosition = FormStartPosition.CenterScreen;
mForm.MinimizeBox = false;
mForm.MaximizeBox = false;
mForm.AcceptButton = mOKButton;
DialogResult dialogResult = mForm.ShowDialog();
value = mTextBox.Text;
return dialogResult;
}
示例4: inputBox
public static DialogResult inputBox(string title, string labelText, ref string promptText)
{
Form form = new Form();
Label label = new Label();
Button buttonOk = new Button();
Button buttonCancel = new Button();
TextBox textBox = new TextBox();
label.Text = labelText;
form.Text = title;
textBox.Text = promptText;
buttonOk.Text = "Ok";
buttonCancel.Text = "Cancelar";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
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;
DialogResult res = form.ShowDialog();
promptText = textBox.Text;
return res;
}
示例5: 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();
}
示例6: QuitDialog
//UPGRADE_TODO: Class 'java.awt.Frame' was converted to 'System.Windows.Forms.Form' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtFrame'"
public QuitDialog(System.Windows.Forms.Form parent, bool modal)
: base()
{
//UPGRADE_TODO: Constructor 'java.awt.Dialog.Dialog' was converted to 'SupportClass.DialogSupport.SetDialog' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtDialogDialog_javaawtFrame_boolean'"
SupportClass.DialogSupport.SetDialog(this, parent);
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
//UPGRADE_ISSUE: Method 'java.awt.Container.setLayout' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtContainersetLayout_javaawtLayoutManager'"
/*
setLayout(null);*/
//UPGRADE_TODO: Method 'java.awt.Component.setSize' was converted to 'System.Windows.Forms.Control.Size' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtComponentsetSize_int_int'"
Size = new System.Drawing.Size(SupportClass.GetInsets(this)[1] + SupportClass.GetInsets(this)[2] + 337, SupportClass.GetInsets(this)[0] + SupportClass.GetInsets(this)[3] + 135);
System.Windows.Forms.Button temp_Button;
temp_Button = new System.Windows.Forms.Button();
temp_Button.Text = " Yes ";
yesButton = temp_Button;
yesButton.SetBounds(SupportClass.GetInsets(this)[1] + 72, SupportClass.GetInsets(this)[0] + 80, 79, 22);
//UPGRADE_NOTE: If the given Font Name does not exist, a default Font instance is created. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1075'"
yesButton.Font = new System.Drawing.Font("Dialog", 12, System.Drawing.FontStyle.Bold);
//UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
Controls.Add(yesButton);
System.Windows.Forms.Button temp_Button2;
temp_Button2 = new System.Windows.Forms.Button();
temp_Button2.Text = " No ";
noButton = temp_Button2;
noButton.SetBounds(SupportClass.GetInsets(this)[1] + 185, SupportClass.GetInsets(this)[0] + 80, 79, 22);
//UPGRADE_NOTE: If the given Font Name does not exist, a default Font instance is created. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1075'"
noButton.Font = new System.Drawing.Font("Dialog", 12, System.Drawing.FontStyle.Bold);
//UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
Controls.Add(noButton);
System.Windows.Forms.Label temp_Label;
//UPGRADE_TODO: The equivalent in .NET for field 'java.awt.Label.CENTER' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
temp_Label = new System.Windows.Forms.Label();
temp_Label.Text = "Do you really want to quit?";
temp_Label.TextAlign = (System.Drawing.ContentAlignment) System.Drawing.ContentAlignment.MiddleCenter;
label1 = temp_Label;
label1.SetBounds(78, 33, 180, 23);
//UPGRADE_TODO: Method 'java.awt.Container.add' was converted to 'System.Windows.Forms.ContainerControl.Controls.Add' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaawtContaineradd_javaawtComponent'"
Controls.Add(label1);
Text = "A Basic Application - Quit";
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow(this);
//UPGRADE_NOTE: Some methods of the 'java.awt.event.WindowListener' class are not used in the .NET Framework. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1308'"
this.Closing += new System.ComponentModel.CancelEventHandler(aSymWindow.windowClosing);
SymAction lSymAction = new SymAction(this);
noButton.Click += new System.EventHandler(lSymAction.actionPerformed);
SupportClass.CommandManager.CheckCommand(noButton);
yesButton.Click += new System.EventHandler(lSymAction.actionPerformed);
SupportClass.CommandManager.CheckCommand(yesButton);
//}}
}
示例7: CatBox
public DialogResult CatBox(string promptText, double cost, DateTime dt, ref string value)
{
Form form = new Form();
Label label = new Label();
Label amount = new Label();
Label date = new Label();
ComboBox comboBox = new ComboBox();
Button buttonOk = new Button();
CheckBox checkBox = new CheckBox();
form.Text = "Specify a Category:";
label.Text = promptText;
amount.Text = cost.ToString("C");
date.Text = dt.ToString();
checkBox.Text = "Remember this relationship?";
buttonOk.Text = "OK";
buttonOk.DialogResult = DialogResult.OK;
label.SetBounds(9, 20, 172, 13);
amount.SetBounds(273, 20, 100, 13);
date.SetBounds(173, 20, 100, 13);
comboBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(309, 72, 75, 23);
checkBox.SetBounds(12, 72, 275, 24); // ???
label.AutoSize = true;
comboBox.Anchor = comboBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkBox.Anchor = checkBox.Anchor | AnchorStyles.Right;
comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, amount, date, checkBox, comboBox, buttonOk });
form.ClientSize = new Size(Math.Max(300, amount.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
SqlCeConnection cs = new SqlCeConnection(@"Data Source = Expenses.sdf");
cs.Open();
SqlCeDataReader r = null;
SqlCeCommand getCats = new SqlCeCommand("SELECT * FROM Categories", cs);
r = getCats.ExecuteReader();
while (r.Read()) comboBox.Items.Add(r["Category"]);
cs.Close();
DialogResult dialogResult = form.ShowDialog();
value = comboBox.Text;
// remember relationship if option to do so is checked
if (checkBox.Checked)
{
SqlCeConnection cs2 = new SqlCeConnection(@"Data Source = Expenses.sdf");
cs2.Open();
SqlCeCommand setCat = new SqlCeCommand("INSERT INTO CategorizedItems VALUES (@Description, @Category)", cs2);
setCat.Parameters.AddWithValue("@Description", promptText);
setCat.Parameters.AddWithValue("@Category", value);
setCat.ExecuteNonQuery();
cs2.Close();
}
return dialogResult;
}
示例8: addButton
public void addButton(string name,string text, int x, int y, int w, int h)
{
Button button = new Button();
button.Text = text;
button.Name = name;
button.SetBounds(x, y, w, h);
button.Click += new EventHandler(buttonNext2_Click);
Controls.Add(button);
}
示例9: Show
public static DialogResult Show(string title, string promptText, ref string value,
InputBoxValidation validation)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
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;
if (validation != null)
{
form.FormClosing += delegate(object sender, FormClosingEventArgs e)
{
if (form.DialogResult == DialogResult.OK)
{
string errorText = validation(textBox.Text);
if (e.Cancel = (errorText != ""))
{
MessageBox.Show(form, errorText, "Validation Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox.Focus();
}
}
};
}
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
示例10: Show
/// <summary>
/// Muestra el 'InputTextBox'
/// </summary>
/// <param name="strTexto"> Texto a mostrar en el mensaje </param>
/// <param name="strEncabezado"> Título del InputTextBox </param>
/// <param name="strValor"> Texto ingresado </param>
/// <param name="itbValidacion"> Delegado que valida lo ingresado en el InputTextBox </param>
/// <returns>DialogResult</returns>
public static DialogResult Show(string strTexto, string strEncabezado, ref string strValor, InputBoxValidation itbValidacion)
{
Form frmFormulario = new Form();
Label lblEtiqueta = new Label();
TextBox txtCajaTexto = new TextBox();
Button btnOK = new Button();
Button btnCancel = new Button();
frmFormulario.Text = strEncabezado;
lblEtiqueta.Text = strTexto;
txtCajaTexto.Text = strValor;
btnOK.Text = "OK";
btnCancel.Text = "Cancel";
btnOK.DialogResult = DialogResult.OK;
btnCancel.DialogResult = DialogResult.Cancel;
lblEtiqueta.SetBounds(9, 20, 372, 13);
txtCajaTexto.SetBounds(12, 36, 372, 20);
btnOK.SetBounds(228, 72, 75, 23);
btnCancel.SetBounds(309, 72, 75, 23);
lblEtiqueta.AutoSize = true;
txtCajaTexto.Anchor = txtCajaTexto.Anchor | AnchorStyles.Right;
btnOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
frmFormulario.ClientSize = new Size(396, 107);
frmFormulario.Controls.AddRange(new Control[] { lblEtiqueta, txtCajaTexto, btnOK, btnCancel });
frmFormulario.ClientSize = new Size(Math.Max(300, lblEtiqueta.Right + 10), frmFormulario.ClientSize.Height);
frmFormulario.FormBorderStyle = FormBorderStyle.FixedDialog;
frmFormulario.StartPosition = FormStartPosition.CenterScreen;
frmFormulario.MinimizeBox = false;
frmFormulario.MaximizeBox = false;
frmFormulario.AcceptButton = btnOK;
frmFormulario.CancelButton = btnCancel;
if (itbValidacion != null)
{
frmFormulario.FormClosing += delegate(object sender, FormClosingEventArgs e)
{
if (frmFormulario.DialogResult == DialogResult.OK)
{
string errorText = itbValidacion(txtCajaTexto.Text);
if (e.Cancel = (errorText != ""))
{
MessageBox.Show(frmFormulario, errorText, "Mensaje",
MessageBoxButtons.OK, MessageBoxIcon.Error);
txtCajaTexto.Focus();
}
}
};
}
DialogResult dialogResult = frmFormulario.ShowDialog();
strValor = txtCajaTexto.Text;
return dialogResult;
}
示例11: Show
/// <summary>
/// Displays a dialog with a prompt and textbox where the user can enter information
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="promptText">Dialog prompt</param>
/// <param name="value">Sets the initial value and returns the result</param>
/// <returns>Dialog result</returns>
public static DialogResult Show(Form parent, string title, string promptText, string checkText, ref string value, ref bool isChecked)
{
// TODO: button placement/size has been hardcoded for how it is used in this app.
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
CheckBox checkBox = new CheckBox();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
textBox.Multiline = true;
textBox.Height = (int)(textBox.Height * 2);
checkBox.Checked = isChecked;
checkBox.Text = checkText;
checkBox.Visible = (checkText != null);
//form.TopLevel = true;
//form.StartPosition = FormStartPosition.CenterParent;
//form.Parent = parent;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 76, 372, 50);
buttonOk.SetBounds(228, 130, 75, 23);
buttonCancel.SetBounds(309, 130, 75, 23);
checkBox.SetBounds(12, 60, 150, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
form.ClientSize = new Size(396, 170);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel, checkBox });
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;
isChecked = checkBox.Checked;
return dialogResult;
}
示例12: InputCreateRoomBox
public static TDSRoom InputCreateRoomBox(TDSRoom currentRoom)
{
var form = new Form();
var westRadioButton = new RadioButton {Text = "To the west", Enabled = false};
var eastRadioButton = new RadioButton {Text = "To the east", Enabled = false};
var northRadioButton = new RadioButton {Text = "To the north", Enabled = false};
var southRadioButton = new RadioButton {Text = "To the south", Enabled = false};
var isRequiredCheckBox = new CheckBox {Text = "Is required", Checked = true};
var isSecretCheckBox = new CheckBox {Text = "Is secret", Checked = false};
var doneButton = new Button {Text = "OK"};
form.Text = "Create new room";
form.ClientSize = new Size(396, 200);
form.Controls.AddRange(new Control[]
{
westRadioButton, eastRadioButton, northRadioButton, southRadioButton,
isRequiredCheckBox, isSecretCheckBox, doneButton
});
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
westRadioButton.SetBounds(25, 25, 100, 25);
eastRadioButton.SetBounds(25, 50, 100, 25);
northRadioButton.SetBounds(25, 75, 100, 25);
southRadioButton.SetBounds(25, 100, 100, 25);
isRequiredCheckBox.SetBounds(125, 25, 100, 25);
isSecretCheckBox.SetBounds(125, 50, 100, 25);
doneButton.SetBounds(125, 100, 100, 25);
if (currentRoom.Level.GetRoom(currentRoom.X - 1, currentRoom.Y) == null) westRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X + 1, currentRoom.Y) == null) eastRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y - 1) == null) northRadioButton.Enabled = true;
if (currentRoom.Level.GetRoom(currentRoom.X, currentRoom.Y + 1) == null) southRadioButton.Enabled = true;
TDSRoom result = null;
var resultX = 0;
var resultY = 0;
doneButton.Click += (e, sender) =>
{
if (westRadioButton.Checked) resultX = -1;
if (eastRadioButton.Checked) resultX = 1;
if (northRadioButton.Checked) resultY = -1;
if (southRadioButton.Checked) resultY = 1;
result = TDSControl.CreateRoom(currentRoom.Level, currentRoom.X + resultX, currentRoom.Y + resultY, isRequiredCheckBox.Checked, isSecretCheckBox.Checked);
form.Close();
};
form.ShowDialog();
return result;
}
示例13: Clear_Click
private void Clear_Click(object sender, EventArgs e)
{
Form form = new Form(); form.Text = "Clear Databases";
CheckBox clearCategories = new CheckBox();
clearCategories.Text = "Clear All Categories, Expenses, and Relations";
clearCategories.Checked = false;
clearCategories.SetBounds(9, 6, 272, 24);
CheckBox clearLineItems = new CheckBox();
clearLineItems.Text = "Clear Line Item Expenses Only";
clearLineItems.Checked = false;
clearLineItems.SetBounds(9, 30, 272, 24);
CheckBox clearRelations = new CheckBox();
clearRelations.Text = "Clear Saved Relations Only";
clearRelations.Checked = false;
clearRelations.SetBounds(9, 54, 272, 24);
Button OK = new Button(); OK.Text = "OK";
OK.SetBounds(9, 78, 75, 23);
OK.DialogResult = DialogResult.OK;
Button Cancel = new Button(); Cancel.Text = "Cancel";
Cancel.SetBounds(100, 78, 75, 23);
Cancel.DialogResult = DialogResult.Cancel;
form.ClientSize = new Size(296, 107);
form.Controls.AddRange(new Control[] { clearCategories, clearLineItems, clearRelations, OK, Cancel });
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = OK;
form.CancelButton = Cancel;
if (form.ShowDialog() == DialogResult.OK)
{
if (clearCategories.Checked)
{
File.Delete("Expenses.sdf");
Setup.Enabled = true; Edit.Enabled = false; Clear.Enabled = false;
View.Enabled = false; Import.Enabled = false; Manual.Enabled = false;
}
else if (clearLineItems.Checked)
{
if (clearRelations.Checked) Form1_Helper.ClearRelations();
Form1_Helper.ClearLineItems();
}
else if (clearRelations.Checked) Form1_Helper.ClearRelations();
else MessageBox.Show("No action taken.");
}
else MessageBox.Show("No action taken.");
}
示例14: 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();
}
示例15: PeopleForm
public PeopleForm(string title=null, IPeopleFormDelegate peopleFormDelegate = null, bool openForUpdate = false,string surname="", string firstname="", string password="", string comment="")
{
if (null != title) this.Text = title;
_openForUpdate = openForUpdate;
_peopleFormDelegate = peopleFormDelegate;
this.SetBounds(10, 10, 200, 220);
Label lbl1, lbl2,lbl3, lbl4;
TextBox txt1, txt2,txt3,txt4;
Button btn = new Button();
this.Controls.Add(lbl1 = new Label());
lbl1.SetBounds(5, 5, 185, 18);
lbl1.Text = "firstname";
this.Controls.Add(txt1 = new TextBox());
txt1.SetBounds(5, 25, 185, 18);
txt1.Text = firstname;
this.Controls.Add(lbl2 = new Label());
lbl2.Text = "surname";
lbl2.SetBounds(5, 45, 185, 18);
this.Controls.Add(txt2 = new TextBox());
txt2.SetBounds(5, 65, 165, 18);
txt2.Text = surname;
this.Controls.Add(lbl3 = new Label());
lbl3.SetBounds(5, 85, 185, 18);
lbl3.Text = "password";
this.Controls.Add(txt3 = new TextBox());
txt3.SetBounds(5, 105, 185, 18);
txt3.Text = password;
this.Controls.Add(lbl4 = new Label());
lbl4.SetBounds(5, 125, 185, 18);
lbl4.Text = "comment";
this.Controls.Add(txt4 = new TextBox());
txt4.SetBounds(5, 145, 185, 18);
txt4.Text = comment;
this.Controls.Add(btn);
btn.SetBounds(5, 165, 185, 18);
ErrorProvider ep = new ErrorProvider();
ep.SetIconAlignment(txt2, ErrorIconAlignment.MiddleRight);
ep.SetIconPadding(txt2, 2);
btn.Text = openForUpdate ? "Save people" : "Add people";
btn.Click += (object sender1, EventArgs e1) =>
{
if (string.IsNullOrWhiteSpace(txt2.Text))
{
ep.SetError(txt2, "Surname must contain chars");
return;
}
ep.SetError(txt2, string.Empty);
if (null != this._peopleFormDelegate) _peopleFormDelegate.saved(txt2.Text, txt1.Text, txt3.Text, txt4.Text);
if(openForUpdate) this.Close();
};
}