2020-10-01 05:37:46 +02:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
2020-10-06 18:08:41 +02:00
|
|
|
|
using System.Globalization;
|
2020-10-01 05:37:46 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using Wox.Infrastructure;
|
|
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Plugin.Folder.Sources.Result
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FileItemResult : IItemResult
|
|
|
|
|
|
{
|
2020-10-17 01:30:11 +02:00
|
|
|
|
private static readonly IShellAction ShellAction = new ShellAction();
|
2020-10-01 05:37:46 +02:00
|
|
|
|
|
|
|
|
|
|
public string FilePath { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string Title => Path.GetFileName(FilePath);
|
|
|
|
|
|
|
|
|
|
|
|
public string Search { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public Wox.Plugin.Result Create(IPublicAPI contextApi)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = new Wox.Plugin.Result
|
|
|
|
|
|
{
|
|
|
|
|
|
Title = Title,
|
2020-10-06 18:08:41 +02:00
|
|
|
|
SubTitle = string.Format(CultureInfo.CurrentCulture, Properties.Resources.wox_plugin_folder_select_file_result_subtitle, FilePath),
|
2020-10-01 05:37:46 +02:00
|
|
|
|
IcoPath = FilePath,
|
|
|
|
|
|
TitleHighlightData = StringMatcher.FuzzySearch(Search, Path.GetFileName(FilePath)).MatchData,
|
2020-10-17 01:30:11 +02:00
|
|
|
|
Action = c => ShellAction.Execute(FilePath, contextApi),
|
2020-10-01 05:37:46 +02:00
|
|
|
|
ContextData = new SearchResult { Type = ResultType.File, FullPath = FilePath },
|
|
|
|
|
|
};
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|