示例#1
0
        void doImageNode(TreeNode tn)
        {
            EFSNodeTranslation t = (EFSNodeTranslation)tn.Tag;

            if (t.Node.Type == et.EFSNodeType.Folder)
            {
                tn.ImageIndex         = 0;
                tn.SelectedImageIndex = 0;
            }
            else
            {
                int  c = imageList1.Images.Count;
                Icon i = FileIconLoader.GetFileIcon(t.Node.Name, false);
                if (i != null)
                {
                    imageList1.Images.Add(i);
                    tn.ImageIndex         = c;
                    tn.SelectedImageIndex = c;
                }
            }
            foreach (var n in tn.Nodes)
            {
                doImageNode((TreeNode)n);
            }
        }
示例#2
0
        public int AddFile(string f)
        {
            var ext = Path.GetExtension(f).ToLowerInvariant();
            int result;

            if (!extCache.TryGetValue(ext, out result))
            {
                // if we dont call ToBitmap() here, image will be corrupted
                using (var ico = FileIconLoader.GetFileIcon("*" + ext, false))
                    using (var bmp = ico.ToBitmap()) {
                        result = ImageList.Images.Count;
                        ImageList.Images.Add(bmp);
                    }
                extCache.Add(ext, result);
            }

            return(result);
        }