[PTRun] Drag and drop files (#22409)

* [PTRun] Support drag&drop to other application for files in result list

* [PTRun] use file/folder thumbnail as drag image

* (fix spellcheck)

* [PTRun] use _mouseDownResultViewModel.Image to generate the drag image

* fix spelling + refactoring
This commit is contained in:
Daniel Richter
2022-12-09 14:01:44 +01:00
committed by GitHub
parent bb92b03156
commit 08d569ccf6
12 changed files with 184 additions and 16 deletions

View File

@@ -47,7 +47,7 @@ namespace Microsoft.Plugin.Folder
{
try
{
Clipboard.SetText(record.FullPath);
Clipboard.SetText(record.Path);
return true;
}
catch (Exception e)
@@ -75,18 +75,18 @@ namespace Microsoft.Plugin.Folder
{
if (record.Type == ResultType.File)
{
Helper.OpenInConsole(_fileSystem.Path.GetDirectoryName(record.FullPath));
Helper.OpenInConsole(_fileSystem.Path.GetDirectoryName(record.Path));
}
else
{
Helper.OpenInConsole(record.FullPath);
Helper.OpenInConsole(record.Path);
}
return true;
}
catch (Exception e)
{
Log.Exception($"Failed to open {record.FullPath} in console, {e.Message}", e, GetType());
Log.Exception($"Failed to open {record.Path} in console, {e.Message}", e, GetType());
return false;
}
@@ -109,9 +109,9 @@ namespace Microsoft.Plugin.Folder
AcceleratorModifiers = ModifierKeys.Control | ModifierKeys.Shift,
Action = _ =>
{
if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.FullPath}\""))
if (!Helper.OpenInShell("explorer.exe", $"/select,\"{record.Path}\""))
{
var message = $"{Properties.Resources.Microsoft_plugin_folder_file_open_failed} {record.FullPath}";
var message = $"{Properties.Resources.Microsoft_plugin_folder_file_open_failed} {record.Path}";
_context.API.ShowMsg(message);
return false;
}

View File

@@ -4,9 +4,11 @@
namespace Microsoft.Plugin.Folder
{
public class SearchResult
using Wox.Plugin.Interfaces;
public class SearchResult : IFileDropResult
{
public string FullPath { get; set; }
public string Path { get; set; }
public ResultType Type { get; set; }
}

View File

@@ -36,7 +36,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
IcoPath = Search,
Score = 500,
Action = c => _shellAction.ExecuteSanitized(Search, contextApi),
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Search },
ContextData = new SearchResult { Type = ResultType.Folder, Path = Search },
};
}
}

View File

@@ -38,7 +38,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path),
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Path)),
QueryTextDisplay = Path,
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
Action = c => _shellAction.Execute(Path, contextApi),
};
}

View File

@@ -42,7 +42,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath)),
IcoPath = FilePath,
Action = c => ShellAction.Execute(FilePath, contextApi),
ContextData = new SearchResult { Type = ResultType.File, FullPath = FilePath },
ContextData = new SearchResult { Type = ResultType.File, Path = FilePath },
};
return result;
}

View File

@@ -42,7 +42,7 @@ namespace Microsoft.Plugin.Folder.Sources.Result
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
ToolTipData = new ToolTipData(Title, string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle)),
QueryTextDisplay = Path,
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
Action = c => ShellAction.Execute(Path, contextApi),
};
}

View File

@@ -32,7 +32,7 @@ namespace Microsoft.Plugin.Folder
// Using CurrentCulture since this is user facing
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_folder_result_subtitle, Subtitle),
QueryTextDisplay = Path,
ContextData = new SearchResult { Type = ResultType.Folder, FullPath = Path },
ContextData = new SearchResult { Type = ResultType.Folder, Path = Path },
Action = c => _shellAction.Execute(Path, contextApi),
};
}