public BookmarkFolder RegisterPath(string path, string customText) { if (string.IsNullOrEmpty(path)) { return(null); } BookmarkFolder folder = null; string[] parts = path.Split(new char[] { '/' }); for (int i = 0; i < parts.Length; ++i) { string part = parts[i]; StringBuilder sb = new StringBuilder(); for (int j = 0; j <= i; ++j) { if (j != 0) { sb.Append('/'); } sb.Append(parts[j]); } string subPath = sb.ToString(); if (!BookmarkFolders.TryGetValue(subPath, out folder)) { folder = new BookmarkFolder() { Path = subPath, Text = customText ?? part }; BookmarkFolderCancelEventArgs e = new BookmarkFolderCancelEventArgs(subPath, folder); OnFolderAdding(e); if (e.Cancel) { return(null); } BookmarkFolders.Add(subPath, folder); OnFolderAdded(new BookmarkFolderChangeEventArgs(subPath, folder)); } } return(folder); }
public BookmarkFolderCancelEventArgs(string path, BookmarkFolder value) { Path = path; Value = value; }