コード例 #1
0
        private void menuAddTileset_Click(object sender, EventArgs e)
        {
            using (var dialog = new OpenFileDialog())
            {
                dialog.Title           = @"Selected texture to import";
                dialog.Multiselect     = true;
                dialog.CheckFileExists = true;
                dialog.CheckPathExists = true;
                dialog.Filter          = @"Image Files|*.png;";

                var result = dialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    for (int i = 0; i < dialog.FileNames.Length; i++)
                    {
                        Tilesets.Add(new Texture(dialog.FileNames[i]));
                        TilesetString.Add(dialog.SafeFileNames[i]);
                    }

                    CurrentTileset = Tilesets.Count - 1;
                    _tilesetController.UpdateTilesetDisplay();
                }
            }
        }
コード例 #2
0
        private void LoadTilesets()
        {
            var tPath = TilesetPath();

            if (Directory.Exists(Application.StartupPath + tPath))
            {
                string[] tempArray = Directory.GetFiles(Application.StartupPath + tPath, "*.png");
                foreach (string s in tempArray)
                {
                    string temp = Path.GetFileName(s);
                    TilesetString.Add(temp);
                    Tilesets.Add(new Texture(s));
                }
                if (Tilesets.Count > 0)
                {
                    CurrentTileset = 0;
                    _tilesetController.UpdateTilesetDisplay();
                }
            }
            else
            {
                Directory.CreateDirectory("Tileset");
            }
        }