private void OnRender(object sender, double delta) { GLDraw.Fill(ref backgroundColor); var root = (PBTTaskTreeControl <DataType>)TreeContainer.Controls.First().Controls.FirstOrDefault(c => c is PBTTaskTreeControl <DataType>); if (root != null) { lines.Clear(); float scale = Math.Min(InnerWidth / (float)root.Width, InnerHeight / (float)root.Height); RenderSubtree(root, 0, 0, scale); GLDraw.PrepareCustomDrawing(); var sr = GLDraw.CurrentScreenRect; GL.Color3(Color.White); GL.LineWidth(scale); GL.Enable(EnableCap.LineSmooth); GL.Begin(PrimitiveType.Lines); for (int i = 0; i < lines.Count; i++) { GL.Vertex2(sr.X + lines[i].Item1.X, sr.Y + lines[i].Item1.Y); GL.Vertex2(sr.X + lines[i].Item2.X, sr.Y + lines[i].Item2.Y); } GL.End(); GL.LineWidth(2.0f); GL.Begin(PrimitiveType.LineLoop); GL.Vertex2(sr.X + TreeContainer.ScrollPosition.X * scale, sr.Y + TreeContainer.ScrollPosition.Y * scale); GL.Vertex2(sr.X + (TreeContainer.ScrollPosition.X + TreeContainer.InnerWidth) * scale, sr.Y + TreeContainer.ScrollPosition.Y * scale); GL.Vertex2(sr.X + (TreeContainer.ScrollPosition.X + TreeContainer.InnerWidth) * scale, sr.Y + (TreeContainer.ScrollPosition.Y + TreeContainer.InnerHeight) * scale); GL.Vertex2(sr.X + TreeContainer.ScrollPosition.X * scale, sr.Y + (TreeContainer.ScrollPosition.Y + TreeContainer.InnerHeight) * scale); GL.End(); } }