├── .gitattributes ├── .gitignore ├── README.md ├── Snippet.ps1 └── img ├── Running Convert tool.png └── Where-To-make-changes.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PowerShell_XAML 2 | The new home of the PowerShell XAML loader Snippet for easy GUIs 3 | 4 | ###What is this? 5 | Wanna copy-paste XAML into your PowerShell scripts for an easy-peasy GUI? This is the code for you. 6 | 7 | This Snippet is made to simplify the task of creating a GUI using Visual Studio, and then importing it's XAML code into PowerShell for simple GUIs. A full walkthrough of this process is [available here, under **XAML and Visual Studio**.](http://foxdeploy.com/resources/learning-gui-toolmaking-series/) 8 | 9 | ###How to use it 10 | 11 | * Copy-Paste this code into the ISE and hit F5 to Run it 12 | * Install Visual Studio 2013 or higher 13 | * Make a WPF/C# Application 14 | * Create a GUI to fit code you already have 15 | * Copy the XAML code from the editor window in Visual Studio 16 | * In the ISE, hit Control+J to load the Snippet menu, then find 'XAML' in the list, and hit enter 17 | * Paste the XAML code into the first lines of, between $XAMl= @" "@ 18 | 19 | ###What does it do? 20 | This snippet will scan through the XAML code and creat PowerShell Objects associated with every interactable element on the screen. We can now make changes to these things with code, just by changing their objects. 21 | 22 | First time running of a GUI will generate this output 23 | ![What you see when running the script for the first time](img/Running%20Convert%20tool.png) 24 | 25 | You can run it again later if you forget the variable names by running Get-FormVariables, which is a small helper function embedded in the snippet. 26 | 27 | To make the elements on your GUI work, you'll need to add code to them, beginning with lines 51-63, this is titled the 'Make the objects actually work' area. 28 | ![Image of Yaktocat](img/Where-To-make-changes.png) 29 | 30 | You'll find examples of how to do this already within the snippet. 31 | 32 | ###I still don't get it 33 | If this is confusing, please consult the [full step-by-step walkthrough](http://foxdeploy.com/resources/learning-gui-toolmaking-series/) found on [FoxDeploy.com](http://www.foxdeploy.com). 34 | 35 | Alternately, e-mail me at Stephen@Foxdeploy.com. 36 | 37 | -------------------------------------------------------------------------------- /Snippet.ps1: -------------------------------------------------------------------------------- 1 |     #ERASE ALL THIS AND PUT XAML BELOW between the @" "@ 2 | $inputXML = @" 3 | 11 | 12 | 13 | 14 | 15 | "@ 16 | 17 | $inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^