private static InputFormResult GetResult(InputForm currForm) { if (currForm.bCanceled) { return(new InputFormResult(DialogResult.Cancel)); } else { return(new InputFormResult(DialogResult.OK, currForm.txtInput.Text)); } }
private static InputFormResult GetResult(InputForm currForm) { if (currForm.bCanceled) { return new InputFormResult(DialogResult.Cancel); } else { return new InputFormResult(DialogResult.OK, currForm.txtInput.Text); } }
public static InputFormResult ShowModal(System.Windows.Forms.IWin32Window owner, string caption, string title, string defaultText) { InputForm theForm = new InputForm(); theForm.InitializeComponent(); theForm.lblCaption.Text = caption; theForm.Text = title; theForm.txtInput.Text = defaultText; theForm.ShowDialog(owner); return GetResult(theForm); }
public static InputFormResult ShowModal(System.Windows.Forms.IWin32Window owner, string caption, string title, string defaultText) { InputForm theForm = new InputForm(); theForm.InitializeComponent(); theForm.lblCaption.Text = caption; theForm.Text = title; theForm.txtInput.Text = defaultText; theForm.ShowDialog(owner); return(GetResult(theForm)); }
private static void SizeCaption(InputForm currForm, string caption) { // Work out how big the text will be. SizeF layoutSize = new SizeF (currForm.lblCaption.Width, SystemInformation.WorkingArea.Height); System.Drawing.Graphics grph = System.Drawing.Graphics.FromHwnd(currForm.Handle); SizeF stringSize = grph.MeasureString(caption, currForm.lblCaption.Font, layoutSize); // Resize the caption label and other controls appropriately. if ( ((int) stringSize.Height) > currForm.lblCaption.Height) { currForm.SuspendLayout(); currForm.lblCaption.Height = ((int) stringSize.Height) + 4; currForm.txtInput.Top = currForm.lblCaption.Bottom + 12; currForm.btnCancel.Top = currForm.txtInput.Bottom + 8; currForm.btnOK.Top = currForm.btnCancel.Top; currForm.Height = currForm.btnOK.Bottom + (30); currForm.ResumeLayout(true); } }
private static void SizeCaption(InputForm currForm, string caption) { // Work out how big the text will be. SizeF layoutSize = new SizeF(currForm.lblCaption.Width, SystemInformation.WorkingArea.Height); System.Drawing.Graphics grph = System.Drawing.Graphics.FromHwnd(currForm.Handle); SizeF stringSize = grph.MeasureString(caption, currForm.lblCaption.Font, layoutSize); // Resize the caption label and other controls appropriately. if (((int)stringSize.Height) > currForm.lblCaption.Height) { currForm.SuspendLayout(); currForm.lblCaption.Height = ((int)stringSize.Height) + 4; currForm.txtInput.Top = currForm.lblCaption.Bottom + 12; currForm.btnCancel.Top = currForm.txtInput.Bottom + 8; currForm.btnOK.Top = currForm.btnCancel.Top; currForm.Height = currForm.btnOK.Bottom + (30); currForm.ResumeLayout(true); } }