public void AddSprite(CIndexSprite spr)
        {
            loadedISPK.Sprites.Add(spr);

            lbSprites.Items.Add(spr.Name);
            lbSprites.SelectedItems.Clear();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of CIndexSpritePack from a file stream
        /// </summary>
        /// <param name="file">The file stream to be read.</param>
        public CIndexSpritePack(ref FileStream file, string name = null)
        {
            if (file.Length == 0) return;

            if (name != null) this.Name = name;

            Sprites = new List<CIndexSprite>();

            byte[] _spc = new byte[2];

            file.Read(_spc, 0, 2);

            UInt16 spritecount = BitConverter.ToUInt16(_spc, 0);

            for (int i = 0; i < spritecount; i++)
            {

                string str_sprname = "{0}[{1}]";
                object[] objs_sprname = { this.Name, i };

                CIndexSprite ispr = new CIndexSprite(ref file, String.Format(str_sprname, objs_sprname));

                Sprites.Add(ispr);
            }

            this.Initialized = true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of CIndexSpritePack from a file stream
        /// </summary>
        /// <param name="file">The file stream to be read.</param>
        public CIndexSpritePack(ref FileStream file, string name = null)
        {
            if (file.Length == 0)
            {
                return;
            }

            if (name != null)
            {
                this.Name = name;
            }

            Sprites = new List <CIndexSprite>();

            byte[] _spc = new byte[2];

            file.Read(_spc, 0, 2);

            UInt16 spritecount = BitConverter.ToUInt16(_spc, 0);

            for (int i = 0; i < spritecount; i++)
            {
                string   str_sprname  = "{0}[{1}]";
                object[] objs_sprname = { this.Name, i };

                CIndexSprite ispr = new CIndexSprite(ref file, String.Format(str_sprname, objs_sprname));

                Sprites.Add(ispr);
            }

            this.Initialized = true;
        }
        private void tsmiFileImportImage_Click(object sender, EventArgs e)
        {
            openFileDialog.Filter = "PNG Files|*.png|TIFF Files|*.tiff|BMP Files|*.bmp";
            openFileDialog.Multiselect = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog.FileNames.Length == 1)
                {
                    DirectoryInfo dir = new DirectoryInfo(openFileDialog.FileName);

                    Image img = Image.FromFile(openFileDialog.FileName);
                    CIndexSprite ispr = new CIndexSprite(img);

                    ispr.Name = dir.Name;

                    loadedISPK.Sprites.Add(ispr);
                    lbSprites.Items.Add(ispr.Name);
                }
                else
                {
                    foreach(string fn in openFileDialog.FileNames)
                    {
                        DirectoryInfo dir = new DirectoryInfo(fn);

                        Image img = Image.FromFile(fn);
                        CIndexSprite ispr = new CIndexSprite(img);

                        ispr.Name = dir.Name;

                        loadedISPK.Sprites.Add(ispr);
                        lbSprites.Items.Add(ispr.Name);
                    }
                }
            }

            openFileDialog.Multiselect = false;
        }