Skip to content

Commit 65ae342

Browse files
committed
Add documents for Flow.Launcher.Plugin
1 parent a29ed64 commit 65ae342

File tree

10 files changed

+141
-11
lines changed

10 files changed

+141
-11
lines changed

Flow.Launcher.Plugin/ActionContext.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public ModifierKeys ToModifierKeys()
5151
(WinPressed ? ModifierKeys.Windows : ModifierKeys.None);
5252
}
5353

54+
/// <summary>
55+
/// Default <see cref="SpecialKeyState"/> object with all keys not pressed.
56+
/// </summary>
5457
public static readonly SpecialKeyState Default = new () {
5558
CtrlPressed = false,
5659
ShiftPressed = false,

Flow.Launcher.Plugin/Interfaces/IResultUpdated.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,42 @@
44

55
namespace Flow.Launcher.Plugin
66
{
7+
/// <summary>
8+
/// Interface for plugins that want to manually update their results
9+
/// </summary>
710
public interface IResultUpdated : IFeatures
811
{
12+
/// <summary>
13+
/// Event that is triggered when the results are updated
14+
/// </summary>
915
event ResultUpdatedEventHandler ResultsUpdated;
1016
}
1117

18+
/// <summary>
19+
/// Delegate for the ResultsUpdated event
20+
/// </summary>
21+
/// <param name="sender"></param>
22+
/// <param name="e"></param>
1223
public delegate void ResultUpdatedEventHandler(IResultUpdated sender, ResultUpdatedEventArgs e);
1324

25+
/// <summary>
26+
/// Event arguments for the ResultsUpdated event
27+
/// </summary>
1428
public class ResultUpdatedEventArgs : EventArgs
1529
{
30+
/// <summary>
31+
/// List of results that should be displayed
32+
/// </summary>
1633
public List<Result> Results;
34+
35+
/// <summary>
36+
/// Query that triggered the update
37+
/// </summary>
1738
public Query Query;
39+
40+
/// <summary>
41+
/// Token that can be used to cancel the update
42+
/// </summary>
1843
public CancellationToken Token { get; init; }
1944
}
20-
}
45+
}

Flow.Launcher.Plugin/Interfaces/ISettingProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace Flow.Launcher.Plugin
44
{
5+
/// <summary>
6+
/// This interface is used to create settings panel for .Net plugins
7+
/// </summary>
58
public interface ISettingProvider
69
{
10+
/// <summary>
11+
/// Create settings panel control for .Net plugins
12+
/// </summary>
13+
/// <returns></returns>
714
Control CreateSettingPanel();
815
}
916
}

Flow.Launcher.Plugin/PluginInitContext.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
/// </summary>
66
public class PluginInitContext
77
{
8+
/// <summary>
9+
/// Default constructor.
10+
/// </summary>
811
public PluginInitContext()
912
{
1013
}
1114

15+
/// <summary>
16+
/// Constructor.
17+
/// </summary>
18+
/// <param name="currentPluginMetadata"></param>
19+
/// <param name="api"></param>
1220
public PluginInitContext(PluginMetadata currentPluginMetadata, IPublicAPI api)
1321
{
1422
CurrentPluginMetadata = currentPluginMetadata;

Flow.Launcher.Plugin/PluginPair.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
namespace Flow.Launcher.Plugin
22
{
3+
/// <summary>
4+
/// Plugin instance and plugin metadata
5+
/// </summary>
36
public class PluginPair
47
{
8+
/// <summary>
9+
/// Plugin instance
10+
/// </summary>
511
public IAsyncPlugin Plugin { get; internal set; }
6-
public PluginMetadata Metadata { get; internal set; }
712

8-
13+
/// <summary>
14+
/// Plugin metadata
15+
/// </summary>
16+
public PluginMetadata Metadata { get; internal set; }
917

18+
/// <summary>
19+
/// Convert to string
20+
/// </summary>
21+
/// <returns></returns>
1022
public override string ToString()
1123
{
1224
return Metadata.Name;
1325
}
1426

27+
/// <summary>
28+
/// Compare by plugin metadata ID
29+
/// </summary>
30+
/// <param name="obj"></param>
31+
/// <returns></returns>
1532
public override bool Equals(object obj)
1633
{
17-
PluginPair r = obj as PluginPair;
18-
if (r != null)
34+
if (obj is PluginPair r)
1935
{
2036
return string.Equals(r.Metadata.ID, Metadata.ID);
2137
}
@@ -25,6 +41,10 @@ public override bool Equals(object obj)
2541
}
2642
}
2743

44+
/// <summary>
45+
/// Get hash coode
46+
/// </summary>
47+
/// <returns></returns>
2848
public override int GetHashCode()
2949
{
3050
var hashcode = Metadata.ID?.GetHashCode() ?? 0;

Flow.Launcher.Plugin/Query.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace Flow.Launcher.Plugin
44
{
5+
/// <summary>
6+
/// Represents a query that is sent to a plugin.
7+
/// </summary>
58
public class Query
69
{
7-
public Query() { }
8-
910
/// <summary>
1011
/// Raw query, this includes action keyword if it has
1112
/// We didn't recommend use this property directly. You should always use Search property.
@@ -55,13 +56,13 @@ public Query() { }
5556
/// </summary>
5657
public string ActionKeyword { get; init; }
5758

58-
[JsonIgnore]
5959
/// <summary>
6060
/// Splits <see cref="SearchTerms"/> by spaces and returns the first item.
6161
/// </summary>
6262
/// <remarks>
6363
/// returns an empty string when <see cref="SearchTerms"/> does not have enough items.
6464
/// </remarks>
65+
[JsonIgnore]
6566
public string FirstSearch => SplitSearch(0);
6667

6768
[JsonIgnore]

Flow.Launcher.Plugin/Result.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Runtime;
32
using System.Collections.Generic;
43
using System.IO;
54
using System.Threading.Tasks;
@@ -13,7 +12,6 @@ namespace Flow.Launcher.Plugin
1312
/// </summary>
1413
public class Result
1514
{
16-
1715
private string _pluginDirectory;
1816

1917
private string _icoPath;

Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Flow.Launcher.Plugin.SharedCommands
88
{
9+
/// <summary>
10+
/// Contains methods to open a search in a new browser window or tab.
11+
/// </summary>
912
public static class SearchWeb
1013
{
1114
private static string GetDefaultBrowserPath()
@@ -106,4 +109,4 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo
106109
}
107110
}
108111
}
109-
}
112+
}

Flow.Launcher.Plugin/SharedCommands/ShellCommand.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,26 @@
88

99
namespace Flow.Launcher.Plugin.SharedCommands
1010
{
11+
/// <summary>
12+
/// Contains methods for running shell commands
13+
/// </summary>
1114
public static class ShellCommand
1215
{
16+
/// <summary>
17+
/// Delegate for EnumThreadWindows
18+
/// </summary>
19+
/// <param name="hwnd"></param>
20+
/// <param name="lParam"></param>
21+
/// <returns></returns>
1322
public delegate bool EnumThreadDelegate(IntPtr hwnd, IntPtr lParam);
1423

1524
private static bool containsSecurityWindow;
1625

26+
/// <summary>
27+
/// Runs a windows command using the provided ProcessStartInfo
28+
/// </summary>
29+
/// <param name="processStartInfo"></param>
30+
/// <returns></returns>
1731
public static Process RunAsDifferentUser(ProcessStartInfo processStartInfo)
1832
{
1933
processStartInfo.Verb = "RunAsUser";
@@ -65,6 +79,15 @@ private static unsafe string GetWindowTitle(HWND hwnd)
6579
return buffer[..length].ToString();
6680
}
6781

82+
/// <summary>
83+
/// Runs a windows command using the provided ProcessStartInfo
84+
/// </summary>
85+
/// <param name="fileName"></param>
86+
/// <param name="workingDirectory"></param>
87+
/// <param name="arguments"></param>
88+
/// <param name="verb"></param>
89+
/// <param name="createNoWindow"></param>
90+
/// <returns></returns>
6891
public static ProcessStartInfo SetProcessStartInfo(this string fileName, string workingDirectory = "",
6992
string arguments = "", string verb = "", bool createNoWindow = false)
7093
{

Flow.Launcher.Plugin/SharedModels/MatchResult.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22

33
namespace Flow.Launcher.Plugin.SharedModels
44
{
5+
/// <summary>
6+
/// Represents the result of a match operation.
7+
/// </summary>
58
public class MatchResult
69
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="MatchResult"/> class.
12+
/// </summary>
13+
/// <param name="success"></param>
14+
/// <param name="searchPrecision"></param>
715
public MatchResult(bool success, SearchPrecisionScore searchPrecision)
816
{
917
Success = success;
1018
SearchPrecision = searchPrecision;
1119
}
1220

21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="MatchResult"/> class.
23+
/// </summary>
24+
/// <param name="success"></param>
25+
/// <param name="searchPrecision"></param>
26+
/// <param name="matchData"></param>
27+
/// <param name="rawScore"></param>
1328
public MatchResult(bool success, SearchPrecisionScore searchPrecision, List<int> matchData, int rawScore)
1429
{
1530
Success = success;
@@ -18,6 +33,9 @@ public MatchResult(bool success, SearchPrecisionScore searchPrecision, List<int>
1833
RawScore = rawScore;
1934
}
2035

36+
/// <summary>
37+
/// Whether the match operation was successful.
38+
/// </summary>
2139
public bool Success { get; set; }
2240

2341
/// <summary>
@@ -30,6 +48,9 @@ public MatchResult(bool success, SearchPrecisionScore searchPrecision, List<int>
3048
/// </summary>
3149
private int _rawScore;
3250

51+
/// <summary>
52+
/// The raw calculated search score without any search precision filtering applied.
53+
/// </summary>
3354
public int RawScore
3455
{
3556
get { return _rawScore; }
@@ -45,8 +66,15 @@ public int RawScore
4566
/// </summary>
4667
public List<int> MatchData { get; set; }
4768

69+
/// <summary>
70+
/// The search precision score used to filter the search results.
71+
/// </summary>
4872
public SearchPrecisionScore SearchPrecision { get; set; }
4973

74+
/// <summary>
75+
/// Determines if the search precision score is met.
76+
/// </summary>
77+
/// <returns></returns>
5078
public bool IsSearchPrecisionScoreMet()
5179
{
5280
return IsSearchPrecisionScoreMet(_rawScore);
@@ -63,10 +91,24 @@ private int ScoreAfterSearchPrecisionFilter(int rawScore)
6391
}
6492
}
6593

94+
/// <summary>
95+
/// Represents the search precision score used to filter search results.
96+
/// </summary>
6697
public enum SearchPrecisionScore
6798
{
99+
/// <summary>
100+
/// The highest search precision score.
101+
/// </summary>
68102
Regular = 50,
103+
104+
/// <summary>
105+
/// The medium search precision score.
106+
/// </summary>
69107
Low = 20,
108+
109+
/// <summary>
110+
/// The lowest search precision score.
111+
/// </summary>
70112
None = 0
71113
}
72114
}

0 commit comments

Comments
 (0)