private void ConfirmButton_Click(object sender, EventArgs e)
{
if (editValue == null)
{
string name = NameBox.Text;
if (!Regex.Match(name, @"^[a-zA-Z_][a-zA-Z_0-9]*$").Success
|| InvokeLua.util_iskeyword(name))
{
MessageBox.Show("Invalid name. Please choose another.");
NameBox.Focus();
return;
}
if (parentTable.HasField(name))
{
MessageBox.Show("This variable name is already in use. Please choose another.");
NameBox.Focus();
return;
}
VisualLuaValue newValue;
switch (creatingType)
{
case VisualLuaValueType.String:
VisualLuaStringValue newString = new VisualLuaStringValue(component, parentTable.Namespace);
newString.Value = InitialValueBox.Text;
newValue = newString;
break;
default:
throw new Exception("Unsupported type");
}
newValue.Name = name;
parentTable[name] = newValue;
parentTable.RefreshChildren();
this.Close();
return;
}
}