using System; using System.Collections.Generic; using System.IO; using System.Windows.Media; namespace Wox.Plugin { public class Result { private string _pluginDirectory; private string _icoPath; public string Title { get; set; } public string SubTitle { get; set; } public string IcoPath { get { return _icoPath; } set { if (!string.IsNullOrEmpty(PluginDirectory) && !Path.IsPathRooted(value)) { _icoPath = Path.Combine(value, IcoPath); } else { _icoPath = value; } } } public delegate ImageSource IconDelegate(); public IconDelegate Icon; /// /// return true to hide wox after select result /// public Func Action { get; set; } public int Score { get; set; } /// /// A list of indexes for the characters to be highlighted in Title /// public IList TitleHighlightData { get; set; } /// /// A list of indexes for the characters to be highlighted in SubTitle /// public IList SubTitleHighlightData { get; set; } /// /// Only resulsts that originQuery match with curren query will be displayed in the panel /// internal Query OriginQuery { get; set; } /// /// Plugin directory /// public string PluginDirectory { get { return _pluginDirectory; } set { _pluginDirectory = value; if (!string.IsNullOrEmpty(IcoPath) && !Path.IsPathRooted(IcoPath)) { IcoPath = Path.Combine(value, IcoPath); } } } public override bool Equals(object obj) { var r = obj as Result; var equality = string.Equals(r?.Title, Title) && string.Equals(r?.SubTitle, SubTitle) && string.Equals(r?.IcoPath, IcoPath) && TitleHighlightData == r.TitleHighlightData && SubTitleHighlightData == r.SubTitleHighlightData; return equality; } public override int GetHashCode() { var hashcode = (Title?.GetHashCode() ?? 0) ^ (SubTitle?.GetHashCode() ?? 0); return hashcode; } public override string ToString() { return Title + SubTitle; } [Obsolete("Use IContextMenu instead")] /// /// Context menus associate with this result /// public List ContextMenu { get; set; } [Obsolete("Use Object initializers instead")] public Result(string Title, string IcoPath, string SubTitle = null) { this.Title = Title; this.IcoPath = IcoPath; this.SubTitle = SubTitle; } public Result() { } /// /// Additional data associate with this result /// public object ContextData { get; set; } /// /// Plugin ID that generate this result /// public string PluginID { get; internal set; } } }