示例#1
0
        private void MainForm_DragEnter(object sender, DragEventArgs e)
        {
            IDataObject dataObject = e.Data;

            if (lockDragNDrop || !dataObject.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            string ext = Path.GetExtension(((string[])dataObject.GetData(DataFormats.FileDrop))[0]).ToLower();

            e.Effect = FormatFactory.HasExtension(ext) || ext == ".pdb" ? DragDropEffects.Move : DragDropEffects.None;
        }
示例#2
0
        private async void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            IDataObject dataObject = e.Data;

            if (!dataObject.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            List <string> files    = new List <string>((string[])e.Data.GetData(DataFormats.FileDrop));
            List <string> pdbFiles = null;

            string fileToOpen = null;
            int    i          = 0;

            do
            {
                string ext = Path.GetExtension(files[i]).ToLower();

                // search for xml files to open
                if (FormatFactory.HasExtension(ext))
                {
                    fileToOpen = files[i];
                    files.RemoveAt(i);
                    continue;
                }

                // search for pdb files to attach after open
                if (ext == ".pdb")
                {
                    if (pdbFiles == null)
                    {
                        pdbFiles = new List <string>();
                    }
                    pdbFiles.Add(files[i]);
                }

                i++;
            }while (i < files.Count);

            // open file if found. found pdbs will be attached after open (pdbToAttach)
            if (fileToOpen != null)
            {
                if (TaskDialogHelper.ShowMessageBox(
                        Handle,
                        "Open File",
                        "Open file?",
                        fileToOpen,
                        TaskDialogStandardIcon.Information,
                        TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No
                        ) !=
                    TaskDialogResult.Yes
                    )
                {
                    return;
                }

                await OpenFile(fileToOpen);

                return;
            }

            if (mapping == null)
            {
                return;
            }

            AttachPDB(pdbFiles, true);
        }