I am creating a treeview which wil have folder images for directories and want to know if there is a way to access the system image list so that I can display the system default folder image.
Thx
Mark.
There is no out-of-the-box image list for the system images (they depend on things like the current visual theme). The entry for SHGetFileInfo at pinvoke.net has a code sample for extracting icons for files (and, I presume, folders). You can use that and dynamically populate an ImageList component to get the tree view display the appropriate icons.
To get the current system icons you should take a look into the registry at HKEY_CLASSES_ROOT\Folder\DefaultIcon. Here you'll find the path and position of the used folder icon.
Related
I am building an add-in which requires selection of multiple outlook folders. For that purpose I created selection dialog that lists folders and allows user to select one or more by checking the check boxes next to tree view items.
I was hoping that somehow I could read/get the outlook folder icons from my add in code which is written in C# (any solution that works with outlook object model would do).
I was trying hard around MAPIFolder.GetCustomIcon but it returns null for all folders and when you read the documentation it is clear that it is not meant for this i.e. it returns value only if folder has custom icon and if it is not any of default folders.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mapifolder.getcustomicon%28v=office.14%29.aspx
Thanks for reading.
You'll have to use an icon editing tool (like Axialis Icon Workshop) that can extract icon and image resources from related Outlook .dll and .exe files. It's a real mess to figure out what icon is where there as they exist in small and large quantities in very many different files.
My app has over 100 images. And how to I specify resources for other resolutions? I see both methods.
One by naming the folders scale-100 and other by naming each file with a suffix of scale 100. My app is developed in C#. And how do I test which image is taken?
For now my folder structure is
Assets -> Images-> scale-100 -> tab_icon_notes_clicked_1366.png
And in the code when I need to reference the image, I reference it like this.
("ms-appx:/Assets/Images/tab_icon_notes_clicked_1366.png");
So without using scale-100 in the image path, it is retrieving an image. I have another folder named as scale-140 in which the higher resolution of the same image is placed. But I cant figure out which image it is taking.. scale-100 or scale-140 ?
You can identify the System Display Scale Information by the Code below
var scaleInfo= DisplayProperties.ResolutionScale;
The system will take care of loading the correct Scale Images from the respective Scale Folders [100,140,180].
How can I retrieve the system icon associated with a file/folder so that
I can show it in the list view adjacent to the file/folder name?
You need to use Icon.ExtractAssociatedIcon
Icon icon = Icon.ExtractAssociatedIcon(filepath);
Take a look at Icon.ExtractAssociatedIcon documentation
Note: this works only for files. For folders you need P/Invoke sample is here Edit: Page is now defunct, please refer to this copy on the Wayback Machine.
See Obtaining (and managing) file and folder icons using SHGetFileInfo in C#.
i have a picture box in my win forms app. the question is, how can i make the image load from a directory within that application,
for example, i have a program and it lies under Debug directory. Now i have an image located under Debug/source/images/logo.png. I dont want to make use of resources file (embedded within the assembly)
How can i point it towards that path, instead of getting the image/picture from the local resources file.
Try this
String.Format(#"{0}\myDesiredPath\MyFile.MyExtension",System.Reflection.Assembly.GetExecutingAssembly().Location);
There are a number of ways to do this, you can use the ImageLocation property or the Load method to specify the path just take a look at the documentation here
I am working on a file explorer using Silverlight OOB. I need a way to get and display the icon associated with each file in my application. Note, I only need to show the icons, I donĀ“t need to open the files.
If I understood you right, you're building something like Windows Explorer and want to mimic its list view by showing the program icons right before their names.
I'm not sure whether OOB has access to the System.Drawing.Icon class, but if so, you can use the following code to get the icon for any given file:
Bitmap icon = System.Drawing.Icon.ExtractAssociatedIcon(filename).ToBitmap();
If not, the only way you can do it is by storing the icons for most common file formats in a dictionary and retrieving them from there based upon file extension.