Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 public FileSystemTreeNodeSpecialFolder(IIconManager icon_mgr, ExtraSpecialFolder folder)
     : base(icon_mgr, true)
 {
     this.Folder             = folder;
     this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
     this.Text = this.DisplayName;
 }
Esempio n. 3
0
 public string GetDisplayName(ExtraSpecialFolder folder)
 {
     switch (folder)
     {
     case ExtraSpecialFolder.MyComputer:
         return("/");
     }
     return(Path.GetFileName(Environment.GetFolderPath((Environment.SpecialFolder)folder)));
 }
Esempio n. 4
0
        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());
        }
Esempio n. 5
0
 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);
 }
Esempio n. 6
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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 public void SetFolderPath(ExtraSpecialFolder folder, string path)
 {
     throw new Exception("SetFolderPath not supported");
 }
Esempio n. 9
0
 /// <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);
 }
Esempio n. 10
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);
		}
Esempio n. 11
0
		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();
		}
Esempio n. 12
0
		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;
		}
Esempio n. 14
0
		/// <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;
		}
Esempio n. 15
0
		public string GetDisplayName(ExtraSpecialFolder folder)
		{
			switch (folder)
			{
				case ExtraSpecialFolder.MyComputer:
					return "/";
			}
			return Path.GetFileName(Environment.GetFolderPath((Environment.SpecialFolder) folder));
		}
Esempio n. 16
0
		public void SetFolderPath(ExtraSpecialFolder folder, string path)
		{
			throw new Exception("SetFolderPath not supported");
		}
Esempio n. 17
0
		public string GetFolderPath(ExtraSpecialFolder folder)
		{
			switch (folder)
			{
				case ExtraSpecialFolder.MyComputer:
					return "/";
			}
			return Environment.GetFolderPath((Environment.SpecialFolder)folder);
		}
		public FileSystemTreeNodeSpecialFolder(IIconManager icon_mgr, ExtraSpecialFolder folder)
			: base(icon_mgr, true)
		{
			this.Folder = folder;
			this.SelectedImageIndex = this.ImageIndex = this.DisplayIcon;
			this.Text = this.DisplayName;
		}
Esempio n. 19
0
 public TreeNode NewNode(ExtraSpecialFolder folder)
 {
     return(new FileSystemTreeNodeSpecialFolder(m_icon_mgr, folder));
 }
		public TreeNode NewNode(ExtraSpecialFolder folder)
		{
			return new FileSystemTreeNodeSpecialFolder(m_icon_mgr, folder);
		}
Esempio n. 21
0
		/// <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;
		}