Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (tv.ImageList != null)
            {
                tv.ImageList.Dispose();
            }
            lv.Items.Clear();
            tv.Nodes.Clear();
            foreach (string js in Directory.GetLogicalDrives())
            {
                AddTVPath(js);
            }

            tv.Sorted = true;
            tv.Sort();

            User32.SendMessage(
                tv.Handle,
                (uint)TVM.TVM_SETIMAGELIST,
                (uint)TVSIL.NORMAL,
                Shell32.ImgListPtr(curpath, SHGFI.SYSICONINDEX | SHGFI.ICON | ModelIconSize)
                );
        }
Exemple #2
0
        public void Initialize(ListView listView, SHGFI iconReadStyle, SHGFI iconWriteStyle)
        {
            Debug.Print("Initialize Directories\n");
            foreach (
                KeyValuePair <string, CsShellFile_ListItem> mojo
                in CurrentShellPath.Directories.Paths)
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(mojo.Value.Path);
                using (CsShellFile shellFile = new CsShellFile(mojo.Value.Path, iconWriteStyle))
                {
                    ListViewItem listViewItem = new ListViewItem(directoryInfo.Name);
                    listViewItem.ImageIndex = (int)shellFile.IIcon;
                    if (listView.Groups[shellFile.TypeName] == null)
                    {
                        listView.Groups.Add(shellFile.TypeName, shellFile.TypeName);
                    }
                    listViewItem.Group = listView.Groups[shellFile.TypeName];
                    listViewItem.SubItems.Add(shellFile.TypeName);
                    listView.Items.Add(listViewItem);
                }
            }
            Debug.Print("Initialize Files\n");
            foreach (
                KeyValuePair <string, CsShellFile_ListItem> mojo
                in CurrentShellPath.Files.Paths)
            {
                FileInfo     FI       = new FileInfo(mojo.Value.Path);
                ListViewItem listItem = new ListViewItem(FI.Name);

                SHFileInfo shFile = SHFileInfo.Create(mojo.Value.Path, iconWriteStyle);

                listItem.ImageIndex = (int)shFile.iIcon;

                if (listView.Groups[shFile.szTypeName] == null)
                {
                    listView.Groups.Add(shFile.szTypeName, shFile.szTypeName);
                }

                listItem.Group = listView.Groups[shFile.szTypeName];
                listItem.SubItems.Add(mojo.Value.TypeName);
                listItem.SubItems.Add(checkType(Path.GetExtension(mojo.Value.Path).Trim('.')));
                listView.Items.Add(listItem);
                User32.DestroyIcon(shFile.hIcon);
            }

            User32.SendMessage(listView.Handle, (uint)wm_message.LVM_SETIMAGELIST, (uint)LVSIL.NORMAL, Shell32.ImgListPtr(CurrentPath, iconReadStyle | SHGFI.SYSICONINDEX));
            User32.SendMessage(listView.Handle, (uint)wm_message.LVM_SETIMAGELIST, (uint)LVSIL.SMALL, Shell32.ImgListPtr(CurrentPath, iconReadStyle | SHGFI.SYSICONINDEX));
        }