Advertisement
1RedOne

Fixed gui

May 16th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #ERASE ALL THIS AND PUT XAML BELOW between the @" "@
  2. $inputXML = @"
  3. <Window x:Class="Azure.Window1"
  4.        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  5. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. xmlns:local="clr-namespace:WpfApplication2"
  9.        
  10.        Title="iVision Azure Accelerator" Height="524.256" Width="332.076">
  11.    <Grid Margin="0,0,174,0">
  12.    </Grid>
  13. </Window>
  14. "@      
  15.  
  16. $inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N'  -replace '^<Win.*', '<Window'
  17.  
  18.  
  19. [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
  20. [xml]$XAML = $inputXML
  21. #Read XAML
  22.  
  23.     $reader=(New-Object System.Xml.XmlNodeReader $xaml)
  24.   try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
  25. catch{Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."}
  26.  
  27. #===========================================================================
  28. # Load XAML Objects In PowerShell
  29. #===========================================================================
  30.  
  31. $xaml.SelectNodes("//*[@Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Form.FindName($_.Name)}
  32.  
  33. Function Get-FormVariables{
  34. if ($global:ReadmeDisplay -ne $true){Write-host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow;$global:ReadmeDisplay=$true}
  35. write-host "Found the following interactable elements from our form" -ForegroundColor Cyan
  36. get-variable WPF*
  37. }
  38.  
  39. Get-FormVariables
  40.  
  41. #===========================================================================
  42. # Actually make the objects work
  43. #===========================================================================
  44.  
  45.  
  46. #Sample entry of how to add data to a field
  47.  
  48. #$vmpicklistView.items.Add([pscustomobject]@{'VMName'=($_).Name;Status=$_.Status;Other="Yes"})
  49.  
  50. #===========================================================================
  51. # Shows the form
  52. #===========================================================================
  53. write-host "To show the form, run the following" -ForegroundColor Cyan
  54. $Form.ShowDialog() | out-null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement