2014-03-19 02:06:51 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2014-03-19 03:24:15 +08:00
|
|
|
|
using System.Diagnostics;
|
2014-03-19 02:06:51 +08:00
|
|
|
|
|
|
|
|
|
namespace Wox.Plugin.System
|
|
|
|
|
{
|
|
|
|
|
public interface IProgramSource
|
|
|
|
|
{
|
|
|
|
|
List<Program> LoadPrograms();
|
|
|
|
|
int BonusPoints { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class AbstractProgramSource : IProgramSource
|
|
|
|
|
{
|
|
|
|
|
public abstract List<Program> LoadPrograms();
|
|
|
|
|
|
|
|
|
|
public int BonusPoints
|
|
|
|
|
{
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Program CreateEntry(string file)
|
|
|
|
|
{
|
|
|
|
|
Program p = new Program()
|
|
|
|
|
{
|
|
|
|
|
Title = global::System.IO.Path.GetFileNameWithoutExtension(file),
|
|
|
|
|
IcoPath = file,
|
|
|
|
|
ExecutePath = file
|
|
|
|
|
};
|
|
|
|
|
|
2014-03-19 03:24:15 +08:00
|
|
|
|
switch (global::System.IO.Path.GetExtension(file).ToLower())
|
|
|
|
|
{
|
|
|
|
|
case ".exe":
|
2014-03-20 04:15:05 +08:00
|
|
|
|
p.ExecuteName = global::System.IO.Path.GetFileName(file);
|
2014-03-19 03:24:15 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file);
|
|
|
|
|
if (versionInfo.FileDescription != null && versionInfo.FileDescription != string.Empty) p.Title = versionInfo.FileDescription;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception) { }
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-03-19 02:06:51 +08:00
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|