2013-12-19 23:51:20 +08:00
|
|
|
|
using System;
|
2013-12-20 19:38:10 +08:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-16 18:52:00 +08:00
|
|
|
|
using System.IO;
|
2013-12-19 23:51:20 +08:00
|
|
|
|
|
2014-10-23 18:39:11 +08:00
|
|
|
|
namespace Wox.Plugin
|
|
|
|
|
{
|
2014-07-05 23:10:34 +08:00
|
|
|
|
|
2014-10-23 18:39:11 +08:00
|
|
|
|
public class Result
|
|
|
|
|
{
|
2016-05-04 04:18:26 +08:00
|
|
|
|
private string _pluginDirectory;
|
|
|
|
|
private string _icoPath;
|
2014-10-23 18:39:11 +08:00
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public string SubTitle { get; set; }
|
|
|
|
|
|
2016-05-04 04:18:26 +08:00
|
|
|
|
public string IcoPath
|
2014-10-23 18:39:11 +08:00
|
|
|
|
{
|
2016-05-04 04:18:26 +08:00
|
|
|
|
get { return _icoPath; }
|
|
|
|
|
set
|
2014-10-23 18:39:11 +08:00
|
|
|
|
{
|
2016-05-04 04:18:26 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
|
2014-10-23 18:39:11 +08:00
|
|
|
|
{
|
2016-05-04 04:18:26 +08:00
|
|
|
|
_icoPath = Path.Combine(value, IcoPath);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_icoPath = value;
|
2014-10-23 18:39:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// return true to hide wox after select result
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Func<ActionContext, bool> Action { get; set; }
|
|
|
|
|
|
|
|
|
|
public int Score { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Only resulsts that originQuery match with curren query will be displayed in the panel
|
|
|
|
|
/// </summary>
|
2015-01-24 22:34:55 +08:00
|
|
|
|
internal Query OriginQuery { get; set; }
|
2014-10-23 18:39:11 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2015-01-24 22:34:55 +08:00
|
|
|
|
/// Plugin directory
|
2014-10-23 18:39:11 +08:00
|
|
|
|
/// </summary>
|
2016-05-04 04:18:26 +08:00
|
|
|
|
public string PluginDirectory
|
|
|
|
|
{
|
|
|
|
|
get { return _pluginDirectory; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_pluginDirectory = value;
|
2016-05-04 06:21:03 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
|
2016-05-04 04:18:26 +08:00
|
|
|
|
{
|
|
|
|
|
IcoPath = Path.Combine(value, IcoPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-23 18:39:11 +08:00
|
|
|
|
|
2015-11-07 05:30:38 +08:00
|
|
|
|
public override bool Equals(object obj)
|
2014-10-23 18:39:11 +08:00
|
|
|
|
{
|
2015-11-07 05:30:38 +08:00
|
|
|
|
Result r = obj as Result;
|
|
|
|
|
if (r != null)
|
|
|
|
|
{
|
2015-11-11 14:20:52 +08:00
|
|
|
|
var equality = string.Equals(r.Title, Title) &&
|
2016-01-02 14:59:06 +08:00
|
|
|
|
string.Equals(r.SubTitle, SubTitle);
|
2015-11-11 14:20:52 +08:00
|
|
|
|
return equality;
|
2015-11-07 05:30:38 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-10-23 18:39:11 +08:00
|
|
|
|
|
2015-11-07 05:30:38 +08:00
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
2015-11-11 14:20:52 +08:00
|
|
|
|
var hashcode = (Title?.GetHashCode() ?? 0) ^
|
2016-04-27 09:15:53 +08:00
|
|
|
|
(SubTitle?.GetHashCode() ?? 0);
|
2015-11-09 11:20:02 +08:00
|
|
|
|
return hashcode;
|
2014-10-23 18:39:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Title + SubTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 09:15:53 +08:00
|
|
|
|
[Obsolete("Use IContextMenu instead")]
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Context menus associate with this result
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<Result> ContextMenu { get; set; }
|
|
|
|
|
|
|
|
|
|
[Obsolete("Use Object initializers instead")]
|
|
|
|
|
public Result(string Titles, string IcoPath, string SubTitle = null)
|
2014-10-23 18:39:11 +08:00
|
|
|
|
{
|
|
|
|
|
this.Title = Title;
|
|
|
|
|
this.IcoPath = IcoPath;
|
|
|
|
|
this.SubTitle = SubTitle;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 09:15:53 +08:00
|
|
|
|
public Result() { }
|
2015-01-24 22:34:55 +08:00
|
|
|
|
|
2015-02-04 23:16:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Additional data associate with this result
|
|
|
|
|
/// </summary>
|
|
|
|
|
public object ContextData { get; set; }
|
|
|
|
|
|
2015-01-24 22:34:55 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Plugin ID that generate this result
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string PluginID { get; set; }
|
2014-10-23 18:39:11 +08:00
|
|
|
|
}
|
2013-12-19 23:51:20 +08:00
|
|
|
|
}
|