Example #1
0
        /// <summary>
        /// Reads the icon group from a .ico file.
        /// </summary>
        /// <param name="path">Path to an icon file (.ico).</param>
        public void ReadFromFile(string path)
        {
            this.rawGroupIconInfo = new GroupIconInfo();
            this.icons = new List<Resource>();
            using (FileStream fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                this.rawGroupIconInfo.ReadFromFile(fs);

                // After reading the group icon info header from the file, read all the icons.
                for (int i = 0; i < this.rawGroupIconInfo.DirectoryInfo.Length; ++i)
                {
                    ushort index = this.rawGroupIconInfo.DirectoryInfo[i].imageIndex;
                    uint offset = this.rawGroupIconInfo.DirectoryInfo[i].imageOffset;
                    uint size = this.rawGroupIconInfo.DirectoryInfo[i].imageSize;
                    byte[] data = new byte[size];

                    fs.Seek(offset, SeekOrigin.Begin);
                    fs.Read(data, 0, data.Length);

                    Resource resource = new Resource(ResourceType.Icon, String.Concat("#", index), this.Locale, data);
                    this.icons.Add(resource);
                }
            }

            this.dirty = true;
        }
Example #2
0
        private void RefreshIconGroupInfo(byte[] refreshData)
        {
            this.rawGroupIconInfo = new GroupIconInfo();
            this.icons = new List<Resource>();
            if (refreshData != null)
            {
                this.rawGroupIconInfo.ReadFromResource(refreshData);
            }

            this.dirty = true;
        }