private void fireBookmarkPathRemoved(BookmarkPath path) { if (BookmarkPathRemoved != null) { BookmarkPathRemoved.Invoke(path); } }
void item_MouseButtonReleased(ButtonGridItem source, MouseEventArgs arg) { if (bookmarksController.PremiumBookmarks) { if (dragIconPreview.Visible) { wasDragging = true; dragIconPreview.setItemResource(null); dragIconPreview.Visible = false; IntVector2 mousePos = arg.Position; if (currentDragNode != null) { BookmarkPath path = currentDragNode.UserData as BookmarkPath; Bookmark bookmark = liveThumbController.getUserObject(source); currentDragNode.showHover(false); try { bookmarksController.moveBookmark(path, bookmark); } catch (Exception ex) { MessageBox.show(String.Format("There was an error moving this bookmark."), "Move Error", MessageBoxStyle.IconError | MessageBoxStyle.Ok); Log.Error("Exception moving bookmark. Type {0}. Message {1}.", ex.GetType().ToString(), ex.Message); } } } } }
private void loadBookmarksFoldersBgThread(BookmarkPath path) { if (bookmarksResourceProvider.CanWrite && !bookmarksResourceProvider.directoryExists(path.Path)) { bookmarksResourceProvider.createDirectory(path.Path); } ThreadManager.invokeAndWait(() => fireBookmarkPathAdded(path)); if (currentPath == null) { CurrentPath = path; } foreach (String directory in bookmarksResourceProvider.listDirectories("*", path.Path, false)) { if (directory.ToLowerInvariant() != TrashFolderNameLower) { loadBookmarksFoldersBgThread(new BookmarkPath() { Path = directory, DisplayName = Path.GetFileNameWithoutExtension(directory), Parent = path }); } } }
public void clearBookmarkPaths() { currentPath = null; if (BookmarkPathsCleared != null) { BookmarkPathsCleared.Invoke(); } }
public void moveBookmark(BookmarkPath path, Bookmark bookmark) { if (path != currentPath) { Bookmark copy = CopySaver.Default.copy(bookmark); copy.BookmarkPath = path; saveBookmark(copy, path, bookmarksResourceProvider); deleteBookmark(bookmark); } }
void bookmarksController_CurrentPathChanged(BookmarkPath path) { removeFolder.Enabled = path != null && path.Parent != null && !path.IsTrash; addFolder.Enabled = path != null && !path.IsTrash; if (path != null) { TreeNode node = pathNodes[path]; if (folderTree.SelectedNode != node) { folderTree.SelectedNode = pathNodes[path]; } emptyTrashButton.Visible = path.IsTrash; } }
void bookmarksController_BookmarkPathRemoved(BookmarkPath path) { TreeNode bookmarkNode = pathNodes[path]; pathNodes.Remove(path); if (path.Parent != null) { pathNodes[path.Parent].Children.remove(bookmarkNode); } else { folderTree.Nodes.remove(bookmarkNode); } folderTree.layout(); }
void bookmarksController_BookmarkPathAdded(BookmarkPath path) { BookmarksTreeNode bookmarkNode = new BookmarksTreeNode(path.DisplayName, new BookmarksTreeNodeWidget()); bookmarkNode.UserData = path; pathNodes.Add(path, bookmarkNode); if (path.Parent != null) { pathNodes[path.Parent].Children.add(bookmarkNode); } else { folderTree.Nodes.add(bookmarkNode); bookmarkNode.Expanded = true; } folderTree.layout(); }
public void removeFolder(BookmarkPath path) { if (bookmarksResourceProvider.CanWrite && path.Parent != null) { if (bookmarksResourceProvider.directoryExists(path.Path)) { bookmarksResourceProvider.delete(path.Path); if (path == CurrentPath) { CurrentPath = path.Parent; } fireBookmarkPathRemoved(path); } } }
/// <summary> /// This function just saves a bookmark to disk, it does not fire the bookmark added event. /// </summary> /// <param name="bookmark"></param> private static void saveBookmark(Bookmark bookmark, BookmarkPath path, ResourceProvider bookmarksResourceProvider) { if (bookmarksResourceProvider.CanWrite) { String directory = ""; if (path != null) { directory = path.Path; } if (!bookmarksResourceProvider.directoryExists(directory)) { bookmarksResourceProvider.createDirectory(directory); } String fileFormat = Path.Combine(directory, bookmark.Name + "{0}.bmk"); String filename = String.Format(fileFormat, ""); int index = 0; int tries = 0; while (bookmarksResourceProvider.fileExists(filename) && tries < MaxFileNameTries) { filename = String.Format(fileFormat, (++index).ToString()); } if (tries == MaxFileNameTries) { filename = Path.Combine(MedicalConfig.BookmarksFolder, Guid.NewGuid().ToString() + ".bmk"); } bookmark.BackingFile = filename; using (Stream stream = bookmarksResourceProvider.openWriteStream(filename)) { using (XmlTextWriter xmlWriter = new XmlTextWriter(stream, Encoding.Unicode)) { xmlWriter.Formatting = Formatting.Indented; xmlSaver.saveObject(bookmark, xmlWriter); } } } }
public void loadBookmarks(BookmarkPath path) { this.currentPath = path; this.CanDoWork = !controller.bookmarksResourceProvider.CanWrite || controller.bookmarksResourceProvider.directoryExists(currentPath.Path); bgWorker.startWork(); }