private void bakeResultToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Title = "Save Baked Values"; sfd.Filter = "Baked Value File (*.baked)|*.baked"; if (sfd.ShowDialog() == DialogResult.OK) { var data = DisplayManager.Current.CityModel.Extents.GetGrid2d(Convert.ToDouble(taskPanel.numGridSize.Value)).MapArray2d(p => DisplayManager.Current.CityModel.GetValue(p)); BakedResult br = new BakedResult(DisplayManager.Current.CityModel.Extents, data); BinaryFormatter bf = new BinaryFormatter(); using (System.IO.FileStream fs = new System.IO.FileStream(sfd.FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None)) { bf.Serialize(fs, br); } } }
private void importBakedResultToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "Choose Baked Result"; ofd.Filter = "Baked Value File (*.baked)|*.baked"; if (ofd.ShowDialog() == DialogResult.OK) { BinaryFormatter bf = new BinaryFormatter(); using (System.IO.Stream fs = System.IO.File.OpenRead(ofd.FileName)) { BakedResult br = bf.Deserialize(fs) as BakedResult; _display.CityModel.Factors.Add(br); _display.CityModel.Extents = br.Extents; } taskPanel.cbbValueMode.SelectedIndex = ValueMode.GridPrice; canvasWindow.ZoomExtent(); Canvas.Invalidate(); } }