Пример #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 : "";
        }
Пример #2
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()); }
        }
Пример #3
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()); }
        }
Пример #4
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"));
     }
 }