public void SetupMap(string mapName, int mapWidth, int mapHeight, int tileWidth, int tileHeight) { _map.SetupMap(mapName, mapWidth, mapHeight, tileWidth, tileHeight); TilesManagement.RenderTiles(_map, ref _tile_library, pnlTileLibrary); RenderMap(); ClearSelectedTile(); tbMapName.Text = Path.GetFileNameWithoutExtension(_map.MapFileName); _history.ResetHistory(); undoToolStripMenuItem.Enabled = false; redoToolStripMenuItem.Enabled = false; }
private void clearTilesToolStripMenuItem_Click(object sender, EventArgs e) { // clear tile library Cursor.Current = Cursors.WaitCursor; if (MessageBox.Show("Clear the Tile Library?", "Clear Tile Library", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { ClearTiles(); TilesManagement.RenderTiles(_map, ref _tile_library, pnlTileLibrary); RenderMap(); } Cursor.Current = Cursors.Default; }
public D2DMapEditor() { InitializeComponent(); Init(); _map = new Map(); string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { // open file String d2dFileName = Convert.ToString(args[1]); if (Path.GetExtension(d2dFileName) != ".d2d") { MessageBox.Show(d2dFileName + " is not a d2d file", "Cannot Load File", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { Cursor.Current = Cursors.WaitCursor; OpenMap(d2dFileName); TilesManagement.RenderTiles(_map, ref _tile_library, pnlTileLibrary); // switch to design view tctrlDesign.SelectedTab = tpgDesign; Cursor.Current = Cursors.Default; saveMapToolStripMenuItem.Enabled = true; } catch (Exception ex) { MessageBox.Show("Failed to open: " + d2dFileName + "\n" + ex.Message); } } } else { // reset and render map ResetMap(); } tbMapName.Text = Path.GetFileNameWithoutExtension(_map.MapFileName); ClearSelectedTile(); ReloadLayers(0); RenderMap(); }
private void loadMapToolStripMenuItem_Click(object sender, EventArgs e) { // open saved map openMapDialog.InitialDirectory = Application.ExecutablePath; DialogResult openMap = this.openMapDialog.ShowDialog(); if (openMap == DialogResult.OK) { // open Map string d2dFileName = this.openMapDialog.FileName; if (Path.GetExtension(d2dFileName) != ".d2d") { MessageBox.Show(d2dFileName + " is not a d2d file", "Cannot Load File", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { Cursor.Current = Cursors.WaitCursor; OpenMap(this.openMapDialog.FileName); TilesManagement.RenderTiles(_map, ref _tile_library, pnlTileLibrary); // switch to design view tctrlDesign.SelectedTab = tpgDesign; Cursor.Current = Cursors.Default; ReloadLayers(0); RenderMap(); saveMapToolStripMenuItem.Enabled = true; } catch (Exception ex) { MessageBox.Show("Failed to open: " + this.openMapDialog.FileName + "\n" + ex.Message); } } } }