protected override void HandleHitTest(Graphics g, OlvListViewHitTestInfo hti, int x, int y) { BrightIdeasSoftware.TreeListView.Branch branch = this.Branch; Rectangle bounds = base.Bounds; if (branch.CanExpand) { bounds.Offset((branch.Level - 1) * PIXELS_PER_LEVEL, 0); bounds.Width = PIXELS_PER_LEVEL; if (bounds.Contains(x, y)) { hti.HitTestLocation = HitTestLocation.ExpandButton; return; } } bounds = base.Bounds; int num = branch.Level * PIXELS_PER_LEVEL; bounds.X += num; bounds.Width -= num; if (x < bounds.Left) { hti.HitTestLocation = HitTestLocation.Nothing; } else { base.StandardHitTest(g, hti, bounds, x, y); } }
private void DrawLines(Graphics g, Rectangle r, Pen p, BrightIdeasSoftware.TreeListView.Branch br) { int num2; Rectangle rectangle = r; rectangle.Width = PIXELS_PER_LEVEL; int top = rectangle.Top; if ((p.DashStyle == DashStyle.Dot) && ((top & 1) == 1)) { top++; } IList <BrightIdeasSoftware.TreeListView.Branch> ancestors = br.Ancestors; foreach (BrightIdeasSoftware.TreeListView.Branch branch in ancestors) { if (!branch.IsLastChild) { num2 = rectangle.Left + (rectangle.Width / 2); g.DrawLine(p, num2, top, num2, rectangle.Bottom); } rectangle.Offset(PIXELS_PER_LEVEL, 0); } num2 = rectangle.Left + (rectangle.Width / 2); int num3 = rectangle.Top + (rectangle.Height / 2); g.DrawLine(p, num2, num3, rectangle.Right, num3); if (br.IsFirstBranch) { if (!br.IsOnlyBranch) { g.DrawLine(p, num2, num3, num2, rectangle.Bottom); } } else if (br.IsLastChild) { g.DrawLine(p, num2, top, num2, num3); } else { g.DrawLine(p, num2, top, num2, rectangle.Bottom); } }
public override void Render(Graphics g, Rectangle r) { this.DrawBackground(g, r); BrightIdeasSoftware.TreeListView.Branch br = this.Branch; if (this.IsShowLines) { this.DrawLines(g, r, this.LinePen, br); } if (br.CanExpand) { Rectangle bounds = r; bounds.Offset((br.Level - 1) * PIXELS_PER_LEVEL, 0); bounds.Width = PIXELS_PER_LEVEL; if (!base.IsPrinting && Application.RenderWithVisualStyles) { VisualStyleElement closed = VisualStyleElement.TreeView.Glyph.Closed; if (br.IsExpanded) { closed = VisualStyleElement.TreeView.Glyph.Opened; } new VisualStyleRenderer(closed).DrawBackground(g, bounds); } else { int height = 8; int width = 8; int num3 = bounds.X + 4; int y = (bounds.Y + (bounds.Height / 2)) - 4; g.DrawRectangle(new Pen(SystemBrushes.ControlDark), num3, y, width, height); g.FillRectangle(Brushes.White, (int)(num3 + 1), (int)(y + 1), (int)(width - 1), (int)(height - 1)); g.DrawLine(Pens.Black, (int)(num3 + 2), (int)(y + 4), (int)((num3 + width) - 2), (int)(y + 4)); if (!br.IsExpanded) { g.DrawLine(Pens.Black, (int)(num3 + 4), (int)(y + 2), (int)(num3 + 4), (int)((y + height) - 2)); } } } int x = br.Level * PIXELS_PER_LEVEL; r.Offset(x, 0); r.Width -= x; this.DrawImageAndText(g, r); }