Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for airreggui.ps

(view source code of airreggui.ps as plain text)

  1. <#
  2. .SYNOPSIS
  3. Search for aircraft photos on Airport-data.com by the aircraft's registration number
  4.  
  5. .DESCRIPTION
  6. This simple GUI script allows you to enter an aircraft registration and then search Airport-data.com for photos and specifications of that aircraft.
  7. Interactive usage: enter an aircraft registration in the input texbox and press Enter or click the Search button to search Airport-data.com's website for photos and detailed specifications.
  8. Command line usage: run this script with -Help parameter to view its command line syntax.
  9.  
  10. .NOTES
  11. Dashes are mandatory in many aircraft registrations, but not all, e.g. PH-PBY and N1944S will work, but PHPBY and N-1944S won't.
  12.  
  13. Invalid command line switches starting with a dash will trigger a PowerShell error message.
  14.  
  15. All command line switches starting with a slash will trigger this script's help screen.
  16.  
  17. This script can be extended by using downloaded local aircraft registration databases; see this script's web page (see links section) for details.
  18.  
  19. Return code ("ErrorLevel") is 1 in case of errors, otherwise 0.
  20.  
  21. .PARAMETER AircraftRegistration
  22. (optional) A valid aircraft registration, e.g. PH-PBY or N1944S or OK-NUL.
  23. Aircraft registration may be entered in the GUI if not specified on the command line.
  24.  
  25. .PARAMETER SearchEngine
  26. (optional) Alternative search engine if no match was found on Airport-data.com.
  27. Valid SearchEngine values are 'DuckDuckGo', 'Google' (default) or 'StartPage'.
  28. Useful only if local database extension scripts are installed.
  29. Command line only, cannot be changed interactively in the GUI.
  30.  
  31. .PARAMETER Hide
  32. Hides the console window (GUI remains visible).
  33. Command line only, cannot be changed interactively in the GUI.
  34.  
  35. .PARAMETER Debug
  36. Shows some progress messages, especially usefull when using local databases.
  37. Command line only, cannot be changed interactively in the GUI.
  38.  
  39. .PARAMETER Version
  40. Show this script's version number.
  41. If combined with -Verbose show full script path, version number and last/modified/release date.
  42.  
  43. .PARAMETER Help
  44. Shows this script's help screen, with more details than the Help button's help text.
  45.  
  46. .EXAMPLE
  47. powershell . ./AirRegGUI.ps1
  48. Will open the GUI with empty input textbox, the console remains visible
  49.  
  50. .EXAMPLE
  51. powershell . ./AirRegGUI.ps1 -Hide
  52. Will open the GUI with empty input textbox and hide the console
  53.  
  54. .EXAMPLE
  55. powershell . ./AirRegGUI.ps1 N1944S
  56. Will open the GUI with N1944S in input textbox, and start search immediately, the console remains visible
  57.  
  58. .EXAMPLE
  59. powershell . ./AirRegGUI.ps1 -AircraftRegistration N1944S
  60. Will open the GUI with N1944S in input textbox, and start search immediately, the console remains visible
  61.  
  62. .EXAMPLE
  63. powershell . ./AirRegGUI.ps1 PH-PBY -Hide
  64. Will open the GUI with PH-PBY in input textbox, start search immediately, and hide the console
  65.  
  66. .EXAMPLE
  67. powershell . ./AirRegGUI.ps1 -AircraftRegistration PH-PBY -Hide
  68. Will open the GUI with PH-PBY in input textbox, start search immediately, and hide the console
  69.  
  70. .LINK
  71. Script written by Rob van der Woude:
  72. https://www.robvanderwoude.com/airreg.php
  73.  
  74. .LINK
  75. Airport-data API courtesy of Airport-data.com:
  76. http://www.airport-data.com/api/doc.php
  77.  
  78. .LINK
  79. Script created in Visual Studio Community 2019 with a trial version of Ironman Software's PowerShell Pro Tools Suite:
  80. https://ironmansoftware.com/powershell-pro-tools/
  81.  
  82. .LINK
  83. Capturing Enter key (as a work-around for the form's AcceptButton not working as expected) by sodawillow on StackOverflow.com:
  84. https://stackoverflow.com/a/41441704
  85.  
  86. .LINK
  87. Code to hide console window by Anthony on StackOverflow.com:
  88. http://stackoverflow.com/a/15079092
  89.  
  90. .LINK
  91. Use of Shown event (to make sure the GUI is visible before starting an optional immediate search) by Matthias Schippling on StackOverflow.com:
  92. https://stackoverflow.com/a/219155
  93.  
  94. .LINK
  95. Capture -Debug and -Verbose parameter by mklement0 on StackOverflow.com:
  96. https://stackoverflow.com/a/48643616
  97. #>
  98.  
  99. param (
  100. 	[parameter( ValueFromPipeline )]
  101. 	[ValidatePattern("(^\s*$|[\?/]|^\w[\w-]{2,3}\w+)")]
  102. 	[string]$AircraftRegistration = '',
  103. 	[parameter( ValueFromPipeline )]
  104. 	[ValidateSet('DuckDuckGo','Google','StartPage')]
  105. 	[string]$SearchEngine = 'Google',
  106. 	[switch]$Hide,
  107. 	[switch]$Help,
  108. 	[switch]$Version
  109. )
  110.  
  111. $progver = "2.13"
  112.  
  113. $AircraftRegistration = $AircraftRegistration.ToUpper( )
  114. $Manufacturer = ''
  115. $Model = ''
  116. [bool]$Debug = ( $PSBoundParameters.ContainsKey( 'Debug' ) )
  117. [bool]$Verbose = ( $PSBoundParameters.ContainsKey( 'Verbose' ) )
  118. $global:notfound = $true
  119.  
  120. if ( $Version ) {
  121. 	if ( $Verbose ) {
  122. 		$lastmod = ( [System.IO.File]::GetLastWriteTime( $PSCommandPath ) )
  123. 		if ( $lastmod.ToString( "h.mm" ) -eq $progver ) {
  124. 			"`"{0}`", Version {1}, release date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
  125. 		} else {
  126. 			# if last modified time is not equal to program version, the script has been tampered with
  127. 			"`"{0}`", Version {1}, last modified date {2}" -f $PSCommandPath, $progver, $lastmod.ToString( "yyyy-MM-dd" )
  128. 		}
  129. 	} else {
  130. 		$progver
  131. 	}
  132. 	exit 0
  133. }
  134.  
  135. if ( $Help -or ( $AircraftRegistration -match "[/\?]" ) ) {
  136. 	Clear-Host
  137. 	Write-Host ( "`"{0}`", Version {1}" -f ( "$PSCommandPath" -replace "$PSScriptRoot","" ), $progver ) -NoNewline
  138. 	$lastmod = ( [System.IO.File]::GetLastWriteTime( $PSCommandPath ) )
  139. 	if ( $lastmod.ToString( "h.mm" ) -eq $progver ) {
  140. 		Write-Host ", release date " -NoNewline
  141. 	} else {
  142. 		# if last modified time is not equal to program version, the script has been tampered with
  143. 		Write-Host ", last modified date " -NoNewline
  144. 	}
  145. 	Write-Host $lastmod.ToString( "yyyy-MM-dd" )
  146. 	Write-Host
  147. 	Get-Help $PSCommandPath -Full
  148. 	exit -1
  149. }
  150.  
  151. $global:airportdatalink = ''
  152. $Debug = ( $PSBoundParameters.ContainsKey( 'Debug' ) )
  153. $defaulthelptext = "Enter an aircraft registration number, e.g. `"PH-PBY`" and click the Search button.`n`n" + `
  154.                    "This script will then search Airport-Data.com for photos of the aircraft with that registration.`n`n" + `
  155.                    "If found, a thumbnail of the photo will be displayed in this script's window, plus a button to view the photo full size in your default browser.`n`n" + `
  156.                    "{0} 2020 Rob van der Woude`nhttps://www.robvanderwoude.com" -f [char]0x00A9
  157.  
  158. # Search query templates
  159. if ( $SearchEngine -match '^DuckDuckGo$' ) {
  160. 	$SearchEngine = 'DuckDuckGo'
  161. 	$searchtemplate = "https://duckduckgo.com/html/?q=x{0}"
  162. } elseif ( $SearchEngine -match '^Google$' ) {
  163. 	$SearchEngine = 'Google'
  164. 	$searchtemplate = "https://www.google.com/search?q={0}" # Google by default
  165. } elseif ( $SearchEngine -match '^Startpage$' ) {
  166. 	$SearchEngine = 'StartPage'
  167. 	$searchtemplate = "https://startpage.com/do/search?cat=web&cmd=process_search&language=english&engine0=v1all&query={0}"
  168. } else {
  169. 	$SearchEngine = 'Google'
  170. 	$searchtemplate = "https://www.google.com/search?q={0}" # Google by default
  171. 	if ( -not $Quiet ) {
  172. 		Write-Host ( "Invalid -SearchEngine value `"{0}`", using Google instead" -f $SearchEngine )
  173. 	}
  174. }
  175. if ( $Debug ) {
  176. 	Write-Host ( "Search Engine: {0}" -f $SearchEngine )
  177. 	Write-Host ( "Search template: {0}" -f $searchtemplate )
  178. }
  179.  
  180. #######################################
  181. # Hide console window                 #
  182. # by Anthony on StackOverflow.com     #
  183. # http://stackoverflow.com/a/15079092 #
  184. #######################################
  185.  
  186. $signature1 = @'
  187. public static void ShowConsoleWindow( int state )
  188. {
  189. 	var handle = GetConsoleWindow( );
  190. 	ShowWindow( handle, state );
  191. }
  192.  
  193. [System.Runtime.InteropServices.DllImport( "kernel32.dll" )]
  194. static extern IntPtr GetConsoleWindow( );
  195.  
  196. [System.Runtime.InteropServices.DllImport( "user32.dll" )]
  197. static extern bool ShowWindow( IntPtr hWnd, int nCmdShow );
  198. '@
  199.  
  200. # Hide console if requested
  201. if ( $Hide ) {
  202. 	$hideconsole = Add-Type -MemberDefinition $signature1 -Name Hide -Namespace HideConsole -ReferencedAssemblies System.Runtime.InteropServices -PassThru
  203. 	$hideconsole::ShowConsoleWindow( 0 )
  204. }
  205.  
  206. #######################
  207. # End of Hide console #
  208. #######################
  209.  
  210. ###########################
  211. # Start of Event handlers #
  212. ###########################
  213.  
  214. $ButtonHelp_Click = {
  215. 	$inserttext = "If local database extensions are installed, a local search will be initiated if no match was found online on Airport-data.com.`n" + `
  216. 	              "Local searches take considerably longer than online searches!`n" + `
  217. 	              "See https://www.robvanderwoude.com/airreg.php for details on local database extensions.`n`n" + `
  218. 	              "For detailed help use the command:`n`n" + `
  219. 	              "      . '.{0}' -Help`n`nor:`n`n" -f $PSCommandPath.Substring( $PSScriptRoot.Length ) + `
  220. 				  "      . '.{0}' /?`n`nor:`n`n" -f $PSCommandPath.Substring( $PSScriptRoot.Length ) + `
  221. 	              "      Get-Help '.{0}' -Full`n`n" -f $PSCommandPath.Substring( $PSScriptRoot.Length ) + `
  222. 				  "Do you want to open this script's web page now?`n`n{1}" -f $PSCommandPath.Substring( $PSScriptRoot.Length ), [char]0x00A9
  223. 	$helptext = $defaulthelptext -replace [char]0x00A9, $inserttext
  224. 	$title = "Help for {0}" -f $AirRegGUI.Text
  225. 	$answer = [System.Windows.Forms.MessageBox]::Show( $helptext, $title, 'YesNo' )
  226. 	if ( $answer -eq 'Yes' ) {
  227. 		Start-Process 'https://www.robvanderwoude.com/airreg.php'
  228. 	}
  229. }
  230.  
  231. $ButtonOpenLink_Click = {
  232. 	Start-Process $global:airportdatalink -WindowStyle 1
  233. }
  234.  
  235. $ButtonSearch_Click = {
  236. 	Search-Aircraft
  237. }
  238.  
  239. $TextboxReg_KeyUp = {
  240. 	Validate-Input( $_.KeyCode )
  241. }
  242.  
  243. $TextboxReg_TextChanged = {
  244. 	Validate-Input
  245. }
  246.  
  247. $Window_Load = {
  248. 	$AirRegGUI.Text = "AirRegGUI.ps1 - Version {0}" -f $progver # window title
  249. 	$LabelHelptext.Text = $defaulthelptext # help text in window
  250. }
  251.  
  252. $Window_Shown = {
  253. 	if ( ![string]::IsNullOrWhiteSpace( $AircraftRegistration ) ) {
  254. 		$TextboxReg.Text = $AircraftRegistration # enter specified aircraft registration in input textbox
  255. 		$TextboxReg.SelectionStart = $TextboxReg.Text.Length # move cursor to end of input text
  256. 		$TextboxReg.SelectionLength = 0
  257. 		# Start search immediately
  258. 		[System.Windows.Forms.Application]::DoEvents( ) # start updating GUI
  259. 		Start-Sleep -Seconds 1 # allow GUI update to complete
  260. 		Validate-Input( 'Return' )
  261. 	}
  262. }
  263.  
  264. #########################
  265. # End of Event handlers #
  266. #########################
  267.  
  268. function Check-Update( ) {
  269. 	$ProgressPreference = 'SilentlyContinue'
  270. 	$checkupdate = ( Invoke-WebRequest -Uri 'https://www.robvanderwoude.com/updates/airreg.txt' -TimeoutSec 10 )
  271. 	$ProgressPreference = 'Continue'
  272. 	if ( $checkupdate.StatusCode -eq 200 ) {
  273. 		$latestversion = [float]$checkupdate.Content
  274. 		$currentversion = [float]$progver
  275. 		if ( $latestversion -gt $currentversion ) {
  276. 			$title = 'Update Available'
  277. 			$message = ( "An update for this script is available.`nYour current version is {0}, the latest version available is {1}.`n`n" + `
  278. 			             "Do you want to open the download page for the update?" -f ( $currentversion -replace ",","." ), ( $latestversion -replace ",","." ) )
  279. 			$buttons = [System.Windows.Forms.MessageBoxButtons]::YesNo
  280. 			if ( [System.Windows.Forms.MessageBox]::Show( $message, $title, $buttons ) -eq 'Yes' ) {
  281. 				Start-Process 'https://www.robvanderwoude.com/airreg.php'
  282. 			}
  283. 		}
  284. 	}
  285. }
  286.  
  287. function Search-LocalDB( $message = 'Not found' ) {
  288. 	[OutputType([bool])]
  289. 	$prefix = ''
  290. 	$registration = $TextboxReg.Text
  291. 	$found = $false
  292. 	if ( $registration.Contains( '-' ) ) {
  293. 		$prefix = $registration.Split( '-' )[0]
  294. 	} else {
  295. 		$prefix = $registration.Substring( 0, 1 )
  296. 	}
  297. 	$localDBscript = ( Join-Path -Path $PSScriptRoot -ChildPath ( "AirReg{0}Cmd.ps1" -f $prefix ) )
  298. 	if ( Test-Path $localDBscript -PathType 'Leaf' ) {
  299. 		if ( $Debug ) {
  300. 			Write-Host ( "Found local '{0}' database file `"{1}`"" -f $prefix, $localDBscript )
  301. 		}
  302. 		$ButtonOpenLink.Visible = $false
  303. 		$LabelPhotographer.Visible = $false
  304. 		$PictureboxThumbnail.Visible = $false
  305. 		$ButtonOpenLink.Enabled = $false
  306. 		$LabelHelptext.Text = "Searching local database, this may take a while..."
  307. 		$LabelHelptext.Visible = $true
  308. 		[System.Windows.Forms.Application]::DoEvents( ) # update GUI
  309.  
  310. 		$Manufacturer = ''
  311. 		$Model = ''
  312.  
  313. 		if ( $Debug ) {
  314. 			$Stopwatch = [System.Diagnostics.Stopwatch]::StartNew( )
  315. 			Write-Host ( "Start searching local database at {0}" -f ( Get-Date ) )
  316. 			if ( ( Get-Content $localDBscript ) -match 'TerminateExcel' ) {
  317. 				. "$localDBscript" -Registration $registration -TerminateExcel -Debug
  318. 			} else {
  319. 				. "$localDBscript" -Registration $registration -Debug
  320. 			}
  321. 			Write-Host ( "Finished at {0} (time elapsed {1})" -f ( Get-Date ), $Stopwatch.Elapsed )
  322. 			$Stopwatch.Stop( )
  323. 			Write-Host ( "Registration = {0}" -f $registration )
  324. 			Write-Host ( "Manufacturer = {0}" -f $Manufacturer )
  325. 			Write-Host ( "Model        = {0}" -f $Model )
  326. 		} else {
  327. 			if ( ( Get-Help "$localDBscript" ) -match '[-TerminateExcel]' ) {
  328. 				. "$localDBscript" -Registration $registration -TerminateExcel
  329. 			} else {
  330. 				. "$localDBscript" -Registration $registration
  331. 			}
  332. 		}
  333. 		if ( $Model ) {
  334. 			if ( $Manufacturer ) {
  335. 				$LabelHelptext.Text = ( "{0} {1}" -f $Manufacturer, $Model )
  336. 				$searchquery = ( ( ( "{0} {1} {2}" -f $Manufacturer, $Model, $registration ) -replace " ","+" ) -replace ",","" )
  337. 			} else {
  338. 				$LabelHelptext.Text = $Model
  339. 				$searchquery = ( ( ( "{0} {1}" -f $Model, $registration ) -replace " ","+" ) -replace ",","" )
  340. 			}
  341. 			$global:airportdatalink = ( $searchtemplate -f $searchquery )
  342. 			$ButtonOpenLink.Enabled = $true
  343. 			$ButtonOpenLink.Text = ( 'Search on {0}' -f $SearchEngine )
  344. 			$ButtonOpenLink.Visible = $true
  345. 			[System.Windows.Forms.Application]::DoEvents( ) # start updating GUI
  346. 			Start-Sleep -Seconds 1 # allow GUI update to complete
  347. 			$found = $true
  348. 			$global:notfound = $false
  349. 		} else {
  350. 			$message = ( "$message, and not found in local {0} database either" -f $prefix )
  351. 			$LabelHelptext.Text = $message
  352. 			[System.Windows.Forms.Application]::DoEvents( ) # start updating GUI
  353. 			Start-Sleep -Seconds 1 # allow GUI update to complete
  354. 			if ( Search-OpenSky $message ) {
  355. 				$true
  356. 			}
  357. 		}
  358. 	} else {
  359. 		$message = ( "$message, no local {0} database found" -f $prefix )
  360. 		$LabelHelptext.Text = $message
  361. 		[System.Windows.Forms.Application]::DoEvents( ) # start updating GUI
  362. 		Start-Sleep -Seconds 1 # allow GUI update to complete
  363. 		if ( Search-OpenSky $message ) {
  364. 			$true
  365. 		}
  366. 	}
  367. 	$found
  368. }
  369.  
  370. function Search-OpenSky( $message = 'Not found' ) {
  371. 	[OutputType([bool])]
  372. 	$registration = $TextboxReg.Text
  373. 	$found = $false
  374. 	$openskyscript = ( Join-Path $PSScriptRoot 'AirRegOpenSkyCmd.ps1' )
  375. 	if ( Test-Path -Path $openskyscript -PathType 'Leaf' ) {
  376. 		$LabelHelptext.Text = ( "{0}, searching OpenSky database, this may take a minute..." -f $LabelHelptext.Text )
  377. 		[System.Windows.Forms.Application]::DoEvents( ) # start updating GUI
  378. 		Start-Sleep -Seconds 1 # allow GUI update to complete
  379. 		if ( $Debug ) {
  380. 			Write-Host ( "Found OpenSky extension `"{0}`"" -f $openskyscript )
  381. 			. "$openskyscript" -Registration $registration -NoBreak -Debug
  382. 		} else {
  383. 			. "$openskyscript" -Registration $registration -NoBreak
  384. 		}
  385. 		if ( $Model ) {
  386. 			if ( $Manufacturer ) {
  387. 				$LabelHelptext.Text = ( ( "{0} {1}" -f $Manufacturer, $Model ) -replace "`"","" )
  388. 				$searchquery = ( ( ( ( "{0} {1} {2}" -f $Manufacturer, $Model, $registration ) -replace " ","+" ) -replace ",","" ) -replace "`"","" )
  389. 			} else {
  390. 				$LabelHelptext.Text = $Model
  391. 				$searchquery = ( ( ( ( "{0} {1}" -f $Model, $registration ) -replace " ","+" ) -replace ",","" ) -replace "`"","" )
  392. 			}
  393. 			$global:airportdatalink = ( $searchtemplate -f $searchquery )
  394. 			$ButtonOpenLink.Enabled = $true
  395. 			$ButtonOpenLink.Text = ( 'Search on {0}' -f $SearchEngine )
  396. 			$ButtonOpenLink.Visible = $true
  397. 			$found = $true
  398. 			$global:notfound = $false
  399. 		} else {
  400. 			$LabelHelptext.Text = "$message, nor in OpenSky database"
  401. 		}
  402. 	} else {
  403. 		$LabelHelptext.Text = $message
  404. 	}
  405. 	$global:notfound
  406. }
  407.  
  408. function Search-Aircraft( ) {
  409. 	$url = ( 'http://www.airport-data.com/api/ac_thumb.json?r={0}' -f $TextboxReg.Text )
  410. 	$ProgressPreference = 'SilentlyContinue'
  411. 	$json = ( Invoke-WebRequest -Uri $url -TimeoutSec 10 ).Content | ConvertFrom-Json -ErrorAction Stop
  412. 	$ProgressPreference = 'Continue'
  413. 	if ( $json.status -eq 200 ) {
  414. 		$LabelHelptext.Visible = $false
  415. 		$PictureboxThumbnail.ImageLocation = $json.data.image
  416. 		$LabelPhotographer.Visible = $true
  417. 		$LabelPhotographer.Text = ( "Photographer: {0}" -f $json.data.photographer )
  418. 		$ButtonOpenLink.Enabled = $true
  419. 		$global:airportdatalink = $json.data.link
  420. 		$PictureboxThumbnail.Visible = $true
  421. 		$ButtonOpenLink.Visible = $true
  422. 	} else {
  423. 		$ButtonOpenLink.Visible = $false
  424. 		$LabelPhotographer.Visible = $false
  425. 		$PictureboxThumbnail.Visible = $false
  426. 		$ButtonOpenLink.Enabled = $false
  427. 		if ( Search-LocalDB( ( 'Status {0}, error {1} (aircraft registration not found on Airport-Data.com)' -f $json.status, $json.error ) ) ) {
  428. 			if ( $global:notfound ) {
  429. 				[console]::Beep( 500, 500 ) # beep if registration not found
  430. 			}
  431. 		}
  432. 		$LabelHelptext.Visible = $true
  433. 	}
  434. }
  435.  
  436. function Validate-Input( $key = $null ) {
  437. 	if ( $key -eq 'Return' ) {
  438. 		Search-Aircraft
  439. 	} else {
  440. 		$cursorpos = $TextboxReg.SelectionStart + $TextboxReg.SelectionLength
  441. 		$inputtext = $TextboxReg.Text.ToUpper( )
  442. 		$inputtext = $inputtext -replace "[^A-Z\d\-]",""
  443. 		if ( $inputtext -cne $TextboxReg.Text ) {
  444. 			if ( $inputtext -cne $TextboxReg.Text.ToUpper( ) ) {
  445. 				[console]::Beep( 500, 500 ) # beep in case of invalid character
  446. 			}
  447. 			$TextboxReg.Text = $inputtext
  448. 			$TextboxReg.SelectionStart = [Math]::Min( $cursorpos, $inputtext.Length )
  449. 			$TextboxReg.SelectionLength = 0
  450. 		}
  451. 		if ( ( $inputtext -replace "-","" ).Length -ge 4 ) {
  452. 			$ButtonSearch.Enabled = $true
  453. 		} else {
  454. 			$ButtonSearch.Enabled = $false
  455. 		}
  456. 		$LabelHelptext.Visible = $true
  457. 		$LabelHelptext.Text = $defaulthelptext
  458. 		$LabelPhotographer.Visible = $false
  459. 		$PictureboxThumbnail.Visible = $false
  460. 		$ButtonOpenLink.Text = 'View photo on Airport-data.com'
  461. 		$ButtonOpenLink.Enabled = $false
  462. 		$ButtonOpenLink.Visible = $false
  463. 	}
  464. }
  465.  
  466. ############################################
  467. # GUI form design was saved separately by  #
  468. # Visual Studio/Ironman Software's         #
  469. # PowerShell Pro Tools Suite as            #
  470. # AirRegGUI.designer.ps1 and then manually #
  471. # embedded in AirRegGUI.ps1 by yours truly #
  472. #                                          #
  473. # Start of embedded AirRegGUI.designer.ps1 #
  474. ############################################
  475.  
  476. [void][System.Reflection.Assembly]::Load( 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' )
  477. [void][System.Reflection.Assembly]::Load( 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' )
  478.  
  479. $AirRegGUI = New-Object -TypeName System.Windows.Forms.Form
  480. [System.Windows.Forms.TextBox]$TextboxReg = ( New-Object -TypeName System.Windows.Forms.TextBox )
  481. [System.Windows.Forms.Button]$ButtonSearch = ( New-Object -TypeName System.Windows.Forms.Button )
  482. [System.Windows.Forms.Button]$ButtonHelp = ( New-Object -TypeName System.Windows.Forms.Button )
  483. [System.Windows.Forms.Button]$ButtonOpenLink = ( New-Object -TypeName System.Windows.Forms.Button )
  484. [System.Windows.Forms.PictureBox]$PictureboxThumbnail = ( New-Object -TypeName System.Windows.Forms.PictureBox )
  485. [System.Windows.Forms.Label]$LabelHelptext = ( New-Object -TypeName System.Windows.Forms.Label )
  486. [System.Windows.Forms.Label]$LabelPhotographer = ( New-Object -TypeName System.Windows.Forms.Label )
  487. ( [System.ComponentModel.ISupportInitialize]$PictureboxThumbnail ).BeginInit( )
  488. $AirRegGUI.SuspendLayout( )
  489.  
  490. $TextboxReg.Location = (New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]37, [System.Int32]41 ) )
  491. $TextboxReg.MaxLength = [System.Int32]8
  492. $TextboxReg.Name = [System.String]'TextboxReg'
  493. $TextboxReg.Size = (New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]100, [System.Int32]26 ) )
  494. $TextboxReg.TabIndex = [System.Int32]0
  495. $TextboxReg.Add_TextChanged( $TextboxReg_TextChanged )
  496. $TextboxReg.Add_KeyUp( $TextboxReg_KeyUp )
  497.  
  498. $ButtonSearch.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]159, [System.Int32]40 ) )
  499. $ButtonSearch.Name = [System.String]'ButtonSearch'
  500. $ButtonSearch.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]75, [System.Int32]28 ) )
  501. $ButtonSearch.TabIndex = [System.Int32]1
  502. $ButtonSearch.Text = [System.String]'Search'
  503. $ButtonSearch.UseVisualStyleBackColor = $true
  504. $ButtonSearch.Add_Click( $ButtonSearch_Click )
  505. $ButtonSearch.Enabled = $false
  506.  
  507. $ButtonHelp.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]256, [System.Int32]40 ) )
  508. $ButtonHelp.Name = [System.String]'ButtonHelp'
  509. $ButtonHelp.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]75, [System.Int32]28 ) )
  510. $ButtonHelp.TabIndex = [System.Int32]2
  511. $ButtonHelp.Text = [System.String]'Help'
  512. $ButtonHelp.UseVisualStyleBackColor = $true
  513. $ButtonHelp.Add_Click( $ButtonHelp_Click )
  514.  
  515. $ButtonOpenLink.Enabled = $false
  516. $ButtonOpenLink.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]37, [System.Int32]315 ) )
  517. $ButtonOpenLink.Name = [System.String]'ButtonOpenLink'
  518. $ButtonOpenLink.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]294, [System.Int32]28 ) )
  519. $ButtonOpenLink.TabIndex = [System.Int32]4
  520. $ButtonOpenLink.Text = [System.String]'View photo on Airport-data.com'
  521. $ButtonOpenLink.UseVisualStyleBackColor = $true
  522. $ButtonOpenLink.Add_Click( $ButtonOpenLink_Click )
  523. $ButtonOpenLink.Visible = $false
  524.  
  525. $PictureboxThumbnail.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]82, [System.Int32]101 ) )
  526. $PictureboxThumbnail.Name = [System.String]'PictureboxThumbnail'
  527. $PictureboxThumbnail.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]200, [System.Int32]150 ) )
  528. $PictureboxThumbnail.TabIndex = [System.Int32]3
  529. $PictureboxThumbnail.TabStop = $false
  530. $PictureboxThumbnail.Visible = $false
  531.  
  532. $LabelHelptext.AutoSize = $true
  533. $LabelHelptext.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]37, [System.Int32]101 ) )
  534. $LabelHelptext.MaximumSize = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]294, [System.Int32]0 ) )
  535. $LabelHelptext.Name = [System.String]'LabelHelptext'
  536. $LabelHelptext.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]275, [System.Int32]60 ) )
  537. $LabelHelptext.TabIndex = [System.Int32]6
  538. $LabelHelptext.Text = [System.String]''
  539.  
  540. $LabelPhotographer.AutoSize = $true
  541. $LabelPhotographer.Location = ( New-Object -TypeName System.Drawing.Point -ArgumentList @( [System.Int32]33, [System.Int32]273 ) )
  542. $LabelPhotographer.Name = [System.String]'label1'
  543. $LabelPhotographer.Size = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]110, [System.Int32]20 ) )
  544. $LabelPhotographer.TabIndex = [System.Int32]5
  545. $LabelPhotographer.Text = [System.String]'Photographer:'
  546. $LabelPhotographer.Visible = $false
  547.  
  548. $AirRegGUI.ClientSize = ( New-Object -TypeName System.Drawing.Size -ArgumentList @( [System.Int32]384, [System.Int32]441 ) )
  549. $AirRegGUI.Controls.Add( $LabelHelptext )
  550. $AirRegGUI.Controls.Add( $LabelPhotographer )
  551. $AirRegGUI.Controls.Add( $ButtonOpenLink )
  552. $AirRegGUI.Controls.Add( $PictureboxThumbnail )
  553. $AirRegGUI.Controls.Add( $ButtonHelp )
  554. $AirRegGUI.Controls.Add( $ButtonSearch )
  555. $AirRegGUI.Controls.Add( $TextboxReg )
  556. $AirRegGUI.Font = ( New-Object -TypeName System.Drawing.Font -ArgumentList @( [System.String]'Microsoft Sans Serif', [System.Single]12, [System.Drawing.FontStyle]::Regular, [System.Drawing.GraphicsUnit]::Point, ( [System.Byte][System.Byte]0) ) )
  557. $AirRegGUI.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
  558. $AirRegGUI.MaximizeBox = $false
  559. $AirRegGUI.Name = [System.String]'AirRegGUI'
  560. $AirRegGUI.SizeGripStyle = [System.Windows.Forms.SizeGripStyle]::Hide
  561. $AirRegGUI.StartPosition = 'CenterScreen'
  562. $AirRegGUI.Text = [System.String]'AirRegGUI.ps1'
  563. $AirRegGUI.Add_Load( $Window_Load )
  564. $AirRegGUI.Add_Shown( $Window_Shown )
  565. $AirRegGUI.Add_HelpRequested( $ButtonHelp_Click )
  566. ( [System.ComponentModel.ISupportInitialize]$PictureboxThumbnail ).EndInit( )
  567. $AirRegGUI.ResumeLayout( $false )
  568. $AirRegGUI.PerformLayout( )
  569.  
  570. Add-Member -InputObject $AirRegGUI -Name base -Value $base -MemberType NoteProperty
  571. Add-Member -InputObject $AirRegGUI -Name TextboxReg -Value $TextboxReg -MemberType NoteProperty
  572. Add-Member -InputObject $AirRegGUI -Name ButtonSearch -Value $ButtonSearch -MemberType NoteProperty
  573. Add-Member -InputObject $AirRegGUI -Name ButtonHelp -Value $ButtonHelp -MemberType NoteProperty
  574. Add-Member -InputObject $AirRegGUI -Name PictureboxThumbnail -Value $PictureboxThumbnail -MemberType NoteProperty
  575. Add-Member -InputObject $AirRegGUI -Name ButtonOpenLink -Value $ButtonOpenLink -MemberType NoteProperty
  576. Add-Member -InputObject $AirRegGUI -Name LabelHelptext -Value $LabelHelptext -MemberType NoteProperty
  577. Add-Member -InputObject $AirRegGUI -Name LabelPhotographer -Value $LabelPhotographer -MemberType NoteProperty
  578.  
  579. ##########################################
  580. # End of embedded AirRegGUI.designer.ps1 #
  581. ##########################################
  582.  
  583. # Check for program updates and notify user if available
  584. Check-Update
  585.  
  586. # Open GUI window
  587. [void] $AirRegGUI.ShowDialog( )
  588.  
  589. # Clean up (ShowDialog does not always clean up by itself)
  590. [void] $AirRegGUI.Dispose( )
  591.  

page last uploaded: 2019-01-21, 22:48