public void Save(StreamWriter sw) { int subnode = 0; if (LeftTop != null) { subnode = 4; } sw.Write(rec.X.ToString() + "\t\t\t" + rec.Y.ToString() + "\t\t\t" + rec.Width.ToString() + "\t\t\t" + rec.Height.ToString() + "\t\t\t" + subnode + "\t\t\t" + listObj.Count + "\t\t\t"); if (listObj.Count > 0) { foreach (ObjectGame o in listObj) { sw.Write(o.index + "\t\t"); } } sw.WriteLine(); if (LeftTop != null) { LeftTop.Save(sw); RightTop.Save(sw); LeftBot.Save(sw); RightBot.Save(sw); } }
private void SaveQuadTree(QuadNode root, string path) { StreamWriter stream = new StreamWriter(path); root.Save(stream); stream.Close(); }
private void btn_Save_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); // saveFileDialog1.Filter = "Images|*.bmp;"; ImageFormat format = ImageFormat.Png; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileDirectory = Path.GetDirectoryName(saveFileDialog1.FileName); fileName = Path.GetFileName(saveFileDialog1.FileName); format = ImageFormat.Bmp; pictureBox2.BackgroundImage.Save(Path.Combine(fileDirectory, fileName + ".bmp"), format); // StreamWriter writer = new StreamWriter(Path.Combine(fileDirectory,Name+"txt")); string text = ""; text += listTile.Count + "\r\n"; text += countRow + "\r\n"; text += countCol + "\r\n"; text += writeMatrix; File.WriteAllText(Path.Combine(fileDirectory, fileName + ".txt"), text); String s = ""; StreamWriter writer = new StreamWriter(saveFileDialog1.FileName + "OBJ.txt"); s += listobjmap.Count + "\r\n" + "\r\n"; foreach (ObjectGame obj in listobjmap) { s += obj.ID + "\r\n"; s += obj.location.X + "\r\n"; s += obj.location.Y + "\r\n"; s += obj.bm.Width + "\r\n"; s += obj.bm.Height + "\r\n"; s += "\r\n"; } writer.Write(s); writer.Close(); StreamWriter quadtree = new StreamWriter(saveFileDialog1.FileName + "Quadtree.txt"); rootNode = new QuadNode("0", new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height)); int ind = 0; foreach (ObjectGame obj in listobjmap) { obj.index = ind; ind++; } rootNode.listObj = listobjmap; rootNode.BuildTree(); rootNode.Save(quadtree); quadtree.Close(); MessageBox.Show("Saved"); } }
public void Save(StreamWriter writer) { int nodeSub = leftTop is null ? 0 : 4; writer.Write(id + " " + region.Left + " " + region.Top + " " + region.Right + " " + region.Bottom + " " + nodeSub + " " + objects.Count + " "); writer.Flush(); for (int i = 0; i < objects.Count; ++i) { writer.Write(objects[i].ID + " "); } writer.WriteLine(); writer.Flush(); if (leftTop != null) { leftTop.Save(writer); rightTop.Save(writer); leftBottom.Save(writer); rightBottom.Save(writer); } }