public MainForm() { InitializeComponent(); objectListForm = new ObjectListForm(this); objectListForm.Show(this); SCALE = (float)pictureBox1.Width / 32.0f; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { objectListForm.Close(); objectListForm = new ObjectListForm(this); objectListForm.Show(); txtX.Text = txtY.Text = "0"; filename = null; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = "lev"; ofd.Filter = "Bounce levels (*.lev)|*.lev|All files|*.*"; ofd.Multiselect = false; if (ofd.ShowDialog() != DialogResult.OK) { return; } objectListForm.Close(); objectListForm = new ObjectListForm(this); objectListForm.Show(); txtX.Text = txtY.Text = "0"; filename = ofd.FileName; StreamReader file = new StreamReader(filename); string ln = file.ReadLine(); if (!ln.StartsWith("actor ")) { throw new Exception("Error parsing input, 'actor ' expected."); } string[] actorpos = ln.Split(' '); actorPosition.X = Convert.ToSingle(actorpos[1]); actorPosition.Y = Convert.ToSingle(actorpos[2]); ln = file.ReadLine(); if (ln != "static") { throw new Exception("Error parsing input, 'static' expected."); } if (objectListForm.loadStaticData(file) != "dynamic") { } // throw new Exception("Error parsing input, 'dynamic' expected."); objectListForm.loadDynamicData(file); file.Close(); Refresh(); }