private void abrirToolStripMenuItem_Click(object sender, EventArgs e) { String file = String.Empty; using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.AddExtension = true; ofd.Title = "Abrir mapa"; ofd.CheckFileExists = true; ofd.AutoUpgradeEnabled = true; ofd.Filter = "Tribalia map files (*.map)|*.map|All files|*.*"; ofd.FilterIndex = 0; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { file = ofd.FileName; } else { return; } } try { map = new Map(file); map.Open(); lblSize.Text = map.Width + " x " + map.Height; lblPlayerPos.Text = "(" + map.PlayerX + ", " + map.PlayerY + ")"; pnlMapInfo.Visible = true; this.Text = map.Filename + " - Criador de Mapas"; gfxData.xoff = 0; gfxData.yoff = 0; gfxData.elWidth = (pnlMapDraw.Width / 32) + 1; gfxData.elHeight = (pnlMapDraw.Height / 32) + 1; //habilita o double buffering *apenas* no painel de desenho de mapa typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, pnlMapDraw, new object[] { true }); if (gfxData.elHeight > 0) { // vScrollBar1.Maximum = gfxData.elHeight; vScrollBar1.Minimum = 0; vScrollBar1.Enabled = true; contextMenuStrip1.Enabled = true; pnlMapDraw.Refresh(); mapaToolStripMenuItem.Visible = true; } } catch (InvalidMapException ex) { MessageBox.Show(this, "Mapa inválido", "Criador de mapas", MessageBoxButtons.OK, MessageBoxIcon.Error); } }