|
| 1 | +using BarRaider.SdTools.Events; |
| 2 | +using BarRaider.SdTools.Wrappers; |
| 3 | +using Newtonsoft.Json; |
| 4 | +using Newtonsoft.Json.Linq; |
| 5 | +using System; |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Drawing; |
| 8 | +using System.Text; |
| 9 | +using System.Threading.Tasks; |
| 10 | + |
| 11 | +namespace BarRaider.SdTools |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Interface for a Stream Deck connection |
| 15 | + /// </summary> |
| 16 | + public interface ISDConnection : IDisposable |
| 17 | + { |
| 18 | + #region Events |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Event received by the plugin when the Property Inspector uses the sendToPlugin event. |
| 22 | + /// </summary> |
| 23 | + event EventHandler<SDEventReceivedEventArgs<SendToPlugin>> OnSendToPlugin; |
| 24 | + /// <summary> |
| 25 | + /// Event received when the user changes the title or title parameters. |
| 26 | + /// </summary> |
| 27 | + event EventHandler<SDEventReceivedEventArgs<TitleParametersDidChange>> OnTitleParametersDidChange; |
| 28 | + /// <summary> |
| 29 | + /// Event received when a monitored application is terminated |
| 30 | + /// </summary> |
| 31 | + event EventHandler<SDEventReceivedEventArgs<ApplicationDidTerminate>> OnApplicationDidTerminate; |
| 32 | + /// <summary> |
| 33 | + /// Event received when a monitored application is launched |
| 34 | + /// </summary> |
| 35 | + event EventHandler<SDEventReceivedEventArgs<ApplicationDidLaunch>> OnApplicationDidLaunch; |
| 36 | + /// <summary> |
| 37 | + /// Event received when a device is unplugged from the computer |
| 38 | + /// </summary> |
| 39 | + event EventHandler<SDEventReceivedEventArgs<DeviceDidDisconnect>> OnDeviceDidDisconnect; |
| 40 | + /// <summary> |
| 41 | + /// Event received when a device is plugged to the computer. |
| 42 | + /// </summary> |
| 43 | + event EventHandler<SDEventReceivedEventArgs<DeviceDidConnect>> OnDeviceDidConnect; |
| 44 | + /// <summary> |
| 45 | + /// Event received when the Property Inspector appears in the Stream Deck software user interface, for example when selecting a new instance. |
| 46 | + /// </summary> |
| 47 | + event EventHandler<SDEventReceivedEventArgs<PropertyInspectorDidAppear>> OnPropertyInspectorDidAppear; |
| 48 | + /// <summary> |
| 49 | + /// Event received when the Property Inspector for an instance is removed from the Stream Deck software user interface, for example when selecting a different instance. |
| 50 | + /// </summary> |
| 51 | + event EventHandler<SDEventReceivedEventArgs<PropertyInspectorDidDisappear>> OnPropertyInspectorDidDisappear; |
| 52 | + |
| 53 | + #endregion |
| 54 | + |
| 55 | + #region Methods |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Send settings to the PropertyInspector |
| 59 | + /// </summary> |
| 60 | + /// <param name="settings"></param> |
| 61 | + /// <returns></returns> |
| 62 | + Task SendToPropertyInspectorAsync(JObject settings); |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Persists your plugin settings |
| 66 | + /// </summary> |
| 67 | + /// <param name="settings"></param> |
| 68 | + /// <returns></returns> |
| 69 | + Task SetSettingsAsync(JObject settings); |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Persists your global plugin settings |
| 73 | + /// </summary> |
| 74 | + /// <param name="settings">Settings to save globally</param> |
| 75 | + /// <param name="triggerDidReceiveGlobalSettings">Boolean whether to also trigger a didReceiveGlobalSettings event. Default is true</param> |
| 76 | + /// <returns></returns> |
| 77 | + Task SetGlobalSettingsAsync(JObject settings, bool triggerDidReceiveGlobalSettings = true); |
| 78 | + |
| 79 | + /// <summary> |
| 80 | + /// Persists your global plugin settings |
| 81 | + /// </summary> |
| 82 | + /// <returns></returns> |
| 83 | + Task GetGlobalSettingsAsync(); |
| 84 | + |
| 85 | + /// <summary> |
| 86 | + /// Sets an image on the StreamDeck key. |
| 87 | + /// </summary> |
| 88 | + /// <param name="base64Image">Base64 encoded image</param> |
| 89 | + /// <param name="state">A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the title is set to all states.</param> |
| 90 | + /// <param name="forceSendToStreamdeck">Should image be sent even if it is identical to the one sent previously. Default is false</param> |
| 91 | + /// <returns></returns> |
| 92 | + Task SetImageAsync(string base64Image, int? state = null, bool forceSendToStreamdeck = false); |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Sets an image on the StreamDeck key |
| 96 | + /// </summary> |
| 97 | + /// <param name="image">Image object</param> |
| 98 | + /// <param name="state">A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the title is set to all states.</param> |
| 99 | + /// <param name="forceSendToStreamdeck">Should image be sent even if it is identical to the one sent previously. Default is false</param> |
| 100 | + /// <returns></returns> |
| 101 | + Task SetImageAsync(Image image, int? state = null, bool forceSendToStreamdeck = false); |
| 102 | + |
| 103 | + /// <summary> |
| 104 | + /// Sets the default image for this state, as configured in the manifest |
| 105 | + /// </summary> |
| 106 | + /// <returns></returns> |
| 107 | + Task SetDefaultImageAsync(); |
| 108 | + |
| 109 | + /// <summary> |
| 110 | + /// Sets a title on the StreamDeck key |
| 111 | + /// </summary> |
| 112 | + /// <param name="title"></param> |
| 113 | + /// <param name="state">A 0-based integer value representing the state of an action with multiple states. This is an optional parameter. If not specified, the title is set to all states.</param> |
| 114 | + /// <returns></returns> |
| 115 | + Task SetTitleAsync(string title, int? state = null); |
| 116 | + |
| 117 | + /// <summary> |
| 118 | + /// Switches to one of the plugin's built-in profiles |
| 119 | + /// </summary> |
| 120 | + /// <param name="profileName"></param> |
| 121 | + /// <returns></returns> |
| 122 | + Task SwitchProfileAsync(string profileName); |
| 123 | + |
| 124 | + /// <summary> |
| 125 | + /// Switches to one of the plugin's built-in profiles. Allows to choose which device to switch it on. |
| 126 | + /// </summary> |
| 127 | + /// <param name="profileName"></param> |
| 128 | + /// <param name="deviceId"></param> |
| 129 | + /// <returns></returns> |
| 130 | + Task SwitchProfileAsync(string profileName, string deviceId); |
| 131 | + |
| 132 | + /// <summary> |
| 133 | + /// Shows the Alert (Yellow Triangle) on the StreamDeck key |
| 134 | + /// </summary> |
| 135 | + /// <returns></returns> |
| 136 | + Task ShowAlert(); |
| 137 | + |
| 138 | + /// <summary> |
| 139 | + /// Shows the Success (Green checkmark) on the StreamDeck key |
| 140 | + /// </summary> |
| 141 | + /// <returns></returns> |
| 142 | + Task ShowOk(); |
| 143 | + |
| 144 | + /// <summary> |
| 145 | + /// Add a message to the Stream Deck log. This is the log located at: %appdata%\Elgato\StreamDeck\logs\StreamDeck0.log |
| 146 | + /// </summary> |
| 147 | + /// <param name="message"></param> |
| 148 | + /// <returns></returns> |
| 149 | + Task LogSDMessage(string message); |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Gets the Stream Deck device's info |
| 153 | + /// </summary> |
| 154 | + /// <returns></returns> |
| 155 | + StreamDeckDeviceInfo DeviceInfo(); |
| 156 | + |
| 157 | + /// <summary> |
| 158 | + /// Tells Stream Deck to return the current plugin settings via the ReceivedSettings function |
| 159 | + /// </summary> |
| 160 | + /// <returns></returns> |
| 161 | + Task GetSettingsAsync(); |
| 162 | + |
| 163 | + /// <summary> |
| 164 | + /// Opens a URI in the user's browser |
| 165 | + /// </summary> |
| 166 | + /// <param name="uri"></param> |
| 167 | + /// <returns></returns> |
| 168 | + Task OpenUrlAsync(string uri); |
| 169 | + |
| 170 | + /// <summary> |
| 171 | + /// Opens a URI in the user's browser |
| 172 | + /// </summary> |
| 173 | + /// <param name="uri"></param> |
| 174 | + /// <returns></returns> |
| 175 | + Task OpenUrlAsync(Uri uri); |
| 176 | + |
| 177 | + /// <summary> |
| 178 | + /// Sets the plugin to a specific state which is pre-configured in the manifest file |
| 179 | + /// </summary> |
| 180 | + /// <param name="state"></param> |
| 181 | + /// <returns></returns> |
| 182 | + Task SetStateAsync(uint state); |
| 183 | + |
| 184 | + #endregion |
| 185 | + |
| 186 | + /// <summary> |
| 187 | + /// An opaque value identifying the plugin. This value is received during the Registration procedure |
| 188 | + /// </summary> |
| 189 | + [JsonIgnore] |
| 190 | + String ContextId { get; } |
| 191 | + |
| 192 | + /// <summary> |
| 193 | + /// An opaque value identifying the device the plugin is launched on. |
| 194 | + /// </summary> |
| 195 | + [JsonIgnore] |
| 196 | + String DeviceId { get; } |
| 197 | + |
| 198 | + /// <summary> |
| 199 | + /// StreamDeckConnection object, initialized based on the args received when launching the program |
| 200 | + /// </summary> |
| 201 | + [JsonIgnore] |
| 202 | + streamdeck_client_csharp.StreamDeckConnection StreamDeckConnection { get; } |
| 203 | + } |
| 204 | +} |
0 commit comments