/// <summary>
        /// Enumerates the Favourites within the specified directory and adds them to Favourites TreeView
        /// </summary>
        /// <param name="di">
        /// The directory to find the Favourites in
        /// </param>
        /// <param name="dirNode">
        /// The FavouritesTreeView Node to add the Favourites to
        /// </param>
        /// <remarks>
        /// Uses a PInvoke call to GetPrivateProfileString to get Favourite information
        /// </remarks>
        private void GetFavouritesForDirectory(DirectoryInfo di, TreeNode dirNode)
        {
            foreach (FileInfo fileInfo in di.GetFiles())
            {
                result = GetPrivateProfileString("InternetShortcut", "URL", "", sb, (uint)sb.Capacity, fileInfo.FullName);
                if (result > 0)
                {
                    FavouriteTreeNode myFav = new FavouriteTreeNode();
                    myFav.Text          = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                    myFav.Url           = new Uri(sb.ToString());
                    myFav.DirectoryPath = fileInfo.FullName;

                    if (dirNode == null)
                    {
                        this.favouritesTreeView.Nodes.Add(myFav);
                    }
                    else
                    {
                        dirNode.Nodes.Add(myFav);
                    }
                }
            }
        }
        private void favouritesTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            FavouriteTreeNode myFav = (FavouriteTreeNode)e.Node;

            this.currentBrowser.Navigate(myFav.Url);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Enumerates the Favourites within the specified directory and adds them to Favourites TreeView
        /// </summary>
        /// <param name="di">
        /// The directory to find the Favourites in
        /// </param>
        /// <param name="dirNode">
        /// The FavouritesTreeView Node to add the Favourites to
        /// </param>
        /// <remarks>
        /// Uses a PInvoke call to GetPrivateProfileString to get Favourite information
        /// </remarks>
        private void GetFavouritesForDirectory(DirectoryInfo di, TreeNode dirNode)
        {
            foreach (DirectoryInfo dirInfo in di.GetDirectories())
            {
                TreeNode newNode = new TreeNode();
                newNode.Text               = dirInfo.Name;
                newNode.Tag                = dirInfo.FullName;
                newNode.ImageIndex         = 0;
                newNode.SelectedImageIndex = 0;

                if (dirNode == null)
                {
                    this.favouritesTreeView.Nodes.Add(newNode);
                }
                else
                {
                    dirNode.Nodes.Add(newNode);
                }

                newNode.Nodes.Add("*");
            }

            var imageKeyIndex = 0;

            foreach (FileInfo fileInfo in di.GetFiles())
            {
                result = GetPrivateProfileString("InternetShortcut", "URL", "", sb, (uint)sb.Capacity, fileInfo.FullName);
                if (result > 0)
                {
                    FavouriteTreeNode myFav = new FavouriteTreeNode();
                    myFav.Text               = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                    myFav.Url                = new Uri(sb.ToString());
                    myFav.DirectoryPath      = fileInfo.FullName;
                    myFav.ImageIndex         = 1;
                    myFav.SelectedImageIndex = 1;

                    // attempt to find an icon for the favourite
                    result = GetPrivateProfileString("InternetShortcut", "IconFile", "", sb1, (uint)sb.Capacity, fileInfo.FullName);
                    if (result > 0)
                    {
                        var image = this.LoadImage(sb1.ToString());
                        if (image != null)
                        {
                            this.iconImageList.Images.Add(string.Format("fav{0}", imageKeyIndex), image);
                            myFav.ImageKey         = string.Format("fav{0}", imageKeyIndex);
                            myFav.SelectedImageKey = string.Format("fav{0}", imageKeyIndex);
                        }

                        imageKeyIndex++;
                    }

                    if (dirNode == null)
                    {
                        this.favouritesTreeView.Nodes.Add(myFav);
                    }
                    else
                    {
                        dirNode.Nodes.Add(myFav);
                    }
                }
            }
        }
        /// <summary>
        /// Enumerates the Favourites within the specified directory and adds them to Favourites TreeView
        /// </summary>
        /// <param name="di">
        /// The directory to find the Favourites in
        /// </param>
        /// <param name="dirNode">
        /// The FavouritesTreeView Node to add the Favourites to
        /// </param>
        /// <remarks>
        /// Uses a PInvoke call to GetPrivateProfileString to get Favourite information
        /// </remarks>
        private void GetFavouritesForDirectory(DirectoryInfo di, TreeNode dirNode)
        {
            foreach (FileInfo fileInfo in di.GetFiles())
            {
                result = GetPrivateProfileString("InternetShortcut", "URL", "", sb, (uint)sb.Capacity, fileInfo.FullName);
                if (result > 0)
                {
                    FavouriteTreeNode myFav = new FavouriteTreeNode();
                    myFav.Text = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                    myFav.Url = new Uri(sb.ToString());
                    myFav.DirectoryPath = fileInfo.FullName;

                    if (dirNode == null)
                    {
                        this.favouritesTreeView.Nodes.Add(myFav);
                    }
                    else
                    {
                        dirNode.Nodes.Add(myFav);
                    }
                }
            }
        }
        /// <summary>
        /// Enumerates the Favourites within the specified directory and adds them to Favourites TreeView
        /// </summary>
        /// <param name="di">
        /// The directory to find the Favourites in
        /// </param>
        /// <param name="dirNode">
        /// The FavouritesTreeView Node to add the Favourites to
        /// </param>
        /// <remarks>
        /// Uses a PInvoke call to GetPrivateProfileString to get Favourite information
        /// </remarks>
        private void GetFavouritesForDirectory(DirectoryInfo di, TreeNode dirNode)
        {
            foreach (DirectoryInfo dirInfo in di.GetDirectories())
            {
                TreeNode newNode = new TreeNode();
                newNode.Text = dirInfo.Name;
                newNode.Tag = dirInfo.FullName;
                newNode.ImageIndex = 0;
                newNode.SelectedImageIndex = 0;

                if (dirNode == null)
                {
                    this.favouritesTreeView.Nodes.Add(newNode);
                }
                else
                {
                    dirNode.Nodes.Add(newNode);
                }

                newNode.Nodes.Add("*");
            }

            var imageKeyIndex = 0;

            foreach (FileInfo fileInfo in di.GetFiles())
            {
                result = GetPrivateProfileString("InternetShortcut", "URL", "", sb, (uint)sb.Capacity, fileInfo.FullName);
                if (result > 0)
                {
                    FavouriteTreeNode myFav = new FavouriteTreeNode();
                    myFav.Text = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                    myFav.Url = new Uri(sb.ToString());
                    myFav.DirectoryPath = fileInfo.FullName;
                    myFav.ImageIndex = 1;
                    myFav.SelectedImageIndex = 1;

                    // attempt to find an icon for the favourite
                    result = GetPrivateProfileString("InternetShortcut", "IconFile", "", sb1, (uint)sb.Capacity, fileInfo.FullName);
                    if (result > 0)
                    {
                        var image = this.LoadImage(sb1.ToString());
                        if (image != null)
                        {
                            this.iconImageList.Images.Add(string.Format("fav{0}", imageKeyIndex), image);
                            myFav.ImageKey = string.Format("fav{0}", imageKeyIndex);
                            myFav.SelectedImageKey = string.Format("fav{0}", imageKeyIndex);
                        }

                        imageKeyIndex++;
                    }

                    if (dirNode == null)
                    {
                        this.favouritesTreeView.Nodes.Add(myFav);
                    }
                    else
                    {
                        dirNode.Nodes.Add(myFav);
                    }
                }
            }
        }