Flow.Launcher/Flow.Launcher.Plugin/ActionContext.cs

65 lines
2 KiB
C#
Raw Permalink Normal View History

2023-03-24 06:22:10 +00:00
using System.Windows.Input;
namespace Flow.Launcher.Plugin
{
2023-06-18 19:53:01 +00:00
/// <summary>
/// Context provided as a parameter when invoking a
/// <see cref="Result.Action"/> or <see cref="Result.AsyncAction"/>
/// </summary>
public class ActionContext
{
2023-06-18 19:53:01 +00:00
/// <summary>
/// Contains the press state of certain special keys.
/// </summary>
public SpecialKeyState SpecialKeyState { get; set; }
}
2023-06-18 19:53:01 +00:00
/// <summary>
/// Contains the press state of certain special keys.
/// </summary>
public class SpecialKeyState
{
2023-06-18 19:53:01 +00:00
/// <summary>
/// True if the Ctrl key is pressed.
/// </summary>
public bool CtrlPressed { get; set; }
2023-06-18 19:53:01 +00:00
/// <summary>
/// True if the Shift key is pressed.
/// </summary>
public bool ShiftPressed { get; set; }
2023-06-18 19:53:01 +00:00
/// <summary>
/// True if the Alt key is pressed.
/// </summary>
public bool AltPressed { get; set; }
2023-06-18 19:53:01 +00:00
/// <summary>
/// True if the Windows key is pressed.
/// </summary>
public bool WinPressed { get; set; }
2023-03-24 06:22:10 +00:00
2023-06-18 19:53:01 +00:00
/// <summary>
/// Get this object represented as a <see cref="ModifierKeys"/> flag combination.
/// </summary>
/// <returns></returns>
2023-03-24 06:22:10 +00:00
public ModifierKeys ToModifierKeys()
{
return (CtrlPressed ? ModifierKeys.Control : ModifierKeys.None) |
(ShiftPressed ? ModifierKeys.Shift : ModifierKeys.None) |
(AltPressed ? ModifierKeys.Alt : ModifierKeys.None) |
(WinPressed ? ModifierKeys.Windows : ModifierKeys.None);
}
2023-11-20 15:20:59 +00:00
2025-02-24 07:37:13 +00:00
/// <summary>
/// Default <see cref="SpecialKeyState"/> object with all keys not pressed.
/// </summary>
2023-11-20 15:20:59 +00:00
public static readonly SpecialKeyState Default = new () {
CtrlPressed = false,
ShiftPressed = false,
AltPressed = false,
WinPressed = false
};
}
2023-03-24 06:22:10 +00:00
}