Skip to content

Commit

Permalink
Enable drag & drop file or folder into output box.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 30, 2024
1 parent f3aa85e commit 9f2e844
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions FindInFilesForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public FindInFilesForm(string[] args) {
if (font != null) {
SetFindResultFont(font);
}
richTextBox.AllowDrop = true;
richTextBox.DragEnter += FindInFilesForm_DragEnter;
richTextBox.DragDrop += FindInFilesForm_DragDrop;
foreach (var arg in args) {
if (Util.PathExists(arg)) {
textBoxSearchPath.Text = arg;
Expand Down Expand Up @@ -214,15 +217,15 @@ private void AppendText(string text, Color color) {
richTextBox.SelectedText = text;
}

private void FindInFilesForm_DragEnter(object sender, DragEventArgs e) {
private void FindInFilesForm_DragEnter(object? sender, DragEventArgs e) {
if (e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.Copy;
} else {
e.Effect = DragDropEffects.None;
}
}

private void FindInFilesForm_DragDrop(object sender, DragEventArgs e) {
private void FindInFilesForm_DragDrop(object? sender, DragEventArgs e) {
if (e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)) {
if (e.Data.GetData(DataFormats.FileDrop) is string[] files && files.Length > 0) {
textBoxSearchPath.Text = files[0];
Expand Down

0 comments on commit 9f2e844

Please sign in to comment.