//Save as private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); if (sfd.ShowDialog() == DialogResult.OK) { LevelSerializor serializor = new LevelSerializor(); serializor.Serialize(this.level, sfd.OpenFile()); fileName = sfd.FileName; } }
//save private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (fileName == null) { saveAsToolStripMenuItem_Click(sender, e); } else { FileStream currentStream = File.Open(fileName, FileMode.Open); LevelSerializor serializor = new LevelSerializor(); serializor.Serialize(this.level, currentStream); } }
//open private void kkkToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { LevelSerializor serializor = new LevelSerializor(); this.level = serializor.DeSerialize(ofd.OpenFile()); } init(); fileName = ofd.FileName; paintBoard.Visible = true; paintBoard.Invalidate(); }