private void findusagestree_DrawNode(object sender, DrawTreeNodeEventArgs e) { if (!e.Node.IsVisible) { return; } FindUsagesResult result = e.Node.Tag as FindUsagesResult; Point location = new Point(e.Bounds.Location.X, e.Bounds.Location.Y + 1); if (result != null) { Size preferredsize = new Size(e.Bounds.Width, e.Bounds.Height); // Draw line number string linenum = "Line " + result.LineIndex + ": "; TextRenderer.DrawText(e.Graphics, linenum, findusagestree.Font, location, SystemColors.GrayText); //TECH: TextFormatFlags are ignored when using TextRenderer.MeasureText override without IDeviceContext location.X += TextRenderer.MeasureText(e.Graphics, linenum, findusagestree.Font, preferredsize, TextFormatFlags.NoPadding).Width; // Draw text before match string before = result.Line.Substring(0, result.MatchStart).TrimStart(); if (!string.IsNullOrEmpty(before)) { TextRenderer.DrawText(e.Graphics, before, findusagestree.Font, location, findusagestree.ForeColor); location.X += TextRenderer.MeasureText(e.Graphics, before, findusagestree.Font, preferredsize, TextFormatFlags.NoPadding).Width; } // Draw matching text string match = result.Line.Substring(result.MatchStart, result.MatchEnd - result.MatchStart); TextRenderer.DrawText(e.Graphics, match, findusagestree.Font, location, SystemColors.HotTrack); location.X += TextRenderer.MeasureText(e.Graphics, match, findusagestree.Font, preferredsize, TextFormatFlags.NoPadding).Width; // Draw text after match string after = result.Line.Substring(result.MatchEnd, result.Line.Length - result.MatchEnd).TrimEnd(); if (!string.IsNullOrEmpty(after)) { TextRenderer.DrawText(e.Graphics, after, findusagestree.Font, location, findusagestree.ForeColor); } } else { // Draw node text TextRenderer.DrawText(e.Graphics, e.Node.Text, findusagestree.Font, location, findusagestree.ForeColor); } }
private void findusagestree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { FindUsagesResult result = e.Node.Tag as FindUsagesResult; if (result != null) { ScriptResourceDocumentTab t = scriptpanel.OpenResource(result.Resource); if (t != null) { // Show target text t.MoveToLine(result.LineIndex); int pos = t.Editor.Scintilla.Lines[result.LineIndex].Position + result.MatchStart; t.SelectionStart = pos; t.SelectionEnd = pos; t.Focus(); // Show in resources control scriptpanel.ScriptResourcesControl.SelectItem(t); } } }