-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerShellGUI_Draft.ps1
More file actions
138 lines (119 loc) · 5.7 KB
/
PowerShellGUI_Draft.ps1
File metadata and controls
138 lines (119 loc) · 5.7 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
$inputXML = @"
<Window x:Class="ReleaseApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ReleaseApp"
mc:Ignorable="d"
Title="Release Checker"
ResizeMode="CanMinimize"
Height="500" Width="800" >
<Window.Resources>
</Window.Resources>
<DockPanel LastChildFill="True">
<Grid DockPanel.Dock="Top" Height="325">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<!-- Version ComboBox -->
<StackPanel Orientation="Horizontal" Margin="10,5" HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="3" Grid.Row="0">
<Label Content="Version: " />
<ComboBox x:Name="VersionPicker" Height="20" Width="125"/>
</StackPanel>
<!-- Functions -->
<StackPanel x:Name="FunctionPanel" Grid.Column="1" Grid.Row="1">
<Label Content="Available Tests: " />
<CheckBox x:Name="SigningTest" Content="Check Assembly Signing" Margin="10,6"/>
<CheckBox Content="FunctionB" Margin="10,6"/>
<CheckBox Content="FunctionC" Margin="10,6"/>
</StackPanel>
<!-- Status -->
<StackPanel x:Name="StatusPanel" Grid.Column="2" Grid.Row="1">
<Label Content="Test Status: " />
<Border BorderThickness="1" BorderBrush="Black" Padding="5,0" Margin="10,5">
<TextBlock x:Name="SigningTestStatus" Text="Not Run" />
</Border>
<Border BorderThickness="1" BorderBrush="Black" Padding="5,0" Margin="10,5">
<TextBlock x:Name="FunctionBStatus" Text="Not Run" />
</Border>
<Border BorderThickness="1" BorderBrush="Black" Padding="5,0" Margin="10,5">
<TextBlock x:Name="FunctionCStatus" Text="Not Run" />
</Border>
</StackPanel>
<!-- Execute Button -->
<Button Content="Execute Selected Tests" Width="140" Height="20" Margin="10,5" Grid.Column="3" Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</Grid>
<StackPanel>
<!-- Console -->
<TextBox x:Name="ConsoleBox" Margin="10" ScrollViewer.VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" Height="115" />
</StackPanel>
</DockPanel>
</Window>
"@
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try{
$Form=[Windows.Markup.XamlReader]::Load( $reader )
}
catch{
Write-Warning "Unable to parse XML, with error: $($Error[0])`n Ensure that there are NO SelectionChanged or TextChanged properties in your textboxes (PowerShell cannot process them)"
throw
}
#===========================================================================
# Load XAML Objects In PowerShell
#===========================================================================
$xaml.SelectNodes("//*[@Name]") | %{"trying item $($_.Name)";
try {Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name) -ErrorAction Stop}
catch{throw}
}
Function Get-FormVariables{
if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
write-Debug "Found the following interactable elements from our form:"
get-variable WPF* | Write-Debug
}
Get-FormVariables
#===========================================================================
# Use this space to add code to the various form elements in your GUI
#===========================================================================
$WPFSigningTestStatus.Text = "Hello!"
#Reference
#Adding items to a dropdown/combo box
#$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
#Setting the text of a text box to the current PC name
#$WPFtextBox.Text = $env:COMPUTERNAME
#Adding code to a button, so that when clicked, it pings a system
# $WPFbutton.Add_Click({ Test-connection -count 1 -ComputerName $WPFtextBox.Text
# })
#===========================================================================
# Functions
#===========================================================================
function DetermineSignatureState
{
Param(
[parameter(Mandatory=$true)]
[String]
$FullPath,
[parameter(Mandatory=$true)]
[Boolean]
$Recurse
)
if (!(Test-Path -Path $FullPath)) {
$WPFConsoleBox.Text += "$FullPath is not a valid location."
}
}
#===========================================================================
# Shows the form
#===========================================================================
DetermineSignatureState "F:\" $true
$Form.ShowDialog() | out-null