Exemplo n.º 1
0
        private void FileSystemWatcher_Deleted(object sender, FileSystemEventArgs e)
        {
            foreach (TreeNode node in TreeView.Nodes)
            {
                if ((node.Tag as string).Equals(e.FullPath, StringComparison.OrdinalIgnoreCase))
                {
                    WebBrowserToolTip.RemoveToolTip(node);

                    node.Remove();
                    break;
                }
            }
        }
Exemplo n.º 2
0
        private void OnNodeAdded(TreeNode treeNode)
        {
            string fullName = treeNode.Tag as string;

            if (string.IsNullOrEmpty(fullName))
            {
                return;
            }

            int galleryId;

            if (int.TryParse(Path.GetFileNameWithoutExtension(fullName), out galleryId))
            {
                WebBrowserToolTip.SetToolTip(treeNode, galleryId);
            }
        }
Exemplo n.º 3
0
        public TreeNode AddItem(string path, BookmarkNode item)
        {
            TreeNode contentNode = new TreeNode();

            contentNode.Text = item.Text;
            contentNode.Tag  = new AddBookmarkItemTask(path, item);

            TreeNodeCollection parentNodes = null;

            if (path.Contains('/') && !path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
            {
                TreeNode parentNode = AddFolder(path, true);

                parentNodes = parentNode.Nodes;
            }
            else
            {
                parentNodes = treeView.Nodes;
            }

            ContextMenu contentNodeContextMenu = new ContextMenu();

            contentNodeContextMenu.Popup += ItemContentNodeContextMenu_Popup;
            contentNodeContextMenu.Tag    = contentNode;
            contentNode.ContextMenu       = contentNodeContextMenu;

            parentNodes.Add(contentNode);

            string[] tokens = item.Value.Split(new char[] { ':' });
            int      galleryId;

            if (QueryParser.ParseDetailsSearch(tokens, out galleryId) ||
                QueryParser.ParseDownloadSearch(tokens, out galleryId))
            {
                WebBrowserToolTip.SetToolTip(contentNode, galleryId);
            }

            treeView.SelectedNode = contentNode;

            return(contentNode);
        }
Exemplo n.º 4
0
        private void ItemContentNodeContextMenu_Popup(object sender, EventArgs e)
        {
            ContextMenu         contextMenu = sender as ContextMenu;
            TreeNode            treeNode    = contextMenu.Tag as TreeNode;
            AddBookmarkItemTask item        = treeNode.Tag as AddBookmarkItemTask;

            contextMenu.MenuItems.Clear();

            if (item != null)
            {
                string[] tokens = item.Item.Value.Split(new char[] { ':' });
                int      galleryId;
                int      pageIndex;
                string   query;
                int      tagId;
                string   tagType;
                string   tagName;

                if (QueryParser.ParseDetailsSearch(tokens, out galleryId))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Show Details", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));

                    contextMenu.MenuItems.Add("-");

                    contextMenu.MenuItems.Add(new MenuItem("&Read", (sender2, e2) =>
                    {
                        CacheFileSystem.OpenFirstCachedPage(galleryId);
                    }));

                    contextMenu.MenuItems.Add(new MenuItem("&Browse", (sender2, e2) =>
                    {
                        CacheFileSystem.SelectFirstCachedPage(galleryId);
                    }));

                    contextMenu.MenuItems.Add(new MenuItem("&Show in Explorer", (sender2, e2) =>
                    {
                        CacheFileSystem.SelectPagesFolder(galleryId);
                    }));
                }
                else if (QueryParser.ParseDownloadSearch(tokens, out galleryId))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Show Download", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));

                    contextMenu.MenuItems.Add("-");

                    contextMenu.MenuItems.Add(new MenuItem("&Read", (sender2, e2) =>
                    {
                        CacheFileSystem.OpenFirstCachedPage(galleryId);
                    }));

                    contextMenu.MenuItems.Add(new MenuItem("&Browse", (sender2, e2) =>
                    {
                        CacheFileSystem.SelectFirstCachedPage(galleryId);
                    }));

                    contextMenu.MenuItems.Add(new MenuItem("&Show in Explorer", (sender2, e2) =>
                    {
                        CacheFileSystem.SelectPagesFolder(galleryId);
                    }));
                }
                else if (QueryParser.ParseRecentSearch(tokens, out pageIndex))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Recent Search", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));
                }
                else if (QueryParser.ParseQuerySearch(tokens, out query, out pageIndex))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Query Search", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));
                }
                else if (QueryParser.ParseTaggedSearch(tokens, out tagId, out tagType, out tagName, out pageIndex))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Tagged Search", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));
                }
                else if (QueryParser.ParseLibrarySearch(tokens, out pageIndex))
                {
                    contextMenu.MenuItems.Add(new MenuItem("&Show in Library", (sender2, e2) =>
                    {
                        SearchHandler.ParseAndExecuteSearchText(item.Item.Value);
                    }));
                }

                contextMenu.MenuItems.Add("-");

                contextMenu.MenuItems.Add(new MenuItem("&Remove bookmark", (sender2, e2) =>
                {
                    WebBrowserToolTip.RemoveToolTip(treeNode);
                    treeNode.Remove();
                    BookmarksModel.RemoveBookmark(item.Path);
                })
                {
                    Name = "remove"
                });

                // TODO: "move to..." command (to change the bookmark path)
            }
        }