1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+ using System . Text ;
5+ using System . Threading . Tasks ;
6+ using BarRaider . SdTools . Payloads ;
7+ using Newtonsoft . Json . Linq ;
8+
9+ namespace BarRaider . SdTools
10+ {
11+
12+ /// <summary>
13+ /// Main abstract class your plugin should derive from for keys (not dials)
14+ /// For dials use the EncoderBase or KeyAndEncoderBase
15+ /// Holds implementation for all the basic functions
16+ /// If you're missing an event, you can register to it from the Connection.StreamDeckConnection object
17+ /// </summary>
18+ public abstract class KeyAndEncoderBase : IKeypadPlugin , IEncoderPlugin
19+ {
20+ /// <summary>
21+ /// Called when the dial is rotated
22+ /// </summary>
23+ public abstract void DialRotate ( DialRotatePayload payload ) ;
24+
25+ /// <summary>
26+ /// Called when the Dial is pressed or released
27+ /// </summary>
28+ public abstract void DialPress ( DialPressPayload payload ) ;
29+
30+ /// <summary>
31+ /// Called when the touchpad (above the dials) is pressed
32+ /// </summary>
33+ public abstract void TouchPress ( TouchpadPressPayload payload ) ;
34+
35+ /// <summary>
36+ /// Called when a Stream Deck key is pressed
37+ /// </summary>
38+ public abstract void KeyPressed ( KeyPayload payload ) ;
39+
40+ /// <summary>
41+ /// Called when a Stream Deck key is released
42+ /// </summary>
43+ public abstract void KeyReleased ( KeyPayload payload ) ;
44+
45+ /// <summary>
46+ /// Called when the PropertyInspector has new settings
47+ /// </summary>
48+ /// <param name="payload"></param>
49+ public abstract void ReceivedSettings ( ReceivedSettingsPayload payload ) ;
50+
51+ /// <summary>
52+ /// Called when GetGlobalSettings is called.
53+ /// </summary>
54+ /// <param name="payload"></param>
55+ public abstract void ReceivedGlobalSettings ( ReceivedGlobalSettingsPayload payload ) ;
56+
57+ /// <summary>
58+ /// Called every second
59+ /// Logic for displaying title/image can go here
60+ /// </summary>
61+ public abstract void OnTick ( ) ;
62+
63+ /// <summary>
64+ /// Abstract method Called when the plugin is disposed
65+ /// </summary>
66+ public abstract void Dispose ( ) ;
67+
68+ /// <summary>
69+ /// Main iDisposable Dispose function
70+ /// </summary>
71+ public void Destroy ( )
72+ {
73+ Dispose ( ) ;
74+ if ( Connection != null )
75+ {
76+ Connection . Dispose ( ) ;
77+ }
78+ }
79+
80+ /// <summary>
81+ /// Connection object which handles your communication with the Stream Deck app
82+ /// </summary>
83+ protected ISDConnection Connection { get ; private set ; }
84+
85+ /// <summary>
86+ /// Constructor for PluginBase. Receives the communication and plugin settings
87+ /// Note that the settings object is not used by the base and should be consumed by the deriving class.
88+ /// Usually, a private class inside the deriving class is created which stores the settings
89+ /// Example for settings usage:
90+ /// * if (payload.Settings == null || payload.Settings.Count == 0)
91+ /// * {
92+ /// * // Create default settings
93+ /// * }
94+ /// * else
95+ /// * {
96+ /// this.settings = payload.Settings.ToObject();
97+ /// * }
98+ ///
99+ /// </summary>
100+ /// <param name="connection">Communication module with Stream Deck</param>
101+ /// <param name="payload">Plugin settings - NOTE: Not used in base class, should be consumed by deriving class</param>
102+ #pragma warning disable IDE0060 // Remove unused parameter
103+ public KeyAndEncoderBase ( ISDConnection connection , InitialPayload payload )
104+ #pragma warning restore IDE0060 // Remove unused parameter
105+ {
106+ Connection = connection ;
107+ }
108+ }
109+ }
0 commit comments