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(); } }
private void OnRender(object sender, double delta) { if (Subtrees.Count == 0) { return; } // draw connection lines GLDraw.PrepareCustomDrawing(); var sr = GLDraw.CurrentScreenRect; GL.Color3(Color.White); GL.LineWidth(1.0f); GL.Enable(EnableCap.LineSmooth); GL.Begin(PrimitiveType.Lines); for (int i = 0; i < Subtrees.Count; i++) { var src = new OpenTK.Vector2( sr.X + TaskControl.X + TaskControl.Width * (i + 1) / (Subtrees.Count + 1), sr.Y + TaskControl.Outer.Bottom + 1); var dst = new OpenTK.Vector2( sr.X + Subtrees[i].Parent.X + Subtrees[i].Parent.Inner.X + Subtrees[i].X + Subtrees[i].Inner.X + Subtrees[i].TaskControl.X + Subtrees[i].TaskControl.Width / 2, sr.Y + Subtrees[i].Parent.Y + Subtrees[i].Parent.Inner.Y + Subtrees[i].Y + Subtrees[i].Inner.Y + Subtrees[i].TaskControl.Y + 1); float srcX2 = src.X + (dst.X - src.X) * 0.02f; float dstX2 = dst.X - (dst.X - src.X) * 0.02f; GL.Vertex2(src); GL.Vertex2(srcX2, src.Y + 2); GL.Vertex2(srcX2, src.Y + 2); GL.Vertex2(dstX2, dst.Y - 2); GL.Vertex2(dstX2, dst.Y - 2); GL.Vertex2(dst); } GL.End(); }