Icicles/ScriptCop.Icicle.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
@{
    Name = 'ScriptCop'
    Screen = {
        New-ListBox -On_MouseDoubleClick { 
            if ($this.SelectedItem) {
                $file = $this.SelectedItem.ItemWithProblem.ScriptBlock.File
                $ise = [Windows.Window]::GetWindow($this).Resources.ISE
                if ($file -and $ise) {
                    $ise.CurrentPowerShellTab.Invoke("
                    `$psise.CurrentPowerShellTab.Files.Add('`$file')
                    `$psise.CurrentPowerShellTab.ExpandedScript = `$true
                    "
)
                }
            }
        } -ItemTemplate {
            New-StackPanel -Orientation Horizontal -MaxWidth 640 -Children { 
                New-TextBlock -Name "ItemWithProblem" -FontWeight DemiBold
                New-TextBlock ":"
                New-TextBlock -Name "Problem" -TextWrapping Wrap 
            } | ConvertTo-DataTemplate @{
                "ItemWithProblem.Text" = "ItemWithProblem"
                "Problem.Text" = "Problem"
            }

        }
    }
    DataUpdate = {
        $sb = try {[ScriptBlock]::Create($psise.CurrentFile.Editor.Text ) } catch {} 
        if ($sb)  {
            Test-Command -ScriptBlock $sb
        }
    }
    UiUpdate = {
        $this.Content.ItemsSource=  $args
    }
    UpdateFrequency = "0:0:15"
    UpdateOnFileChange = $true

}, @{
    Name = 'ScriptCop Online'
    Site = 'http://scriptcop.start-automating.com/Test-Command'
    #Horizontal = $true
}