Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. Add-Type -AssemblyName System.Windows.Forms
  2. Set-StrictMode -Version Latest
  3.  
  4. $global:form = New-Object System.Windows.Forms.Form
  5. $global:TextBox = New-Object System.Windows.Forms.RichTextBox
  6. $type = New-Object "Collections.Generic.Dictionary[String, [Drawing.Color]]"
  7.  
  8. $type["CommandArgument"] = [Drawing.Color]::Yellow
  9. $type["attribute"] = [Drawing.Color]::Cyan
  10. $type["Command"] = [Drawing.Color]::Yellow
  11. $type["GroupStart"] = [Drawing.Color]::Yellow
  12. $type["GroupEnd"] = [Drawing.Color]::Yellow
  13. $type["StatementSeparator"] = [Drawing.Color]::White
  14.  
  15. $global:form.Size = New-Object System.Drawing.Size(600,300)
  16. $global:TextBox.BackColor = [Drawing.Color]::FromArgb(1, 36, 86)
  17. $global:TextBox.Dock = "Fill"
  18. $global:TextBox.Font = New-Object Drawing.Font("Courier New", 10,[Drawing.FontStyle]::Bold)
  19. $global:TextBox.Location = New-Object System.Drawing.Size(10,20)
  20. $global:TextBox.Size = New-Object System.Drawing.Size(500,200)
  21.  
  22. $global:TextBox.AcceptsTab = $false
  23. $global:TextBox.Multiline = $true
  24. $global:TextBox.ScrollBars = 'Both'
  25. $global:form.Controls.Add($global:TextBox)
  26.  
  27. $NL= "`r`n"
  28.  
  29. $keys = Get-ItemProperty -Path "HKLM:SOFTWARERegistry_key_path"
  30. $values = @("Data", "Project", "link")
  31. foreach ($val in $values)
  32. {
  33. $global:TextBox.Text = $global:TextBox.Text + $keys.$val
  34. }
  35. [Management.Automation.PSParser]::Tokenize(
  36. $global:TextBox.Text,
  37. [ref](New-Object "Collections.ObjectModel.Collection[Management.Automation.PSParseError]")
  38. ) | % {
  39. $global:TextBox.SelectionStart = $_.Start - $i
  40. $global:TextBox.SelectionLength = $_.Length
  41.  
  42. #skip unnecessary types
  43. if ($_.Type -eq "LineContinuation" -or $_.Type -eq "NewLine") {
  44. $i++
  45. }
  46. else {
  47. $global:TextBox.SelectionColor = $type[$_.Type.ToString()]
  48. }
  49. }
  50. $global:TextBox.DeselectAll()
  51.  
  52. $global:form.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement