Exemple #1
0
        public bool ResourceRenamed(IResource res, string newName)
        {
            string oldName = res.GetStringProp(Core.Props.Name);

            if (oldName == null || newName == null || oldName == newName)
            {
                return(false);
            }
            if (newName.Length == 0 || newName == "New Folder")
            {
                MessageBox.Show(Core.MainWindow,
                                "Please specify a name.", "Rename", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            // check duplicates on the same level for some cases
            IBookmarkProfile profile = _bookmarkService.GetOwnerProfile(res);
            IResource        parent  = res.GetLinkProp(_propParent);

            if (parent != null && (profile == _favoritesProfile || res.Type == "Folder") &&
                BookmarkService.HasSubNodeWithName(parent, newName))
            {
                MessageBox.Show(Core.MainWindow,
                                "The name is already used, please specify another", "Rename", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }
            if (profile != null)
            {
                profile.Rename(res, newName);
            }
            new ResourceProxy(res).SetPropAsync(Core.Props.Name, newName);
            return(true);
        }