コード例 #1
0
ファイル: BniFile.cs プロジェクト: pvpgn/bni-icon-builder
        public void Save(IconItem[] icons, byte[] data, string outFileName)
        {
            // sort items by flag
            sortIcons(ref icons);

            var bni = new BniFormat()
            {
                HeaderLength = 0x10,
                BniVersion = 0x01,
                NumIcons = icons.Length,
                Icons = icons,
                Data = data
            };

            // calc data start offset
            int offset = 16;
            foreach (IconItem i in icons)
            {
                offset += 16;
                if (i.Tag != null && i.Tag.Length == 4)
                    offset += 4;
            }
            bni.DataStart = offset;

            var bytes = _serialize(bni);

            File.WriteAllBytes(outFileName, bytes);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: yujintong/bni-icon-builder
        /// <summary>
        /// Export icons from the listbox
        /// </summary>
        /// <returns></returns>
        private IconItem[] _getIconItemsFromList()
        {
            // get images from listbox
            var icons = new IconItem[customDrawListBox1.Items.Count];

            for (int i = 0; i < customDrawListBox1.Items.Count; i++)
            {
                icons[i] = (IconItem)customDrawListBox1.Items[i];
            }

            return(icons);
        }
コード例 #3
0
ファイル: BniFile.cs プロジェクト: pvpgn/bni-icon-builder
        /// <summary>
        /// Sort items by flag; icons with tags always at the end of the array
        /// </summary>
        /// <param name="icons"></param>
        private void sortIcons(ref IconItem[] icons)
        {
            var iconList = icons.ToList();
            // select flags and order by flag
            var sortedIcons = icons.ToList().Where(x => string.IsNullOrEmpty(x.Tag)).OrderBy(x => x.Flag)
                // select tags and merge with flags (flags first)
                .Concat(iconList.Where(x => !string.IsNullOrEmpty(x.Tag)));

            icons = sortedIcons.ToArray();
        }