示例#1
0
        protected void InitializeTreeView(XmlNode favoritesFolder, FavoritesFolder currentFolder)
        {
            if (favoritesFolder == null)
                return;

            foreach (XmlNode favorite in favoritesFolder.SelectNodes("favorite"))
                currentFolder.Favorites.Add(new RDCConnection(favorite, _password));

            foreach (XmlNode folder in favoritesFolder.SelectNodes("folder"))
            {
                FavoritesFolder newFolder = new FavoritesFolder
                                                {
                                                    Name = folder.SelectSingleNode("@name").Value
                                                };

                currentFolder.ChildFolders.Add(newFolder);
                InitializeTreeView(folder, newFolder);
            }
        }
示例#2
0
        protected void SaveTreeView(FavoritesFolder currentFolder, XmlNode parentNode)
        {
            foreach (RDCConnection favorite in currentFolder.Favorites)
            {
                XmlNode connectionNode = parentNode.OwnerDocument.CreateNode(XmlNodeType.Element, "favorite", null);
                parentNode.AppendChild(connectionNode);

                favorite.ToXmlNode(connectionNode);
            }

            foreach (FavoritesFolder folder in currentFolder.ChildFolders)
            {
                XmlNode folderNode = parentNode.OwnerDocument.CreateNode(XmlNodeType.Element, "folder", null);

                folderNode.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("name"));
                folderNode.Attributes["name"].Value = folder.Name;

                parentNode.AppendChild(folderNode);
                SaveTreeView(folder, folderNode);
            }
        }
示例#3
0
        private void PopulateBookmarks(FavoritesFolder currentFolder, ToolStripItemCollection menuItems, bool root)
        {
            ToolStripItemCollection addLocation = menuItems;

            if (!root)
            {
                ToolStripMenuItem folderMenuItem = new ToolStripMenuItem(currentFolder.Name, Resources.Folder);
                menuItems.Add(folderMenuItem);

                addLocation = folderMenuItem.DropDownItems;
            }

            foreach (FavoritesFolder childFolder in currentFolder.ChildFolders)
                PopulateBookmarks(childFolder, addLocation, false);

            foreach (RDCConnection bookmark in currentFolder.Favorites)
            {
                ToolStripMenuItem bookmarkMenuItem = new ToolStripMenuItem(String.IsNullOrEmpty(bookmark.Name)
                                                                               ? bookmark.Host
                                                                               : bookmark.Name, Resources.RDCSmall,
                                                                           (object sender, EventArgs e) =>
                                                                           Connect(
                                                                               _menuItemConnections[
                                                                                   (ToolStripMenuItem) sender]));

                _menuItemConnections[bookmarkMenuItem] = bookmark;
                addLocation.Add(bookmarkMenuItem);
            }
        }