Imports System Imports System.Drawing Imports System.IO Imports System.Collections.Generic Imports System.ComponentModel Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.Misc Imports Infragistics.Win.Misc.UltraWinNavigationBar Imports Infragistics.Win.UltraWinTree Public Class FileSystemSupport Private Const PATH_SEPARATOR As String = "\" Private navigationBar As UltraNavigationBar = Nothing Private tree As UltraTree = Nothing Public Sub New(ByVal navigationBar As UltraNavigationBar, ByVal tree As UltraTree) MyBase.New() ' Store references to the UltraNavigationBar and UltraTree Me.navigationBar = navigationBar Me.tree = tree ' Create the images we will use for the drives, folders, etc. Me.CreateImages() ' Assign the folder image to the general node and location appearances. Me.navigationBar.LocationSettings.Appearance.Image = Me.GetImage(Images.Folder) Me.tree.Override.NodeAppearance.Image = Me.GetImage(Images.Folder) ' Synchronize the ImageSize properties for each control. Me.tree.Override.ImageSize = Me.navigationBar.ImageSizeResolved ' Since we are lazily populating the nodes collections, ' show the expansion indicator initially for all nodes. Me.tree.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand ' Set any additional properties on the UltraTree. Me.tree.ScrollBounds = ScrollBounds.ScrollToFill Me.tree.Override.SelectionType = SelectType.Single Me.tree.HideSelection = False ' Add an action button so the end user can refresh the directories. Me.navigationBar.ActionButtons.Clear() Dim actionButton As UltraNavigationBarActionButton = Me.navigationBar.ActionButtons.Add("Refresh") actionButton.Settings.Appearance.Image = Me.GetImage(Images.Refresh) ' Restrict the width of the location's text button so very long ' directory names don't hog up all the space. Me.navigationBar.LocationSettings.MaximumTextButtonWidth = 100 ' Restrict the number of items that can appear in the locations dropdown list. Me.navigationBar.LocationSettings.MaximumDropDownItems = 10 ' Register as a listener for the events of interest Me.HookEvents(True) End Sub Private Sub HookEvents(ByVal hook As Boolean) If (hook) Then ' NavigationBar AddHandler Me.navigationBar.InitializeLocations, AddressOf Me.OnNavigationBarInitializeLocations AddHandler Me.navigationBar.SelectedLocationChanged, AddressOf Me.OnNavigationBarSelectedLocationChanged AddHandler Me.navigationBar.ActionButtonClicked, AddressOf Me.OnNavigationBarActionButtonClicked AddHandler Me.navigationBar.ActionButtonToolTipDisplaying, AddressOf Me.OnNavigationBarActionButtonToolTipDisplaying ' Tree AddHandler Me.tree.BeforeExpand, AddressOf Me.OnTreeBeforeExpand AddHandler Me.tree.AfterActivate, AddressOf Me.OnTreeAfterActivate Else ' NavigationBar RemoveHandler Me.navigationBar.InitializeLocations, AddressOf Me.OnNavigationBarInitializeLocations RemoveHandler Me.navigationBar.SelectedLocationChanged, AddressOf Me.OnNavigationBarSelectedLocationChanged RemoveHandler Me.navigationBar.ActionButtonClicked, AddressOf Me.OnNavigationBarActionButtonClicked RemoveHandler Me.navigationBar.ActionButtonToolTipDisplaying, AddressOf Me.OnNavigationBarActionButtonToolTipDisplaying ' Tree RemoveHandler Me.tree.BeforeExpand, AddressOf Me.OnTreeBeforeExpand RemoveHandler Me.tree.AfterActivate, AddressOf Me.OnTreeAfterActivate End If End Sub End Class
using System; using System.Drawing; using System.IO; using System.Collections.Generic; using System.ComponentModel; using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.Misc; using Infragistics.Win.Misc.UltraWinNavigationBar; using Infragistics.Win.UltraWinTree; public class FileSystemSupport { private const string PATH_SEPARATOR = "\\"; private UltraNavigationBar navigationBar = null; private UltraTree tree = null; public FileSystemSupport( UltraNavigationBar navigationBar, UltraTree tree ) { // Store references to the UltraNavigationBar and UltraTree this.navigationBar = navigationBar; this.tree = tree; // Create the images we will use for the drives, folders, etc. this.CreateImages(); // Assign the folder image to the general node and location appearances. this.navigationBar.LocationSettings.Appearance.Image = this.GetImage( Images.Folder ); this.tree.Override.NodeAppearance.Image = this.GetImage( Images.Folder ); // Synchronize the ImageSize properties for each control. this.tree.Override.ImageSize = this.navigationBar.ImageSizeResolved; // Since we are lazily populating the nodes collections, // show the expansion indicator initially for all nodes. this.tree.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand; // Set any additional properties on the UltraTree. this.tree.ScrollBounds = ScrollBounds.ScrollToFill; this.tree.Override.SelectionType = SelectType.Single; this.tree.HideSelection = false; // Add an action button so the end user can refresh the directories. this.navigationBar.ActionButtons.Clear(); UltraNavigationBarActionButton actionButton = this.navigationBar.ActionButtons.Add( "Refresh" ); actionButton.Settings.Appearance.Image = this.GetImage( Images.Refresh ); // Restrict the width of the location's text button so very long // directory names don't hog up all the space. this.navigationBar.LocationSettings.MaximumTextButtonWidth = 100; // Restrict the number of items that can appear in the locations dropdown list. this.navigationBar.LocationSettings.MaximumDropDownItems = 10; // Register as a listener for the events of interest this.HookEvents( true ); } private void HookEvents( bool hook ) { if ( hook ) { // NavigationBar this.navigationBar.InitializeLocations += new InitializeLocationsHandler(this.OnNavigationBarInitializeLocations); this.navigationBar.SelectedLocationChanged += new SelectedLocationChangedHandler(this.OnNavigationBarSelectedLocationChanged); this.navigationBar.ActionButtonClicked += new ActionButtonClickedHandler(this.OnNavigationBarActionButtonClicked); this.navigationBar.ActionButtonToolTipDisplaying += new ActionButtonToolTipDisplayingHandler(this.OnNavigationBarActionButtonToolTipDisplaying); // Tree this.tree.BeforeExpand += new BeforeNodeChangedEventHandler(this.OnTreeBeforeExpand); this.tree.AfterActivate += new AfterNodeChangedEventHandler(this.OnTreeAfterActivate); } else { // NavigationBar this.navigationBar.InitializeLocations -= new InitializeLocationsHandler(this.OnNavigationBarInitializeLocations); this.navigationBar.SelectedLocationChanged -= new SelectedLocationChangedHandler(this.OnNavigationBarSelectedLocationChanged); this.navigationBar.ActionButtonClicked -= new ActionButtonClickedHandler(this.OnNavigationBarActionButtonClicked); this.navigationBar.ActionButtonToolTipDisplaying += new ActionButtonToolTipDisplayingHandler(this.OnNavigationBarActionButtonToolTipDisplaying); // Tree this.tree.BeforeExpand -= new BeforeNodeChangedEventHandler(this.OnTreeBeforeExpand); this.tree.AfterActivate -= new AfterNodeChangedEventHandler(this.OnTreeAfterActivate); } } }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2