示例#1
0
        private static Icon ExtractIcon(string fileName)
        {
            // Are we looking at an icon itself?
            if (TryExtractIconFromIco(fileName, out Icon icon))
            {
                return(icon);
            }

            // Otherwise, fall back to the first icon in the file
            return(IconExtractor.ExtractIconByIndex(fileName, 0));
        }
示例#2
0
        public static Icon ExtractIconByIdOrIndex(string fileNameAndIdOrIndex)
        {
            string[] parts = fileNameAndIdOrIndex.Split(new char[] { ',' }, 2);

            parts[0] = Environment.ExpandEnvironmentVariables(parts[0]);
            if (parts.Length == 1)
            {
                return(ExtractIcon(parts[0]));
            }

            if (!int.TryParse(parts[1], out int index))
            {
                throw new FormatException();
            }

            if (index >= 0)
            {
                return(IconExtractor.ExtractIconByIndex(parts[0], index));
            }

            return(IconExtractor.ExtractIconById(parts[0], Math.Abs(index)));
        }