46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
|
|
namespace KMBIM
|
|
{
|
|
public partial class GetRadius : Form
|
|
{
|
|
public GetRadius()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void GetRadius_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Escape)
|
|
{
|
|
//this.Close();
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
else if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.DialogResult = DialogResult.OK;
|
|
}
|
|
}
|
|
|
|
private void GetRadius_Load(object sender, EventArgs e)
|
|
{
|
|
this.KeyPreview = true;
|
|
}
|
|
|
|
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
int keyCode = (int)e.KeyChar;
|
|
if ((keyCode < 48 || keyCode > 57) && keyCode != 8 && keyCode != 46)
|
|
e.Handled = true;
|
|
|
|
if (keyCode == 46)
|
|
{
|
|
if (string.IsNullOrEmpty(textBox1.Text) || textBox1.Text.Contains('.') == true)
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|