public int AddFolderIcon(FolderType type)
        {
            string text = "folder_" + type.ToString();
            int    result;

            if (this._extensionList.ContainsKey(text))
            {
                result = (int)this._extensionList[text];
            }
            else
            {
                int count = ((ImageList)this._imageLists[0]).Images.Count;
                if (this._manageBothSizes)
                {
                    ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type));
                    ((ImageList)this._imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type));
                }
                else
                {
                    ((ImageList)this._imageLists[0]).Images.Add(IconReader.GetFolderIcon(this._iconSize, type));
                }
                this.AddExtension(text, count);
                result = count;
            }
            return(result);
        }
        /// <summary>
        /// Adds a folder iconto the imagelist.
        /// </summary>
        /// <param name="type">The type of folder (opened/closed).</param>
        /// <returns>Index in the imagelist pointing to the icon.</returns>
        public int AddFolderIcon(FolderType type)
        {
            string key = "folder_" + type.ToString();

            if (_extensionList.ContainsKey(key))
            {
                return((int)_extensionList[key]);
            }
            else
            {
                // It's not already been added, so add it and record its position.

                int pos = ((ImageList)_imageLists[0]).Images.Count;             //store current count -- new item's index

                if (_manageBothSizes == true)
                {
                    //managing two lists, so add it to small first, then large
                    ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFolderIcon(IconSize.Small, type));
                    ((ImageList)_imageLists[1]).Images.Add(IconReader.GetFolderIcon(IconSize.Large, type));
                }
                else
                {
                    //only doing one size, so use IconSize as specified in _iconSize.
                    ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFolderIcon(_iconSize, type));  //add to image list
                }

                AddExtension(key, pos); // add to hash table
                return(pos);
            }
        }
Beispiel #3
0
        public int AddFileId(string extension, string filePath, bool isFolder = false, FolderType folderType = FolderType.Closed)
        {
            // Split it down so we can get the extension
            // string[] splitPath = filePath.Split(new Char[] { '.' });
            // string extension = (string)splitPath.GetValue(splitPath.GetUpperBound(0));

            //Check that we haven't already got the extension, if we have, then
            //return back its index
            if (_extensionList.ContainsKey(extension.ToUpper()))
            {
                return((int)_extensionList[extension.ToUpper()]);        //return existing index
            }
            else
            {
                // It's not already been added, so add it and record its position.

                int pos = ((ImageList)_imageLists[0]).Images.Count;     //store current count -- new item's index

                if (ManageBothSizes == true)
                {
                    //managing two lists, so add it to small first, then large
                    if (!isFolder)
                    {
                        ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFileIcon(filePath, IconReader.IconSize.Small, false));
                        ((ImageList)_imageLists[1]).Images.Add(IconReader.GetFileIcon(filePath, IconReader.IconSize.Large, false));
                    }
                    else
                    {
                        ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFolderIcon(filePath, IconReader.IconSize.Small, folderType));
                        ((ImageList)_imageLists[1]).Images.Add(IconReader.GetFolderIcon(filePath, IconReader.IconSize.Large, folderType));
                    }
                }
                else
                {
                    //only doing one size, so use IconSize as specified in _iconSize.
                    if (!isFolder)
                    {
                        ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFileIcon(filePath, _iconSize, false)); //add to image list
                    }
                    else
                    {
                        ((ImageList)_imageLists[1]).Images.Add(IconReader.GetFolderIcon(filePath, IconReader.IconSize.Large, folderType));
                    }
                }

                AddExtension(extension.ToUpper(), pos); // add to hash table
                return(pos);
            }
        }