2013-12-19 15:51:20 +00:00
|
|
|
|
using System;
|
2013-12-20 11:38:10 +00:00
|
|
|
|
using System.Collections.Generic;
|
2014-07-16 10:52:00 +00:00
|
|
|
|
using System.IO;
|
2016-08-18 00:16:40 +00:00
|
|
|
|
using System.Windows.Media;
|
2013-12-19 15:51:20 +00:00
|
|
|
|
|
2020-04-21 09:12:17 +00:00
|
|
|
|
namespace Flow.Launcher.Plugin
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
2014-07-05 15:10:34 +00:00
|
|
|
|
|
2014-10-23 10:39:11 +00:00
|
|
|
|
public class Result
|
|
|
|
|
|
{
|
2016-05-05 15:08:44 +00:00
|
|
|
|
|
2016-05-03 20:18:26 +00:00
|
|
|
|
private string _pluginDirectory;
|
|
|
|
|
|
private string _icoPath;
|
2014-10-23 10:39:11 +00:00
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
public string SubTitle { get; set; }
|
|
|
|
|
|
|
2020-03-31 11:00:09 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This holds the action keyword that triggered the result.
|
|
|
|
|
|
/// If result is triggered by global keyword: *, this should be empty.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string ActionKeywordAssigned { get; set; }
|
|
|
|
|
|
|
2016-08-18 00:16:40 +00:00
|
|
|
|
public string IcoPath
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
2016-05-03 20:18:26 +00:00
|
|
|
|
get { return _icoPath; }
|
|
|
|
|
|
set
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
2016-05-03 20:18:26 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value))
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
2016-05-03 20:18:26 +00:00
|
|
|
|
_icoPath = Path.Combine(value, IcoPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_icoPath = value;
|
2014-10-23 10:39:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-08-18 00:16:40 +00:00
|
|
|
|
public delegate ImageSource IconDelegate();
|
|
|
|
|
|
|
|
|
|
|
|
public IconDelegate Icon;
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-23 10:39:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// return true to hide wox after select result
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Func<ActionContext, bool> Action { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public int Score { get; set; }
|
|
|
|
|
|
|
2019-12-03 14:10:21 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A list of indexes for the characters to be highlighted in Title
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IList<int> TitleHighlightData { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A list of indexes for the characters to be highlighted in SubTitle
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public IList<int> SubTitleHighlightData { get; set; }
|
|
|
|
|
|
|
2014-10-23 10:39:11 +00:00
|
|
|
|
/// <summary>
|
2020-03-31 11:00:09 +00:00
|
|
|
|
/// Only results that originQuery match with current query will be displayed in the panel
|
2014-10-23 10:39:11 +00:00
|
|
|
|
/// </summary>
|
2020-03-03 22:25:59 +00:00
|
|
|
|
internal Query OriginQuery { get; set; }
|
2014-10-23 10:39:11 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2015-01-24 14:34:55 +00:00
|
|
|
|
/// Plugin directory
|
2014-10-23 10:39:11 +00:00
|
|
|
|
/// </summary>
|
2016-05-03 20:18:26 +00:00
|
|
|
|
public string PluginDirectory
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return _pluginDirectory; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
_pluginDirectory = value;
|
2016-05-03 22:21:03 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath))
|
2016-05-03 20:18:26 +00:00
|
|
|
|
{
|
|
|
|
|
|
IcoPath = Path.Combine(value, IcoPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2014-10-23 10:39:11 +00:00
|
|
|
|
|
2015-11-06 21:30:38 +00:00
|
|
|
|
public override bool Equals(object obj)
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
2019-08-31 06:58:15 +00:00
|
|
|
|
var r = obj as Result;
|
|
|
|
|
|
|
|
|
|
|
|
var equality = string.Equals(r?.Title, Title) &&
|
|
|
|
|
|
string.Equals(r?.SubTitle, SubTitle) &&
|
2019-12-03 14:10:21 +00:00
|
|
|
|
string.Equals(r?.IcoPath, IcoPath) &&
|
|
|
|
|
|
TitleHighlightData == r.TitleHighlightData &&
|
|
|
|
|
|
SubTitleHighlightData == r.SubTitleHighlightData;
|
2019-08-31 06:58:15 +00:00
|
|
|
|
|
|
|
|
|
|
return equality;
|
2015-11-06 21:30:38 +00:00
|
|
|
|
}
|
2014-10-23 10:39:11 +00:00
|
|
|
|
|
2015-11-06 21:30:38 +00:00
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
2015-11-11 06:20:52 +00:00
|
|
|
|
var hashcode = (Title?.GetHashCode() ?? 0) ^
|
2016-04-27 01:15:53 +00:00
|
|
|
|
(SubTitle?.GetHashCode() ?? 0);
|
2015-11-09 03:20:02 +00:00
|
|
|
|
return hashcode;
|
2014-10-23 10:39:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Title + SubTitle;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-31 11:00:09 +00:00
|
|
|
|
|
2016-04-27 01:15:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Context menus associate with this result
|
|
|
|
|
|
/// </summary>
|
2020-03-31 11:00:09 +00:00
|
|
|
|
[Obsolete("Use IContextMenu instead")]
|
2016-04-27 01:15:53 +00:00
|
|
|
|
public List<Result> ContextMenu { get; set; }
|
|
|
|
|
|
|
2020-03-31 11:00:09 +00:00
|
|
|
|
[Obsolete("Use Object initializer instead")]
|
2016-07-30 15:16:28 +00:00
|
|
|
|
public Result(string Title, string IcoPath, string SubTitle = null)
|
2014-10-23 10:39:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
this.Title = Title;
|
|
|
|
|
|
this.IcoPath = IcoPath;
|
|
|
|
|
|
this.SubTitle = SubTitle;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-27 01:15:53 +00:00
|
|
|
|
public Result() { }
|
2015-01-24 14:34:55 +00:00
|
|
|
|
|
2015-02-04 15:16:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Additional data associate with this result
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public object ContextData { get; set; }
|
|
|
|
|
|
|
2015-01-24 14:34:55 +00:00
|
|
|
|
/// <summary>
|
2019-12-03 21:02:24 +00:00
|
|
|
|
/// Plugin ID that generated this result
|
2015-01-24 14:34:55 +00:00
|
|
|
|
/// </summary>
|
2020-03-03 22:25:59 +00:00
|
|
|
|
public string PluginID { get; internal set; }
|
2014-10-23 10:39:11 +00:00
|
|
|
|
}
|
2013-12-19 15:51:20 +00:00
|
|
|
|
}
|