2019-04-21 17:53:56 +00:00
|
|
|
using System;
|
2020-08-29 08:56:25 +00:00
|
|
|
using System.ComponentModel;
|
2019-04-21 17:53:56 +00:00
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
namespace RyzStudio.Windows.ThemedForms
|
|
|
|
{
|
2019-04-22 11:40:29 +00:00
|
|
|
public partial class TextBoxForm : System.Windows.Forms.Form
|
2019-04-21 17:53:56 +00:00
|
|
|
{
|
2020-08-29 08:56:25 +00:00
|
|
|
protected bool returnValue = false;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
public TextBoxForm(string title, string labelText, string defaultValue)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
textBox1.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Text = title;
|
|
|
|
label2.Text = labelText;
|
|
|
|
textBox1.Text = defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextBoxForm(string title, string labelText, string defaultValue, bool password)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
textBox1.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Text = title;
|
|
|
|
label2.Text = labelText;
|
|
|
|
textBox1.Text = defaultValue;
|
|
|
|
textBox1.UseSystemPasswordChar = password;
|
2019-04-22 14:51:03 +00:00
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public TextBoxForm(string title, string labelText)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
textBox1.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Text = title;
|
|
|
|
label2.Text = labelText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextBoxForm(string title, string labelText, bool password)
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
2019-04-22 14:51:03 +00:00
|
|
|
textBox1.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
textBox1.InnerTextBox.PreviewKeyDown += textBox1_PreviewKeyDown;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Text = title;
|
|
|
|
label2.Text = labelText;
|
|
|
|
textBox1.UseSystemPasswordChar = password;
|
|
|
|
}
|
|
|
|
|
2020-08-29 08:56:25 +00:00
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnClosing(e);
|
|
|
|
|
|
|
|
if (!returnValue)
|
|
|
|
{
|
|
|
|
textBox1.Text = string.Empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
|
|
{
|
2020-08-29 08:56:25 +00:00
|
|
|
returnValue = true;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void textBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
|
|
|
{
|
|
|
|
switch (e.KeyCode)
|
|
|
|
{
|
|
|
|
case Keys.Escape:
|
2019-04-23 19:15:17 +00:00
|
|
|
textBox1.Text = string.Empty;
|
2019-04-21 17:53:56 +00:00
|
|
|
this.Close();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public new string ShowDialog()
|
|
|
|
{
|
2020-08-29 08:56:25 +00:00
|
|
|
returnValue = false;
|
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
base.ShowDialog();
|
|
|
|
|
|
|
|
return textBox1.Text;
|
|
|
|
}
|
2020-08-29 08:56:25 +00:00
|
|
|
|
2019-04-21 17:53:56 +00:00
|
|
|
}
|
|
|
|
}
|