APG.CodeHelper.IconHelper.IconListManager.AddFileIcon C# (CSharp) Метод

AddFileIcon() публичный Метод

Called publicly to add a file's icon to the ImageList.
public AddFileIcon ( string filePath ) : int
filePath string Full path to the file.
Результат int
        public int AddFileIcon(string filePath)
        {
            // Check if the file exists, otherwise, throw exception.
               // if (!System.IO.File.Exists(filePath)) throw new System.IO.FileNotFoundException("File does not exist");

            // 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
                    ((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
                {
                    //only doing one size, so use IconSize as specified in _iconSize.
                    ((ImageList)_imageLists[0]).Images.Add(IconReader.GetFileIcon(filePath, _iconSize, false));	//add to image list
                }

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