private void drawQuadTreeNode(QNode node, Graphics graphics) { if (node == null) return; if (node.isLeaf() == true) { if (node.ListObject.Any()) graphics.FillRectangle(brush_quadnode, node.Bound); else graphics.FillRectangle(brush_quadnode_noobject, node.Bound); graphics.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(255, 45, 45, 45))), node.Bound); } else { for (int i = 0; i < 4; i++) { drawQuadTreeNode(node.Childs[i], graphics); } } }
private static void Save(XmlTextWriter writter, QNode qnode, string path) { if (qnode == null) return; writter.WriteStartElement("QNode"); { writter.WriteAttributeString("Id", qnode.Id.ToString()); writter.WriteAttributeString("Level", qnode.Level.ToString()); writter.WriteAttributeString("X", qnode.Bound.X.ToString()); writter.WriteAttributeString("Y", qnode.Bound.Y.ToString()); writter.WriteAttributeString("Width", qnode.Bound.Width.ToString()); writter.WriteAttributeString("Height", qnode.Bound.Height.ToString()); if (qnode.isLeaf() == true && qnode.ListObject.Any()) { string str = String.Empty; foreach (var obj in qnode.ListObject) { str += obj.Name + " "; } writter.WriteStartElement("Objects"); writter.WriteString(str); writter.WriteEndElement(); } else { for (int i = 0; i < 4; i++) { Save(writter, qnode.Childs[i], path); } } } writter.WriteEndElement(); }