private void ImportFile(string type, TileSet.TileSetDataType tsetType)
        {
            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "PNG files|*.png|All Files|*.*";
                ofd.Title  = "Select a " + type + " tilset file";

                if (ofd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (!ofd.CheckPathExists)
                {
                    throw new FileNotFoundException();
                }

                byte[] data     = File.ReadAllBytes(ofd.FileName);
                Bitmap inImage  = BitmapHandler.LoadBitmap(data);
                byte[] tsetData = DecodeIndices(inImage);

                var room = MapManager.Instance.MapAreas.Single(a => a.Index == currentArea).Rooms.First();
                room.tileSet.SetTileSetData(tsetType, tsetData);
                RedrawTiles(room);

                switch (tsetType)
                {
                case TileSet.TileSetDataType.BG1:
                    Project.Instance.AddPendingChange(new Bg1TileSetChange(currentArea));
                    break;

                case TileSet.TileSetDataType.BG2:
                    Project.Instance.AddPendingChange(new Bg2TileSetChange(currentArea));
                    break;

                case TileSet.TileSetDataType.COMMON:
                    Project.Instance.AddPendingChange(new CommonTileSetChange(currentArea));
                    break;
                }
            }
        }
        private void ExportTileSet(TileSet.TileSetDataType tsetType, int offset, int layer)
        {
            using (SaveFileDialog sfd = new SaveFileDialog())
            {
                var room = MapManager.Instance.MapAreas.Single(a => a.Index == currentArea).Rooms.First();
                sfd.Filter   = "Bitmap files|*.png|All Files|*.*";
                sfd.Title    = "Save " + tsetType + " tileset file";
                sfd.FileName = tsetType + "_" + currentArea.Hex() + ".png";

                if (sfd.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var fileData = room.tileSet.GetTileSetData(tsetType);
                var bmap     = new Bitmap(0x100, 0x80, PixelFormat.Format8bppIndexed);

                EncodeIndices(ref bmap, fileData);

                bmap.Save(sfd.FileName);
            }
        }