void Obj_OnNameChanging(object sender, EventArgs e) { EventArgNameChange en = (EventArgNameChange)e; TreeNode nd = this.Parent; if (nd != null) { for (int i = 0; i < nd.Nodes.Count; i++) { if (i != this.Index) { if (string.CompareOrdinal(nd.Nodes[i].Text, en.NewName) == 0) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "The component name is already used", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } if (!en.Cancel) { NameCreation nc = new NameCreation(); if (!nc.IsValidName(en.NewName)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } if (!en.Cancel) { string sn = en.NewName.ToLowerInvariant(); if (WebPageCompilerUtility.IsReservedPhpWord(sn)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name. It is a reserved word.", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } }
public bool ParameterNameValid(string name) { NameCreation nc = new NameCreation(); return(nc.IsValidName(name)); }