Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ERASE ALL THIS AND PUT XAML BELOW between the @" "@
- $inputXML = @"
- <Window x:Class="WpfApplication2.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:WpfApplication2"
- mc:Ignorable="d"
- Title="AMP Deployer" Height="558.437" Width="525">
- <Grid>
- <GroupBox x:Name="groupBox2" Header="Email Addresses" Height="100" Margin="11,341,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="490" Foreground="#FFC2C3C9"/>
- <GroupBox x:Name="groupBox1" Header="Details" Height="129" Margin="11,100,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="490" Foreground="#FFC2C3C9"/>
- <GroupBox x:Name="groupBox" Header="SIP Domains" Height="100" Margin="11,235,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="490" Foreground="#FFC2C3C9"/>
- <Image x:Name="image" HorizontalAlignment="Left" Height="49" Margin="0,10,-0.333,0" VerticalAlignment="Top" Width="519" Source="C:\Users\User\Pictures\Logo\Logo.png"/>
- <TextBox x:Name="textBoxCustomerName" HorizontalAlignment="Left" Height="23" Margin="128,122,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="348" ToolTip="Enter the customer name"/>
- <Button x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" Margin="419,466,0,0" VerticalAlignment="Top" Width="75" ToolTip="Cancel the deployment"/>
- <Button x:Name="btnDeploy" Content="Deploy" HorizontalAlignment="Left" Margin="329,466,0,0" VerticalAlignment="Top" Width="75" ToolTip="Start the deployment"/>
- <Label x:Name="label" Content="Customer Name" HorizontalAlignment="Left" Margin="-1,122,0,0" VerticalAlignment="Top" Height="23" Width="117" FlowDirection="RightToLeft"/>
- <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="10,64,0,0" TextWrapping="Wrap" Text="Welcome to AMP Deployer. Use this tool to deploy a new environment on a vmware datacenter. Just answer the questions below and press Deploy." VerticalAlignment="Top" Height="36" Width="499"/>
- <TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="23" Margin="127.667,155.792,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="46" UseLayoutRounding="False" MaxLength="3" ToolTip="Example: uc025"/>
- <Label x:Name="label1" Content="Environment Nr" HorizontalAlignment="Left" Margin="23,154,0,0" VerticalAlignment="Top" Height="23" Width="93" FlowDirection="RightToLeft"/>
- <Label x:Name="label2" Content="Type" HorizontalAlignment="Left" Margin="317,190,0,0" VerticalAlignment="Top" FlowDirection="RightToLeft"/>
- <RadioButton x:Name="radioButton" Content="L" HorizontalAlignment="Left" Margin="361,197,0,0" VerticalAlignment="Top" ToolTip="Single Server deployment"/>
- <RadioButton x:Name="radioButton1" Content="XL" HorizontalAlignment="Left" Margin="398,197,0,0" VerticalAlignment="Top" ToolTip="High Available deployment"/>
- <RadioButton x:Name="radioButton2" Content="XXL
" HorizontalAlignment="Left" Margin="435,197,0,0" VerticalAlignment="Top" IsEnabled="False" Height="15" ToolTip="Geo Redundant deployment"/>
- <Label x:Name="label3" Content="Anywhere365" HorizontalAlignment="Left" Margin="34,190,0,0" VerticalAlignment="Top" FlowDirection="RightToLeft"/>
- <ComboBox x:Name="comboBox" HorizontalAlignment="Left" Margin="128,192,0,0" VerticalAlignment="Top" Width="120" >
- <ComboBoxItem Content="No" HorizontalAlignment="Left" Width="118"/>
- <ComboBoxItem Content="Yes, Single Server" HorizontalAlignment="Left" Width="118"/>
- <ComboBoxItem Content="Yes, High Available" HorizontalAlignment="Left" Width="118"/>
- </ComboBox>
- <TextBox x:Name="textBox_Copy" HorizontalAlignment="Left" Height="23" Margin="128,258,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="348" ToolTip="Primary SIP Domain"/>
- <Label x:Name="label_Copy" Content="Primary" HorizontalAlignment="Left" Margin="-1,258,0,0" VerticalAlignment="Top" Height="23" Width="117" FlowDirection="RightToLeft"/>
- <TextBox x:Name="textBox_Copy1" HorizontalAlignment="Left" Height="23" Margin="128,295,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="348" ToolTip="Additional SIP Domains (comma seperated)"/>
- <Label x:Name="label_Copy1" Content="Additional" HorizontalAlignment="Left" Margin="-1,295,0,0" VerticalAlignment="Top" Height="23" Width="117" FlowDirection="RightToLeft"/>
- <TextBox x:Name="textBox_Copy2" HorizontalAlignment="Left" Height="23" Margin="128,364,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="348" ToolTip="Email address of the Technical Consultant"/>
- <Label x:Name="label_Copy2" Content="Tech. Consultant" HorizontalAlignment="Left" Margin="-1,364,0,0" VerticalAlignment="Top" Height="23" Width="117" FlowDirection="RightToLeft"/>
- <TextBox x:Name="textBox_Copy3" HorizontalAlignment="Left" Height="23" Margin="128,400,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="348" ToolTip="Email address of the project manager"/>
- <Label x:Name="label_Copy3" Content="Project Manager" HorizontalAlignment="Left" Margin="-1,401,0,0" VerticalAlignment="Top" Height="23" Width="117" FlowDirection="RightToLeft"/>
- <StatusBar HorizontalAlignment="Left" Height="31" Margin="0,498,-0.333,0" VerticalAlignment="Top" Width="519" ToolTip="Status information is displayed here"/>
- </Grid>
- </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{
- $error[0]
- Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
- break
- }
- #===========================================================================
- # Load XAML Objects In PowerShell
- #===========================================================================
- $xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
- 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-host "Found the following interactable elements from our form" -ForegroundColor Cyan
- get-variable WPF*
- }
- Get-FormVariables
- #===========================================================================
- # Actually make the objects work
- #===========================================================================
- #Sample entry of how to add data to a field
- #$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
- #===========================================================================
- # Shows the form
- #===========================================================================
- write-host "To show the form, run the following" -ForegroundColor Cyan
- $Form.ShowDialog() | out-null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement