├── Ep1 WPFGUIinTenLines ├── PoSHGUI.ps1 ├── PoSHGUIWithActions.ps1 ├── TwitterApi.ps1 ├── WPFGUIinTenLines │ └── MainWindow.xaml └── objects and properties.ps1 ├── Ep2 Basic Wizard ├── Basic Wizard │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml ├── BasicWizard.ps1 └── Get-XamlObject.ps1 ├── Ep3 CheckBoxesAndRadioButtons ├── CheckBoxesAndRadioButons.ps1 ├── CheckBoxesAndRadioButtons │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml └── EventObjectExplore.ps1 ├── Ep4 Enable Disable Hide and Collapse ├── EnableDisableHideCollapse.ps1 └── Ep4 Enable Disable Hide and Collapse │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml ├── Ep5 3 ways to do IP address boxes ├── Ep5 3 Ways To Do IP Address Boxes │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml └── IPAddressBoxes.ps1 ├── Ep6 Routed Events ├── Ep6 Routed Events │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml └── Routed Events.ps1 ├── Ep7 Runspaces ├── DebugRunspace.ps1 ├── Ep7 Runspaces │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml ├── Ep7 Runspaces1.ps1 ├── Ep7 Runspaces2.ps1 ├── Ep7 Runspaces3.ps1 ├── Ep7 Runspaces4.ps1 └── Ep7 Runspaces5.ps1 ├── Ep8 Runspaces Pt2 ├── DebugRunspacePt2.ps1 ├── Ep8 Runspaces Pt2 │ ├── Finish.xaml │ ├── MainWindow.xaml │ ├── Middle.xaml │ └── Title.xaml └── Ep8 Runspaces1.ps1 ├── README.md └── bubbleuproutedevents.xml /Ep1 WPFGUIinTenLines/PoSHGUI.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Author : Jim Moyle @jimmoyle 4 | GitHub : https://github.com/JimMoyle/GUIDemo 5 | 6 | Version 0.0.1 7 | #> 8 | 9 | #Add in the frameworks so that we can create the WPF GUI 10 | Add-Type -AssemblyName presentationframework, presentationcore 11 | 12 | 13 | #Create empty hashtable into which we will place the GUI objects 14 | $wpf = @{ } 15 | 16 | 17 | #Grab the content of the Visual Studio xaml file as a string 18 | $inputXML = Get-Content -Path ".\WPFGUIinTenLines\MainWindow.xaml" 19 | 20 | Clear-Host 21 | $inputXML 22 | 23 | Clear-Host 24 | $firstItem = $inputXML | select-object -first 1 25 | $firstItem.gettype().Fullname 26 | 27 | 28 | #clean up xml there is syntax which Visual Studio 2015 creates which PoSH can't understand 29 | $inputXMLClean = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace 'x:Class=".*?"','' -replace 'd:DesignHeight="\d*?"','' -replace 'd:DesignWidth="\d*?"','' 30 | 31 | Clear-Host 32 | $inputXMLClean 33 | 34 | 35 | #change string variable into xml 36 | [xml]$xaml = $inputXMLClean 37 | 38 | Clear-Host 39 | $xaml.GetType().Fullname 40 | 41 | 42 | #read xml data into xaml node reader object 43 | $reader = New-Object System.Xml.XmlNodeReader $xaml 44 | 45 | #create System.Windows.Window object 46 | $tempform = [Windows.Markup.XamlReader]::Load($reader) 47 | $tempform.GetType().Fullname 48 | 49 | #select each named node using an Xpath expression. 50 | $namedNodes = $xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") 51 | 52 | 53 | #add all the named nodes as members to the $wpf variable, this also adds in the correct type for the objects. 54 | $namedNodes | ForEach-Object { 55 | 56 | $wpf.Add($_.Name, $tempform.FindName($_.Name)) 57 | 58 | } 59 | 60 | 61 | #show what's inside $wpf 62 | clear-Host 63 | $wpf 64 | 65 | Clear-Host 66 | $wpf.YouTubeButton.GetType().Fullname 67 | 68 | Clear-Host 69 | $wpf.YouTubeButton 70 | 71 | Clear-Host 72 | $wpf.YouTubeButton.Content 73 | 74 | Clear-Host 75 | $buttonEvents = $wpf.YouTubeButton | Get-Member | Where-Object {$_.MemberType -eq 'Event'} 76 | $buttonEvents.count 77 | 78 | 79 | $wpf.YouTubeWindow.ShowDialog() | Out-Null -------------------------------------------------------------------------------- /Ep1 WPFGUIinTenLines/PoSHGUIWithActions.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Author : Jim Moyle @jimmoyle 4 | GitHub : https://github.com/JimMoyle/GUIDemo 5 | 6 | Version 0.0.1 7 | #> 8 | 9 | 10 | #======================================================== 11 | #code from previous script 12 | #======================================================== 13 | 14 | 15 | Add-Type -AssemblyName presentationframework, presentationcore 16 | $wpf = @{ } 17 | $inputXML = Get-Content -Path ".\WPFGUIinTenLines\MainWindow.xaml" 18 | $inputXMLClean = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace 'x:Class=".*?"','' -replace 'd:DesignHeight="\d*?"','' -replace 'd:DesignWidth="\d*?"','' 19 | [xml]$xaml = $inputXMLClean 20 | $reader = New-Object System.Xml.XmlNodeReader $xaml 21 | $tempform = [Windows.Markup.XamlReader]::Load($reader) 22 | $namedNodes = $xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") 23 | $namedNodes | ForEach-Object {$wpf.Add($_.Name, $tempform.FindName($_.Name))} 24 | 25 | 26 | #======================================================== 27 | 28 | 29 | 30 | #======================================================== 31 | #Your Code goes here 32 | #======================================================== 33 | 34 | #Import Twitter Module 35 | Import-Module InvokeTwitterAPIs 36 | 37 | #This code runs when the button is clicked 38 | $wpf.YouTubeButton.add_Click({ 39 | 40 | #Get screen name from textbox 41 | $screenName = $wpf.YouTubetextBox.text 42 | 43 | #Get Userdata from Twitter 44 | $userdata = Get-TwitterUser_Lookup -screen_name $screenName 45 | 46 | #Show user image in GUI 47 | $wpf.YouTubeimage.source = $userdata.profile_image_url 48 | 49 | }) 50 | 51 | #======================================================= 52 | #End of Your Code 53 | #======================================================= 54 | 55 | 56 | 57 | $wpf.YouTubeWindow.ShowDialog() | Out-Null -------------------------------------------------------------------------------- /Ep1 WPFGUIinTenLines/TwitterApi.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | Author : Jim Moyle @jimmoyle 4 | GitHub : https://github.com/JimMoyle/GUIDemo 5 | 6 | Version 0.0.1 7 | #> 8 | 9 | Find-module *twitter* 10 | 11 | #import the twitter API module after downloading it from the gallery 12 | Import-Module InvokeTwitterAPIs 13 | 14 | #Show twitter oath dev page 15 | Start-process https://dev.twitter.com/oauth 16 | 17 | 18 | #check it is there 19 | Get-Command -Module InvokeTwitterAPIs 20 | 21 | 22 | #Set screenName variable to the user you want to look up 23 | $screenName = 'JimMoyle' 24 | 25 | 26 | #Test username lookup 27 | $userdata = Get-TwitterUser_Lookup -screen_name $screenName 28 | $userdata 29 | $userdata.location 30 | 31 | 32 | #Test location of profile pic 33 | $url = $userdata.profile_image_url 34 | Start-Process $url -------------------------------------------------------------------------------- /Ep1 WPFGUIinTenLines/WPFGUIinTenLines/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 |