private void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                switch (payload["property_inspector"].ToString().ToLower())
                {
                case "loadsavepicker":
                    string propertyName = (string)payload["property_name"];
                    string pickerTitle  = (string)payload["picker_title"];
                    string pickerFilter = (string)payload["picker_filter"];
                    string fileName     = PickersUtil.Pickers.SaveFilePicker(pickerTitle, null, pickerFilter);
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        if (!PickersUtil.Pickers.SetJsonPropertyValue(settings, propertyName, fileName))
                        {
                            Logger.Instance.LogMessage(TracingLevel.ERROR, "Failed to save picker value to settings");
                        }
                        SaveSettings();
                    }
                    break;
                }
            }
        }
        private async void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                string fileName;
                switch (payload["property_inspector"].ToString().ToLowerInvariant())
                {
                case "exportsettings":
                    fileName = PickersUtil.Pickers.SaveFilePicker("Export Image Settings", null, "OBS Image Settings files (*.obsimg)|*.obsimg|All files (*.*)|*.*");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        Logger.Instance.LogMessage(TracingLevel.INFO, $"Exporting settings to {fileName}");
                        File.WriteAllText(fileName, JsonConvert.SerializeObject(Settings));
                        await Connection.ShowOk();
                    }
                    break;

                case "importsettings":
                    fileName = PickersUtil.Pickers.OpenFilePicker("Import Image Settings", null, "OBS Image Settings files (*.obsimg)|*.obsimg|All files (*.*)|*.*");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        if (!File.Exists(fileName))
                        {
                            Logger.Instance.LogMessage(TracingLevel.ERROR, $"ImportSettings called but file does not exist {fileName}");
                            await Connection.ShowAlert();

                            return;
                        }

                        try
                        {
                            Logger.Instance.LogMessage(TracingLevel.INFO, $"Importing settings from {fileName}");
                            string json = File.ReadAllText(fileName);
                            Settings = JsonConvert.DeserializeObject <PluginSettings>(json);
                            await SaveSettings();

                            await Connection.ShowOk();
                        }
                        catch (Exception ex)
                        {
                            Logger.Instance.LogMessage(TracingLevel.ERROR, $"ImportSettings exception:\n\t{ex}");
                            await Connection.ShowAlert();

                            return;
                        }
                    }
                    break;
                }
            }
        }
        private async void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                switch (payload["property_inspector"].ToString().ToLower())
                {
                case "getwindowdetails":
                    await FetchWindowLocation();

                    break;
                }
            }
        }
        private async void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                switch (payload["property_inspector"].ToString().ToLowerInvariant())
                {
                case "reloadapps":
                    Logger.Instance.LogMessage(TracingLevel.INFO, "reloadApps called");
                    PopulateApplications();
                    await SaveSettings();

                    break;
                }
            }
        }
Exemplo n.º 5
0
        private async void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                switch (payload["property_inspector"].ToString().ToLower())
                {
                case "setserverinfo":
                    string ip       = ((string)payload["ip"]).Trim();
                    string port     = ((string)payload["port"]).Trim();
                    string password = ((string)payload["password"]).Trim();
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"Setting server info. Ip: {ip} Port: {port} Password: {String.IsNullOrEmpty(password)}");
                    ServerManager.Instance.InitTokens(ip, port, password, DateTime.Now);
                    break;

                case "updateapproval":
                    string approvalCode = (string)payload["approvalCode"];
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"Twitch Requesting approval with code: {approvalCode}");
                    ChatPager.Twitch.TwitchTokenManager.Instance.SetToken(new ChatPager.Twitch.TwitchToken()
                    {
                        Token = approvalCode, TokenLastRefresh = DateTime.Now
                    });
                    Logger.Instance.LogMessage(TracingLevel.INFO, $"Twitch RefreshToken completed. Token Exists: {ChatPager.Twitch.TwitchTokenManager.Instance.TokenExists}");
                    break;

                case "resetplugin":
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"ResetPlugin called. Tokens are cleared");
                    ChatPager.Twitch.TwitchTokenManager.Instance.RevokeToken();
                    Thread.Sleep(3000);
                    ServerManager.Instance.InitTokens(null, null, null, DateTime.Now);
                    await SaveSettings();

                    break;
                }
            }
        }
Exemplo n.º 6
0
 private void Connection_OnPropertyInspectorDidAppear(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.PropertyInspectorDidAppear> e)
 {
     LoadSourcesList();
     SaveSettings();
 }
 private void Connection_OnTitleParametersDidChange(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.TitleParametersDidChange> e)
 {
     titleParameters = e.Event?.Payload?.TitleParameters;
 }
Exemplo n.º 8
0
        private async void Connection_OnSendToPlugin(object sender, SdTools.Wrappers.SDEventReceivedEventArgs <SdTools.Events.SendToPlugin> e)
        {
            var payload = e.Event.Payload;

            if (payload["property_inspector"] != null)
            {
                string fileName;
                switch (payload["property_inspector"].ToString().ToLowerInvariant())
                {
                case "addanimationphasebelow":     // Animation PHASE not Animation Property!
                case "addanimationphaseabove":
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"addAnimationPhase called");
                    int phase = selectedPhase + 1;

                    if (payload["property_inspector"].ToString().ToLowerInvariant() == "addanimationphaseabove")
                    {
                        phase = selectedPhase;
                    }
                    AddAnimationPhase(phase);
                    Settings.SelectedPhase = phase.ToString();
                    SetActionGeneralSettings();
                    InitializeSettings();
                    break;

                case "delanimationphase":     // Animation PHASE not Animation Property!
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"delAnimationPhase called");
                    Settings.AnimationPhases.RemoveAt(selectedPhase);
                    Settings.SelectedPhase = "0";
                    SetActionGeneralSettings();
                    InitializeSettings();
                    break;

                case "addanimation":     // Animation Property NOT Animation Phase!
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"addAnimation called");
                    string propertyName = (string)payload["propertyName"];
                    string startValue   = (string)payload["startValue"];
                    string endValue     = (string)payload["endValue"];
                    TryAddNewAnimation(propertyName, startValue, endValue);
                    break;

                case "removeanimation":     // Animation Property NOT Animation Phase!
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"removeAnimation called");
                    string indexStr = (string)payload["removeIndex"];
                    if (!Int32.TryParse(indexStr, out int index) || index < 0)
                    {
                        Logger.Instance.LogMessage(TracingLevel.ERROR, $"removeAnimation called with invalid index: {indexStr}");
                        await Connection.ShowAlert();

                        return;
                    }
                    Logger.Instance.LogMessage(TracingLevel.WARN, $"removeAnimation removing item at index {indexStr}");
                    Settings.AnimationPhases[selectedPhase].AnimationActions.RemoveAt(index);
                    await SaveSettings();

                    break;

                case "exportsettings":
                    fileName = PickersUtil.Pickers.SaveFilePicker("Export Animation Settings", null, "OBS Animation files (*.obsanim)|*.obsanim|All files (*.*)|*.*");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        Logger.Instance.LogMessage(TracingLevel.INFO, $"Exporting settings to {fileName}");
                        File.WriteAllText(fileName, JsonConvert.SerializeObject(settings));
                        await Connection.ShowOk();
                    }
                    break;

                case "importsettings":
                    fileName = PickersUtil.Pickers.OpenFilePicker("Import Animation Settings", null, "OBS Animation files (*.obsanim)|*.obsanim|All files (*.*)|*.*");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        if (!File.Exists(fileName))
                        {
                            Logger.Instance.LogMessage(TracingLevel.ERROR, $"ImportSettings called but file does not exist {fileName}");
                            await Connection.ShowAlert();

                            return;
                        }

                        try
                        {
                            Logger.Instance.LogMessage(TracingLevel.INFO, $"Importing settings from {fileName}");
                            string json = File.ReadAllText(fileName);
                            settings = JsonConvert.DeserializeObject <SourceAnimationActionSettings>(json);
                            await SaveSettings();

                            await Connection.ShowOk();
                        }
                        catch (Exception ex)
                        {
                            Logger.Instance.LogMessage(TracingLevel.ERROR, $"ImportSettings exception:\n\t{ex}");
                            await Connection.ShowAlert();

                            return;
                        }
                    }
                    break;

                case "startrecording":
                    Settings.IsRecording = true;
                    await SaveSettings();

                    StartSourceRecording();
                    break;

                case "endrecording":
                    Settings.IsRecording = false;
                    await SaveSettings();

                    HandleRecording();
                    break;
                }
            }
        }