private Field findNode(Field node, int w, int h) { if (node.used) { var result = this.findNode(node.nodeRight, w, h); return result != null ? result : this.findNode(node.nodeDown, w, h); } else if ((w <= node.Width) && (h <= node.Height)) { return node; } else return null; }
public Field(int page) { Point point = new Point(1,1); this.Location = point; this.Page = page; this.Name = "field" + page; this.Width = 400; this.Height = 500; this.BackColor = Color.White; this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.root = this; this.used = false; this.x = 0; this.y = 0; }
private void SplitNode (Field node, int w, int h) { node.used = true; node.nodeDown = new Field(node.x,node.y+h,node.Width,node.Height-h); node.nodeRight = new Field(node.x+w,node.y,node.Width-w,h); }