Exemple #1
0
        private void expTree1_ExpTreeNodeSelected(string pathName, CShItem CSI)
        {
            if (SelectedPathChanged != null)
                SelectedPathChanged(this, EventArgs.Empty);

            if (browseMode == BrowseModes.FolderBrowser) return;

            List<CShItem> dirList = new List<CShItem>();
            List<CShItem> fileList = new List<CShItem>();

            int TotalItems;

            if (CSI.DisplayName.Equals(CShItem.strMyComputer))
                //avoid re-query since only has dirs
                dirList = CSI.GetDirectories(true);
            else
            {
                dirList = CSI.GetDirectories(true);
                fileList = (this.DesignMode || SelectedFilter == "*.*")? CSI.GetFiles() : CSI.GetFiles(SelectedFilter);
            }

            TotalItems = dirList.Count + fileList.Count;

            if (TotalItems > 0)
            {
                dirList.Sort();
                fileList.Sort();

                browseStatusBar.Text = dirList.Count + " Directories " +
                            fileList.Count + " Files";

                ArrayList combList = new ArrayList(TotalItems);

                combList.AddRange(dirList);
                combList.AddRange(fileList);

                //Build the ListViewItems & add to lv1
                explorerLV.BeginUpdate();
                explorerLV.Items.Clear();

                foreach (CShItem item in combList)
                {
                    ListViewItem lvi = new ListViewItem(item.DisplayName);
                    /*if (!item.IsDisk && item.IsFileSystem)
                    {
                        FileAttributes attr = File.GetAttributes(item.Path);
                        StringBuilder SB = new StringBuilder();

                        if ((attr & FileAttributes.System) == FileAttributes.System) SB.Append("S");
                        if ((attr & FileAttributes.Hidden) == FileAttributes.Hidden) SB.Append("H");
                        if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) SB.Append("R");
                        if ((attr & FileAttributes.Archive) == FileAttributes.Archive) SB.Append("A");

                        lvi.SubItems.Add(SB.ToString());
                    }
                    else
                        lvi.SubItems.Add("");

                    if ((!item.IsDisk) && item.IsFileSystem && (!item.IsFolder))
                    {
                        if (item.Length > 1024)
                            lvi.SubItems.Add(string.Format("{0:#,###} KB", item.Length / 1024));
                        else
                            lvi.SubItems.Add(string.Format("{0:##0} Bytes", item.Length));
                    }
                    else
                        lvi.SubItems.Add("");

                    lvi.SubItems.Add(item.TypeName);
                    if (item.IsDisk)
                        lvi.SubItems.Add("");*/

                    lvi.Tag = item;
                    CShItem refItem = item;
                    lvi.ImageIndex = SystemImageListManager.GetIconIndex(refItem, false, false);
                    explorerLV.Items.Add(lvi);
                }

                explorerLV.EndUpdate();
                //LoadLV1Images();
            }
            else
            {
                explorerLV.Items.Clear();
                browseStatusBar.Text = "No Items";
            }

            pathTextBox.Text = (CSI.IsFileSystem) ? pathName : "";
        }
Exemple #2
0
 private TreeNode MakeNode(CShItem item)
 {
     TreeNode newNode = new TreeNode(item.DisplayName);
     newNode.Tag = item;
     newNode.ImageIndex = SystemImageListManager.GetIconIndex(item, false, false);
     newNode.SelectedImageIndex = SystemImageListManager.GetIconIndex(item, true, false);
     //The following code, from Calum implements the following logic
     // Allow/disallow the showing of Hidden folders based on ShowHidden Propert
     // For Removable disks, always show + (allow expansion) - avoids floppy access
     // For all others, add + based on HasSubFolders
     //  Except - If showing Hidden dirs, do extra check to  allow for
     //  the case of all hidden items in the Dir which will cause
     //  HasSubFolders to be always left unset
     if (item.IsRemovable) //Calum's fix to hidden file fix
     {
         newNode.Nodes.Add(new TreeNode(" : "));
     }
     else if (item.HasSubFolders)
     {
         newNode.Nodes.Add(new TreeNode(" : "));
         //Begin Calum's change so Hidden dirs with all hidden content are expandable
     }
     else if (item.GetDirectories(true).Count > 0) //Added Code
     {
         newNode.Nodes.Add(new TreeNode(" : ")); //Added Code
         //End Calum's change
     }
     return newNode;
 }
Exemple #3
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            ImageList imgList = new ImageList();
            imgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            imgList.ImageSize = new System.Drawing.Size(130, 130);
            
            lvIncludedBG.BeginUpdate();
            lvIncludedBG.Items.Clear();

            ArrayList dirList = new ArrayList();
            ArrayList fileList = new ArrayList();

            if (!Directory.Exists(Application.StartupPath + "\\Backgrounds")) return;

            CShItem CSI = new CShItem(Application.StartupPath + "\\Backgrounds");
            dirList = CSI.GetDirectories(true);
            fileList = CSI.GetFiles();


            try
            {
                foreach (CShItem file in fileList)
                {
                    if (file.Path.ToLower().EndsWith(".jpg") || file.Path.ToLower().EndsWith(".png") || file.Path.ToLower().EndsWith(".bmp"))
                    {
                        try
                        {
                            Image thumb = Image.FromFile(file.Path);
                            imgList.Images.Add(thumb);

                            ListViewItem lvi = lvIncludedBG.Items.Add(String.Empty);
                            lvi.ImageIndex = lvi.Index;
                            lvi.Tag = file.Path;
                        }
                        catch (Exception Ex)
                        {
                        }
                    }
                }
                lvIncludedBG.LargeImageList = imgList;
                lvIncludedBG.EndUpdate();
            }
            catch (Exception Exc) { MessageBox.Show(Exc.ToString()); }
        }
Exemple #4
0
        private void expTree1_ExpTreeNodeSelected(string SelPath, CShItem CSI)
        {
            ImageList imgList = new ImageList();
            imgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
            imgList.ImageSize = new System.Drawing.Size(130, 130);
            lv.BeginUpdate();
            lv.Items.Clear();

            ArrayList dirList = new ArrayList();
            ArrayList fileList = new ArrayList();

            if (CSI.DisplayName.Equals(CShItem.strMyComputer))
            {
                dirList = CSI.GetDirectories(true);
            }
            else
            {
                dirList = CSI.GetDirectories(true);
                fileList = CSI.GetFiles();
            }

            
           try {
            foreach (CShItem file in fileList)
            {
                if (file.Path.ToLower().EndsWith(".jpg") || file.Path.ToLower().EndsWith(".png") || file.Path.ToLower().EndsWith(".bmp"))
                {
                    try { 
                        Image thumb = Image.FromFile(file.Path);
                        imgList.Images.Add(thumb);
                        ListViewItem lvi = lv.Items.Add(file.GetFileName());
                        lvi.ImageIndex = lvi.Index;
                        lvi.Tag = file.Path;
                    }
                    catch (Exception Ex) {
                    }
                }
            }
            lv.LargeImageList = imgList;
            lv.EndUpdate();
            }
           catch (Exception Exc) { MessageBox.Show(Exc.ToString()); }
        }
Exemple #5
0
 ///<Summary>
 /// AllFolderWalk recursively walks down directories from cStart, calling its
 ///   callback routine, WalkAllCallBack, for each Directory and File encountered, including those in
 ///   cStart.  UserLevel is incremented by 1 for each level of dirs that DirWalker
 ///  recurses thru.  Tag in an Integer that is simply passed, unmodified to the
 ///  callback, with each CShItem encountered, both File and Directory CShItems.
 /// </Summary>
 /// <param name="cStart"></param>
 /// <param name="cback"></param>
 /// <param name="UserLevel"></param>
 /// <param name="Tag"></param>
 ///
 public static bool AllFolderWalk(CShItem cStart, WalkAllCallBack cback, int UserLevel, int Tag)
 {
     if (cStart != null&& cStart.IsFolder)
     {
         CShItem cItem;
         //first processes all files in this directory
         foreach (CShItem tempLoopVar_cItem in cStart.GetFiles())
         {
             cItem = tempLoopVar_cItem;
             if (! cback(cItem, UserLevel, Tag))
             {
                 return false; //user said stop
             }
         }
         //then process all dirs in this directory, recursively
         foreach (CShItem tempLoopVar_cItem in cStart.GetDirectories(true))
         {
             cItem = tempLoopVar_cItem;
             if (! cback(cItem, UserLevel + 1, Tag))
             {
                 return false; //user said stop
             }
             else
             {
                 if (! AllFolderWalk(cItem, cback, UserLevel + 1, Tag))
                 {
                     return false;
                 }
             }
         }
         return true;
     }
     else //Invalid call
     {
         throw (new ApplicationException("AllFolderWalk -- Invalid Start Directory"));
     }
 }