• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MorganKryze / ConsoleAppVisuals / 7972444880

pending completion
7972444880

push

github

MorganKryze
📖 add legacy docs

827 of 916 branches covered (90.28%)

Branch coverage included in aggregate %.

1676 of 1694 relevant lines covered (98.94%)

105.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/ConsoleAppVisuals/models/InteractiveElement.cs
1
/*
2
    GNU GPL License 2024 MorganKryze(Yann Vidamment)
3
    For full license information, please visit: https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE
4
*/
5
namespace ConsoleAppVisuals;
6

7
/// <summary>
8
/// Defines the basic properties of an console element.
9
/// </summary>
10
/// <remarks>
11
/// For more information, refer to the following resources:
12
/// <list type="bullet">
13
/// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
14
/// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
15
/// </list>
16
/// </remarks>
17
public abstract class InteractiveElement<TResponse> : Element
18
{
19
    #region Properties
20
    /// <summary>
21
    /// Whether the element is interactive or not.
22
    /// </summary>
23
    public sealed override bool IsInteractive { get; } = true;
657✔
24

25
    /// <summary>
26
    /// The maximum number of this element that can be drawn on the console. As an interactive element, the value is 1.
27
    /// </summary>
28
    public sealed override int MaxNumberOfThisElement { get; } = 1;
495✔
29

30
    /// <summary>
31
    ///
32
    /// </summary>
33
    public event EventHandler<InteractionEventArgs<TResponse>>? EndOfInteractionEvent;
34

35
    /// <summary>
36
    /// The response of the user.
37
    /// </summary>
38
    protected InteractionEventArgs<TResponse>? _interactionResponse;
39

40
    /// <summary>
41
    /// Returns the response of the user.
42
    /// </summary>
43
    public InteractionEventArgs<TResponse>? GetInteractionResponse => _interactionResponse;
6✔
44
    #endregion
45

46
    #region Methods
47
    /// <summary>
48
    /// Sets the response of the user in the attribute field.
49
    /// </summary>
50
    /// <param name="sender">The sender of the event.</param>
51
    /// <param name="e">The response of the user.</param>
52
    protected void SetInteractionResponse(object? sender, InteractionEventArgs<TResponse> e)
53
    {
54
        _interactionResponse = e;
6✔
55
    }
6✔
56

57
    /// <summary>
58
    /// Triggers the EndOfInteractionEvent event.
59
    /// </summary>
60
    /// <param name="sender">The sender of the event.</param>
61
    /// <param name="e">The response of the user.</param>
62
    protected void SendResponse(object? sender, InteractionEventArgs<TResponse> e)
63
    {
64
        EndOfInteractionEvent?.Invoke(sender, e);
6!
65
    }
6✔
66

67
    /// <summary>
68
    /// This method is used to set options before drawing the element on the console.
69
    /// </summary>
70
    protected sealed override void RenderOptionsBeforeHand()
71
    {
72
        EndOfInteractionEvent += SetInteractionResponse;
6✔
73
    }
6✔
74

75
    /// <summary>
76
    /// This method is used to set options after drawing the element on the console.
77
    /// </summary>
78
    protected sealed override void RenderOptionsAfterHand()
79
    {
80
        EndOfInteractionEvent -= SetInteractionResponse;
6✔
81
    }
6✔
82
    #endregion
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc