public bool Execute(MapEditor _mapEditor) { // old name == new name? if (oldName == newName) { return(false); } // judge if the name duplicate CatModelList list = Mgr <CatProject> .Singleton.modelList1; CatModel oldModel = list.GetModel(oldName); // old material dose not exit if (oldModel == null) { MessageBox.Show("Error, no model has a name: " + oldName); return(false); } // new name is occupied if (list.ContainKey(newName)) { if (list.GetModel(newName) != oldModel) { MessageBox.Show("Error, existing model named: " + newName); } // else, dose not change the name at all return(false); } // rename list.RemoveItem(oldName); oldModel.SetName(newName); list.AddModel(oldModel); return(true); }
public bool Execute(MapEditor _mapEditor) { // find the model if (Mgr <CatProject> .Singleton != null && Mgr <CatProject> .Singleton.modelList1 != null) { CatModelList modelList = Mgr <CatProject> .Singleton.modelList1; CatModel model = modelList.GetModel(observingModelName); if (model != null) { _mapEditor.UpdateModelAttribute(model); return(true); } } _mapEditor.UpdateModelAttribute(null); return(false); }