コード例 #1
0
        private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
        {
            //Extract file
            if (lockedItemDrop)
            {
                return;
            }
            if (selectedPck == null)
            {
                return;
            }
            List <PckEntry> selectedFiles = new List <PckEntry>();
            string          pckName       = selectedPck.fiullFilePath;

            if (openedPckFies != null)
            {
                lockedItemDrop = true;
                foreach (ListViewItem item in FileList.SelectedItems)
                {
                    int index = item.Index;
                    if (FileList.Items[index].Tag is PckEntry)
                    {
                        PckEntry file = (PckEntry)FileList.Items[index].Tag;
                        if (file != null)
                        {
                            byte[] bytes = openedPckFies.getChunk(file.packPath, file);
                            if (bytes != null)
                            {
                                file.memory = new MemoryStream(openedPckFies.getChunk(file.packPath, file));
                                selectedFiles.Add(file);
                            }
                        }
                    }
                }
                DataDragObject dataDragObject = new DataDragObject(selectedFiles.ToArray());
                dataDragObject.SetData(NativeMethods.CFSTR_FILEDESCRIPTORW, null);
                dataDragObject.SetData(NativeMethods.CFSTR_FILECONTENTS, null);
                dataDragObject.SetData(NativeMethods.CFSTR_PERFORMEDDROPEFFECT, null);
                DoDragDrop(dataDragObject, DragDropEffects.Copy);
                lockedItemDrop = false;
            }
        }