Files
2025-07-14 12:03:59 +02:00

49 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MaterialSkin.Controls;
namespace MaterialSkin.Core.Controls
{
public partial class MaterialInputBox : MaterialForm
{
private MaterialInputBox()
{
InitializeComponent();
}
public static DialogResult Prompt(string title, string defaultValue, out string result, bool masked = false)
{
MaterialInputBox box = new MaterialInputBox {label1 = {Text = title}, textBox1 = {Text = defaultValue}};
if (masked) box.textBox1.PasswordChar = '*';
var res= box.ShowDialog();
result = box.textBox1.Text;
return res;
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
DialogResult = DialogResult.OK;
}
}
private void materialRaisedButton2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void materialRaisedButton1_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
}
}