#------------------------------------------------------------------------ # Source File Information (DO NOT MODIFY) # Source ID: 18302f9d-05f3-4e63-84f6-48f57c61ba49 # Source File: C:\Documents and Settings\jvierra\My Documents\SAPIEN\PowerShell Studio 2012\Files\Demo-TreeView.pff #------------------------------------------------------------------------ #======================================================================== # Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.0.7 # Generated On: 7/16/2012 12:07 PM # Generated By: James Vierra # Organization: Designed Systems & Services #======================================================================== #---------------------------------------------- #region Application Functions #---------------------------------------------- function OnApplicationLoad { return $true #return true for success or false for failure } function OnApplicationExit { #Note: This function is not called in Projects #Note: This function runs after the form is closed #TODO: Add custom code to clean up and unload snapins when the application exits $script:ExitCode = 0 #Set the exit code for the Packager } #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Call-Demo-TreeView_pff { #---------------------------------------------- #region Import the Assemblies #---------------------------------------------- [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") #endregion Import Assemblies #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $form1 = New-Object 'System.Windows.Forms.Form' $splitcontainer1 = New-Object 'System.Windows.Forms.SplitContainer' $buttonExit = New-Object 'System.Windows.Forms.Button' $treeviewNav = New-Object 'System.Windows.Forms.TreeView' $imagelistLargeImages = New-Object 'System.Windows.Forms.ImageList' $imagelistSmallImages = New-Object 'System.Windows.Forms.ImageList' $listbox1 = New-Object 'System.Windows.Forms.ListBox' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' #endregion Generated Form Objects #---------------------------------------------- # User Generated Script #---------------------------------------------- $FormEvent_Load={ #TODO: Initialize Form Controls here } $treeviewNav_AfterSelect=[System.Windows.Forms.TreeViewEventHandler]{ Show-FolderDetails $treeviewNav.SelectedNode.Tag } $treeviewNav_DoubleClick={ $node=$treeviewNav.SelectedNode if($node.Nodes.Count -eq 0){ #[system.Windows.Forms.MessageBox]::Show($_.Node.Tag) $children=dir $($node.Tag) |?{$_.PsIsContainer} foreach($child in $children){ if($child){ $newnode=New-Object System.Windows.Forms.TreeNode $newnode.Name=$child.Name $newnode.Text=$child.Name $newnode.Tag=$child.FullName $node.Nodes.Add($newnode) } } $node.Expand() Show-FolderDetails $node.Tag } } function Show-FolderDetails($foldername){ $item=[System.IO.DirectoryInfo]$foldername $listbox1.Items.Clear() $listbox1.Items.Add("Name:$($item.Name)") $listbox1.Items.Add("CreationTIme:$($item.CreationTime)") $listbox1.Items.Add("LastWriteTime:$($item.LastWriteTime)") } # --End User Generated Script-- #---------------------------------------------- #region Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $form1.WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed= { #Remove all event handlers from the controls try { $form1.remove_Load($FormEvent_Load) $treeviewNav.remove_AfterSelect($treeviewNav_AfterSelect) $treeviewNav.remove_DoubleClick($treeviewNav_DoubleClick) $form1.remove_Load($Form_StateCorrection_Load) $form1.remove_FormClosed($Form_Cleanup_FormClosed) } catch [Exception] { } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- # # form1 # $form1.Controls.Add($splitcontainer1) $form1.Controls.Add($buttonExit) $form1.ClientSize = '640, 392' $form1.Name = "form1" $form1.StartPosition = 'CenterScreen' $form1.Text = "Form" $form1.add_Load($FormEvent_Load) # # splitcontainer1 # $splitcontainer1.Anchor = 'Top, Bottom, Left, Right' $splitcontainer1.Location = '12, 12' $splitcontainer1.Name = "splitcontainer1" [void]$splitcontainer1.Panel1.Controls.Add($treeviewNav) [void]$splitcontainer1.Panel2.Controls.Add($listbox1) $splitcontainer1.Size = '616, 341' $splitcontainer1.SplitterDistance = 199 $splitcontainer1.TabIndex = 3 # # buttonExit # $buttonExit.DialogResult = 'Cancel' $buttonExit.Location = '553, 359' $buttonExit.Name = "buttonExit" $buttonExit.Size = '75, 23' $buttonExit.TabIndex = 2 $buttonExit.Text = "E&xit" $buttonExit.UseVisualStyleBackColor = $True # # treeviewNav # $treeviewNav.Dock = 'Fill' $treeviewNav.Location = '0, 0' $treeviewNav.Name = "treeviewNav" $System_Windows_Forms_TreeNode_1 = New-Object 'System.Windows.Forms.TreeNode' ("C:\") $System_Windows_Forms_TreeNode_1.Name = "Node0" $System_Windows_Forms_TreeNode_1.Tag = "c:\" $System_Windows_Forms_TreeNode_1.Text = "C:\" [void]$treeviewNav.Nodes.Add($System_Windows_Forms_TreeNode_1) $treeviewNav.Size = '199, 341' $treeviewNav.TabIndex = 0 $treeviewNav.add_AfterSelect($treeviewNav_AfterSelect) $treeviewNav.add_DoubleClick($treeviewNav_DoubleClick) # # imagelistLargeImages # $imagelistLargeImages.ColorDepth = 'Depth32Bit' $imagelistLargeImages.ImageSize = '32, 32' $imagelistLargeImages.TransparentColor = 'Transparent' # # imagelistSmallImages # $imagelistSmallImages.ColorDepth = 'Depth32Bit' $imagelistSmallImages.ImageSize = '16, 16' $imagelistSmallImages.TransparentColor = 'Transparent' # # listbox1 # $listbox1.FormattingEnabled = $True $listbox1.Location = '3, 3' $listbox1.Name = "listbox1" $listbox1.Size = '407, 329' $listbox1.TabIndex = 0 #endregion Generated Form Code #---------------------------------------------- #Save the initial state of the form $InitialFormWindowState = $form1.WindowState #Init the OnLoad event to correct the initial state of the form $form1.add_Load($Form_StateCorrection_Load) #Clean up the control events $form1.add_FormClosed($Form_Cleanup_FormClosed) #Show the Form return $form1.ShowDialog() } #End Function #Call OnApplicationLoad to initialize if((OnApplicationLoad) -eq $true) { #Call the form Call-Demo-TreeView_pff | Out-Null #Perform cleanup OnApplicationExit }