2014-03-19 02:06:51 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-03-19 03:24:15 +08:00
|
|
|
|
using System.Diagnostics;
|
2014-08-10 22:22:54 +08:00
|
|
|
|
using System.IO;
|
2014-03-19 02:06:51 +08:00
|
|
|
|
|
2015-01-03 15:20:34 +08:00
|
|
|
|
namespace Wox.Plugin.Program
|
2014-03-19 02:06:51 +08:00
|
|
|
|
{
|
|
|
|
|
public interface IProgramSource
|
|
|
|
|
{
|
|
|
|
|
List<Program> LoadPrograms();
|
|
|
|
|
int BonusPoints { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:58:49 +08:00
|
|
|
|
[Serializable]
|
2014-03-19 02:06:51 +08:00
|
|
|
|
public abstract class AbstractProgramSource : IProgramSource
|
|
|
|
|
{
|
|
|
|
|
public abstract List<Program> LoadPrograms();
|
|
|
|
|
|
2016-04-23 06:03:32 +08:00
|
|
|
|
public int BonusPoints { get; set; }
|
2014-03-19 02:06:51 +08:00
|
|
|
|
|
2014-08-10 22:22:54 +08:00
|
|
|
|
protected Program CreateEntry(string file)
|
2014-03-19 02:06:51 +08:00
|
|
|
|
{
|
2016-01-07 05:34:42 +08:00
|
|
|
|
var p = new Program
|
2014-03-19 02:06:51 +08:00
|
|
|
|
{
|
2014-08-10 22:22:54 +08:00
|
|
|
|
Title = Path.GetFileNameWithoutExtension(file),
|
2014-03-19 02:06:51 +08:00
|
|
|
|
IcoPath = file,
|
|
|
|
|
ExecutePath = file
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-10 22:22:54 +08:00
|
|
|
|
switch (Path.GetExtension(file).ToLower())
|
2014-03-19 03:24:15 +08:00
|
|
|
|
{
|
|
|
|
|
case ".exe":
|
2014-08-12 12:21:04 +08:00
|
|
|
|
p.ExecuteName = Path.GetFileName(file);
|
2014-03-19 03:24:15 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file);
|
2014-08-10 22:22:54 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(versionInfo.FileDescription))
|
|
|
|
|
{
|
|
|
|
|
p.Title = versionInfo.FileDescription;
|
|
|
|
|
}
|
2014-03-19 03:24:15 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception) { }
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-03-19 02:06:51 +08:00
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|