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); }
public Formulario(int qtdeVariaveis, int qtdeRestricoes) { InitializeComponent(); contadorEixoY = 40; for (int i = 0; i < qtdeRestricoes; i++) { contadorEixoX = 100; Label lbRestricoes = new Label(); lbRestricoes.SetBounds(10, contadorEixoY, 80, 25); lbRestricoes.Text = "Restricao " + (i+1).ToString(); this.Controls.Add(lbRestricoes); for (int j = 0; j < qtdeVariaveis; j++) { Label lbVariaveis = new Label(); lbVariaveis.SetBounds(contadorEixoX, 10, 30, 25); lbVariaveis.Text = "X" + (j+1).ToString(); this.Controls.Add(lbVariaveis); TextBox txt = new TextBox(); txt.SetBounds(contadorEixoX, contadorEixoY, 30, 30); this.Controls.Add(txt); contadorEixoX += 40; } contadorEixoY += 30; } }
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; }
public string InputBox(string title, string promptText) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox(); System.Windows.Forms.Button buttonOk = new System.Windows.Forms.Button(); form.Text = title; label.Text = promptText; buttonOk.Text = "OK"; buttonOk.DialogResult = DialogResult.OK; label.SetBounds(9, 10, 372, 13); textBox.SetBounds(12, 36, 372, 20); buttonOk.SetBounds(228, 72, 75, 23); label.AutoSize = true; label.Anchor = AnchorStyles.Left; textBox.Anchor = textBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, textBox, buttonOk });//Out of memory error caused on this line 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; DialogResult dialogResult = form.ShowDialog(); return(textBox.Text); }
public void InitEditors() { const int startX = 20, labelWd = 170, labelHt = 18, editorWd = 100, editorLeft = 198; const int startY = 20, deltaY = 22; var row = 0; foreach (var ptr in CodeTemplate.parameters.Values) { var top = startY + (row++)*deltaY; // подпись var lbl = new Label {Text = ptr.Title, Parent = panelControls}; lbl.SetBounds(startX, top, labelWd, labelHt); panelControls.Controls.Add(lbl); // редактор значения if (ptr.IsNumber || ptr.IsString) { var textBox = new TextBox {Parent = panelControls}; textBox.SetBounds(editorLeft, top, editorWd, labelHt + 2); panelControls.Controls.Add(textBox); paramEditors.Add(textBox); } if (ptr.IsBoolean) { var checkBox = new CheckBox {Parent = panelControls, Left = editorLeft, Top = top}; panelControls.Controls.Add(checkBox); paramEditors.Add(checkBox); } } }
private void PerformCellMove(int x, int y) { textBox1.Visible = true; ListViewItem theRow = null; int index = 0; Rectangle r = RetrieveCellBounds(x, y, ref theRow, ref index); textBox1.SetBounds(r.X + 2, r.Y, r.Width, r.Height - 5); if (theRow != null) { CurrentColumn = index; CurrentRow = theRow.Index; PopulateTextBox(theRow, index); } }
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(); }
/// <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; }
public void addTextBox(string text, int x, int y, int w, int h) { TextBox tb = new TextBox(); tb.Name = text; tb.SetBounds(x, y, w, h); TextboxList.Add(tb); Controls.Add(tb); }
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; }
/// <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; }
/// <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; }
private void escondeLabel() { try { m_tbObservacoes.SetBounds(8, m_tbObservacoes.Bounds.Y, m_gbFields.Bounds.Width - 16, m_tbObservacoes.Bounds.Height); } catch (Exception err) { Object erro = err; m_cls_ter_tratadorErro.trataErro(ref erro); } }
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(); }; }
/// <summary> /// Initialize find and replace. /// </summary> private void InitializeFindAndReplace() { FindText = new TextBox(); FindText.Parent = this; FindText.MinimumSize = new Size(0, 0); FindText.MaximumSize = new Size(1, 1); FindText.SetBounds(0, 0, 1, 1); FindText.BackColor = Theme.BackColor; FindText.ForeColor = Theme.BackColor; FindText.TextChanged += new EventHandler(HandleFindTextChanged); FindText.KeyUp += new KeyEventHandler(HandleFindKeyUp); FindText.GotFocus += new EventHandler(HandleFindGotFocus); FindText.LostFocus += new EventHandler(HandleFindLostFocus); }
private void bAgregar_Click(object sender, EventArgs e) { TabPage Nueva = new TabPage("Archivo"+cont+".dx"); TextBox texto = new TextBox(); texto.Name = "texto"; texto.Text = ""; texto.Multiline = true; texto.SetBounds(0, 0, tabDx.Width, tabDx.Height); Nueva.Controls.Add(texto); tabDx.TabPages.Add(Nueva); cont++; tabDx.SelectedTab = Nueva; tabDx.ResetText(); }
public static DialogResult InputBox(string title, string promptText, out string value) { if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) { value = null; return DialogResult.Abort; } Form form = new Form(); Label label = new Label(); TextBox textBox = new TextBox(); textBox.Width = 1000; Button buttonOk = new Button(); Button buttonCancel = new Button(); form.Text = title; label.Text = promptText; 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; }
private void createStackDisplay() { TextBox box; for (int i = 0; i < PIC.Data.OperationStack.STACK_SIZE; i++) { box = new TextBox(); box.SetBounds(5 + STACK_X_OFFSET, stackIndex0Label.Bounds.Y - TEXT_BOX_Y_OFFSET + i * 20, 25, 25); box.Parent = this; box.ReadOnly = true; box.Show(); stackBoxes[i] = box; } updateStackDisplay(); //throw new NotImplementedException(); }
//, Point p) public static string InputBox(string title, string promptText, string value) { var form = new Form(); var label = new Label(); var textBox = new TextBox(); var buttonOk = new Button(); var buttonCancel = new Button(); form.Text = promptText; label.Text = title; 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; textBox.Text = value; 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; form.StartPosition = FormStartPosition.CenterParent; //form.Location = new Point(p.X,p.Y); var dialogResult = form.ShowDialog(); return textBox.Text; }
public static DialogResult InputBox(string title, string promptText, ref string value, bool isPassword = false) { 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 ?? title; 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, 90, 372, 20); buttonOk.SetBounds(228, 122, 75, 23); buttonCancel.SetBounds(309, 122, 75, 23); label.AutoSize = true; textBox.Anchor = textBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; if (isPassword) textBox.UseSystemPasswordChar = true; form.ClientSize = new Size(396, 157); 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; }
public static DialogResult Show(string text, string caption, ref string value) { Form form = new Form(); Label label = new Label(); TextBox textBox = new TextBox(); Button buttonOk = new Button(); Button buttonCancel = new Button(); form.Text = caption; label.Text = text; 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; textBox.MaxLength = 128; var dialogResult = form.ShowDialog(); if (dialogResult == DialogResult.OK) value = textBox.Text; return dialogResult; }
public DialogResult InputBox(string title, string promptText, ref string value) { Form form = new Form(); form.Font = CS410Project.Properties.Settings.Default.SysFont; form.BackColor = CS410Project.Properties.Settings.Default.BackgroundColor; Label label = new Label(); TextBox textBox = new TextBox(); Button buttonOk = new Button(); buttonOk.BackColor = CS410Project.Properties.Settings.Default.ButtonColor; Button buttonCancel = new Button(); buttonCancel.BackColor = CS410Project.Properties.Settings.Default.ButtonColor; 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; }
public static DialogResult InputBox(string title, string promptText, ref string value) { Form form = new Form(); Label label = new Label(); System.Windows.Forms.TextBox textBox = new System.Windows.Forms.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; DialogResult dialogResult = form.ShowDialog(); value = textBox.Text; return(dialogResult); }
public static DialogResult Show(IWin32Window owner, string title, string promptText, ref string value) { using (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; DialogResult dialogResult = owner != null ? form.ShowDialog(owner) : form.ShowDialog(); value = textBox.Text; return dialogResult; } }
internal static String CuadroDialogo(string sTitulo, string sEtiqueta, string sValor) { Form frmCuadroDialogo = new Form(); Label lblTitulo = new Label(); TextBox txtInput = new TextBox(); Button btnOk = new Button(); Button btnCancel = new Button(); frmCuadroDialogo.Text = sTitulo; lblTitulo.Text = sEtiqueta; txtInput.Text = sValor; txtInput.PasswordChar = '*'; btnOk.Text = "OK"; btnCancel.Text = "Cancel"; btnOk.DialogResult = DialogResult.OK; btnCancel.DialogResult = DialogResult.Cancel; lblTitulo.SetBounds(9, 20, 372, 13); txtInput.SetBounds(12, 36, 372, 20); btnOk.SetBounds(228, 72, 75, 23); btnCancel.SetBounds(309, 72, 75, 23); lblTitulo.AutoSize = true; txtInput.Anchor = txtInput.Anchor | AnchorStyles.Right; btnOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; frmCuadroDialogo.ClientSize = new Size(396, 107); frmCuadroDialogo.Controls.AddRange(new Control[] { lblTitulo, txtInput, btnOk, btnCancel }); frmCuadroDialogo.ClientSize = new Size(Math.Max(300, lblTitulo.Right + 10), frmCuadroDialogo.ClientSize.Height); frmCuadroDialogo.FormBorderStyle = FormBorderStyle.FixedDialog; frmCuadroDialogo.StartPosition = FormStartPosition.CenterScreen; frmCuadroDialogo.MinimizeBox = false; frmCuadroDialogo.MaximizeBox = false; frmCuadroDialogo.AcceptButton = btnOk; frmCuadroDialogo.CancelButton = btnCancel; DialogResult dialogResult = frmCuadroDialogo.ShowDialog(); sValor = txtInput.Text; return sValor; }
public static DialogResult InputBox(string title, string promptText, ref string value) { Form form = new Form(); Label label = new Label(); TextBox textBox = new TextBox(); Button buttonOk = new Button(); form.Text = title; label.Text = promptText; textBox.Text = value; buttonOk.Text = "OK"; buttonOk.DialogResult = DialogResult.OK; label.SetBounds(9, 20, 372, 13); textBox.SetBounds(12, 36, 372, 20); buttonOk.SetBounds(228, 72, 75, 23); label.AutoSize = true; textBox.Anchor = textBox.Anchor | AnchorStyles.Right; buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; form.ClientSize = new Size(396, 107); form.Controls.AddRange(new Control[] { label, textBox, buttonOk }); 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; DialogResult dialogResult = form.ShowDialog(); value = textBox.Text; if (value.Count() < 1) { value = "0"; } return dialogResult; }
public void onFire() { TextBox t = new TextBox(); foreach (object o in this.Controls) { if (o is TextBox) { TextBox t1 = (TextBox)o; this.Controls.Remove(t1); } } int k = fireX + 50; //if (k > 738) // k = 135; fireX = k; t.SetBounds(k, 170, 45, 13); t.BackColor = Color.Black; currArrowX = k; currArrowY = 170; this.Controls.Add(t); }
public MessagePrompt(string msgdefault = "",IMessagePromptDelegate myDelegate = null) { _delegate = myDelegate; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.SetBounds(10, 10, 300, 60); TextBox t = new TextBox(); t.SetBounds(5, 5, 280, 18); t.Text = msgdefault; this.Controls.Add(t); t.KeyUp += (object sender, KeyEventArgs e) => { if (e.KeyCode == Keys.Enter) { this.DialogResult = System.Windows.Forms.DialogResult.OK; _delegate.success(((TextBox)sender).Text); this.Close(); } else if (e.KeyCode == Keys.Escape) { this.Close(); } }; }
public void Edit(object sender, System.EventArgs e) { if ( Nodes.Count > 0 && SelectedNode != null && parent.LabelEdit ) { editingNode = (XmlTreeNode) SelectedNode; if ( editingNode.ConnectedXmlElement != null ) { if ( !closingHandlerAssigned ) { Form parentForm = FindForm(); parentForm.Closing += new CancelEventHandler( parent.form_Closing ); closingHandlerAssigned = true; } int height = editingNode.Bounds.Height; int width = editingNode.Bounds.Width; int left = editingNode.Bounds.Left; int top = editingNode.Bounds.Top; editingNode.ExpandAll(); if ( editingNode.ConnectedXmlElement.HasChildNodes && editingNode.ConnectedXmlElement.FirstChild.NodeType != XmlNodeType.Text ) { height = editingNode.NextNode.Bounds.Bottom - editingNode.Bounds.Top; width = Width - left; } editBox = new TextBox(); editBox.Multiline = true; editBox.BorderStyle = BorderStyle.FixedSingle; editBox.ScrollBars = ScrollBars.Both; editBox.Leave += new EventHandler( editBox_Leave ); editBox.KeyUp += new KeyEventHandler( editBox_KeyUp ); editBox.SetBounds( left, top, width, height ); editingNode.RecurseSubNodes( editingNode.Parent ); editBox.Text = editingNode.SelfAndChildren; Controls.Add( editBox ); editBox.Focus(); } } }
private void miRenameTable_Click(object sender, EventArgs e) { int i = lbxDatabase.SelectedIndex; if (i > -1 && lbxDatabase.GetSelected(i)) { Rectangle rect = lbxDatabase.GetItemRectangle(i); edit = new TextBox(); edit.BorderStyle = BorderStyle.FixedSingle; edit.SetBounds(rect.Left + 15, rect.Top, rect.Width - 15, rect.Height - 4); edit.Text = lbxDatabase.Items[i].ToString(); edit.Leave += new EventHandler(edit_Leave); edit.KeyPress += new KeyPressEventHandler(edit_KeyPress); index = i; lbxDatabase.Controls.Add(edit); } }
private void InitializeComponent() { _btnOK = new Button(); _btnCancel = new Button(); _btnUp = new Button(); _btnDown = new Button(); _btnAdd = new Button(); _btnRemove = new Button(); _txtType = new TextBox(); _tvDefinedStyles = new TreeView(); _lvAvailableStyles = new ListView(); _samplePreview = new MSHTMLHost(); _propertyBrowser = new PropertyGrid(); _cntxtMenuItem = new MenuItem(); _cntxtMenu = new ContextMenu(); GroupLabel grplblStyleList = new GroupLabel(); grplblStyleList.SetBounds(6, 5, 432, 16); grplblStyleList.Text = SR.GetString(SR.StylesEditorDialog_StyleListGroupLabel); grplblStyleList.TabStop = false; grplblStyleList.TabIndex = 0; Label lblAvailableStyles = new Label(); lblAvailableStyles.SetBounds(14, 25, 180, 16); lblAvailableStyles.Text = SR.GetString(SR.StylesEditorDialog_AvailableStylesCaption); lblAvailableStyles.TabStop = false; lblAvailableStyles.TabIndex = 1; ColumnHeader chStyleType = new System.Windows.Forms.ColumnHeader(); ColumnHeader chStyleNamespace = new System.Windows.Forms.ColumnHeader(); chStyleType.Width = 16; chStyleType.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; chStyleNamespace.Width = 16; chStyleNamespace.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; _lvAvailableStyles.SetBounds(14, 41, 180, 95); _lvAvailableStyles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; _lvAvailableStyles.MultiSelect = false; _lvAvailableStyles.HideSelection = false; _lvAvailableStyles.FullRowSelect = true; _lvAvailableStyles.View = System.Windows.Forms.View.Details; _lvAvailableStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] {chStyleType, chStyleNamespace}); _lvAvailableStyles.SelectedIndexChanged += new EventHandler(this.OnNewStyleTypeChanged); _lvAvailableStyles.DoubleClick += new EventHandler(this.OnDoubleClick); _lvAvailableStyles.Sorting = SortOrder.Ascending; _lvAvailableStyles.TabIndex = 2; _lvAvailableStyles.TabStop = true; _btnAdd.AccessibleName = SR.GetString(SR.EditableTreeList_AddName); _btnAdd.AccessibleDescription = SR.GetString(SR.EditableTreeList_AddDescription); _btnAdd.Name = SR.GetString(SR.EditableTreeList_AddName); _btnAdd.SetBounds(198, 77, 32, 25); _btnAdd.Text = SR.GetString(SR.StylesEditorDialog_AddBtnCation); _btnAdd.Click += new EventHandler(this.OnClickAddButton); _btnAdd.TabIndex = 3; _btnAdd.TabStop = true; Label lblDefinedStyles = new Label(); lblDefinedStyles.SetBounds(234, 25, 166, 16); lblDefinedStyles.Text = SR.GetString(SR.StylesEditorDialog_DefinedStylesCaption); lblDefinedStyles.TabStop = false; lblDefinedStyles.TabIndex = 4;; _tvDefinedStyles.SetBounds(234, 41, 166, 95); _tvDefinedStyles.AfterSelect += new TreeViewEventHandler(OnStylesSelected); _tvDefinedStyles.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit); _tvDefinedStyles.LabelEdit = true; _tvDefinedStyles.ShowPlusMinus = false; _tvDefinedStyles.HideSelection = false; _tvDefinedStyles.Indent = 15; _tvDefinedStyles.ShowRootLines = false; _tvDefinedStyles.ShowLines = false; _tvDefinedStyles.ContextMenu = _cntxtMenu; _tvDefinedStyles.TabIndex = 5; _tvDefinedStyles.TabStop = true; _tvDefinedStyles.KeyDown += new KeyEventHandler(OnKeyDown); _tvDefinedStyles.MouseUp += new MouseEventHandler(OnListMouseUp); _tvDefinedStyles.MouseDown += new MouseEventHandler(OnListMouseDown); _btnUp.AccessibleName = SR.GetString(SR.EditableTreeList_MoveUpName); _btnUp.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveUpDescription); _btnUp.Name = SR.GetString(SR.EditableTreeList_MoveUpName); _btnUp.SetBounds(404, 41, 28, 27); _btnUp.Click += new EventHandler(this.OnClickUpButton); _btnUp.Image = GenericUI.SortUpIcon; _btnUp.TabIndex = 6; _btnUp.TabStop = true; _btnDown.AccessibleName = SR.GetString(SR.EditableTreeList_MoveDownName); _btnDown.AccessibleDescription = SR.GetString(SR.EditableTreeList_MoveDownDescription); _btnDown.Name = SR.GetString(SR.EditableTreeList_MoveDownName); _btnDown.SetBounds(404, 72, 28, 27); _btnDown.Click += new EventHandler(this.OnClickDownButton); _btnDown.Image = GenericUI.SortDownIcon; _btnDown.TabIndex = 7; _btnDown.TabStop = true; _btnRemove.AccessibleName = SR.GetString(SR.EditableTreeList_DeleteName); _btnRemove.AccessibleDescription = SR.GetString(SR.EditableTreeList_DeleteDescription); _btnRemove.Name = SR.GetString(SR.EditableTreeList_DeleteName); _btnRemove.SetBounds(404, 109, 28, 27); _btnRemove.Click += new EventHandler(this.OnClickRemoveButton); _btnRemove.Image = GenericUI.DeleteIcon; _btnRemove.TabIndex = 8; _btnRemove.TabStop = true; GroupLabel grplblStyleProperties = new GroupLabel(); grplblStyleProperties.SetBounds(6, 145, 432, 16); grplblStyleProperties.Text = SR.GetString(SR.StylesEditorDialog_StylePropertiesGroupLabel); grplblStyleProperties.TabStop = false; grplblStyleProperties.TabIndex = 9; Label lblType = new Label(); lblType.SetBounds(14, 165, 180, 16); lblType.Text = SR.GetString(SR.StylesEditorDialog_TypeCaption); lblType.TabIndex = 10; lblType.TabStop = false; _txtType.SetBounds(14, 181, 180, 16); _txtType.ReadOnly = true; _txtType.TabIndex = 11; _txtType.TabStop = true; Label lblSample = new Label(); lblSample.SetBounds(14, 213, 180, 16); lblSample.Text = SR.GetString(SR.StylesEditorDialog_SampleCaption); lblSample.TabStop = false; lblSample.TabIndex = 12; _samplePreview.SetBounds(14, 229, 180, 76); _samplePreview.TabStop = false; _samplePreview.TabIndex = 13; Label lblProperties = new Label(); lblProperties.SetBounds(234, 165, 198, 16); lblProperties.Text = SR.GetString(SR.StylesEditorDialog_PropertiesCaption); lblProperties.TabIndex = 14; lblProperties.TabStop = false; _propertyBrowser.SetBounds(234, 181, 198, 178); _propertyBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; _propertyBrowser.ToolbarVisible = false; _propertyBrowser.HelpVisible = false; _propertyBrowser.TabIndex = 15; _propertyBrowser.TabStop = true; _propertyBrowser.PropertySort = PropertySort.Alphabetical; _propertyBrowser.PropertyValueChanged += new PropertyValueChangedEventHandler(this.OnPropertyValueChanged); _btnOK.DialogResult = DialogResult.OK; _btnOK.Location = new System.Drawing.Point(282, 370); _btnOK.Size = new System.Drawing.Size(75, 23); _btnOK.TabIndex = 16; _btnOK.Text = SR.GetString(SR.GenericDialog_OKBtnCaption); _btnOK.Click += new EventHandler(this.OnClickOKButton); _btnCancel.DialogResult = DialogResult.Cancel; _btnCancel.Location = new System.Drawing.Point(363, 370); _btnCancel.Size = new System.Drawing.Size(75, 23); _btnCancel.TabIndex = 17; _btnCancel.Text = SR.GetString(SR.GenericDialog_CancelBtnCaption); _cntxtMenuItem.Text = SR.GetString(SR.EditableTreeList_Rename); _cntxtMenu.MenuItems.Add(_cntxtMenuItem); _cntxtMenu.Popup += new EventHandler(OnPopup); _cntxtMenuItem.Click += new EventHandler(OnContextMenuItemClick); GenericUI.InitDialog(this, _styleSheet.Site); this.Text = _styleSheet.ID + " - " + SR.GetString(SR.StylesEditorDialog_Title); this.ClientSize = new Size(444, 401); this.AcceptButton = _btnOK; this.CancelButton = _btnCancel; this.Activated += new System.EventHandler(StylesEditorDialog_Activated); this.Controls.AddRange(new Control[] { grplblStyleList, lblAvailableStyles, _lvAvailableStyles, _btnAdd, lblDefinedStyles, _tvDefinedStyles, _btnUp, _btnDown, _btnRemove, grplblStyleProperties, lblType, _txtType, lblSample, _samplePreview, lblProperties, _propertyBrowser, _btnOK, _btnCancel, }); }
protected override void InitForm() { Debug.Assert(GetBaseControl() != null); _isBaseControlList = (GetBaseControl() is List); this._listDesigner = (IListDesigner)GetBaseDesigner(); Y = (_isBaseControlList ? 52 : 24); base.InitForm(); this.Text = SR.GetString(SR.ListItemsPage_Title); this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "Items.ico" ); this.Size = new Size(382, 220); if (_isBaseControlList) { _itemsAsLinksCheckBox = new CheckBox(); _itemsAsLinksCheckBox.SetBounds(4, 4, 370, 16); _itemsAsLinksCheckBox.Text = SR.GetString(SR.ListItemsPage_ItemsAsLinksCaption); _itemsAsLinksCheckBox.FlatStyle = FlatStyle.System; _itemsAsLinksCheckBox.CheckedChanged += new EventHandler(this.OnSetPageDirty); _itemsAsLinksCheckBox.TabIndex = 0; } GroupLabel grplblItemList = new GroupLabel(); grplblItemList.SetBounds(4, _isBaseControlList ? 32 : 4, 372, LabelHeight); grplblItemList.Text = SR.GetString(SR.ListItemsPage_ItemListGroupLabel); grplblItemList.TabIndex = 1; grplblItemList.TabStop = false; TreeList.TabIndex = 2; Label lblValue = new Label(); lblValue.SetBounds(X, Y, 134, LabelHeight); lblValue.Text = SR.GetString(SR.ListItemsPage_ItemValueCaption); lblValue.TabStop = false; lblValue.TabIndex = Index; Y += LabelHeight; _txtValue = new TextBox(); _txtValue.SetBounds(X, Y, 134, CmbHeight); _txtValue.TextChanged += new EventHandler(this.OnPropertyChanged); _txtValue.TabIndex = Index + 1; this.Controls.AddRange(new Control[] { grplblItemList, lblValue, _txtValue }); if (_isBaseControlList) { this.Controls.Add(_itemsAsLinksCheckBox); } else { Y += CellSpace; _ckbSelected = new CheckBox(); _ckbSelected.SetBounds(X, Y, 134, LabelHeight); _ckbSelected.FlatStyle = System.Windows.Forms.FlatStyle.System; _ckbSelected.Text = SR.GetString(SR.ListItemsPage_ItemSelectedCaption); _ckbSelected.CheckedChanged += new EventHandler(this.OnPropertyChanged); _ckbSelected.TabIndex = Index + 2; this.Controls.Add(_ckbSelected); } }
/// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// /// </para> /// </devdoc> public ThreadExceptionDialog(Exception t) { if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements) { scaledMaxWidth = DpiHelper.LogicalToDeviceUnitsX(MAXWIDTH); scaledMaxHeight = DpiHelper.LogicalToDeviceUnitsY(MAXHEIGHT); scaledPaddingWidth = DpiHelper.LogicalToDeviceUnitsX(PADDINGWIDTH); scaledPaddingHeight = DpiHelper.LogicalToDeviceUnitsY(PADDINGHEIGHT); scaledMaxTextWidth = DpiHelper.LogicalToDeviceUnitsX(MAXTEXTWIDTH); scaledMaxTextHeight = DpiHelper.LogicalToDeviceUnitsY(MAXTEXTHEIGHT); scaledButtonTopPadding = DpiHelper.LogicalToDeviceUnitsY(BUTTONTOPPADDING); scaledButtonDetailsLeftPadding = DpiHelper.LogicalToDeviceUnitsX(BUTTONDETAILS_LEFTPADDING); scaledMessageTopPadding = DpiHelper.LogicalToDeviceUnitsY(MESSAGE_TOPPADDING); scaledHeightPadding = DpiHelper.LogicalToDeviceUnitsY(HEIGHTPADDING); scaledButtonWidth = DpiHelper.LogicalToDeviceUnitsX(BUTTONWIDTH); scaledButtonHeight = DpiHelper.LogicalToDeviceUnitsY(BUTTONHEIGHT); scaledButtonAlignmentWidth = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTWIDTH); scaledButtonAlignmentPadding = DpiHelper.LogicalToDeviceUnitsX(BUTTONALIGNMENTPADDING); scaledDetailsWidthPadding = DpiHelper.LogicalToDeviceUnitsX(DETAILSWIDTHPADDING); scaledDetailsHeight = DpiHelper.LogicalToDeviceUnitsY(DETAILSHEIGHT); scaledPictureWidth = DpiHelper.LogicalToDeviceUnitsX(PICTUREWIDTH); scaledPictureHeight = DpiHelper.LogicalToDeviceUnitsY(PICTUREHEIGHT); scaledExceptionMessageVerticalPadding = DpiHelper.LogicalToDeviceUnitsY(EXCEPTIONMESSAGEVERTICALPADDING); } string messageRes; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageRes = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is SecurityException) { messageRes = "ExDlgSecurityErrorText"; } else { messageRes = "ExDlgErrorText"; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is SecurityException) { messageRes = "ExDlgSecurityContinueErrorText"; } else { messageRes = "ExDlgContinueErrorText"; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is SecurityException) { messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText)); } else { messageText = SR.GetString(messageRes, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.GetString(SR.ExDlgMsgSeperator); string sectionseparator = SR.GetString(SR.ExDlgMsgSectionSeperator); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable)); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection))); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection))); new FileIOPermission(PermissionState.Unrestricted).Assert(); try { foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.GetString(SR.NotAvailable); try { // bug 113573 -- if there's a path with an escaped value in it // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to // c:\temp\foo\bar, which is wrong, and this will fail. It doesn't look like the // assembly name class handles this properly -- even the "CodeBase" property is un-escaped // so we can't circumvent this. // if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } } finally { CodeAccessPermission.RevertAssert(); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection))); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable)); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue); if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements && (Label.UseCompatibleTextRenderingDefault == false)) { // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak)); } else { // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width)); } textSize.Height += scaledExceptionMessageVerticalPadding; g.Dispose(); if (textSize.Width < scaledMaxTextWidth) { textSize.Width = scaledMaxTextWidth; } if (textSize.Height > scaledMaxHeight) { textSize.Height = scaledMaxHeight; } int width = textSize.Width + scaledPaddingWidth; int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight; // SECREVIEW : We must get a hold of the parent to get at it's text // : to make this dialog look like the parent. // IntSecurity.GetParent.Assert(); try { Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.GetString(SR.ExDlgCaption); } else { Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text); } } finally { CodeAccessPermission.RevertAssert(); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + scaledButtonTopPadding); TopMost = true; pictureBox.Location = new Point(0, 0); pictureBox.Size = new Size(scaledPictureWidth, scaledPictureHeight); pictureBox.SizeMode = PictureBoxSizeMode.CenterImage; if (t is SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(scaledPictureWidth, scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.GetString(SR.ExDlgContinue); continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.GetString(SR.ExDlgQuit); quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.GetString(SR.ExDlgHelp); helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.GetString(SR.ExDlgShowDetails); detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = new Bitmap(this.GetType(), "down.bmp"); expandImage.MakeTransparent(); collapseImage = new Bitmap(this.GetType(), "up.bmp"); collapseImage.MakeTransparent(); if (DpiHelper.EnableThreadExceptionDialogHighDpiImprovements) { DpiHelper.ScaleBitmapLogicalToDevice(ref expandImage); DpiHelper.ScaleBitmapLogicalToDevice(ref collapseImage); } b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight); Controls.Add(b); buttonLeft += scaledButtonAlignmentWidth; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight); Controls.Add(details); }
/// <include file='doc\ThreadExceptionDialog.uex' path='docs/doc[@for="ThreadExceptionDialog.ThreadExceptionDialog"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// /// </para> /// </devdoc> public ThreadExceptionDialog(Exception t) { string messageRes; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageRes = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is SecurityException) { messageRes = "ExDlgSecurityErrorText"; } else { messageRes = "ExDlgErrorText"; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is SecurityException) { messageRes = "ExDlgSecurityContinueErrorText"; } else { messageRes = "ExDlgContinueErrorText"; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is SecurityException) { messageText = SR.GetString(messageRes, t.GetType().Name, Trim(messageText)); } else { messageText = SR.GetString(messageRes, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.GetString(SR.ExDlgMsgSeperator); string sectionseparator = SR.GetString(SR.ExDlgMsgSectionSeperator); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgHeaderSwitchable)); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgExceptionSection))); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgLoadedAssembliesSection))); new FileIOPermission(PermissionState.Unrestricted).Assert(); try { foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.GetString(SR.NotAvailable); try { // bug 113573 -- if there's a path with an escaped value in it // like c:\temp\foo%2fbar, the AssemblyName call will unescape it to // c:\temp\foo\bar, which is wrong, and this will fail. It doesn't look like the // assembly name class handles this properly -- even the "CodeBase" property is un-escaped // so we can't circumvent this. // if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } } finally { CodeAccessPermission.RevertAssert(); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.GetString(SR.ExDlgMsgJITDebuggingSection))); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterNonSwitchable)); } else { detailsTextBuilder.Append(SR.GetString(SR.ExDlgMsgFooterSwitchable)); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = Size.Ceiling(g.MeasureString(messageText, Font, MAXWIDTH - 84)); textSize.Height += 4; g.Dispose(); if (textSize.Width < 180) { textSize.Width = 180; } if (textSize.Height > MAXHEIGHT) { textSize.Height = MAXHEIGHT; } int width = textSize.Width + 84; int buttonTop = Math.Max(textSize.Height, 40) + 26; // SECREVIEW : We must get a hold of the parent to get at it's text // : to make this dialog look like the parent. // IntSecurity.GetParent.Assert(); try { Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.GetString(SR.ExDlgCaption); } else { Text = SR.GetString(SR.ExDlgCaption2, activeForm.Text); } } finally { CodeAccessPermission.RevertAssert(); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + 31); TopMost = true; pictureBox.Location = new Point(0, 0); pictureBox.Size = new Size(64, 64); pictureBox.SizeMode = PictureBoxSizeMode.CenterImage; if (t is SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(64, 8 + (40 - Math.Min(textSize.Height, 40)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.GetString(SR.ExDlgContinue); continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.GetString(SR.ExDlgQuit); quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.GetString(SR.ExDlgHelp); helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.GetString(SR.ExDlgShowDetails); detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = new Bitmap(this.GetType(), "down.bmp"); expandImage.MakeTransparent(); collapseImage = new Bitmap(this.GetType(), "up.bmp"); collapseImage.MakeTransparent(); b.SetBounds(8, buttonTop, 100, 23); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - 8 - ((buttons.Length - startIndex) * 105 - 5)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, 100, 23); Controls.Add(b); buttonLeft += 105; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(8, buttonTop + 31, width - 16, 154); Controls.Add(details); }
protected override void InitForm() { base.InitForm(); this._objectList = (ObjectList)Component; this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "Fields.ico" ); this.Size = new Size(402, 300); this.Text = SR.GetString(SR.ObjectListFieldsPage_Title); _ckbAutoGenerateFields = new CheckBox(); _cmbDataField = new UnsettableComboBox(); _ckbVisible = new CheckBox(); _txtDataFormatString = new TextBox(); _txtTitle = new TextBox(); _ckbAutoGenerateFields.SetBounds(4, 4, 396, LabelHeight); _ckbAutoGenerateFields.Text = SR.GetString(SR.ObjectListFieldsPage_AutoGenerateFieldsCaption); _ckbAutoGenerateFields.FlatStyle = FlatStyle.System; _ckbAutoGenerateFields.CheckedChanged += new EventHandler(this.OnSetPageDirty); _ckbAutoGenerateFields.TabIndex = 0; GroupLabel grplblFieldList = new GroupLabel(); grplblFieldList.SetBounds(4, 32, 392, LabelHeight); grplblFieldList.Text = SR.GetString(SR.ObjectListFieldsPage_FieldListGroupLabel); grplblFieldList.TabIndex = 1; grplblFieldList.TabStop = false; TreeList.TabIndex = 2; Label lblDataField = new Label(); lblDataField.SetBounds(X, Y, ControlWidth, LabelHeight); lblDataField.Text = SR.GetString(SR.ObjectListFieldsPage_DataFieldCaption); lblDataField.TabStop = false; lblDataField.TabIndex = Index; Y += LabelHeight; _cmbDataField.SetBounds(X, Y, ControlWidth, CmbHeight); _cmbDataField.DropDownStyle = ComboBoxStyle.DropDown; _cmbDataField.Sorted = true; _cmbDataField.NotSetText = SR.GetString(SR.ObjectListFieldsPage_NoneComboEntry); _cmbDataField.TextChanged += new EventHandler(this.OnPropertyChanged); _cmbDataField.SelectedIndexChanged += new EventHandler(this.OnPropertyChanged); _cmbDataField.TabIndex = Index + 1; Y += CellSpace; Label lblDataFormatString = new Label(); lblDataFormatString.SetBounds(X, Y, ControlWidth, LabelHeight); lblDataFormatString.Text = SR.GetString(SR.ObjectListFieldsPage_DataFormatStringCaption); lblDataFormatString.TabStop = false; lblDataFormatString.TabIndex = Index + 2; Y += LabelHeight; _txtDataFormatString.SetBounds(X, Y, ControlWidth, CmbHeight); _txtDataFormatString.TextChanged += new EventHandler(this.OnPropertyChanged); _txtDataFormatString.TabIndex = Index + 3; Y += CellSpace; Label lblTitle = new Label(); lblTitle.SetBounds(X, Y, ControlWidth, LabelHeight); lblTitle.Text = SR.GetString(SR.ObjectListFieldsPage_TitleCaption); lblTitle.TabStop = false; lblTitle.TabIndex = Index + 4; Y += LabelHeight; _txtTitle.SetBounds(X, Y, ControlWidth, CmbHeight); _txtTitle.TextChanged += new EventHandler(this.OnPropertyChanged); _txtTitle.TabIndex = Index + 5; Y += CellSpace; _ckbVisible.SetBounds(X, Y, ControlWidth, CmbHeight); _ckbVisible.FlatStyle = System.Windows.Forms.FlatStyle.System; _ckbVisible.Text = SR.GetString(SR.ObjectListFieldsPage_VisibleCaption); _ckbVisible.CheckedChanged += new EventHandler(this.OnPropertyChanged); _ckbVisible.TabIndex = Index + 6; this.Controls.AddRange(new Control[] { _ckbAutoGenerateFields, grplblFieldList, lblDataField, _cmbDataField, lblDataFormatString, _txtDataFormatString, lblTitle, _txtTitle, _ckbVisible }); }
/// <summary> /// Initializes a new instance of the <see cref='System.Windows.Forms.ThreadExceptionDialog'/> class. /// </summary> public ThreadExceptionDialog(Exception t) { if (DpiHelper.IsScalingRequirementMet) { scaledMaxWidth = LogicalToDeviceUnits(MAXWIDTH); scaledMaxHeight = LogicalToDeviceUnits(MAXHEIGHT); scaledPaddingWidth = LogicalToDeviceUnits(PADDINGWIDTH); scaledPaddingHeight = LogicalToDeviceUnits(PADDINGHEIGHT); scaledMaxTextWidth = LogicalToDeviceUnits(MAXTEXTWIDTH); scaledMaxTextHeight = LogicalToDeviceUnits(MAXTEXTHEIGHT); scaledButtonTopPadding = LogicalToDeviceUnits(BUTTONTOPPADDING); scaledButtonDetailsLeftPadding = LogicalToDeviceUnits(BUTTONDETAILS_LEFTPADDING); scaledMessageTopPadding = LogicalToDeviceUnits(MESSAGE_TOPPADDING); scaledHeightPadding = LogicalToDeviceUnits(HEIGHTPADDING); scaledButtonWidth = LogicalToDeviceUnits(BUTTONWIDTH); scaledButtonHeight = LogicalToDeviceUnits(BUTTONHEIGHT); scaledButtonAlignmentWidth = LogicalToDeviceUnits(BUTTONALIGNMENTWIDTH); scaledButtonAlignmentPadding = LogicalToDeviceUnits(BUTTONALIGNMENTPADDING); scaledDetailsWidthPadding = LogicalToDeviceUnits(DETAILSWIDTHPADDING); scaledDetailsHeight = LogicalToDeviceUnits(DETAILSHEIGHT); scaledPictureWidth = LogicalToDeviceUnits(PICTUREWIDTH); scaledPictureHeight = LogicalToDeviceUnits(PICTUREHEIGHT); scaledExceptionMessageVerticalPadding = LogicalToDeviceUnits(EXCEPTIONMESSAGEVERTICALPADDING); } string messageFormat; string messageText; Button[] buttons; bool detailAnchor = false; WarningException w = t as WarningException; if (w != null) { messageFormat = SR.ExDlgWarningText; messageText = w.Message; if (w.HelpUrl == null) { buttons = new Button[] { continueButton }; } else { buttons = new Button[] { continueButton, helpButton }; } } else { messageText = t.Message; detailAnchor = true; if (Application.AllowQuit) { if (t is System.Security.SecurityException) { messageFormat = SR.ExDlgSecurityErrorText; } else { messageFormat = SR.ExDlgErrorText; } buttons = new Button[] { detailsButton, continueButton, quitButton }; } else { if (t is System.Security.SecurityException) { messageFormat = SR.ExDlgSecurityContinueErrorText; } else { messageFormat = SR.ExDlgContinueErrorText; } buttons = new Button[] { detailsButton, continueButton }; } } if (messageText.Length == 0) { messageText = t.GetType().Name; } if (t is System.Security.SecurityException) { messageText = string.Format(messageFormat, t.GetType().Name, Trim(messageText)); } else { messageText = string.Format(messageFormat, Trim(messageText)); } StringBuilder detailsTextBuilder = new StringBuilder(); string newline = "\r\n"; string separator = SR.ExDlgMsgSeperator; string sectionseparator = SR.ExDlgMsgSectionSeperator; if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.ExDlgMsgHeaderNonSwitchable); } else { detailsTextBuilder.Append(SR.ExDlgMsgHeaderSwitchable); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgExceptionSection)); detailsTextBuilder.Append(t.ToString()); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgLoadedAssembliesSection)); foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { AssemblyName name = asm.GetName(); string fileVer = SR.NotAvailable; try { if (name.EscapedCodeBase != null && name.EscapedCodeBase.Length > 0) { Uri codeBase = new Uri(name.EscapedCodeBase); if (codeBase.Scheme == "file") { fileVer = FileVersionInfo.GetVersionInfo(NativeMethods.GetLocalPath(name.EscapedCodeBase)).FileVersion; } } } catch (System.IO.FileNotFoundException) { } detailsTextBuilder.Append(string.Format(SR.ExDlgMsgLoadedAssembliesEntry, name.Name, name.Version, fileVer, name.EscapedCodeBase)); detailsTextBuilder.Append(separator); } detailsTextBuilder.Append(string.Format(CultureInfo.CurrentCulture, sectionseparator, SR.ExDlgMsgJITDebuggingSection)); if (Application.CustomThreadExceptionHandlerAttached) { detailsTextBuilder.Append(SR.ExDlgMsgFooterNonSwitchable); } else { detailsTextBuilder.Append(SR.ExDlgMsgFooterSwitchable); } detailsTextBuilder.Append(newline); detailsTextBuilder.Append(newline); string detailsText = detailsTextBuilder.ToString(); Graphics g = message.CreateGraphicsInternal(); Size textSize = new Size(scaledMaxWidth - scaledPaddingWidth, int.MaxValue); if (DpiHelper.IsScalingRequirementMet && Label.UseCompatibleTextRenderingDefault == false) { // we need to measure string using API that matches the rendering engine - TextRenderer.MeasureText for GDI textSize = Size.Ceiling(TextRenderer.MeasureText(messageText, Font, textSize, TextFormatFlags.WordBreak)); } else { // if HighDpi improvements are not enabled, or rendering mode is GDI+, use Graphics.MeasureString textSize = Size.Ceiling(g.MeasureString(messageText, Font, textSize.Width)); } textSize.Height += scaledExceptionMessageVerticalPadding; g.Dispose(); if (textSize.Width < scaledMaxTextWidth) { textSize.Width = scaledMaxTextWidth; } if (textSize.Height > scaledMaxHeight) { textSize.Height = scaledMaxHeight; } int width = textSize.Width + scaledPaddingWidth; int buttonTop = Math.Max(textSize.Height, scaledMaxTextHeight) + scaledPaddingHeight; Form activeForm = Form.ActiveForm; if (activeForm == null || activeForm.Text.Length == 0) { Text = SR.ExDlgCaption; } else { Text = string.Format(SR.ExDlgCaption2, activeForm.Text); } AcceptButton = continueButton; CancelButton = continueButton; FormBorderStyle = FormBorderStyle.FixedDialog; MaximizeBox = false; MinimizeBox = false; StartPosition = FormStartPosition.CenterScreen; Icon = null; ClientSize = new Size(width, buttonTop + scaledButtonTopPadding); TopMost = true; pictureBox.Location = new Point(scaledPictureWidth / 8, scaledPictureHeight / 8); pictureBox.Size = new Size(scaledPictureWidth * 3 / 4, scaledPictureHeight * 3 / 4); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; if (t is System.Security.SecurityException) { pictureBox.Image = SystemIcons.Information.ToBitmap(); } else { pictureBox.Image = SystemIcons.Error.ToBitmap(); } Controls.Add(pictureBox); message.SetBounds(scaledPictureWidth, scaledMessageTopPadding + (scaledMaxTextHeight - Math.Min(textSize.Height, scaledMaxTextHeight)) / 2, textSize.Width, textSize.Height); message.Text = messageText; Controls.Add(message); continueButton.Text = SR.ExDlgContinue; continueButton.FlatStyle = FlatStyle.Standard; continueButton.DialogResult = DialogResult.Cancel; quitButton.Text = SR.ExDlgQuit; quitButton.FlatStyle = FlatStyle.Standard; quitButton.DialogResult = DialogResult.Abort; helpButton.Text = SR.ExDlgHelp; helpButton.FlatStyle = FlatStyle.Standard; helpButton.DialogResult = DialogResult.Yes; detailsButton.Text = SR.ExDlgShowDetails; detailsButton.FlatStyle = FlatStyle.Standard; detailsButton.Click += new EventHandler(DetailsClick); Button b = null; int startIndex = 0; if (detailAnchor) { b = detailsButton; expandImage = DpiHelper.GetBitmapFromIcon(GetType(), DownBitmapName); collapseImage = DpiHelper.GetBitmapFromIcon(GetType(), UpBitmapName); if (DpiHelper.IsScalingRequirementMet) { ScaleBitmapLogicalToDevice(ref expandImage); ScaleBitmapLogicalToDevice(ref collapseImage); } b.SetBounds(scaledButtonDetailsLeftPadding, buttonTop, scaledButtonWidth, scaledButtonHeight); b.Image = expandImage; b.ImageAlign = ContentAlignment.MiddleLeft; Controls.Add(b); startIndex = 1; } int buttonLeft = (width - scaledButtonDetailsLeftPadding - ((buttons.Length - startIndex) * scaledButtonAlignmentWidth - scaledButtonAlignmentPadding)); for (int i = startIndex; i < buttons.Length; i++) { b = buttons[i]; b.SetBounds(buttonLeft, buttonTop, scaledButtonWidth, scaledButtonHeight); Controls.Add(b); buttonLeft += scaledButtonAlignmentWidth; } details.Text = detailsText; details.ScrollBars = ScrollBars.Both; details.Multiline = true; details.ReadOnly = true; details.WordWrap = false; details.TabStop = false; details.AcceptsReturn = false; details.SetBounds(scaledButtonDetailsLeftPadding, buttonTop + scaledButtonTopPadding, width - scaledDetailsWidthPadding, scaledDetailsHeight); details.Visible = detailsVisible; Controls.Add(details); if (DpiHelper.IsScalingRequirementMet) { DpiChanged += ThreadExceptionDialog_DpiChanged; } }
private void mzSearchTextBox_Resize(object sender, System.EventArgs e) { utbJerarquia.SetBounds(this.Width - utbJerarquia.Width, utbJerarquia.Location.Y, utbJerarquia.Width, utbJerarquia.Height); txtNombreJerarquia.SetBounds(txtNombreJerarquia.Location.X, txtNombreJerarquia.Location.Y, this.Width - utbJerarquia.Width, txtNombreJerarquia.Height); mzCEJerarquias.SetBounds(mzCEJerarquias.Location.X, mzCEJerarquias.Location.Y, this.Width - utbJerarquia.Width, mzCEJerarquias.Height); }
public static DialogResult InputBox(string title, string promptText, ref string value) { Button buttonOk = new Button() { Text = "OK", DialogResult = DialogResult.OK, Anchor = AnchorStyles.Bottom | AnchorStyles.Right }; Button buttonCancel = new Button() { Text = "Cancel", DialogResult = DialogResult.Cancel, Anchor = AnchorStyles.Bottom | AnchorStyles.Right }; Form form = new Form() { ClientSize = new Size(396, 107), Text = title, StartPosition = FormStartPosition.CenterScreen, MinimizeBox = false, MaximizeBox = false, AcceptButton = buttonOk, CancelButton = buttonCancel, FormBorderStyle = FormBorderStyle.FixedDialog }; Label label = new Label() { AutoSize = true, Text = promptText }; TextBox textBox = new TextBox() { Text = value }; label.SetBounds(9, 20, 372, 13); textBox.SetBounds(12, 36, 372, 20); buttonOk.SetBounds(228, 72, 75, 23); buttonCancel.SetBounds(309, 72, 75, 23); textBox.Anchor = textBox.Anchor | AnchorStyles.Right; form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel }); form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); DialogResult dialogResult = form.ShowDialog(); value = textBox.Text; return dialogResult; }
private void InitForm() { this._cmbDataSource = new UnsettableComboBox(); this._cmbLabelField = new UnsettableComboBox(); this._cmbDataMember = new UnsettableComboBox(); this._xLists = new InterchangeableLists(); GroupLabel grplblData = new GroupLabel(); grplblData.SetBounds(4, 4, 392, 16); grplblData.Text = SR.GetString(SR.ObjectListGeneralPage_DataGroupLabel); grplblData.TabIndex = 0; grplblData.TabStop = false; Label lblDataSource = new Label(); lblDataSource.SetBounds(12, 24, 174, 16); lblDataSource.Text = SR.GetString(SR.ObjectListGeneralPage_DataSourceCaption); lblDataSource.TabStop = false; lblDataSource.TabIndex = 1; _cmbDataSource.SetBounds(12, 40, 154, 64); _cmbDataSource.DropDownStyle = ComboBoxStyle.DropDownList; _cmbDataSource.Sorted = true; _cmbDataSource.TabIndex = 2; _cmbDataSource.NotSetText = SR.GetString(SR.ObjectListGeneralPage_UnboundComboEntry); _cmbDataSource.SelectedIndexChanged += new EventHandler(this.OnSelChangedDataSource); Label lblDataMember = new Label(); lblDataMember.SetBounds(206, 24, 174, 16); lblDataMember.Text = SR.GetString(SR.ObjectListGeneralPage_DataMemberCaption); lblDataMember.TabStop = false; lblDataMember.TabIndex = 3; _cmbDataMember.SetBounds(206, 40, 154, 64); _cmbDataMember.DropDownStyle = ComboBoxStyle.DropDownList; _cmbDataMember.Sorted = true; _cmbDataMember.TabIndex = 4; _cmbDataMember.NotSetText = SR.GetString(SR.ObjectListGeneralPage_NoneComboEntry); _cmbDataMember.SelectedIndexChanged += new EventHandler(this.OnSelChangedDataMember); Label lblLabelField = new Label(); lblLabelField.SetBounds(12, 67, 174, 16); lblLabelField.Text = SR.GetString(SR.ObjectListGeneralPage_LabelFieldCaption); lblLabelField.TabStop = false; lblLabelField.TabIndex = 5; _cmbLabelField.SetBounds(12, 83, 154, 64); _cmbLabelField.DropDownStyle = ComboBoxStyle.DropDownList; _cmbLabelField.Sorted = true; _cmbLabelField.TabIndex = 6; _cmbLabelField.NotSetText = SR.GetString(SR.ObjectListGeneralPage_NoneComboEntry); _cmbLabelField.SelectedIndexChanged += new EventHandler(this.OnSetPageDirty); _cmbLabelField.TextChanged += new EventHandler(this.OnSetPageDirty); GroupLabel grplblTableFields = new GroupLabel(); grplblTableFields.SetBounds(4, 118, 392, 16); grplblTableFields.Text = SR.GetString(SR.ObjectListGeneralPage_TableFieldsGroupLabel); grplblTableFields.TabIndex = 9; grplblTableFields.TabStop = false; _xLists.Location = new System.Drawing.Point(4, 130); _xLists.TabIndex = 10; _xLists.OnComponentChanged += new EventHandler(this.OnSetPageDirty); _xLists.TabStop = true; _xLists.SetTitles(SR.GetString(SR.ObjectListGeneralPage_TableFieldsAvailableListLabel), SR.GetString(SR.ObjectListGeneralPage_TableFieldsSelectedListLabel)); GroupLabel grplblAppearance = new GroupLabel(); grplblAppearance.SetBounds(4, 257, 392, 16); grplblAppearance.Text = SR.GetString(SR.ObjectListGeneralPage_AppearanceGroupLabel); grplblAppearance.TabIndex = 11; grplblAppearance.TabStop = false; Label lblBackCommandText = new Label(); lblBackCommandText.SetBounds(12, 277, 174, 16); lblBackCommandText.Text = SR.GetString(SR.ObjectListGeneralPage_BackCommandTextCaption); lblBackCommandText.TabStop = false; lblBackCommandText.TabIndex = 12; _txtBackCommandText = new TextBox(); _txtBackCommandText.SetBounds(12, 293, 154, 20); _txtBackCommandText.TabIndex = 13; _txtBackCommandText.TextChanged += new EventHandler(this.OnSetPageDirty); Label lblDetailsCommandText = new Label(); lblDetailsCommandText.SetBounds(206, 277, 174, 16); lblDetailsCommandText.Text = SR.GetString(SR.ObjectListGeneralPage_DetailsCommandTextCaption); lblDetailsCommandText.TabStop = false; lblDetailsCommandText.TabIndex = 14; _txtDetailsCommandText = new TextBox(); _txtDetailsCommandText.SetBounds(206, 293, 154, 20); _txtDetailsCommandText.TabIndex = 15; _txtDetailsCommandText.TextChanged += new EventHandler(this.OnSetPageDirty); Label lblMoreText = new Label(); lblMoreText.SetBounds(12, 320, 174, 16); lblMoreText.Text = SR.GetString(SR.ObjectListGeneralPage_MoreTextCaption); lblMoreText.TabStop = false; lblMoreText.TabIndex = 16; _txtMoreText = new TextBox(); _txtMoreText.SetBounds(12, 336, 154, 20); _txtMoreText.TabIndex = 17; _txtMoreText.TextChanged += new EventHandler(this.OnSetPageDirty); GroupLabel pagingGroup = new GroupLabel(); Label itemCountLabel = new Label(); _txtItemCount = new TextBox(); Label itemsPerPageLabel = new Label(); _txtItemsPerPage = new TextBox(); pagingGroup.SetBounds(4, 371, 392, 16); pagingGroup.Text = SR.GetString(SR.ListGeneralPage_PagingGroupLabel); pagingGroup.TabIndex = 18; pagingGroup.TabStop = false; itemCountLabel.SetBounds(12, 391, 174, 16); itemCountLabel.Text = SR.GetString(SR.ListGeneralPage_ItemCountCaption); itemCountLabel.TabStop = false; itemCountLabel.TabIndex = 19; _txtItemCount.SetBounds(12, 407, 154, 20); _txtItemCount.TextChanged += new EventHandler(this.OnSetPageDirty); _txtItemCount.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _txtItemCount.TabIndex = 20; itemsPerPageLabel.SetBounds(206, 391, 174, 16); itemsPerPageLabel.Text = SR.GetString(SR.ListGeneralPage_ItemsPerPageCaption); itemsPerPageLabel.TabStop = false; itemsPerPageLabel.TabIndex = 21; _txtItemsPerPage.SetBounds(206, 407, 154, 20); _txtItemsPerPage.TextChanged += new EventHandler(this.OnSetPageDirty); _txtItemsPerPage.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _txtItemsPerPage.TabIndex = 22; this.Text = SR.GetString(SR.ObjectListGeneralPage_Title); this.Size = new Size(402, 436); this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "General.ico" ); this.Controls.AddRange(new Control[] { grplblData, lblDataSource, _cmbDataSource, lblDataMember, _cmbDataMember, lblLabelField, _cmbLabelField, grplblTableFields, _xLists, grplblAppearance, lblBackCommandText, _txtBackCommandText, lblDetailsCommandText, _txtDetailsCommandText, lblMoreText, _txtMoreText, pagingGroup, itemCountLabel, _txtItemCount, itemsPerPageLabel, _txtItemsPerPage }); }
private void InitForm() { GroupLabel grplblAppearance = new GroupLabel(); grplblAppearance.SetBounds(4, 4, 392, 16); grplblAppearance.Text = SR.GetString(SR.ObjectListGeneralPage_AppearanceGroupLabel); grplblAppearance.TabIndex = 2; grplblAppearance.TabStop = false; Label lblBackCommandText = new Label(); lblBackCommandText.SetBounds(12, 24, 174, 16); lblBackCommandText.Text = SR.GetString(SR.ObjectListGeneralPage_BackCommandTextCaption); lblBackCommandText.TabStop = false; lblBackCommandText.TabIndex = 3; _txtBackCommandText = new TextBox(); _txtBackCommandText.SetBounds(12, 40, 154, 20); _txtBackCommandText.TabIndex = 4; _txtBackCommandText.TextChanged += new EventHandler(this.OnSetPageDirty); Label lblDetailsCommandText = new Label(); lblDetailsCommandText.SetBounds(206, 24, 174, 16); lblDetailsCommandText.Text = SR.GetString(SR.ObjectListGeneralPage_DetailsCommandTextCaption); lblDetailsCommandText.TabStop = false; lblDetailsCommandText.TabIndex = 5; _txtDetailsCommandText = new TextBox(); _txtDetailsCommandText.SetBounds(206, 40, 154, 20); _txtDetailsCommandText.TabIndex = 6; _txtDetailsCommandText.TextChanged += new EventHandler(this.OnSetPageDirty); Label lblMoreText = new Label(); lblMoreText.SetBounds(12, 67, 174, 16); lblMoreText.Text = SR.GetString(SR.ObjectListGeneralPage_MoreTextCaption); lblMoreText.TabStop = false; lblMoreText.TabIndex = 7; _txtMoreText = new TextBox(); _txtMoreText.SetBounds(12, 83, 154, 20); _txtMoreText.TabIndex = 8; _txtMoreText.TextChanged += new EventHandler(this.OnSetPageDirty); GroupLabel pagingGroup = new GroupLabel(); Label itemCountLabel = new Label(); _txtItemCount = new TextBox(); Label itemsPerPageLabel = new Label(); _txtItemsPerPage = new TextBox(); pagingGroup.SetBounds(4, 118, 392, 16); pagingGroup.Text = SR.GetString(SR.ListGeneralPage_PagingGroupLabel); pagingGroup.TabIndex = 9; pagingGroup.TabStop = false; itemCountLabel.SetBounds(12, 138, 174, 16); itemCountLabel.Text = SR.GetString(SR.ListGeneralPage_ItemCountCaption); itemCountLabel.TabStop = false; itemCountLabel.TabIndex = 10; _txtItemCount.SetBounds(12, 154, 154, 20); _txtItemCount.TextChanged += new EventHandler(this.OnSetPageDirty); _txtItemCount.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _txtItemCount.TabIndex = 11; itemsPerPageLabel.SetBounds(206, 138, 174, 16); itemsPerPageLabel.Text = SR.GetString(SR.ListGeneralPage_ItemsPerPageCaption); itemsPerPageLabel.TabStop = false; itemsPerPageLabel.TabIndex = 12; _txtItemsPerPage.SetBounds(206, 154, 154, 20); _txtItemsPerPage.TextChanged += new EventHandler(this.OnSetPageDirty); _txtItemsPerPage.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _txtItemsPerPage.TabIndex = 13; this.Text = SR.GetString(SR.ObjectListGeneralPage_Title); this.Size = new Size(402, 300); this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "General.ico" ); this.Controls.AddRange(new Control[] { grplblAppearance, lblBackCommandText, _txtBackCommandText, lblDetailsCommandText, _txtDetailsCommandText, lblMoreText, _txtMoreText, pagingGroup, itemCountLabel, _txtItemCount, itemsPerPageLabel, _txtItemsPerPage }); }
protected override void InitForm() { base.InitForm(); this._objectList = (ObjectList)Component; this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "Commands.ico" ); this.Size = new Size(402, 300); this.Text = SR.GetString(SR.ObjectListCommandsPage_Title); GroupLabel grplblCommandList = new GroupLabel(); grplblCommandList.SetBounds(4, 4, 392, LabelHeight); grplblCommandList.Text = SR.GetString(SR.ObjectListCommandsPage_CommandListGroupLabel); grplblCommandList.TabIndex = 0; grplblCommandList.TabStop = false; TreeList.TabIndex = 1; Label lblText = new Label(); lblText.SetBounds(X, Y, ControlWidth, LabelHeight); lblText.Text = SR.GetString(SR.ObjectListCommandsPage_TextCaption); lblText.TabStop = false; lblText.TabIndex = TabIndex; _txtText = new TextBox(); Y += LabelHeight; _txtText.SetBounds(X, Y, ControlWidth, CmbHeight); _txtText.TextChanged += new EventHandler(this.OnPropertyChanged); _txtText.TabIndex = TabIndex + 1; GroupLabel grplblData = new GroupLabel(); grplblData.SetBounds(4, 238, 392, LabelHeight); grplblData.Text = SR.GetString(SR.ObjectListCommandsPage_DataGroupLabel); grplblData.TabIndex = TabIndex + 2; grplblData.TabStop = false; Label lblDefaultCommand = new Label(); lblDefaultCommand.SetBounds(8, 260, 182, LabelHeight); lblDefaultCommand.Text = SR.GetString(SR.ObjectListCommandsPage_DefaultCommandCaption); lblDefaultCommand.TabStop = false; lblDefaultCommand.TabIndex = TabIndex + 3; _cmbDefaultCommand = new ComboBox(); _cmbDefaultCommand.SetBounds(8, 276, 182, 64); _cmbDefaultCommand.DropDownStyle = ComboBoxStyle.DropDown; _cmbDefaultCommand.Sorted = true; _cmbDefaultCommand.TabIndex = TabIndex + 4; _cmbDefaultCommand.SelectedIndexChanged += new EventHandler(this.OnSetPageDirty); _cmbDefaultCommand.TextChanged += new EventHandler(this.OnSetPageDirty); this.Controls.AddRange(new Control[] { grplblCommandList, lblText, _txtText, grplblData, lblDefaultCommand, _cmbDefaultCommand }); }
/// <summary> /// Initializes the UI of the form. /// </summary> private void InitForm() { Debug.Assert(GetBaseControl() != null); _isBaseControlList = (GetBaseControl() is List); // SelectionList otherwise. GroupLabel appearanceGroup = new GroupLabel(); GroupLabel pagingGroup = null; Label itemCountLabel = null; Label itemsPerPageLabel = null; Label rowsLabel = null; Label decorationLabel = null; Label selectTypeLabel = null; if (_isBaseControlList) { pagingGroup = new GroupLabel(); itemCountLabel = new Label(); _itemCountTextBox = new TextBox(); itemsPerPageLabel = new Label(); _itemsPerPageTextBox = new TextBox(); decorationLabel = new Label(); _decorationCombo = new ComboBox(); } else { rowsLabel = new Label(); _rowsTextBox = new TextBox(); selectTypeLabel = new Label(); _selectTypeCombo = new ComboBox(); } appearanceGroup.SetBounds(4, 4, 372, 16); appearanceGroup.Text = SR.GetString(SR.ListGeneralPage_AppearanceGroupLabel); appearanceGroup.TabIndex = 0; appearanceGroup.TabStop = false; if (_isBaseControlList) { decorationLabel.SetBounds(8, 24, 200, 16); decorationLabel.Text = SR.GetString(SR.ListGeneralPage_DecorationCaption); decorationLabel.TabStop = false; decorationLabel.TabIndex = 1; _decorationCombo.SetBounds(8, 40, 161, 21); _decorationCombo.DropDownStyle = ComboBoxStyle.DropDownList; _decorationCombo.SelectedIndexChanged += new EventHandler(this.OnSetPageDirty); _decorationCombo.Items.AddRange(new object[] { SR.GetString(SR.ListGeneralPage_DecorationNone), SR.GetString(SR.ListGeneralPage_DecorationBulleted), SR.GetString(SR.ListGeneralPage_DecorationNumbered) }); _decorationCombo.TabIndex = 2; pagingGroup.SetBounds(4, 77, 372, 16); pagingGroup.Text = SR.GetString(SR.ListGeneralPage_PagingGroupLabel); pagingGroup.TabIndex = 3; pagingGroup.TabStop = false; itemCountLabel.SetBounds(8, 97, 161, 16); itemCountLabel.Text = SR.GetString(SR.ListGeneralPage_ItemCountCaption); itemCountLabel.TabStop = false; itemCountLabel.TabIndex = 4; _itemCountTextBox.SetBounds(8, 113, 161, 20); _itemCountTextBox.TextChanged += new EventHandler(this.OnSetPageDirty); _itemCountTextBox.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _itemCountTextBox.TabIndex = 5; itemsPerPageLabel.SetBounds(211, 97, 161, 16); itemsPerPageLabel.Text = SR.GetString(SR.ListGeneralPage_ItemsPerPageCaption); itemsPerPageLabel.TabStop = false; itemsPerPageLabel.TabIndex = 6; _itemsPerPageTextBox.SetBounds(211, 113, 161, 20); _itemsPerPageTextBox.TextChanged += new EventHandler(this.OnSetPageDirty); _itemsPerPageTextBox.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _itemsPerPageTextBox.TabIndex = 7; } else { selectTypeLabel.SetBounds(8, 24, 161, 16); selectTypeLabel.Text = SR.GetString(SR.ListGeneralPage_SelectTypeCaption); selectTypeLabel.TabStop = false; selectTypeLabel.TabIndex = 1; _selectTypeCombo.SetBounds(8, 40, 161, 21); _selectTypeCombo.DropDownStyle = ComboBoxStyle.DropDownList; _selectTypeCombo.SelectedIndexChanged += new EventHandler(this.OnSetPageDirty); _selectTypeCombo.Items.AddRange(new object[] { SR.GetString(SR.ListGeneralPage_SelectTypeDropDown), SR.GetString(SR.ListGeneralPage_SelectTypeListBox), SR.GetString(SR.ListGeneralPage_SelectTypeRadio), SR.GetString(SR.ListGeneralPage_SelectTypeMultiSelectListBox), SR.GetString(SR.ListGeneralPage_SelectTypeCheckBox) }); _selectTypeCombo.TabIndex = 2; rowsLabel.SetBounds(211, 24, 161, 16); rowsLabel.Text = SR.GetString(SR.ListGeneralPage_RowsCaption); rowsLabel.TabStop = false; rowsLabel.TabIndex = 3; _rowsTextBox.SetBounds(211, 40, 161, 20); _rowsTextBox.TextChanged += new EventHandler(this.OnSetPageDirty); _rowsTextBox.KeyPress += new KeyPressEventHandler(this.OnKeyPressNumberTextBox); _rowsTextBox.TabIndex = 4; } this.Text = SR.GetString(SR.ListGeneralPage_Title); this.Size = new Size(382, 270); this.CommitOnDeactivate = true; this.Icon = new Icon( typeof(System.Web.UI.Design.MobileControls.MobileControlDesigner), "General.ico" ); this.Controls.AddRange(new Control[] { appearanceGroup }); if (_isBaseControlList) { this.Controls.AddRange(new Control[] { _itemsPerPageTextBox, itemsPerPageLabel, _itemCountTextBox, itemCountLabel, pagingGroup, decorationLabel, _decorationCombo }); } else { this.Controls.AddRange(new Control[] { _rowsTextBox, rowsLabel, selectTypeLabel, _selectTypeCombo }); } }
/// <include file='doc\DataGridPagingPage.uex' path='docs/doc[@for="DataGridPagingPage.InitForm"]/*' /> /// <devdoc> /// Creates the UI of the page. /// </devdoc> private void InitForm() { GroupLabel pagingGroup = new GroupLabel(); this.allowPagingCheck = new CheckBox(); this.allowCustomPagingCheck = new CheckBox(); Label pageSizeLabel = new Label(); this.pageSizeEdit = new NumberEdit(); Label miscLabel = new Label(); GroupLabel navigationGroup = new GroupLabel(); this.visibleCheck = new CheckBox(); Label pagingPosLabel = new Label(); this.posCombo = new ComboBox(); Label pagingModeLabel = new Label(); this.modeCombo = new ComboBox(); Label nextPageLabel = new Label(); this.nextPageTextEdit = new TextBox(); Label prevPageLabel = new Label(); this.prevPageTextEdit = new TextBox(); Label pageButtonCountLabel = new Label(); this.pageButtonCountEdit = new NumberEdit(); pagingGroup.SetBounds(4, 4, 431, 16); pagingGroup.Text = SR.GetString(SR.DGPg_PagingGroup); pagingGroup.TabStop = false; pagingGroup.TabIndex = 0; allowPagingCheck.SetBounds(12, 24, 180, 16); allowPagingCheck.Text = SR.GetString(SR.DGPg_AllowPaging); allowPagingCheck.TextAlign = ContentAlignment.MiddleLeft; allowPagingCheck.TabIndex = 1; allowPagingCheck.FlatStyle = FlatStyle.System; allowPagingCheck.CheckedChanged += new EventHandler(this.OnCheckChangedAllowPaging); allowCustomPagingCheck.SetBounds(220, 24, 180, 16); allowCustomPagingCheck.Text = SR.GetString(SR.DGPg_AllowCustomPaging); allowCustomPagingCheck.TextAlign = ContentAlignment.MiddleLeft; allowCustomPagingCheck.TabIndex = 2; allowCustomPagingCheck.FlatStyle = FlatStyle.System; allowCustomPagingCheck.CheckedChanged += new EventHandler(this.OnCheckChangedAllowCustomPaging); pageSizeLabel.SetBounds(12, 50, 100, 14); pageSizeLabel.Text = SR.GetString(SR.DGPg_PageSize); pageSizeLabel.TabStop = false; pageSizeLabel.TabIndex = 3; pageSizeEdit.SetBounds(112, 46, 40, 24); pageSizeEdit.TabIndex = 4; pageSizeEdit.AllowDecimal = false; pageSizeEdit.AllowNegative = false; pageSizeEdit.TextChanged += new EventHandler(this.OnTextChangedPageSize); miscLabel.SetBounds(158, 50, 80, 14); miscLabel.Text = SR.GetString(SR.DGPg_Rows); miscLabel.TabStop = false; miscLabel.TabIndex = 5; navigationGroup.SetBounds(4, 78, 431, 14); navigationGroup.Text = SR.GetString(SR.DGPg_NavigationGroup); navigationGroup.TabStop = false; navigationGroup.TabIndex = 6; visibleCheck.SetBounds(12, 100, 260, 16); visibleCheck.Text = SR.GetString(SR.DGPg_Visible); visibleCheck.TextAlign = ContentAlignment.MiddleLeft; visibleCheck.TabIndex = 7; visibleCheck.FlatStyle = FlatStyle.System; visibleCheck.CheckedChanged += new EventHandler(this.OnCheckChangedVisible); pagingPosLabel.SetBounds(12, 122, 150, 14); pagingPosLabel.Text = SR.GetString(SR.DGPg_Position); pagingPosLabel.TabStop = false; pagingPosLabel.TabIndex = 8; posCombo.SetBounds(12, 138, 144, 21); posCombo.TabIndex = 9; posCombo.DropDownStyle = ComboBoxStyle.DropDownList; posCombo.Items.AddRange(new object[] { SR.GetString(SR.DGPg_Pos_Top), SR.GetString(SR.DGPg_Pos_Bottom), SR.GetString(SR.DGPg_Pos_TopBottom) }); posCombo.SelectedIndexChanged += new EventHandler(this.OnPagerChanged); pagingModeLabel.SetBounds(12, 166, 150, 14); pagingModeLabel.Text = SR.GetString(SR.DGPg_Mode); pagingModeLabel.TabStop = false; pagingModeLabel.TabIndex = 10; modeCombo.SetBounds(12, 182, 144, 64); modeCombo.TabIndex = 11; modeCombo.DropDownStyle = ComboBoxStyle.DropDownList; modeCombo.Items.AddRange(new object[] { SR.GetString(SR.DGPg_Mode_Buttons), SR.GetString(SR.DGPg_Mode_Numbers) }); modeCombo.SelectedIndexChanged += new EventHandler(this.OnPagerChanged); nextPageLabel.SetBounds(12, 210, 200, 14); nextPageLabel.Text = SR.GetString(SR.DGPg_NextPage); nextPageLabel.TabStop = false; nextPageLabel.TabIndex = 12; nextPageTextEdit.SetBounds(12, 226, 144, 24); nextPageTextEdit.TabIndex = 13; nextPageTextEdit.TextChanged += new EventHandler(this.OnPagerChanged); prevPageLabel.SetBounds(220, 210, 200, 14); prevPageLabel.Text = SR.GetString(SR.DGPg_PrevPage); prevPageLabel.TabStop = false; prevPageLabel.TabIndex = 14; prevPageTextEdit.SetBounds(220, 226, 140, 24); prevPageTextEdit.TabIndex = 15; prevPageTextEdit.TextChanged += new EventHandler(this.OnPagerChanged); pageButtonCountLabel.SetBounds(12, 254, 200, 14); pageButtonCountLabel.Text = SR.GetString(SR.DGPg_ButtonCount); pageButtonCountLabel.TabStop = false; pageButtonCountLabel.TabIndex = 16; pageButtonCountEdit.SetBounds(12, 270, 40, 24); pageButtonCountEdit.TabIndex = 17; pageButtonCountEdit.AllowDecimal = false; pageButtonCountEdit.AllowNegative = false; pageButtonCountEdit.TextChanged += new EventHandler(this.OnPagerChanged); this.Text = SR.GetString(SR.DGPg_Text); this.Size = new Size(464, 300); this.CommitOnDeactivate = true; this.Icon = new Icon(this.GetType(), "DataGridPagingPage.ico"); this.Controls.Clear(); this.Controls.AddRange(new Control[] { pageButtonCountEdit, pageButtonCountLabel, prevPageTextEdit, prevPageLabel, nextPageTextEdit, nextPageLabel, modeCombo, pagingModeLabel, posCombo, pagingPosLabel, visibleCheck, navigationGroup, miscLabel, pageSizeEdit, pageSizeLabel, allowCustomPagingCheck, allowPagingCheck, pagingGroup }); }
private void InitializeComponent() { _btnOK = new Button(); _btnCancel = new Button(); _btnHelp = new Button(); _btnUp = new Button(); _btnDown = new Button(); _btnAdd = new Button(); _btnRemove = new Button(); _txtType = new TextBox(); _tvDefinedStyles = new TreeView(); _lvAvailableStyles = new ListView(); _samplePreview = new MSHTMLHost(); _propertyBrowser = new PropertyGrid(); _cntxtMenuItem = new MenuItem(); _cntxtMenu = new ContextMenu(); GroupLabel grplblStyleList = new GroupLabel(); grplblStyleList.SetBounds(6, 5, 432, 16); grplblStyleList.Text = SR.GetString(SR.StylesEditorDialog_StyleListGroupLabel); grplblStyleList.TabStop = false; grplblStyleList.TabIndex = 0; Label lblAvailableStyles = new Label(); lblAvailableStyles.SetBounds(14, 25, 180, 16); lblAvailableStyles.Text = SR.GetString(SR.StylesEditorDialog_AvailableStylesCaption); lblAvailableStyles.TabStop = false; lblAvailableStyles.TabIndex = 1; ColumnHeader chStyleType = new System.Windows.Forms.ColumnHeader(); ColumnHeader chStyleNamespace = new System.Windows.Forms.ColumnHeader(); chStyleType.Width = 16; chStyleType.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; chStyleNamespace.Width = 16; chStyleNamespace.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; _lvAvailableStyles.SetBounds(14, 41, 180, 95); _lvAvailableStyles.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; _lvAvailableStyles.MultiSelect = false; _lvAvailableStyles.HideSelection = false; _lvAvailableStyles.FullRowSelect = true; _lvAvailableStyles.View = System.Windows.Forms.View.Details; _lvAvailableStyles.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] { chStyleType, chStyleNamespace }); _lvAvailableStyles.SelectedIndexChanged += new EventHandler(this.OnNewStyleTypeChanged); _lvAvailableStyles.DoubleClick += new EventHandler(this.OnDoubleClick); _lvAvailableStyles.Sorting = SortOrder.Ascending; _lvAvailableStyles.TabIndex = 2; _lvAvailableStyles.TabStop = true; _btnAdd.SetBounds(198, 77, 32, 25); _btnAdd.Text = SR.GetString(SR.StylesEditorDialog_AddBtnCation); _btnAdd.Click += new EventHandler(this.OnClickAddButton); _btnAdd.TabIndex = 3; _btnAdd.TabStop = true; Label lblDefinedStyles = new Label(); lblDefinedStyles.SetBounds(234, 25, 166, 16); lblDefinedStyles.Text = SR.GetString(SR.StylesEditorDialog_DefinedStylesCaption); lblDefinedStyles.TabStop = false; lblDefinedStyles.TabIndex = 4;; _tvDefinedStyles.SetBounds(234, 41, 166, 95); _tvDefinedStyles.AfterSelect += new TreeViewEventHandler(OnStylesSelected); _tvDefinedStyles.AfterLabelEdit += new NodeLabelEditEventHandler(OnAfterLabelEdit); _tvDefinedStyles.LabelEdit = true; _tvDefinedStyles.ShowPlusMinus = false; _tvDefinedStyles.HideSelection = false; _tvDefinedStyles.Indent = 15; _tvDefinedStyles.ShowRootLines = false; _tvDefinedStyles.ShowLines = false; _tvDefinedStyles.ContextMenu = _cntxtMenu; _tvDefinedStyles.TabIndex = 5; _tvDefinedStyles.TabStop = true; _tvDefinedStyles.KeyDown += new KeyEventHandler(OnKeyDown); _tvDefinedStyles.MouseUp += new MouseEventHandler(OnListMouseUp); _tvDefinedStyles.MouseDown += new MouseEventHandler(OnListMouseDown); _btnUp.SetBounds(404, 41, 28, 27); _btnUp.Click += new EventHandler(this.OnClickUpButton); _btnUp.Image = GenericUI.SortUpIcon; _btnUp.TabIndex = 6; _btnUp.TabStop = true; _btnDown.SetBounds(404, 72, 28, 27); _btnDown.Click += new EventHandler(this.OnClickDownButton); _btnDown.Image = GenericUI.SortDownIcon; _btnDown.TabIndex = 7; _btnDown.TabStop = true; _btnRemove.SetBounds(404, 109, 28, 27); _btnRemove.Click += new EventHandler(this.OnClickRemoveButton); _btnRemove.Image = GenericUI.DeleteIcon; _btnRemove.TabIndex = 8; _btnRemove.TabStop = true; GroupLabel grplblStyleProperties = new GroupLabel(); grplblStyleProperties.SetBounds(6, 145, 432, 16); grplblStyleProperties.Text = SR.GetString(SR.StylesEditorDialog_StylePropertiesGroupLabel); grplblStyleProperties.TabStop = false; grplblStyleProperties.TabIndex = 9; Label lblType = new Label(); lblType.SetBounds(14, 165, 180, 16); lblType.Text = SR.GetString(SR.StylesEditorDialog_TypeCaption); lblType.TabIndex = 10; lblType.TabStop = false; _txtType.SetBounds(14, 181, 180, 16); _txtType.ReadOnly = true; _txtType.TabIndex = 11; _txtType.TabStop = true; Label lblSample = new Label(); lblSample.SetBounds(14, 213, 180, 16); lblSample.Text = SR.GetString(SR.StylesEditorDialog_SampleCaption); lblSample.TabStop = false; lblSample.TabIndex = 12; _samplePreview.SetBounds(14, 229, 180, 76); _samplePreview.TabStop = false; _samplePreview.TabIndex = 13; Label lblProperties = new Label(); lblProperties.SetBounds(234, 165, 198, 16); lblProperties.Text = SR.GetString(SR.StylesEditorDialog_PropertiesCaption); lblProperties.TabIndex = 14; lblProperties.TabStop = false; _propertyBrowser.SetBounds(234, 181, 198, 178); _propertyBrowser.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; _propertyBrowser.ToolbarVisible = false; _propertyBrowser.HelpVisible = false; _propertyBrowser.TabIndex = 15; _propertyBrowser.TabStop = true; _propertyBrowser.PropertySort = PropertySort.Alphabetical; _propertyBrowser.PropertyValueChanged += new PropertyValueChangedEventHandler(this.OnPropertyValueChanged); _btnOK.DialogResult = DialogResult.OK; _btnOK.Location = new System.Drawing.Point(201, 370); _btnOK.Size = new System.Drawing.Size(75, 23); _btnOK.TabIndex = 16; _btnOK.Text = SR.GetString(SR.GenericDialog_OKBtnCaption); _btnOK.Click += new EventHandler(this.OnClickOKButton); _btnCancel.DialogResult = DialogResult.Cancel; _btnCancel.Location = new System.Drawing.Point(282, 370); _btnCancel.Size = new System.Drawing.Size(75, 23); _btnCancel.TabIndex = 17; _btnCancel.Text = SR.GetString(SR.GenericDialog_CancelBtnCaption); _btnHelp.Click += new EventHandler(this.OnClickHelpButton); _btnHelp.Location = new System.Drawing.Point(363, 370); _btnHelp.Size = new System.Drawing.Size(75, 23); _btnHelp.TabIndex = 18; _btnHelp.Text = SR.GetString(SR.GenericDialog_HelpBtnCaption); _cntxtMenuItem.Text = SR.GetString(SR.EditableTreeList_Rename); _cntxtMenu.MenuItems.Add(_cntxtMenuItem); _cntxtMenu.Popup += new EventHandler(OnPopup); _cntxtMenuItem.Click += new EventHandler(OnContextMenuItemClick); GenericUI.InitDialog(this, _styleSheet.Site); this.Text = _styleSheet.ID + " - " + SR.GetString(SR.StylesEditorDialog_Title); this.ClientSize = new Size(444, 401); this.AcceptButton = _btnOK; this.CancelButton = _btnCancel; this.Activated += new System.EventHandler(StylesEditorDialog_Activated); this.HelpRequested += new HelpEventHandler(this.OnHelpRequested); this.Controls.AddRange(new Control[] { grplblStyleList, lblAvailableStyles, _lvAvailableStyles, _btnAdd, lblDefinedStyles, _tvDefinedStyles, _btnUp, _btnDown, _btnRemove, grplblStyleProperties, lblType, _txtType, lblSample, _samplePreview, lblProperties, _propertyBrowser, _btnOK, _btnCancel, _btnHelp }); }
static DialogResult ShowUI(string title, string promptText, string value, bool password = false) { Form form = new Form(); System.Windows.Forms.Label label = new System.Windows.Forms.Label(); TextBox textBox = new TextBox(); if (password) textBox.UseSystemPasswordChar = true; Controls.MyButton buttonOk = new Controls.MyButton(); Controls.MyButton buttonCancel = new Controls.MyButton(); //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainV2)); //form.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); form.TopMost = true; form.TopLevel = true; form.Text = title; label.Text = promptText; textBox.Text = value; textBox.TextChanged +=textBox_TextChanged; buttonOk.Text = "OK"; buttonCancel.Text = "Cancel"; buttonOk.DialogResult = DialogResult.OK; buttonCancel.DialogResult = DialogResult.Cancel; label.SetBounds(9, 10, 372, 26); textBox.SetBounds(12, 46, 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.FixedSingle; form.StartPosition = FormStartPosition.CenterScreen; form.MinimizeBox = false; form.MaximizeBox = false; form.AcceptButton = buttonOk; form.CancelButton = buttonCancel; if (ApplyTheme != null) ApplyTheme(form); DialogResult dialogResult = DialogResult.Cancel; Console.WriteLine("Input Box " + System.Threading.Thread.CurrentThread.Name); Application.DoEvents(); form.ShowDialog(); Console.WriteLine("Input Box 2 " + System.Threading.Thread.CurrentThread.Name); dialogResult = form.DialogResult; if (dialogResult == DialogResult.OK) { value = textBox.Text; InputBox.value = value; } form.Dispose(); TextChanged = null; form = null; return dialogResult; }