'Declaration Public Property TextButtonDisplayStyle As TextButtonDisplayStyle
public TextButtonDisplayStyle TextButtonDisplayStyle {get; set;}
Clicking a location's text button is the equivalent of assigning the SelectedLocation property a reference to that location, except in the case where that location is already the SelectedLocation.
The user interface representation of an UltraNavigationBarLocation which appears in the navigation path consists of one or more elements: the LocationTextButtonUIElement, which displays the text associated with the location, and the LocationDropDownButtonUIElement, which provides access to the members of its Locations collection. The TextButtonDisplayStyle property determines whether the LocationTextButtonUIElement displays the location's text, image, or both. Setting the TextButtonDisplayStyle property to 'Hidden' prevents the user interface element from appearing altogether.
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 System.Windows.Forms Public Class FileSystemSupport ' Adds an UltraNavigationBarLocation and UltraTreeNode which each represent ' the current user, and adds "shortcuts" to the system's special folders under ' that location/node. Private Sub AddCurrentUserShortcut(ByVal rootLocation As UltraNavigationBarRootLocation, ByVal rootNode As UltraTreeNode) ' Get the username Dim userName As String = Me.UserName ' Get the constants of the Environment.SpecialFolder enumeration Dim values As Array = System.Enum.GetValues(GetType(Environment.SpecialFolder)) ' Get the path to the users folder, based on the assumption that the parent ' of the 'Desktop' special folder is the current user's root. Dim usersFolderPath As String = Me.UsersFolderPath ' Returns now if we can't get to the current user's root. If usersFolderPath.Length = 0 Or System.IO.Directory.Exists(usersFolderPath) = False Then Return ' Add an UltraNavigationBarLocation for the current user's root Dim userShortcutLocation As UltraNavigationBarLocation = rootLocation.Locations.Add(usersFolderPath, userName) userShortcutLocation.Settings.Appearance.Image = Me.GetImage(Images.Favorites) ' Set the TextButtonDisplayStyle property to 'ImageAndText' so that this ' location is a little more noticeable. userShortcutLocation.Settings.TextButtonDisplayStyle = TextButtonDisplayStyle.ImageAndText ' Add an UltraTreeNode for the current user's root Dim userShortcutNode As UltraTreeNode = rootNode.Nodes.Add(Nothing, userName) userShortcutNode.Override.NodeAppearance.Image = Me.GetImage(Images.Favorites) ' Create a ShortcutWrapper instance for each object and cross-reference them userShortcutLocation.Tag = New ShortcutWrapper(usersFolderPath, userShortcutNode, False) userShortcutNode.Tag = New ShortcutWrapper(usersFolderPath, userShortcutLocation, False) ' Iterate the special system folders, and add a shortcut for each of ' the children of the current user's root. Dim i As Integer For i = 0 To values.Length - 1 Dim folderPath As String = System.Environment.GetFolderPath(values.GetValue(i)) ' Some 'SpecialFolder' constants point to the same directory, ' so continue if we have already processed this one If (userShortcutLocation.Locations.Exists(folderPath)) Then Continue For If (folderPath.StartsWith(usersFolderPath)) Then ' Get the display text for this sub-directory Dim displayText As String = folderPath.Replace(String.Format("{0}\", usersFolderPath), String.Empty) If (displayText.Contains(PATH_SEPARATOR) = False) Then ' Add an UltraNavigationBarLocation for the shorcut Dim childLocation As UltraNavigationBarLocation = userShortcutLocation.Locations.Add(folderPath, displayText) childLocation.Settings.Appearance.Image = Me.GetImage(Images.Shortcut) ' Add an UltraTreeNode for the shorcut Dim childNode As UltraTreeNode = userShortcutNode.Nodes.Add(Nothing, displayText) childNode.Override.NodeAppearance.Image = Me.GetImage(Images.Shortcut) ' Create a ShortcutWrapper instance for each object and cross-reference them childLocation.Tag = New ShortcutWrapper(folderPath, childNode, True) childNode.Tag = New ShortcutWrapper(folderPath, childLocation, True) End If End If Next End Sub Private ReadOnly Property UsersFolderPath() As String Get ' Get the path to the users folder, based on the assumption that the parent ' of the 'Desktop' special folder is the current user's root. Dim path As String = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) Dim usersFolder As DirectoryInfo = Directory.GetParent(path) If usersFolder Is Nothing Then Return String.Empty Return usersFolder.FullName End Get End Property ' Handles the UltraNavigationBar's 'ExitingEditMode' event. Private Sub OnNavigationBarExitingEditMode(ByVal sender As Object, ByVal e As ExitingEditModeEventArgs) ' If the edit mode session was canceled, don't proceed. If e.Cancel Or e.ApplyChanges = False Then Return ' Determine whether the edit mode text contains the special folders root ' if it does, we will replace it with the shortcut to the users folder, ' so that when edit mode is exited, the shortcut location is selected. Dim path As String = e.NavigationPath Dim usersFolderPath As String = Me.UsersFolderPath Dim userName As String = Me.UserName If (path.Contains(usersFolderPath)) Then path = path.Replace(usersFolderPath, userName) e.Editor.Value = path End If End Sub ' Handles the UltraNavigationBar's 'EnteringEditMode' event. Private Sub OnNavigationBarEnteringEditMode(ByVal sender As Object, ByVal e As CancelableEditModeEventArgs) ' Determine whether the edit mode text contains the name of the users folder ' shortcut; if it does, we will replace it with the special folders root, ' so that when edit mode is entered, the path to the actual folder appears. Dim path As String = e.NavigationPath Dim usersFolderPath As String = Me.UsersFolderPath Dim userName As String = Me.UserName If (path.Contains(userName) AndAlso path.Length > userName.Length) Then path = path.Replace(userName, usersFolderPath) e.NavigationPath = path 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 System.Text; using System.Windows.Forms; public class FileSystemSupport { private string UsersFolderPath { get { // Get the path to the users folder, based on the assumption that the parent // of the 'Desktop' special folder is the current user's root. string usersFolderPath = System.Environment.GetFolderPath( Environment.SpecialFolder.Desktop ); DirectoryInfo usersFolder = Directory.GetParent(usersFolderPath); usersFolderPath = usersFolder != null ? usersFolder.FullName : string.Empty; return usersFolderPath; } } private void AddCurrentUserShortcut( UltraNavigationBarRootLocation rootLocation, UltraTreeNode rootNode ) { // Get the username string userName = this.UserName; // Get the constants of the Environment.SpecialFolder enumeration Array values = Enum.GetValues( typeof(Environment.SpecialFolder) ); // Get the path to the users folder, based on the assumption that the parent // of the 'Desktop' special folder is the current user's root. string usersFolderPath = this.UsersFolderPath; // Returns now if we can't get to the current user's root. if ( usersFolderPath.Length == 0 || System.IO.Directory.Exists(usersFolderPath) == false ) return; // Add an UltraNavigationBarLocation for the current user's root UltraNavigationBarLocation userShortcutLocation = rootLocation.Locations.Add( usersFolderPath, userName ); userShortcutLocation.Settings.Appearance.Image = this.GetImage(Images.Favorites); // Set the TextButtonDisplayStyle property to 'ImageAndText' so that this // location is a little more noticeable. userShortcutLocation.Settings.TextButtonDisplayStyle = TextButtonDisplayStyle.ImageAndText; // Add an UltraTreeNode for the current user's root UltraTreeNode userShortcutNode = rootNode.Nodes.Add( null, userName ); userShortcutNode.Override.NodeAppearance.Image = this.GetImage(Images.Favorites); // Create a ShortcutWrapper instance for each object and cross-reference them userShortcutLocation.Tag = new ShortcutWrapper( usersFolderPath, userShortcutNode, false ); userShortcutNode.Tag = new ShortcutWrapper( usersFolderPath, userShortcutLocation, false ); // Iterate the special system folders, and add a shortcut for each of // the children of the current user's root. for ( int i = 0; i < values.Length; i ++ ) { string folderPath = System.Environment.GetFolderPath( (Environment.SpecialFolder)values.GetValue(i) ); // Some 'SpecialFolder' constants point to the same directory, // so continue if we have already processed this one if ( userShortcutLocation.Locations.Exists(folderPath) ) continue; if ( folderPath.StartsWith(usersFolderPath) ) { // Get the display text for this sub-directory string displayText = folderPath.Replace( string.Format(@"{0}\", usersFolderPath), string.Empty ); if ( displayText.Contains(PATH_SEPARATOR) == false ) { // Add an UltraNavigationBarLocation for the shorcut UltraNavigationBarLocation childLocation = userShortcutLocation.Locations.Add( folderPath, displayText ); childLocation.Settings.Appearance.Image = this.GetImage(Images.Shortcut); // Add an UltraTreeNode for the shorcut UltraTreeNode childNode = userShortcutNode.Nodes.Add( null, displayText ); childNode.Override.NodeAppearance.Image = this.GetImage(Images.Shortcut); // Create a ShortcutWrapper instance for each object and cross-reference them childLocation.Tag = new ShortcutWrapper( folderPath, childNode, true ); childNode.Tag = new ShortcutWrapper( folderPath, childLocation, true ); } } } } // Handles the UltraNavigationBar's 'ExitingEditMode' event. private void OnNavigationBarExitingEditMode(object sender, ExitingEditModeEventArgs e) { // If the edit mode session was canceled, don't proceed. if ( e.Cancel || e.ApplyChanges == false ) return; // Determine whether the edit mode text contains the special folders root; // if it does, we will replace it with the shortcut to the users folder, // so that when edit mode is exited, the shortcut location is selected. string path = e.NavigationPath; string usersFolderPath = this.UsersFolderPath; string userName = this.UserName; if ( path.Contains(usersFolderPath) ) { path = path.Replace( usersFolderPath, userName ); e.Editor.Value = path; } } // Handles the UltraNavigationBar's 'EnteringEditMode' event. private void OnNavigationBarEnteringEditMode(object sender, CancelableEditModeEventArgs e) { // Determine whether the edit mode text contains the name of the users folder // shortcut; if it does, we will replace it with the special folders root, // so that when edit mode is entered, the path to the actual folder appears. string path = e.NavigationPath; string usersFolderPath = this.UsersFolderPath; string userName = this.UserName; if ( path.Contains(userName) && path.Length > userName.Length ) { path = path.Replace( userName, usersFolderPath ); e.NavigationPath = path; } } }
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