/// <summary> /// Get the icon index associated with a given filename /// </summary> /// <param name="filename">the filename of interest</param> /// <param name="open">if true, the file is "open", most useful for folders</param> /// <returns>the index into the image list for the icon associated with this file</returns> public int GetIconIndex(ExtraSpecialFolder folder, bool open) { GetInfoFlags flags = GetInfoFlags.SHGFI_ICON | GetInfoFlags.SHGFI_SMALLICON | GetInfoFlags.SHGFI_PIDL; if (open) { flags |= GetInfoFlags.SHGFI_OPENICON; } IntPtr ppidl; if (SHGetFolderLocation(IntPtr.Zero, (int)folder, IntPtr.Zero, 0, out ppidl) != 0) { throw new Exception("SHGetFolderLocation failed"); } SHFILEINFO info = new SHFILEINFO(); SHGetFileInfoPIDL(ppidl, 0, ref info, (uint)Marshal.SizeOf(info), (uint)flags); int iIcon = MapIcon(info.hIcon, info.iIcon); ILFree(ppidl); DestroyIcon(info.hIcon); return(iIcon); }
public FileSystemTreeNodeSpecialFolder(IIconManager icon_mgr, ExtraSpecialFolder folder) : base(icon_mgr, true) { this.Folder = folder; this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon; this.Text = this.DisplayName; }
public string GetDisplayName(ExtraSpecialFolder folder) { switch (folder) { case ExtraSpecialFolder.MyComputer: return("/"); } return(Path.GetFileName(Environment.GetFolderPath((Environment.SpecialFolder)folder))); }
public string GetFolderPath(ExtraSpecialFolder folder) { StringBuilder SB = new StringBuilder(1024); if (0 != SHGetFolderPath(IntPtr.Zero, (int)folder, IntPtr.Zero, 0x0000, SB)) { return(null); } return(SB.ToString()); }
private TreeNode LookupNode(TreeNodeCollection nodes, ExtraSpecialFolder tag) { foreach (TreeNode node in nodes) { if (node is FileSystemTreeNodeSpecialFolder && (node as FileSystemTreeNodeSpecialFolder).Folder == tag) { return(node); } } return(null); }
public void SetFolderPath(ExtraSpecialFolder folder, string path) { Guid rfid; IKnownFolderManager knownFolderManager = (IKnownFolderManager) new KnownFolderManager(); knownFolderManager.FolderIdFromCsidl((int)folder, out rfid); if (path == null) { IKnownFolder knownFolderInterface; knownFolderManager.GetFolder(ref rfid, out knownFolderInterface); knownFolderInterface.GetPath(KnownFolderPathFlags.KF_FLAG_DEFAULT_PATH, out path); } //knownFolderInterface.SetPath(KnownFolderPathFlags.KF_FLAG_DONT_UNEXPAND, path); string ppszError; knownFolderManager.Redirect(ref rfid, IntPtr.Zero, 0, path, 0, ref rfid, out ppszError); }
public string GetDisplayName(ExtraSpecialFolder folder) { GetInfoFlags flags = GetInfoFlags.SHGFI_PIDL | GetInfoFlags.SHGFI_DISPLAYNAME; SHFILEINFO info = new SHFILEINFO(); IntPtr ppidl; if (SHGetFolderLocation(IntPtr.Zero, (int)folder, IntPtr.Zero, 0, out ppidl) != 0) { throw new Exception("SHGetFolderLocation failed"); } if (SHGetFileInfoPIDL(ppidl, 0, ref info, (uint)Marshal.SizeOf(info), (uint)flags) == IntPtr.Zero) { ILFree(ppidl); throw new Exception("SHGetFileInfo failed"); } ILFree(ppidl); return(info.szDisplayName); }
public void SetFolderPath(ExtraSpecialFolder folder, string path) { throw new Exception("SetFolderPath not supported"); }
/// <summary> /// Get the icon index associated with a given filename /// </summary> /// <param name="filename">the filename of interest</param> /// <param name="open">if true, the file is "open", most useful for folders</param> /// <returns>the index into the image list for the icon associated with this file</returns> public int GetIconIndex(ExtraSpecialFolder folder, bool open) { return(0); }
public void SetFolderPath(ExtraSpecialFolder folder, string path) { Guid rfid; IKnownFolderManager knownFolderManager = (IKnownFolderManager) new KnownFolderManager(); knownFolderManager.FolderIdFromCsidl((int) folder, out rfid); if (path == null) { IKnownFolder knownFolderInterface; knownFolderManager.GetFolder(ref rfid, out knownFolderInterface); knownFolderInterface.GetPath(KnownFolderPathFlags.KF_FLAG_DEFAULT_PATH, out path); } //knownFolderInterface.SetPath(KnownFolderPathFlags.KF_FLAG_DONT_UNEXPAND, path); string ppszError; knownFolderManager.Redirect(ref rfid, IntPtr.Zero, 0, path, 0, ref rfid, out ppszError); }
public string GetFolderPath(ExtraSpecialFolder folder) { StringBuilder SB = new StringBuilder(1024); if (0 != SHGetFolderPath(IntPtr.Zero, (int)folder, IntPtr.Zero, 0x0000, SB)) return null; return SB.ToString(); }
public string GetDisplayName(ExtraSpecialFolder folder) { GetInfoFlags flags = GetInfoFlags.SHGFI_PIDL | GetInfoFlags.SHGFI_DISPLAYNAME; SHFILEINFO info = new SHFILEINFO(); IntPtr ppidl; if (SHGetFolderLocation(IntPtr.Zero, (int) folder, IntPtr.Zero, 0, out ppidl) != 0) throw new Exception("SHGetFolderLocation failed"); if (SHGetFileInfoPIDL(ppidl, 0, ref info, (uint)Marshal.SizeOf(info), (uint)flags) == IntPtr.Zero) { ILFree(ppidl); throw new Exception("SHGetFileInfo failed"); } ILFree(ppidl); return info.szDisplayName; }
private TreeNode LookupNode(TreeNodeCollection nodes, ExtraSpecialFolder tag) { foreach (TreeNode node in nodes) if (node is FileSystemTreeNodeSpecialFolder && (node as FileSystemTreeNodeSpecialFolder).Folder == tag) return node; return null; }
/// <summary> /// Get the icon index associated with a given filename /// </summary> /// <param name="filename">the filename of interest</param> /// <param name="open">if true, the file is "open", most useful for folders</param> /// <returns>the index into the image list for the icon associated with this file</returns> public int GetIconIndex(ExtraSpecialFolder folder, bool open) { return 0; }
public string GetDisplayName(ExtraSpecialFolder folder) { switch (folder) { case ExtraSpecialFolder.MyComputer: return "/"; } return Path.GetFileName(Environment.GetFolderPath((Environment.SpecialFolder) folder)); }
public string GetFolderPath(ExtraSpecialFolder folder) { switch (folder) { case ExtraSpecialFolder.MyComputer: return "/"; } return Environment.GetFolderPath((Environment.SpecialFolder)folder); }
public TreeNode NewNode(ExtraSpecialFolder folder) { return(new FileSystemTreeNodeSpecialFolder(m_icon_mgr, folder)); }
public TreeNode NewNode(ExtraSpecialFolder folder) { return new FileSystemTreeNodeSpecialFolder(m_icon_mgr, folder); }
/// <summary> /// Get the icon index associated with a given filename /// </summary> /// <param name="filename">the filename of interest</param> /// <param name="open">if true, the file is "open", most useful for folders</param> /// <returns>the index into the image list for the icon associated with this file</returns> public int GetIconIndex(ExtraSpecialFolder folder, bool open) { GetInfoFlags flags = GetInfoFlags.SHGFI_ICON | GetInfoFlags.SHGFI_SMALLICON | GetInfoFlags.SHGFI_PIDL; if (open) flags |= GetInfoFlags.SHGFI_OPENICON; IntPtr ppidl; if (SHGetFolderLocation(IntPtr.Zero, (int)folder, IntPtr.Zero, 0, out ppidl) != 0) throw new Exception("SHGetFolderLocation failed"); SHFILEINFO info = new SHFILEINFO(); SHGetFileInfoPIDL(ppidl, 0, ref info, (uint)Marshal.SizeOf(info), (uint)flags); int iIcon = MapIcon(info.hIcon, info.iIcon); ILFree(ppidl); DestroyIcon(info.hIcon); return iIcon; }