private async void openMapButton_Click(object sender, EventArgs e) { MapEditorForm form; string fullPath = string.Empty; FileDialog fileDlg = new OpenFileDialog(); if (fileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fullPath = Path.Combine(fileDlg.InitialDirectory, fileDlg.FileName); LevelMapXMLData mapData = await Serializer.FromXml<LevelMapXMLData>(fullPath); form = new MapEditorForm(mapData); } else form = new MapEditorForm(); string mapName; if (!string.IsNullOrWhiteSpace(fullPath)) { mapName = Path.GetFileNameWithoutExtension(fullPath); form.Text = mapName; } form.Show(); }
private void button1_Click(object sender, EventArgs e) { int rows, cols, width, height; int.TryParse(rowTxt.Text,out rows); int.TryParse(colTxt.Text,out cols); int.TryParse(widthTxt.Text,out width); int.TryParse(hieghtTxt.Text, out height); string name = nameTextBox.Text; MapEditorForm form; if(string.IsNullOrWhiteSpace(name)) form = new MapEditorForm(rows, cols, width, height); else form = new MapEditorForm(rows, cols, width, height, name); form.Show(); this.Close(); }