Exemplo n.º 1
0
 /// <summary>
 /// Send settings to the PropertyInspector
 /// </summary>
 /// <param name="settings"></param>
 /// <returns></returns>
 public async Task SendToPropertyInspectorAsync(JObject settings)
 {
     if (StreamDeckConnection != null && !String.IsNullOrEmpty(ContextId) && !String.IsNullOrEmpty(actionId))
     {
         await StreamDeckConnection.SendToPropertyInspectorAsync(actionId, settings, ContextId);
     }
 }
Exemplo n.º 2
0
        private void OnPropertyInspectorAppeared(object sender, StreamDeckEventReceivedEventArgs <streamdeck_client_csharp.Events.PropertyInspectorDidAppearEvent> e)
        {
            try
            {
                __log.DebugFormat("{0} {1} {2} {3}", e.Event.Device, e.Event.Context, e.Event.Action, e.Event.Event);
                var listUsersResponse = Client.ListUsers(new ListUsersRequest {
                    OnlyOnline = true
                });
                string context = e.Event.Context;

                JObject payload = new JObject();
                JArray  array   = new JArray(Songs);
                JArray  users   = new JArray();

                payload.Add("songs", array);
                payload.Add("users", users);

                if (_songs.TryGetValue(context, out string value))
                {
                    payload.Add("soundfile", value);
                }

                foreach (var user in listUsersResponse.Users)
                {
                    JObject u = new JObject();
                    u["id"]   = user.Id;
                    u["name"] = user.Name;

                    users.Add(u);
                }

                __log.DebugFormat("Sending payload {0}", payload);

                Task task = _connection.SendToPropertyInspectorAsync(PLAY_BUTTON_ID, payload, context);
                Task.WaitAll(task);
            }
            catch (Exception ex)
            {
                __log.Fatal(ex);
            }
        }
        public override async Task ProcessPropertyInspectorAsync(SendToPluginEvent propertyInspectorEvent)
        {
            switch (propertyInspectorEvent.Payload["property_inspector"].ToString().ToLower())
            {
            case "propertyinspectorconnected":
                // Send settings to Property Inspector
                await m_Connection.SendToPropertyInspectorAsync(m_Action, JObject.FromObject(m_Settings), m_Context);

                break;

            case "propertyinspectorwilldisappear":
                await SaveAsync();

                break;

            case "updatesettings":
                m_Settings = propertyInspectorEvent.Payload.ToObject <ClockActionSettings>();
                await SaveAsync();

                break;
            }
        }