using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Media;
namespace Flow.Launcher.Plugin
{
public class Result
{
private string _pluginDirectory;
private string _icoPath;
///
/// The title of the result. This is always required.
///
public string Title { get; set; }
///
/// Provides additional details for the result. This is optional
///
public string SubTitle { get; set; } = string.Empty;
///
/// This holds the action keyword that triggered the result.
/// If result is triggered by global keyword: *, this should be empty.
///
public string ActionKeywordAssigned { get; set; }
public string CopyText { get; set; } = String.Empty;
public string FileCopy { get; set; } = String.Empty;
///
/// This holds the text which can be provided by plugin to help Flow autocomplete text
/// for user on the plugin result. If autocomplete action for example is tab, pressing tab will have
/// the default constructed autocomplete text (result's Title), or the text provided here if not empty.
///
public string AutoCompleteText { get; set; }
///
/// Image Displayed on the result
/// Relative Path to the Image File
/// GlyphInfo is prioritized if not null
///
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();
///
/// Delegate to Get Image Source
///
public IconDelegate Icon;
///
/// Information for Glyph Icon (Prioritized than IcoPath/Icon if user enable Glyph Icons)
///
public GlyphInfo Glyph { get; init; }
///
/// Delegate. An action to take in the form of a function call when the result has been selected
///
/// true to hide flowlauncher after select result
///
///
public Func Action { get; set; }
///
/// Priority of the current result
/// default: 0
///
public int Score { get; set; }
///
/// A list of indexes for the characters to be highlighted in Title
///
public IList TitleHighlightData { get; set; }
[Obsolete("Deprecated as of Flow Launcher v1.9.1. Subtitle highlighting is no longer offered")]
public IList SubTitleHighlightData { get; set; }
///
/// Query information associated with the result
///
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;
return equality;
}
///
public override int GetHashCode()
{
var hashcode = (Title?.GetHashCode() ?? 0) ^
(SubTitle?.GetHashCode() ?? 0);
return hashcode;
}
///
public override string ToString()
{
return Title + SubTitle;
}
///
/// Additional data associated with this result
///
/// As external information for ContextMenu
///
///
public object ContextData { get; set; }
///
/// Plugin ID that generated this result
///
public string PluginID { get; internal set; }
///
/// Show message as ToolTip on result Title hover over
///
public string TitleToolTip { get; set; }
///
/// Show message as ToolTip on result SubTitle hover over
///
public string SubTitleToolTip { get; set; }
}
}