Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Show-MessageBox {
- param(
- $Title = "The cool Dialog",
- [Parameter(Mandatory=$true)]
- $Message,
- [System.Windows.Forms.MessageBoxIcon]$Icon = "Information",
- [System.Windows.Forms.MessageBoxButtons]$Buttons = "Ok"
- )
- [System.Windows.Forms.MessageBox]::Show($Message, $Title, $Buttons, $Icon) | Out-Null
- }
- try {
- $folderId = $vaultContext.CurrentSelectionSet | select -First 1 -ExpandProperty "Id"
- if(-not $folderId) {
- throw "No valid folder selected!"
- }
- $fldr = $vault.DocumentService.GetFolderById($folderId)
- $folder = New-Object Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder -ArgumentList @($vaultConnection, $fldr)
- [xml]$xamlContent = Get-Content "$($env:ProgramData)\Autodesk\Vault 2018\Extensions\DataStandard\Vault.Custom\addinVault\Menus\TheCoolDialog.xaml"
- $theCoolWindow = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader -ArgumentList @($xamlContent)))
- $theCoolWindow.FindName("StackPanelCoolView").DataContext = $folder
- $theCoolWindow.FindName("BtnCool").add_Click({
- $coolUserInput = $theCoolWindow.FindName("TxtCoolInput").Text
- if($coolUserInput -notlike "*cool*") {
- Show-MessageBox -Message "Your input was not cool!`nTry it again!" -Icon "Warning"
- } else {
- @(@($theCoolWindow) + $theCoolWindow.FindName("StackPanelCoolView").Children + $theCoolWindow.FindName("StackPanelCoolBtns").Children) | where { $_.GetType() -ne [system.windows.controls.stackpanel] } | foreach {
- $isTextBox = $_.GetType() -eq [system.windows.controls.TextBox]
- $_.BorderBrush = "White"
- $_.Background = if($isTextBox) { "LightGoldenrodYellow" } else { "Orange"}
- $_.Foreground = if($isTextBox) { "DarkOrange" } else { "White" }
- }
- Show-MessageBox -Message "Your input was $coolUserInput!"
- }
- })
- $theCoolWindow.FindName("BtnCancel").add_Click({
- $theCoolWindow.Close()
- })
- $theCoolWindow.ShowDialog() | Out-Null
- } catch {
- $errorMessage = "Error message: '$($_.Exception.Message)'`n`n`nSTACKTRACE:`n$($_.InvocationInfo.PositionMessage)`n`n$($_.ScriptStacktrace)"
- Show-MessageBox -Message $errorMessage -Icon "Error"
- }
Add Comment
Please, Sign In to add comment