Guest User

Untitled

a guest
Jun 10th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. function Show-MessageBox {
  2. param(
  3. $Title = "The cool Dialog",
  4. [Parameter(Mandatory=$true)]
  5. $Message,
  6. [System.Windows.Forms.MessageBoxIcon]$Icon = "Information",
  7. [System.Windows.Forms.MessageBoxButtons]$Buttons = "Ok"
  8. )
  9. [System.Windows.Forms.MessageBox]::Show($Message, $Title, $Buttons, $Icon) | Out-Null
  10. }
  11.  
  12. try {
  13. $folderId = $vaultContext.CurrentSelectionSet | select -First 1 -ExpandProperty "Id"
  14. if(-not $folderId) {
  15. throw "No valid folder selected!"
  16. }
  17. $fldr = $vault.DocumentService.GetFolderById($folderId)
  18. $folder = New-Object Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder -ArgumentList @($vaultConnection, $fldr)
  19.  
  20. [xml]$xamlContent = Get-Content "$($env:ProgramData)\Autodesk\Vault 2018\Extensions\DataStandard\Vault.Custom\addinVault\Menus\TheCoolDialog.xaml"
  21. $theCoolWindow = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader -ArgumentList @($xamlContent)))
  22.  
  23. $theCoolWindow.FindName("StackPanelCoolView").DataContext = $folder
  24. $theCoolWindow.FindName("BtnCool").add_Click({
  25. $coolUserInput = $theCoolWindow.FindName("TxtCoolInput").Text
  26. if($coolUserInput -notlike "*cool*") {
  27. Show-MessageBox -Message "Your input was not cool!`nTry it again!" -Icon "Warning"
  28. } else {
  29. @(@($theCoolWindow) + $theCoolWindow.FindName("StackPanelCoolView").Children + $theCoolWindow.FindName("StackPanelCoolBtns").Children) | where { $_.GetType() -ne [system.windows.controls.stackpanel] } | foreach {
  30. $isTextBox = $_.GetType() -eq [system.windows.controls.TextBox]
  31. $_.BorderBrush = "White"
  32. $_.Background = if($isTextBox) { "LightGoldenrodYellow" } else { "Orange"}
  33. $_.Foreground = if($isTextBox) { "DarkOrange" } else { "White" }
  34. }
  35. Show-MessageBox -Message "Your input was $coolUserInput!"
  36. }
  37. })
  38. $theCoolWindow.FindName("BtnCancel").add_Click({
  39. $theCoolWindow.Close()
  40. })
  41. $theCoolWindow.ShowDialog() | Out-Null
  42. } catch {
  43. $errorMessage = "Error message: '$($_.Exception.Message)'`n`n`nSTACKTRACE:`n$($_.InvocationInfo.PositionMessage)`n`n$($_.ScriptStacktrace)"
  44. Show-MessageBox -Message $errorMessage -Icon "Error"
  45. }
Add Comment
Please, Sign In to add comment