public void SetName(IComponent comp, string newName) { // trim any spaces off of the name newName = newName.Trim(); SampleDesignSite cs = (SampleDesignSite)comp.Site; if (newName.Equals(cs.Name)) { return; } // If the rename is only a case change if (string.Compare(newName, cs.Name, true) != 0) { Host.CheckName(newName); } // Find the name property provided by us. // ((IComponentChangeService)Host).OnComponentChanging(comp, TypeDescriptor.GetProperties(comp, designerNameAttribute)["Name"]); Host.Sites.Remove(cs.Name); Host.Sites[newName] = cs; string oldName = cs.Name; cs.SetName(newName); Host.OnComponentRename(new ComponentRenameEventArgs(comp, oldName, newName)); ((IComponentChangeService)Host).OnComponentChanged(comp, TypeDescriptor.GetProperties(comp, designerNameAttribute)["Name"], oldName, newName); }
public void SetName(IComponent comp, string newName) { newName = newName.Trim(); SampleDesignSite cs = (SampleDesignSite)comp.Site; if (!newName.Equals(cs.Name)) { if (string.Compare(newName, cs.Name, true) != 0) { this.Host.CheckName(newName); } ((IComponentChangeService)this.Host).OnComponentChanging(comp, TypeDescriptor.GetProperties(comp, designerNameAttribute)["Name"]); this.Host.Sites.Remove(cs.Name); this.Host.Sites[newName] = cs; string oldName = cs.Name; cs.SetName(newName); this.Host.OnComponentRename(new ComponentRenameEventArgs(comp, oldName, newName)); ((IComponentChangeService)this.Host).OnComponentChanged(comp, TypeDescriptor.GetProperties(comp, designerNameAttribute)["Name"], oldName, newName); } }