/// <summary> /// Initializes a new instance of the <c>TreeViewFolderBrowser</c> class. /// </summary> public TreeViewFolderBrowser() { InitializeComponent(); // initalize a new helper instance for this tree view. _nodeFactory = new TreeViewFolderBrowserNodeFactory(this); // this.ContextMenu = new System.Windows.Forms.ContextMenu(); this.ContextMenu.Popup += new System.EventHandler(OnContextMenu_Popup); // this.CheckBoxBehaviorMode = CheckBoxBehaviorMode.SingleChecked; // init bold font boldFont_ = new System.Drawing.Font(this.Font, System.Drawing.FontStyle.Bold); // Gets the operating system themes feature. This field is read-only. if (System.Windows.Forms.OSFeature.Feature.GetVersionPresent(System.Windows.Forms.OSFeature.Themes) != null) { ShowRootLines = false; ShowLines = false; } }
public override void Attach(TreeViewFolderBrowserNodeFactory helper) { base.Attach(helper); // this.AttachSystemImageList(helper); }
/// <summary> /// Attaches the Shell32 ImageList to the TreeView /// </summary> /// <param name="helper">Helper class to have access to managed TreeView instance</param> protected virtual void AttachSystemImageList(TreeViewFolderBrowserNodeFactory helper) { if (_checkboxMode != helper.TreeView.CheckBoxBehaviorMode | _systemImageList == null) { // checkboxes recreate the control internal if (this._systemImageList != null) { Raccoom.Win32.SystemImageListHelper.SetTreeViewImageList(helper.TreeView, _systemImageList, false); } // create on demand if (_systemImageList == null) { // Shell32 ImageList _systemImageList = new Raccoom.Win32.SystemImageList(Raccoom.Win32.SystemImageListSize.SmallIcons); Raccoom.Win32.SystemImageListHelper.SetTreeViewImageList(helper.TreeView, _systemImageList, false); } } _checkboxMode = helper.TreeView.CheckBoxBehaviorMode; }
/// <summary> /// Popluates the MyComputer node /// </summary> /// <param name="folderItem"></param> /// <param name="parentCollection"></param> /// <param name="helper"></param> protected virtual void FillMyComputer(Raccoom.Win32.ShellItem folderItem, System.Windows.Forms.TreeNodeCollection parentCollection, TreeViewFolderBrowserNodeFactory helper) { _rootCollection = parentCollection; // get wmi logical disk's if we have to System.IO.DriveInfo driveInfo; // folderItem.Expand(true, true, System.IntPtr.Zero); // foreach (Raccoom.Win32.ShellItem fi in folderItem.SubFolders) { // only File System shell objects ? if (!_showAllShellObjects && !fi.IsFileSystem) continue; // if (DriveTypes != DriveTypes.All && fi.IsDisk) { driveInfo = new System.IO.DriveInfo(fi.Path); // switch (driveInfo.DriveType) { case System.IO.DriveType.CDRom: if ((DriveTypes & DriveTypes.CompactDisc) == 0) continue; break; case System.IO.DriveType.Fixed: if ((DriveTypes & DriveTypes.LocalDisk) == 0) continue; break; case System.IO.DriveType.Network: if ((DriveTypes & DriveTypes.NetworkDrive) == 0) continue; break; case System.IO.DriveType.NoRootDirectory: if ((DriveTypes & DriveTypes.NoRootDirectory) == 0) continue; break; case System.IO.DriveType.Ram: if ((DriveTypes & DriveTypes.RAMDisk) == 0) continue; break; case System.IO.DriveType.Removable: if ((DriveTypes & DriveTypes.RemovableDisk) == 0) continue; break; case System.IO.DriveType.Unknown: if ((DriveTypes & DriveTypes.NoRootDirectory) == 0) continue; break; } } // create new node TreeNodePath node = CreateTreeNode(parentCollection, null, fi); } }