private void saveStateToolStripMenuItem_Click(object sender, EventArgs e) { BitmapState bit = new BitmapState(); bit.setValues(xstart, xende, ystart, yende, xzoom, yzoom); Console.WriteLine("b4 xs : " + bit.getXS() + " xe : " + bit.getXE()); XmlSerializer xs = new XmlSerializer(typeof(BitmapState)); TextWriter tw = new StreamWriter(@"c:\temp\bmpstate.xml"); xs.Serialize(tw, bit); tw.Close(); }
private void saveStateToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog dia = new SaveFileDialog(); dia.Filter = "xml file (*.xml)|*.xml"; BitmapState bit = new BitmapState(); bit.setValues(xstart, xende, ystart, yende, xzoom, yzoom); if (dia.ShowDialog() == DialogResult.OK) { try { XmlSerializer xs = new XmlSerializer(typeof(BitmapState)); TextWriter tw = new StreamWriter(dia.FileName); xs.Serialize(tw, bit); tw.Close(); MessageBox.Show("State Saved!"); } catch { MessageBox.Show("There was a problem saving file."); } } }
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { //save state here SaveFileDialog dia = new SaveFileDialog(); dia.Filter = "xml file (*.xml)|*.xml"; BitmapState bit = new BitmapState(); bit.setValues(xstart, xende, ystart, yende, xzoom, yzoom); if (dia.ShowDialog() == DialogResult.OK) { try { XmlSerializer xs = new XmlSerializer(typeof(BitmapState)); TextWriter tw = new StreamWriter(dia.FileName); xs.Serialize(tw, bit); tw.Close(); MessageBox.Show("State Saved!"); } catch { MessageBox.Show("There was a problem saving file."); } } }