예제 #1
0
        //TODO Cache icons
        public System.Drawing.Image GetIcon(FileName filePath)
        {
            String extension;
            if (filePath.IsDirectory())
                extension = "/f"; // Key for folder icon
            else
                extension = Path.GetExtension(filePath.GetFilePath());

            IntPtr hImgSmall;
            SHFILEINFO shinfo = new SHFILEINFO();
            //Use this to get the small Icon
            hImgSmall = Win32.SHGetFileInfoW(filePath.GetFilePath(), 0, ref shinfo,
                                           (uint)Marshal.SizeOf(shinfo),
                                            Win32.SHGFI_ICON |
                                            Win32.SHGFI_SMALLICON);

            if(iconList.ContainsKey(extension)){
                return iconList[extension];
            } else {
                System.Drawing.Image icon = System.Drawing.Icon.FromHandle(shinfo.hIcon).ToBitmap().GetThumbnailImage(24, 24, null, new IntPtr());
                iconList.Add(extension, icon);
                return icon;
            }
        }
예제 #2
0
        private void FillFileGridRows(string[] files, bool isDir)
        {
            int r = Rows.Count;
            foreach (string s in files)
            {
                FileName fs = new FileName(s);

                Rows.Insert(r);
                this[r, FileIconCol] = new SourceGrid.Cells.Cell();
                //ORIGINAL: this[r, FileIconCol].Image = System.Drawing.Icon.ExtractAssociatedIcon(fs.GetFilePath()).ToBitmap().GetThumbnailImage(16, 16, null, new IntPtr());
                this[r, FileIconCol].Image = fileFetcher.GetIcon(fs);
                this[r, FileOldNameCol] = new SourceGrid.Cells.Cell(fs);
                this[r, FileNewNameCol] = new SourceGrid.Cells.Cell(fs.ToString(), oneClickEditor);
                this[r, FileNewNameCol].AddController(new ValueChangedEvent());
                this[r, FileNewNameCol].Controller.OnValueChanged(new CellContext(this, new Position(r, FileNewNameCol), this[r, FileNewNameCol]), new EventArgs());
                r++;
            }
        }