Custom DataGridColumnStyle with images eats up system resources / cpu
-
Hi everyone. I'm working on an application that displays files with name and path ++ in a DataGrid. One day I came over a ListView project on the inet that could show images / icons + text in one column, so I started working on my own DataGridColumnStyle to try and achieve the same result. Only problem is that its really cpu-consuming when it retrieves the images and displays them. In my custom columnstyle paint method I retrieve the filname, then I extract the extension from the filename, look up extension in Registry to find default application, and at last I get the path to the default Icon file. Finally, I can extract the icon using
hImgSmall = Win32.SHGetFileInfo(filePath, 0, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);I was wondering if anyone has been working with anything similiar and that might have some hints/tips as how to make this less cpu consuming. Maybe a more efficient way of locating the icons. I recon all the "lookups" in registry is what makes this so slow. Might help with double-buffering too? The images and text are drawn to the screen. :S -Larantz-
-
Hi everyone. I'm working on an application that displays files with name and path ++ in a DataGrid. One day I came over a ListView project on the inet that could show images / icons + text in one column, so I started working on my own DataGridColumnStyle to try and achieve the same result. Only problem is that its really cpu-consuming when it retrieves the images and displays them. In my custom columnstyle paint method I retrieve the filname, then I extract the extension from the filename, look up extension in Registry to find default application, and at last I get the path to the default Icon file. Finally, I can extract the icon using
hImgSmall = Win32.SHGetFileInfo(filePath, 0, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
Win32.SHGFI_ICON |
Win32.SHGFI_SMALLICON);I was wondering if anyone has been working with anything similiar and that might have some hints/tips as how to make this less cpu consuming. Maybe a more efficient way of locating the icons. I recon all the "lookups" in registry is what makes this so slow. Might help with double-buffering too? The images and text are drawn to the screen. :S -Larantz-
I haven't tried anything like what you are doing, but one thought struck me. Are you looking up a lot of files with the same extension? If so could you maintain your own list of icons using the extension as a key (maybe the dictonary class would be good for this?) so that you only need to look in the registry the first time you encounter an extension? That would cut down on keep having to recreate the same icon. The procedure would be something like this: 1) Get extension from filename 2) Look in my list to see if I already have a bitmap 3) If I already have it, use it and we're done 4) If we don't have it look it up in the registry and add it to our list
-
I haven't tried anything like what you are doing, but one thought struck me. Are you looking up a lot of files with the same extension? If so could you maintain your own list of icons using the extension as a key (maybe the dictonary class would be good for this?) so that you only need to look in the registry the first time you encounter an extension? That would cut down on keep having to recreate the same icon. The procedure would be something like this: 1) Get extension from filename 2) Look in my list to see if I already have a bitmap 3) If I already have it, use it and we're done 4) If we don't have it look it up in the registry and add it to our list
-
I haven't tried anything like what you are doing, but one thought struck me. Are you looking up a lot of files with the same extension? If so could you maintain your own list of icons using the extension as a key (maybe the dictonary class would be good for this?) so that you only need to look in the registry the first time you encounter an extension? That would cut down on keep having to recreate the same icon. The procedure would be something like this: 1) Get extension from filename 2) Look in my list to see if I already have a bitmap 3) If I already have it, use it and we're done 4) If we don't have it look it up in the registry and add it to our list
I implemented iconbuffering now but it still flicks and takes up resources. I'll try with double-buffering. That should atleast take care of the flickering. When it comes to resources, maybe I can't improve that considering the fact that it's many paint operations. -Larantz-