private void loadToolStripMenuItem_Click(object sender, EventArgs e) { Filer.Form1 f = new Filer.Form1(); string fileName = f.LoadFile(); if (fileName != "") { fileName = new Sokoban.GetPath().GetTheDirectory() + "\\" + fileName; this.Ctl.Load(fileName); } }
/*****************************Load Display**********************************************************************/ private void openPToolStripMenuItem_Click(object sender, EventArgs e) { this.btnGridPanel.Controls.Clear(); Filer.Form1 f = new Filer.Form1(); string fileName = f.LoadFile(); if (fileName != "") { fileName = new Sokoban.GetPath().GetTheDirectory() + "\\" + fileName; this.Ctl.Load(fileName); } }
/* public string LoadFile() * { * InputForm input = new InputForm(); * input.SetLabel("File name: "); * input.Text = "Load"; * string value = ""; * if (input.ShowDialog() == DialogResult.OK) * { * value = input.Read(); * } * input.Dispose(); * return value; * }*/ public string LoadFile() { string value = ""; string path = new Sokoban.GetPath().GetTheDirectory(); OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = path; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.Title = "Choose a file to import"; if (openFileDialog1.ShowDialog() == DialogResult.Cancel) { MessageBox.Show("No file selected!"); } else { value = openFileDialog1.SafeFileName; } return(value); }