Inheritance: Raccoom.Windows.Forms.TreeNodeBase
        public override bool HasSelectedChildNodes(System.Collections.ObjectModel.Collection<string> items, TreeNodePath node)
        {
            bool isBold = false;
            //
            foreach (string s in items)
            {
                // if path is equal, return
                if (s.Equals(node.Path)) continue;

                var currentSelectedPath = s;
                var currentNodePath = node.Path;

                if (!currentSelectedPath.EndsWith("\\"))
                {
                    currentSelectedPath += "\\";
                }

                if (!currentNodePath.EndsWith("\\"))
                {
                    currentNodePath += "\\";
                }

                // if path is substring, mark node bold, otherwise normal font is used
                if (currentSelectedPath.IndexOf(currentNodePath) != -1)
                {
                    isBold = true;
                    break;
                }
                else
                {
                    isBold = false;
                }
            }
            return isBold;
        }
Example #2
0
 public override void RequestChildNodes(TreeNodePath parent, System.Windows.Forms.TreeViewCancelEventArgs e)
 {
     if (parent.Path == null)
     {
         return;
     }
     //
     System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(parent.Path);
     // check persmission
     new System.Security.Permissions.FileIOPermission(System.Security.Permissions.FileIOPermissionAccess.PathDiscovery, directory.FullName).Demand();
     //
     foreach (System.IO.DirectoryInfo dir in directory.GetDirectories())
     {
         if ((dir.Attributes & FileAttributes.System) == FileAttributes.System)
         {
             continue;
         }
         if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
         {
             continue;
         }
         TreeNodePath newNode = this.CreateTreeNode(parent, dir.Name, dir.FullName, false, false, false);
         //
         try
         {
             if (dir.GetDirectories().GetLength(0) > 0)
             {
                 newNode.AddDummyNode();
             }
         }
         catch (System.UnauthorizedAccessException)
         {
             // eat the exception
         }
         catch (System.Exception ex)
         {
             throw ex;
         }
     }
     if (ShowFiles)
     {
         foreach (System.IO.FileInfo file in directory.GetFiles())
         {
             this.CreateTreeNode(parent.Nodes, parent, file.Name, file.FullName, true, false, false);
         }
     }
 }
Example #3
0
 private void AddImageListResourceImages(TreeView treeView, TreeNodePath node, string imageKey, Bitmap image, string selectedImageKey, Bitmap selectedImage)
 {
     if (treeView.ImageList == null)
     {
         treeView.ImageList = new System.Windows.Forms.ImageList();
     }
     if (!node.TreeView.ImageList.Images.ContainsKey(imageKey))
     {
         node.TreeView.ImageList.Images.Add(imageKey, image);
     }
     node.ImageKey = imageKey;
     if (!node.TreeView.ImageList.Images.ContainsKey(selectedImageKey))
     {
         node.TreeView.ImageList.Images.Add(selectedImageKey, selectedImage);
     }
     node.SelectedImageKey = selectedImageKey;
 }
Example #4
0
        /// <summary>
        /// Handles the OnMenuPopup event and invokes <c>QueryContextMenuItems</c> on the current Dataprovider.
        /// </summary>
        /// <param name="e"></param>
        protected virtual void OnContextMenuPopup(System.EventArgs e)
        {
            if (_dataProvider == null)
            {
                return;
            }
            //
            ContextMenu.MenuItems.Clear();
            //
            TreeNodePath node = _nodeFactory.TreeView.GetNodeAt(_nodeFactory.TreeView.PointToClient(System.Windows.Forms.Cursor.Position)) as TreeNodePath;

            if (node == null)
            {
                return;
            }
            //
            _dataProvider.QueryContextMenuItems(node);
        }
Example #5
0
 /// <summary>
 /// Add or removes the nodes recursive to or from the folderList_.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="add"></param>
 protected virtual void ExchangeFoldersRecursive(TreeNodePath parent, bool add)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     //
     foreach (TreeNodePath n in parent.Nodes)
     {
         if (n.Path != null)
         {
             ExchangePath(n.Path, add);
             MarkNode(parent);
         }
         //
         ExchangeFoldersRecursive(n, add);
     }
 }
        protected virtual void OnContextMenuPopup(EventArgs e)
        {
            if (_dataProvider == null)
            {
                return;
            }
            //
            ContextMenu.MenuItems.Clear();
            //
            TreeNodePath node = _helper.TreeView.GetNodeAt(_helper.TreeView.PointToClient(Cursor.Position)) as TreeNodePath;

            if (node == null)
            {
                return;
            }
            //
            _dataProvider.QueryContextMenuItems(_helper, node);
        }
Example #7
0
 /// <summary>
 /// Set the text bold for each parent node if there is a child node checked.
 /// </summary>
 /// <param name="parent"></param>
 protected virtual void MarkNodesRecursive(TreeNodePath parent)
 {
     if (this._checkboxBehavior == CheckBoxBehaviorMode.None)
     {
         return;
     }
     //
     if (parent == null)
     {
         return;
     }
     //
     MarkNode(parent);
     if (parent.Parent != null)
     {
         MarkNodesRecursive(parent.Parent as TreeNodePath);
     }
 }
 /// <summary>
 /// Extract the icon for the file type (Extension)
 /// </summary>
 protected virtual void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
 {
     if (_systemImageList == null)
     {
         throw new ArgumentNullException("_systemImageList");
     }
     if (treeView == null)
     {
         throw new ArgumentNullException("treeView");
     }
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     //
     node.ImageIndex         = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateNormal);
     node.SelectedImageIndex = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateOpen);
 }
Example #9
0
        private TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool isSpecialFolder)
        {
            //
            if (text == "Pictures" || text == "Videos")
            {
            }
            TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder);

            newNode.Path = path;
            //
            if (addDummyNode)
            {
                // add dummy node, otherwise there is no + sign
                newNode.AddDummyNode();
            }
            //
            return(newNode);
        }
        /// <summary>
        /// Extract the icon for the file type (Extension)
        /// </summary>
        protected virtual void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
        {
            InitializeIcon();

            if (_systemImageList == null)
            {
                throw new ArgumentNullException("_systemImageList");
            }
            if (treeView == null)
            {
                throw new ArgumentNullException("treeView");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.IsSpecialFolder || node.Parent == null || (node.Parent is TreeNodePath && ((TreeNodePath)node.Parent).IsSpecialFolder))
            {
                if (node.Parent == null)
                {
                    fSetIcon(node, Resources.brick_link, "brick_link");
                }
                else if (node.IsSpecialFolder)
                {
                    fSetIcon(node, Resources.package_link, "package_link");
                }
                else
                {
                    fSetIcon(node, Resources.folder_link, "folder_link");
                }

                //    fSetIcon(node,   new Icon(assembly.GetManifestResourceStream("Raccoom.TreeViewFolderBrowser.DataProviders.FatCow.Link.brick_link.ico")), "Resources.brick_link");
            }
            else
            {
                //node.ImageIndex         = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateNormal);
                //node.SelectedImageIndex = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateOpen);

                int _nIndex = _systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateNormal);
                fSetIcon(node, _systemImageList.Icon(_nIndex), _nIndex.ToString());
            }
        }
        /// <summary>
        /// Creates a tree node and add it to the <c>TreeNodeCollection</c>.
        /// </summary>
        /// <param name="parentCollection"><c>TreeNodeCollection</c> to which the new node will added.</param>
        /// <param name="parentNode">Parent node for the new created child node.</param>
        /// <param name="text">The text displayed in the label of the tree node.</param>
        /// <param name="path">The path the node represents.</param>
        /// <param name="addDummyNode">True to add + sign, otherwise no + sign appears.</param>
        /// <param name="forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param>
        /// <param name="isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param>
        /// <returns>The newly created and added node</returns>
        public virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder)
        {
            if (parentCollection == null)
            {
                throw new ArgumentNullException("parentCollection");
            }
            //
            if (_treeView.InvokeRequired)
            {
                return(_treeView.Invoke(new CreateTreeNodeDelegate(CreateTreeNode), new object[] { parentNode, text, path, addDummyNode, forceChecked, isSpecialFolder }) as TreeNodePath);
            }
            //
            forceChecked = forceChecked || (TreeView.CheckBoxBehaviorMode == CheckBoxBehaviorMode.RecursiveChecked && (parentNode != null && parentNode.Checked));
            //
            TreeNodePath childNode = CreateTreeNode(text, path, addDummyNode, forceChecked, isSpecialFolder);

            parentCollection.Add(childNode);
            return(childNode);
        }
Example #12
0
        public virtual void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent,
                                           TreeViewCancelEventArgs e)
        {
            if (parent.Path == null)
            {
                return;
            }
            //
            DirectoryInfo directory = new DirectoryInfo(parent.Path);

            // check persmission
            new FileIOPermission(FileIOPermissionAccess.PathDiscovery, directory.FullName).Demand();
            //

            // Sort the Directories, as Samba might return unsorted
            DirectoryInfo[] dirInfo = directory.GetDirectories();
            Array.Sort(dirInfo,
                       new Comparison <DirectoryInfo>(
                           delegate(DirectoryInfo d1, DirectoryInfo d2) { return(string.Compare(d1.Name, d2.Name)); }));


            foreach (DirectoryInfo dir in dirInfo)
            {
                if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                {
                    continue;
                }
                TreeNodePath newNode = CreateTreeNode(helper, dir.Name, dir.FullName, false,
                                                      ((helper.TreeView.CheckboxBehaviorMode != CheckboxBehaviorMode.None) &&
                                                       (parent.Checked)), false);
                parent.Nodes.Add(newNode);
                //
                try
                {
                    if (dir.GetDirectories().GetLength(0) > 0)
                    {
                        newNode.AddDummyNode();
                    }
                }
                catch {}
            }
        }
Example #13
0
 public void fAddRootNode(TreeNodePath _oRoot) //Cw+
 {
     if (_oRoot != null)
     {
         //  parentCollection.Add(childNode);
         //parentNode.Nodes : Helper.TreeView.Nodes
         //   bool _bFound = false;
         foreach (TreeNodePath _oNode in Helper.TreeView.Nodes)
         {
             if (_oNode == _oRoot)
             {
                 //    _bFound = true;
                 return;
             }
         }
         // if(!_bFound){
         Helper.TreeView.Nodes.Add(_oRoot);
         // }
     }
 }
        /// <summary>
        /// Creates a tree node and add it to the <c>TreeNodeCollection</c>.
        /// </summary>
        /// <param name="text">The text displayed in the label of the tree node.</param>
        /// <param name="path">The path the node represents.</param>
        /// <param name="addDummyNode">True to add + sign, otherwise no + sign appears.</param>
        /// <param name="forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param>
        /// <param name="isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param>
        /// <returns></returns>
        private TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder)
        {
            //
            TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder);

            // path
            newNode.Path = path;

            //
            try
            {
                _treeView.SuppressCheckEvent(true);
                //
                if (forceChecked)
                {
                    newNode.Checked = true;
                }
                else
                {
                    newNode.Checked = _treeView.SelectedDirectories.Contains(path);
                }
                _treeView.MarkNode(newNode);
            }
            catch (System.ApplicationException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message, _treeView.Name);
            }
            finally
            {
                _treeView.SuppressCheckEvent(false);
            }
            //

            if (addDummyNode)
            {
                // add dummy node, otherwise there is no + sign
                newNode.AddDummyNode();
            }
            //
            return(newNode);
        }
Example #15
0
 protected virtual void FillMyComputer(FolderItem folderItem, TreeNodeCollection parentCollection,
                                       TreeViewFolderBrowserHelper helper)
 {
     _rootCollection = parentCollection;
     Logicaldisk.LogicaldiskCollection logicalDisks = null;
     // get wmi logical disk's if we have to
     if (helper.TreeView.DriveTypes != DriveTypes.All)
     {
         logicalDisks = Logicaldisk.GetInstances(null, GetWMIQueryStatement(helper.TreeView));
     }
     //
     foreach (FolderItem fi in ((Folder)folderItem.GetFolder).Items())
     {
         // only File System shell objects ?
         if (!_showAllShellObjects && !fi.IsFileSystem)
         {
             continue;
         }
         // check drive type
         if (fi.IsFileSystem && logicalDisks != null)
         {
             bool skipDrive = true;
             foreach (Logicaldisk lg in logicalDisks)
             {
                 if (lg.Name + "\\" == fi.Path)
                 {
                     skipDrive = false;
                     break;
                 }
             }
             if (skipDrive)
             {
                 continue;
             }
         }
         // create new node
         TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, IsFolderWithChilds(fi), false, true);
         node.Tag = fi;
         parentCollection.Add(node);
     }
 }
        /// <summary>
        /// Fired before node expands, used to fill next level in directory structure.
        /// </summary>
        protected override void OnBeforeExpand(System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            TreeNodePath node = e.Node as TreeNodePath;

            Cursor = System.Windows.Forms.Cursors.WaitCursor;
            try
            {
                RequestChildNodes(node, e);
            }
            catch (System.Exception ex)
            {
                UIVisualizeErrorMessage("OnBeforeExpand", ex);
                e.Cancel = true;
            }
            finally
            {
                Cursor = System.Windows.Forms.Cursors.Default;
            }

            base.OnBeforeExpand(e);
        }
Example #17
0
        protected virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, Raccoom.Win32.ShellItem shellItem)
        {
            if (shellItem == null)
            {
                throw new ArgumentNullException("shellItem");
            }
            //
            TreeNodePath node = CreateTreeNode(parentCollection, parentNode, shellItem.Text, shellItem.Path, !shellItem.IsFolder, shellItem.HasSubfolder, !shellItem.IsFileSystem);

            node.ImageIndex         = shellItem.ImageIndex;
            node.SelectedImageIndex = shellItem.SelectedImageIndex;
            node.Tag = shellItem;
            //
            shellItem.ShellItemUpdated += delegate(object sender, EventArgs e)
            {
                node.Text               = shellItem.Text;
                node.ImageIndex         = shellItem.ImageIndex;
                node.SelectedImageIndex = shellItem.SelectedImageIndex;
            };
            return(node);
        }
Example #18
0
 public override void QueryContextMenuItems(TreeNodePath node)
 {
     if (!EnableContextMenu)
     {
         return;
     }
     //
     Raccoom.Win32.ShellItem fi = node.Tag as Raccoom.Win32.ShellItem;
     if (fi == null)
     {
         return;
     }
     ////
     //foreach (.FolderItemVerb verb in fi..Verbs())
     //{
     //    if (verb.Name.Length == 0) continue;
     //    //
     //    MenuItemShellVerb item = new MenuItemShellVerb(verb);
     //    Helper.TreeView.ContextMenu.MenuItems.Add(item);
     //}
 }
        /// <summary>
        ///   Fired before node expands, used to fill next level in directory structure.
        /// </summary>
        protected override void OnBeforeExpand(TreeViewCancelEventArgs e)
        {
            TreeNodePath node = e.Node as TreeNodePath;

            //
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                GetSubDirs(node, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, MethodBase.GetCurrentMethod().Name);
                e.Cancel = true;
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
            //
            base.OnBeforeExpand(e);
        }
Example #20
0
        public override void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent,
                                            TreeViewCancelEventArgs e)
        {
            if (!parent.IsSpecialFolder)
            {
                return;
            }
            //
            FolderItem2 folderItem = ((FolderItem2)parent.Tag);

            //
            if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES).Title == folderItem.Name)
            {
                FillMyComputer(folderItem, parent.Nodes, helper);
            }
            else
            {
                List <TreeNodePath> nodes = new List <TreeNodePath>();
                foreach (FolderItem2 fi in ((Folder2)folderItem.GetFolder).Items())
                {
                    if (!_showAllShellObjects && !fi.IsFileSystem || !fi.IsFolder)
                    {
                        continue;
                    }
                    //
                    TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, IsFolderWithChilds(fi), false, true);
                    node.Tag = fi;
                    nodes.Add(node);
                }

                // Sort the Directories, as Samba might return unsorted
                TreeNodePath[] nodesArray = nodes.ToArray();
                Array.Sort(nodesArray,
                           new Comparison <TreeNodePath>(
                               delegate(TreeNodePath p1, TreeNodePath p2) { return(string.Compare(p1.Text, p2.Text)); }));

                parent.Nodes.AddRange(nodesArray);
            }
        }
Example #21
0
        public override void RequestRootNode()
        {
            // do not call base class here
            // base.RequestRootNode();

            AttachSystemImageList(Helper);
            // setup up root node collection
            switch (RootFolder)
            {
            case Raccoom.Win32.ShellAPI.CSIDL.DESKTOP:
                // create root node <Desktop>
                TreeNodePath desktopNode = CreateTreeNode(Helper.TreeView.Nodes, null, _shell.DesktopItem);
                AddImageListImage(Helper.TreeView, desktopNode);
                _rootCollection = desktopNode.Nodes;
                // enable shell objects always to fill desktop level
                bool settingBackup = _showAllShellObjects;
                _showAllShellObjects = true;
                // set setting back to original value
                _showAllShellObjects = settingBackup;

                break;

            case  Raccoom.Win32.ShellAPI.CSIDL.DRIVES:
                this.FillMyComputer(_shell.MyComputerItem, Helper.TreeView.Nodes, Helper);
                break;

            default:
                //
                TreeNodePath rootNode = CreateTreeNode(Helper.TreeView.Nodes, null, _shell.GetSpecialFolderShellItem(RootFolder));
                AddImageListImage(Helper.TreeView, rootNode);
                if (!rootNode.HasDummyNode)
                {
                    rootNode.AddDummyNode();
                }
                _rootCollection = rootNode.Nodes;
                break;
            }
        }
Example #22
0
        /// <summary>
        /// Used for drives like floppy, cd - rom ect. where it can be that no valid medium is inserted.
        /// in this case the click on the + will remove the +, after double click there's a new + to give the user
        /// the chance to browse this device after inserting a valid medium.
        /// </summary>
        protected override void OnDoubleClick(System.EventArgs e)
        {
            if (this.SelectedNode == null)
            {
                return;
            }
            //
            TreeNodePath node = this.SelectedNode as TreeNodePath;

            if (node == null || node.Path == null)
            {
                return;
            }
            //
            if ((node.Nodes.Count > 0) || (node.Path.Length > 3))
            {
                return;
            }
            //
            node.AddDummyNode();
            //
            base.OnDoubleClick(e);
        }
        /// <summary>
        /// Set the text bold if there is a child node checked.
        /// </summary>
        /// <param name="node"></param>
        protected internal virtual void MarkNode(TreeNodePath node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (this._checkboxBehavior == CheckBoxBehaviorMode.None)
            {
                return;
            }

            if (node == null)
            {
                return;
            }

            // no path selected, no node could be marked
            if (_folderList.Count == 0)
            {
                if ((node.NodeFont != null) && (node.NodeFont.Bold))
                {
                    node.NodeFont = this.Font;
                }
                return;
            }

            // check current node path against selected item list (folderlist_)
            if (_dataProvider.HasSelectedChildNodes(_folderList, node))
            {
                node.NodeFont = boldFont_;
            }
            else
            {
                node.NodeFont = this.Font;
            }
        }
 /// <summary>
 ///   Set the text bold if there is a child node checked.
 /// </summary>
 /// <param name = "node"></param>
 protected internal virtual void MarkNode(TreeNodePath node)
 {
     if (_checkboxBehavior == CheckboxBehaviorMode.None) return;
       //
       if (node == null) return;
       // no path selected, no node could be marked
       if (folderList_.Count == 0)
       {
     try
     {
       if ((node.NodeFont != null) && (node.NodeFont.Bold))
       {
     node.NodeFont = Font;
       }
     }
     catch {}
     return;
       }
       // there are a few paths, so we have to check each against our node path
       string path = node.Path;
       //
       bool isBold = false;
       foreach (string s in folderList_)
       {
     // if path is equal, return
     if (s.Equals(path)) continue;
     // if path is substring, mark node bold, otherwise normal font is used
     if (s.IndexOf(path) != -1)
     {
       isBold = true;
       break;
     }
     else
     {
       isBold = false;
     }
       }
       //
       if (isBold)
       {
     node.NodeFont = boldFont_;
       }
       else
       {
     node.NodeFont = Font;
       }
 }
 /// <summary>
 /// Add or removes the nodes recursive to or from the folderList_.
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="add"></param>
 protected virtual void ExchangeFoldersRecursive(TreeNodePath parent, bool add)
 {
     if (parent == null) throw new ArgumentNullException("parent");
     //
     foreach (TreeNodePath n in parent.Nodes)
     {
         if (n.Path != null)
         {
             ExchangePath(n.Path, add);
             MarkNode(parent);
         }
         //
         ExchangeFoldersRecursive(n, add);
     }
 }
        /// <summary>
        ///   Extract the icon for the file type (Extension)
        /// </summary>
        protected virtual void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
        {
            // create on demand
              if (_systemImageList == null)
              {
            // Shell32 ImageList
            _systemImageList = new SystemImageList(SystemImageListSize.SmallIcons);
            SystemImageListHelper.SetTreeViewImageList(treeView, _systemImageList, false);
              }

              node.ImageIndex = _systemImageList.IconIndex("", true);
              node.SelectedImageIndex = node.ImageIndex;
        }
 public void QueryContextMenuItems(TreeViewFolderBrowserHelper helper, TreeNodePath node)
 {
 }
 /// <summary>
 ///   Cut Button has been selected in Context Menu
 /// </summary>
 /// <param name = "sender"></param>
 /// <param name = "e"></param>
 private void contextMenuTreeViewCut_Click(object sender, EventArgs e)
 {
     contextMenuTreeView.Items[2].Enabled = true; // Enable the Paste Menu item
       _actionCopy = false; // we do a move
       _nodeToCopyCut = treeViewFolderBrowser.SelectedNode as TreeNodePath;
 }
        public override bool HasSelectedChildNodes(System.Collections.ObjectModel.Collection <string> items, TreeNodePath node)
        {
            bool isBold = false;

            //
            foreach (string s in items)
            {
                // if path is equal, return
                if (s.Equals(node.Path))
                {
                    continue;
                }
                // if path is substring, mark node bold, otherwise normal font is used
                if (s.IndexOf(node.Path) != -1)
                {
                    isBold = true;
                    break;
                }
                else
                {
                    isBold = false;
                }
            }
            return(isBold);
        }
Example #30
0
        public override void QueryContextMenuItems(TreeViewFolderBrowserHelper helper, TreeNodePath node)
        {
            if (!EnableContextMenu)
            {
                return;
            }
            //
            FolderItem fi = node.Tag as FolderItem;

            if (fi == null)
            {
                return;
            }
            //
            foreach (FolderItemVerb verb in fi.Verbs())
            {
                if (verb.Name.Length == 0)
                {
                    continue;
                }
                //
                MenuItemShellVerb item = new MenuItemShellVerb(verb);
                helper.TreeView.ContextMenu.MenuItems.Add(item);
            }
        }
        public virtual void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent,
            TreeViewCancelEventArgs e)
        {
            if (parent.Path == null) return;
              //
              DirectoryInfo directory = new DirectoryInfo(parent.Path);
              // check persmission
              new FileIOPermission(FileIOPermissionAccess.PathDiscovery, directory.FullName).Demand();
              //

              // Sort the Directories, as Samba might return unsorted
              DirectoryInfo[] dirInfo = directory.GetDirectories();
              Array.Sort(dirInfo,
                 new Comparison<DirectoryInfo>(
                   delegate(DirectoryInfo d1, DirectoryInfo d2) { return string.Compare(d1.Name, d2.Name); }));

              foreach (DirectoryInfo dir in dirInfo)
              {
            if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
              continue;
            }
            TreeNodePath newNode = CreateTreeNode(helper, dir.Name, dir.FullName, false,
                                              ((helper.TreeView.CheckboxBehaviorMode != CheckboxBehaviorMode.None) &&
                                               (parent.Checked)), false);
            parent.Nodes.Add(newNode);
            //
            try
            {
              if (dir.GetDirectories().GetLength(0) > 0)
              {
            newNode.AddDummyNode();
              }
            }
            catch {}
              }
        }
 protected virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, Raccoom.Win32.ShellItem shellItem)
 {
     if (shellItem == null) throw new ArgumentNullException("shellItem");
     //
     TreeNodePath node = CreateTreeNode(parentCollection, parentNode, shellItem.Text, shellItem.Path, !shellItem.IsFolder, shellItem.HasSubfolder, !shellItem.IsFileSystem);
     node.ImageIndex = shellItem.ImageIndex;
     node.SelectedImageIndex = shellItem.SelectedImageIndex;
     node.Tag = shellItem;
     //
     shellItem.ShellItemUpdated += delegate(object sender, EventArgs e)
     {
         node.Text = shellItem.Text;
         node.ImageIndex = shellItem.ImageIndex;
         node.SelectedImageIndex = shellItem.SelectedImageIndex;
     };
     return node;
 }
 /// <summary>
 /// Extract the icon for the file type (Extension)
 /// </summary>
 protected virtual void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
 {
     if (_systemImageList == null) throw new ArgumentNullException("_systemImageList");
     if (treeView == null) throw new ArgumentNullException("treeView");
     if (node == null) throw new ArgumentNullException("node");
     //
     node.ImageIndex = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateNormal);
     node.SelectedImageIndex = this._systemImageList.IconIndex(node.Path, true, Raccoom.Win32.ShellIconStateConstants.ShellIconStateOpen);
 }
 /// <summary>
 ///   Populates the Directory structure for a given path.
 /// </summary>
 /// <param name = "parent"></param>
 protected virtual void GetSubDirs(TreeNodePath parent, TreeViewCancelEventArgs e)
 {
     if (parent.Path == null) return;
       // everything ok, here we go
       BeginUpdate();
       try
       {
     parent.RemoveDummyNode();
     // if we have not scanned this folder before
     if (parent.Nodes.Count == 0)
     {
       _dataProvider.RequestSubDirs(_helper, parent, e);
     }
       }
       catch (Exception ex)
       {
     throw ex;
       }
       finally
       {
     EndUpdate();
       }
 }
 /// <summary>
 ///   Add or removes the nodes recursive to or from the folderList_.
 /// </summary>
 /// <param name = "parent"></param>
 /// <param name = "add"></param>
 protected virtual void ExchangeFoldersRec(TreeNodePath parent, bool add)
 {
     foreach (TreeNodePath n in parent.Nodes)
       {
     if (n.Path != null)
     {
       ExchangePath(n.Path, add);
       MarkNode(parent);
     }
     //
     ExchangeFoldersRec(n, add);
       }
 }
Example #36
0
        /// <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);
            }
        }
 /// <summary>
 /// Creates a new node and assigns an icon
 /// </summary>
 protected virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
 {
     TreeNodePath node = Helper.CreateTreeNode(parentCollection != null ? parentCollection : parentNode.Nodes, parentNode, text, path, addDummyNode, false, isSpecialFolder);
     try
     {
         SetIcon(Helper.TreeView, node);
     }
     catch
     {
         node.ImageIndex = -1;
         node.SelectedImageIndex = -1;
     }
     return node;
 }
        public override void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent,
            TreeViewCancelEventArgs e)
        {
            if (!parent.IsSpecialFolder) return;
              //
              FolderItem2 folderItem = ((FolderItem2)parent.Tag);
              //
              if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES).Title == folderItem.Name)
              {
            FillMyComputer(folderItem, parent.Nodes, helper);
              }
              else
              {
            List<TreeNodePath> nodes = new List<TreeNodePath>();
            foreach (FolderItem2 fi in ((Folder2)folderItem.GetFolder).Items())
            {
              if (!_showAllShellObjects && !fi.IsFileSystem || !fi.IsFolder) continue;
              //
              TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, IsFolderWithChilds(fi), false, true);
              node.Tag = fi;
              nodes.Add(node);
            }

            // Sort the Directories, as Samba might return unsorted
            TreeNodePath[] nodesArray = nodes.ToArray();
            Array.Sort(nodesArray,
                   new Comparison<TreeNodePath>(
                     delegate(TreeNodePath p1, TreeNodePath p2) { return string.Compare(p1.Text, p2.Text); }));

            parent.Nodes.AddRange(nodesArray);
              }
        }
 /// <summary>
 /// Creates a new node and assigns an icon
 /// </summary>
 protected virtual TreeNodePath CreateTreeNode(TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
 {
     return CreateTreeNode(parentNode != null ? parentNode.Nodes : Helper.TreeView.Nodes, parentNode, text, path, isFile, addDummyNode, isSpecialFolder);
 }
        /// <summary>
        /// Creates a new node and assigns an icon
        /// </summary>
        protected virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
        {
            TreeNodePath node = Helper.CreateTreeNode(parentCollection != null ? parentCollection : parentNode.Nodes, parentNode, text, path, addDummyNode, false, isSpecialFolder);

            try
            {
                SetIcon(Helper.TreeView, node);
            }
            catch
            {
                node.ImageIndex         = -1;
                node.SelectedImageIndex = -1;
            }
            return(node);
        }
 public override void RequestChildNodes(TreeNodePath parent, System.Windows.Forms.TreeViewCancelEventArgs e)
 {
     Raccoom.Win32.ShellItem folderItem = ((Raccoom.Win32.ShellItem)parent.Tag);
     folderItem.Expand(this.ShowFiles, true, System.IntPtr.Zero);
     //
     TreeNodePath node = null;
     System.IO.DriveInfo driveInfo;
     //
     foreach (Raccoom.Win32.ShellItem childFolder in folderItem.SubFolders)
     {
         if (!_showAllShellObjects && !childFolder.IsFileSystem) continue;
         //
         if (DriveTypes != DriveTypes.All && childFolder.IsDisk)
         {
             driveInfo = new System.IO.DriveInfo(childFolder.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;
             }
         }
         //
         node = CreateTreeNode(null, parent, childFolder);
     }
     if (!ShowFiles) return;
     //
     foreach (Raccoom.Win32.ShellItem fileItem in folderItem.SubFiles)
     {
         node = CreateTreeNode(null, parent, fileItem);
     }
 }
 protected override TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
 {
     if (isFile && _hideFileExention)
     {
         text = System.IO.Path.GetFileNameWithoutExtension(path);
     }
     return(base.CreateTreeNode(parentCollection, parentNode, text, path, isFile, addDummyNode, isSpecialFolder));
 }
 public override void QueryContextMenuItems(TreeNodePath node)
 {
     if (!EnableContextMenu) return;
     //
     Raccoom.Win32.ShellItem fi = node.Tag as Raccoom.Win32.ShellItem;
     if (fi == null) return;
     ////
     //foreach (.FolderItemVerb verb in fi..Verbs())
     //{
     //    if (verb.Name.Length == 0) continue;
     //    //
     //    MenuItemShellVerb item = new MenuItemShellVerb(verb);
     //    Helper.TreeView.ContextMenu.MenuItems.Add(item);
     //}
 }
 /// <summary>
 /// Creates a new node and assigns an icon
 /// </summary>
 protected virtual TreeNodePath CreateTreeNode(TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
 {
     return(CreateTreeNode(parentNode != null ? parentNode.Nodes : Helper.TreeView.Nodes, parentNode, text, path, isFile, addDummyNode, isSpecialFolder));
 }
        /// <summary>
        ///   Paste Button has been selected in Context Menu
        /// </summary>
        /// <param name = "sender"></param>
        /// <param name = "e"></param>
        private void contextMenuTreeViewPaste_Click(object sender, EventArgs e)
        {
            contextMenuTreeView.Items[2].Enabled = false; // Disable the Paste Menu item
              string targetPath = Path.Combine((treeViewFolderBrowser.SelectedNode as TreeNodePath).Path, _nodeToCopyCut.Text);
              try
              {
            if (!Directory.Exists(targetPath))
            {
              Directory.CreateDirectory(targetPath);
            }
              }
              catch (Exception ex)
              {
            log.Error("TreeView: Error creating folder {0}. {1}", targetPath, ex.Message);
              }

              bool bError = false;
              try
              {
            if (_actionCopy)
            {
              log.Debug("TreeView: Copying folder {0} to {1}", _nodeToCopyCut, targetPath);
              FileSystem.CopyDirectory(_nodeToCopyCut.Path, targetPath, UIOption.AllDialogs, UICancelOption.DoNothing);
            }
            else
            {
              log.Debug("TreeView: Moving folder {0} to {1}", _nodeToCopyCut, targetPath);
              FileSystem.MoveDirectory(_nodeToCopyCut.Path, targetPath, UIOption.AllDialogs, UICancelOption.DoNothing);
            }
              }
              catch (Exception ex)
              {
            bError = true;
            log.Error("TreeView: Error copying / moving folder {0}. {1}", _nodeToCopyCut.Path, ex.Message);
              }
              if (!bError)
              {
            _nodeToCopyCut = null;
            _main.CurrentDirectory = targetPath;
            RefreshFolders();
            _main.RefreshTrackList();
              }
        }
        public void RequestSubDirs(TreeViewFolderBrowserHelper helper, TreeNodePath parent, TreeViewCancelEventArgs e)
        {
            if (parent.Path == null)
              {
            return;
              }

              if (parent.Path == "")
              {
            rootFolder = RootFolder.None;
              }

              string sql = string.Empty;
              bool createDummyNode = true;
              string nodeTag;

              // We have a Special folder, when we are at the root level
              if (parent.IsSpecialFolder)
              {
            rootFolder = RootFolder.None;
              }

              if (rootFolder == RootFolder.None)
              {
            switch ((string)parent.Tag)
            {
              case "artist":
            rootFolder = RootFolder.Artist;
            sql = SQL_STMT_ARTIST;
            break;

              case "albumartist":
            rootFolder = RootFolder.AlbumArtist;
            sql = SQL_STMT_ALBUMARTIST;
            break;

              case "album":
            rootFolder = RootFolder.Album;
            sql = SQL_STMT_ALBUM;
            createDummyNode = false;
            break;

              case "genre":
            rootFolder = RootFolder.Genre;
            sql = SQL_STMT_GENRE;
            break;
            }
              }
              else if (rootFolder == RootFolder.Artist)
              {
            sql = string.Format(SQL_STMT_ARTISTSEARCH, Util.RemoveInvalidChars(parent.Path));
            isRootFolder = false;
            createDummyNode = false;
              }
              else if (rootFolder == RootFolder.AlbumArtist)
              {
            sql = string.Format(SQL_STMT_ALBUMARTISTSEARCH, Util.RemoveInvalidChars(parent.Path));
            isRootFolder = false;
            createDummyNode = false;
              }
              else if (rootFolder == RootFolder.Genre)
              {
            isRootFolder = false;
            string[] searchString = (parent.Tag as string).Split('\\');
            if (searchString.GetLength(0) == 2)
            {
              sql = string.Format(SQL_STMT_GENREARTISTSEARCH, Util.RemoveInvalidChars(parent.Path));
              createDummyNode = true;
            }
            else
            {
              sql = string.Format(SQL_STMT_GENREARTISTALBUMSEARCH, Util.RemoveInvalidChars(searchString[1]),
                              Util.RemoveInvalidChars(parent.Path));
              createDummyNode = false;
            }
              }

              string connection = string.Format(@"Data Source={0}", Options.MainSettings.MediaPortalDatabase);
              try
              {
            SQLiteConnection conn = new SQLiteConnection(connection);
            conn.Open();
            using (SQLiteCommand cmd = new SQLiteCommand())
            {
              cmd.Connection = conn;
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = sql;
              log.Debug("TreeViewBrowser: Executing sql: {0}", sql);
              using (SQLiteDataReader reader = cmd.ExecuteReader())
              {
            while (reader.Read())
            {
              string dbValue = reader.GetString(0);
              TreeNodePath newNode = CreateTreeNode(helper, dbValue, dbValue, createDummyNode, false, false);
              if (isRootFolder)
              {
                nodeTag = (string)parent.Tag;
              }
              else
              {
                nodeTag = string.Format(@"{0}\{1}", parent.Tag, dbValue);
              }
              newNode.Tag = nodeTag;
              parent.Nodes.Add(newNode);
            }
              }
            }
            conn.Close();
              }
              catch (Exception ex)
              {
            log.Error("TreeViewBrowser: Error executing sql: {0}", ex.Message);
              }
        }
 /// <summary>
 /// Populates the Directory structure for a given path.
 /// </summary>
 /// <param name="parent">Parent node for which the data is to retrieve</param>
 /// <param name="e"><c>TreeViewCancelEventArgs</c> to abort current expanding.</param>
 protected virtual void RequestChildNodes(TreeNodePath parent, System.Windows.Forms.TreeViewCancelEventArgs e)
 {
     if (parent == null) throw new ArgumentNullException("parent");
     if (e == null) throw new ArgumentNullException("e");
     //
     if (!parent.HasDummyNode || parent.Path == null) return;
     // everything ok, here we go
     this.BeginUpdate();
     try
     {
         parent.RemoveDummyNode();
         // if we have not scanned this folder before
         _dataProvider.RequestChildNodes(parent, e);
     }
     finally
     {
         this.EndUpdate();
     }
 }
 /// <summary>
 /// Set the text bold if there is a child node checked.
 /// </summary>
 /// <param name="node"></param>
 protected internal virtual void MarkNode(TreeNodePath node)
 {
     if (node == null) throw new ArgumentNullException("node");
     //
     if (this._checkboxBehavior == CheckBoxBehaviorMode.None) return;
     //
     if (node == null) return;
     // no path selected, no node could be marked
     if (_folderList.Count == 0)
     {
         if ((node.NodeFont != null) && (node.NodeFont.Bold))
         {
             node.NodeFont = this.Font;
         }
         return;
     }
     // check current node path against selected item list (folderlist_)
     if (_dataProvider.HasSelectedChildNodes(_folderList, node))
     {
         node.NodeFont = boldFont_;
     }
     else
     {
         node.NodeFont = this.Font;
     }
 }
Example #49
0
        public override void RequestChildNodes(TreeNodePath parent, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            Raccoom.Win32.ShellItem folderItem = ((Raccoom.Win32.ShellItem)parent.Tag);
            folderItem.Expand(this.ShowFiles, true, System.IntPtr.Zero);
            //
            TreeNodePath node = null;

            System.IO.DriveInfo driveInfo;
            //
            foreach (Raccoom.Win32.ShellItem childFolder in folderItem.SubFolders)
            {
                if (!_showAllShellObjects && !childFolder.IsFileSystem)
                {
                    continue;
                }
                //
                if (DriveTypes != DriveTypes.All && childFolder.IsDisk)
                {
                    driveInfo = new System.IO.DriveInfo(childFolder.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;
                    }
                }
                //
                node = CreateTreeNode(null, parent, childFolder);
            }
            if (!ShowFiles)
            {
                return;
            }
            //
            foreach (Raccoom.Win32.ShellItem fileItem in folderItem.SubFiles)
            {
                node = CreateTreeNode(null, parent, fileItem);
            }
        }
 /// <summary>
 /// Set the text bold for each parent node if there is a child node checked.
 /// </summary>
 /// <param name="parent"></param>
 protected virtual void MarkNodesRecursive(TreeNodePath parent)
 {
     if (this._checkboxBehavior == CheckBoxBehaviorMode.None) return;
     //
     if (parent == null) return;
     //
     MarkNode(parent);
     if (parent.Parent != null)
     {
         MarkNodesRecursive(parent.Parent as TreeNodePath);
     }
 }
 /// <summary>
 ///   Creates a tree node and add it to the <c>TreeNodeCollection</c>.
 /// </summary>
 /// <param name = "text">The text displayed in the label of the tree node.</param>
 /// <param name = "path">The path the node represents.</param>
 /// <param name = "addDummyNode">True to add + sign, otherwise no + sign appears.</param>
 /// <param name = "forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param>
 /// <param name = "isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param>
 /// <returns></returns>
 public virtual TreeNodePath CreateTreeNode(string text, string path, bool addDummyNode, bool forceChecked,
                                        bool isSpecialFolder)
 {
     TreeNodePath newNode = new TreeNodePath(text, isSpecialFolder);
       // path
       newNode.Path = path;
       //
       try
       {
     _treeView.SupressCheckEvent(true);
     //
     if (forceChecked)
     {
       newNode.Checked = true;
     }
     else
     {
       newNode.Checked = _treeView.SelectedDirectories.Contains(path);
     }
     _treeView.MarkNode(newNode);
       }
       catch (Exception e)
       {
     Debug.WriteLine(e.Message, _treeView.Name);
       }
       finally
       {
     _treeView.SupressCheckEvent(false);
       }
       //
       if (addDummyNode)
       {
     // add dummy node, otherwise there is no + sign
     newNode.AddDummyNode();
       }
       //
       return newNode;
 }
Example #52
0
 protected override void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
 {
     // base.SetIcon(treeView, node);
 }
 protected override TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool isFile, bool addDummyNode, bool isSpecialFolder)
 {
     if (isFile && _hideFileExention)
     {
         text = System.IO.Path.GetFileNameWithoutExtension(path);
     }
     return base.CreateTreeNode(parentCollection, parentNode, text, path, isFile, addDummyNode, isSpecialFolder);
 }
 /// <summary>
 /// Creates a tree node and add it to the <c>TreeNodeCollection</c>.
 /// </summary>
 /// <param name="parentCollection"><c>TreeNodeCollection</c> to which the new node will added.</param>
 /// <param name="parentNode">Parent node for the new created child node.</param>
 /// <param name="text">The text displayed in the label of the tree node.</param>
 /// <param name="path">The path the node represents.</param>
 /// <param name="addDummyNode">True to add + sign, otherwise no + sign appears.</param>
 /// <param name="forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param>
 /// <param name="isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param>
 /// <returns>The newly created and added node</returns>
 public virtual TreeNodePath CreateTreeNode(System.Windows.Forms.TreeNodeCollection parentCollection, TreeNodePath parentNode, string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder)
 {
     if (parentCollection == null) throw new ArgumentNullException("parentCollection");
     //
     if (_treeView.InvokeRequired)
     {
         return _treeView.Invoke(new CreateTreeNodeDelegate(CreateTreeNode), new object[] { parentNode, text, path, addDummyNode, forceChecked, isSpecialFolder }) as TreeNodePath;
     }
     //
     forceChecked = forceChecked || (TreeView.CheckBoxBehaviorMode == CheckBoxBehaviorMode.RecursiveChecked && (parentNode != null && parentNode.Checked));
     //
     TreeNodePath childNode = CreateTreeNode(text, path, addDummyNode, forceChecked, isSpecialFolder);
     parentCollection.Add(childNode);
     return childNode;
 }
 /// <summary>
 /// Creates a tree node and add it to the <c>parentNode</c>.
 /// </summary>
 /// <param name="parentNode">Parent node for the new created child node, can be null to indicate root level.</param>
 /// <param name="text">The text displayed in the label of the tree node.</param>
 /// <param name="path">The path the node represents.</param>
 /// <param name="addDummyNode">True to add + sign, otherwise no + sign appears.</param>
 /// <param name="forceChecked">True to check node in each case, otherwise false to allow normal check against selected paths.</param>
 /// <param name="isSpecialFolder">Specifies if this node is a special folder. Special folders do not request data from the attached data provider.</param>
 /// <returns>The newly created and added node</returns>
 public virtual TreeNodePath CreateTreeNode(TreeNodePath parentNode, string text, string path, bool addDummyNode, bool forceChecked, bool isSpecialFolder)
 {
     return CreateTreeNode(parentNode != null ? parentNode.Nodes : TreeView.Nodes, parentNode, text, path, addDummyNode, forceChecked, isSpecialFolder);
 }
 protected override void SetIcon(TreeViewFolderBrowser treeView, TreeNodePath node)
 {
     // base.SetIcon(treeView, node);
 }
 public override void QueryContextMenuItems(TreeViewFolderBrowserHelper helper, TreeNodePath node)
 {
     if (!EnableContextMenu) return;
       //
       FolderItem fi = node.Tag as FolderItem;
       if (fi == null) return;
       //
       foreach (FolderItemVerb verb in fi.Verbs())
       {
     if (verb.Name.Length == 0) continue;
     //
     MenuItemShellVerb item = new MenuItemShellVerb(verb);
     helper.TreeView.ContextMenu.MenuItems.Add(item);
       }
 }