public void AddModule(IGenericMenuCallback callback) { String name = callback.RequestString("Add Module", "Name for new module:"); if (name != null) { bool success; Transaction xn = new Transaction(); IProjectAccess proj = xn.RequestWriteAccess(window.Project); using (xn.Start()) { ProjectModule cur = proj.GetModule(name); if (cur == null) { success = true; proj.AddModule(name, new LayoutModel()); } else { success = false; } } if (!success) { callback.Notify("Cannot Add", "Cannot add second module of same name."); } } }
public void RenameModule(IGenericMenuCallback callback) { ProjectModule toRename = window.CurrentModule; String name = callback.RequestString("Rename Module", "New name for module:"); if (name != null) { name = name.Trim(); if (name == "") { callback.Notify("Cannot Rename", "Module cannot have an empty name."); } else { bool success; Transaction xn = new Transaction(); IProjectAccess proj = xn.RequestWriteAccess(window.Project); using (xn.Start()) { ProjectModule cur = proj.GetModule(name); if (cur == null) { success = true; proj.SetModuleName(toRename, name); } else { success = false; } } if (!success) { callback.Notify("Cannot Rename", "Cannot add second module of same name."); } } } }