/snippets/VS2010/Nemerle.VisualStudio/GUI/InlineRefactoringPreview.cs

http://github.com/xxVisorxx/nemerle
C# | 60 lines | 51 code | 9 blank | 0 comment | 0 complexity | ae1654d11fb42e695f543ca55703d160 MD5 | raw file

✨ Summary
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using Nemerle.Completion2;
  11. namespace Nemerle.VisualStudio.GUI
  12. {
  13. public partial class InlineRefactoringPreview : Form
  14. {
  15. public InlineRefactoringPreview(Nemerle.Completion2.Project project)
  16. {
  17. InitializeComponent();
  18. _project = project;
  19. }
  20. private void FillUsagesTextBox()
  21. {
  22. var prevTextLength = 0;
  23. rtbFoundUsages.Text = "";
  24. foreach (var usage in Usages)
  25. {
  26. var loc = usage.Location;
  27. var strUsageLine = loc.Line.ToString();
  28. var line = string.Format("{0}: {1}\n", strUsageLine, usage.GetLineOfCode(_project.Engine));
  29. rtbFoundUsages.AppendText(line);
  30. int lineStart = prevTextLength;
  31. int selectionLength = loc.EndColumn - loc.Column;
  32. rtbFoundUsages.SelectionStart = lineStart + strUsageLine.Length + 2 + loc.Column - 1;
  33. rtbFoundUsages.SelectionLength = selectionLength;
  34. rtbFoundUsages.SelectionBackColor = Color.LightGreen;
  35. rtbFoundUsages.SelectedText = ExpressionToInline;
  36. prevTextLength = rtbFoundUsages.Text.Length;
  37. }
  38. rtbFoundUsages.SelectionStart = rtbFoundUsages.SelectionLength = 0;
  39. }
  40. public GotoInfo[] Usages{ get; set;}
  41. private Nemerle.Completion2.Project _project;
  42. public string ExpressionToInline
  43. {
  44. get; set;
  45. }
  46. private void InlineRefactoringPreview_Shown(object sender, EventArgs e)
  47. {
  48. FillUsagesTextBox();
  49. }
  50. }
  51. }