Change Directory plugin subdirectory list action

This commit is contained in:
cxfksword
2014-03-24 00:51:07 +08:00
parent 0dd540a048
commit e1f71cae37

View File

@@ -10,6 +10,7 @@ namespace Wox.Plugin.System
{ {
public class DirectoryIndicator : BaseSystemPlugin public class DirectoryIndicator : BaseSystemPlugin
{ {
private PluginInitContext context;
private static List<string> driverNames = null; private static List<string> driverNames = null;
private static Dictionary<string, DirectoryInfo[]> parentDirectories = new Dictionary<string, DirectoryInfo[]>(); private static Dictionary<string, DirectoryInfo[]> parentDirectories = new Dictionary<string, DirectoryInfo[]>();
@@ -25,6 +26,8 @@ namespace Wox.Plugin.System
return results; return results;
} }
InitialDriverList();
var input = query.RawQuery.ToLower(); var input = query.RawQuery.ToLower();
if (driverNames.FirstOrDefault(x => input.StartsWith(x)) == null) return results; if (driverNames.FirstOrDefault(x => input.StartsWith(x)) == null) return results;
@@ -49,12 +52,11 @@ namespace Wox.Plugin.System
Result result = new Result Result result = new Result
{ {
Title = dir.Name, Title = dir.Name,
SubTitle = "Open this directory",
IcoPath = "Images/folder.png", IcoPath = "Images/folder.png",
Action = (c) => Action = (c) =>
{ {
Process.Start(dirPath); context.ChangeQuery(dirPath);
return true; return false;
} }
}; };
results.Add(result); results.Add(result);
@@ -64,9 +66,14 @@ namespace Wox.Plugin.System
{ {
Result result = new Result Result result = new Result
{ {
Title = "No files in this directory", Title = "Open this directory",
SubTitle = "", SubTitle = "No files in this directory",
IcoPath = "Images/folder.png", IcoPath = "Images/folder.png",
Action = (c) =>
{
Process.Start(query.RawQuery);
return true;
}
}; };
results.Add(result); results.Add(result);
} }
@@ -111,12 +118,11 @@ namespace Wox.Plugin.System
Result result = new Result Result result = new Result
{ {
Title = dir.Name, Title = dir.Name,
SubTitle = "Open this directory",
IcoPath = "Images/folder.png", IcoPath = "Images/folder.png",
Action = (c) => Action = (c) =>
{ {
Process.Start(dirPath); context.ChangeQuery(dirPath);
return true; return false;
} }
}; };
results.Add(result); results.Add(result);
@@ -128,7 +134,7 @@ namespace Wox.Plugin.System
return results; return results;
} }
protected override void InitInternal(PluginInitContext context) private void InitialDriverList()
{ {
if (driverNames == null) if (driverNames == null)
{ {
@@ -141,5 +147,10 @@ namespace Wox.Plugin.System
} }
} }
protected override void InitInternal(PluginInitContext context)
{
this.context = context;
}
} }
} }