Exemplo n.º 1
0
        public async Task SetSourceDimensions(string sceneName, string sourceName, StreamingSourceDimensions dimensions)
        {
            StreamlabsOBSSceneItem sceneItem = await this.GetSceneItem(sceneName, sourceName);

            if (sceneItem != null)
            {
                StreamlabsOBSRequest request = new StreamlabsOBSRequest("setTransform", sceneItem.ResourceID);

                JObject positionJObj = new JObject();
                positionJObj["x"] = dimensions.X;
                positionJObj["y"] = dimensions.Y;

                JObject scaleObj = new JObject();
                scaleObj["x"] = dimensions.XScale;
                scaleObj["y"] = dimensions.YScale;

                JObject jobj = new JObject();
                jobj["position"] = positionJObj;
                jobj["scale"]    = scaleObj;
                jobj["rotation"] = dimensions.Rotation;

                request.Arguments.Add(jobj);
                await this.SendAndReceive(request);
            }
        }
Exemplo n.º 2
0
 public Task SetSourceDimensions(string sourceName, StreamingSourceDimensions dimensions)
 {
     try
     {
         this.OBSWebsocket.SetSceneItemPosition(sourceName, dimensions.X, dimensions.Y);
         this.OBSWebsocket.SetSceneItemTransform(sourceName, dimensions.Rotation, dimensions.XScale, dimensions.YScale);
     }
     catch (Exception ex) { Logger.Log(ex); }
     return(Task.FromResult(0));
 }
        public async Task SetSourceDimensions(string sceneName, string sourceName, StreamingSourceDimensions dimensions)
        {
            await this.OBSCommandTimeoutWrapper(() =>
            {
                Logger.Log(LogLevel.Debug, "Setting source dimensions - " + sourceName);

                this.OBSWebsocket.SetSceneItemPosition(sourceName, dimensions.X, dimensions.Y, sceneName);
                this.OBSWebsocket.SetSceneItemTransform(sourceName, dimensions.Rotation, dimensions.XScale, dimensions.YScale, sceneName);

                return(false);
            });
        }
Exemplo n.º 4
0
        private async void GetSourcesDimensionsButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.StreamingSoftwareComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.SourceNameTextBox.Text))
            {
                await this.containerControl.RunAsyncOperation(async() =>
                {
                    StreamingSourceDimensions dimensions = null;

                    StreamingSoftwareTypeEnum software = this.GetSelectedSoftware();
                    if (software == StreamingSoftwareTypeEnum.OBSStudio)
                    {
                        if (ChannelSession.Services.OBSWebsocket != null || await ChannelSession.Services.InitializeOBSWebsocket())
                        {
                            dimensions = await ChannelSession.Services.OBSWebsocket.GetSourceDimensions(this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text);
                        }
                        else
                        {
                            await MessageBoxHelper.ShowMessageDialog("Could not connect to OBS Studio. Please try establishing connection with it in the Services area.");
                        }
                    }
                    else if (software == StreamingSoftwareTypeEnum.StreamlabsOBS)
                    {
                        if (ChannelSession.Services.StreamlabsOBSService != null || await ChannelSession.Services.InitializeStreamlabsOBSService())
                        {
                            dimensions = await ChannelSession.Services.StreamlabsOBSService.GetSourceDimensions(this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text);
                        }
                        else
                        {
                            await MessageBoxHelper.ShowMessageDialog("Could not connect to OBS Studio. Please try establishing connection with it in the Services area.");
                        }
                    }

                    if (dimensions != null)
                    {
                        this.SourceDimensionsXPositionTextBox.Text = dimensions.X.ToString();
                        this.SourceDimensionsYPositionTextBox.Text = dimensions.Y.ToString();
                        this.SourceDimensionsRotationTextBox.Text  = dimensions.Rotation.ToString();
                        this.SourceDimensionsXScaleTextBox.Text    = dimensions.XScale.ToString();
                        this.SourceDimensionsYScaleTextBox.Text    = dimensions.YScale.ToString();
                    }
                });
            }
        }
        private async void GetSourcesDimensionsButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.StreamingSoftwareComboBox.SelectedIndex >= 0 && !string.IsNullOrEmpty(this.SourceNameTextBox.Text))
            {
                StreamingSourceDimensions dimensions = null;

                StreamingSoftwareTypeEnum software = this.GetSelectedSoftware();
                if (software == StreamingSoftwareTypeEnum.OBSStudio)
                {
                    if (ChannelSession.Services.OBSStudio.IsConnected || (await ChannelSession.Services.OBSStudio.Connect()).Success)
                    {
                        dimensions = await ChannelSession.Services.OBSStudio.GetSourceDimensions(this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text);
                    }
                    else
                    {
                        await DialogHelper.ShowMessage("Could not connect to OBS Studio. Please try establishing connection with it in the Services area.");
                    }
                }
                else if (software == StreamingSoftwareTypeEnum.StreamlabsOBS)
                {
                    if (ChannelSession.Services.StreamlabsOBS.IsConnected || (await ChannelSession.Services.StreamlabsOBS.Connect()).Success)
                    {
                        dimensions = await ChannelSession.Services.StreamlabsOBS.GetSourceDimensions(this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text);
                    }
                    else
                    {
                        await DialogHelper.ShowMessage("Could not connect to OBS Studio. Please try establishing connection with it in the Services area.");
                    }
                }

                if (dimensions != null)
                {
                    this.SourceDimensionsXPositionTextBox.Text = dimensions.X.ToString();
                    this.SourceDimensionsYPositionTextBox.Text = dimensions.Y.ToString();
                    this.SourceDimensionsRotationTextBox.Text  = dimensions.Rotation.ToString();
                    this.SourceDimensionsXScaleTextBox.Text    = dimensions.XScale.ToString();
                    this.SourceDimensionsYScaleTextBox.Text    = dimensions.YScale.ToString();
                }
            }
        }
        private static async Task Version16Upgrade(int version, string filePath)
        {
            if (version < 16)
            {
                string data = File.ReadAllText(filePath);
                DesktopChannelSettings settings = SerializerHelper.DeserializeFromString <DesktopChannelSettings>(data);
                await ChannelSession.Services.Settings.Initialize(settings);

                List <CommandBase> commands = new List <CommandBase>();
                commands.AddRange(settings.ChatCommands);
                commands.AddRange(settings.EventCommands);
                commands.AddRange(settings.InteractiveCommands);
                commands.AddRange(settings.TimerCommands);
                commands.AddRange(settings.ActionGroupCommands);
                commands.AddRange(settings.GameCommands);
                foreach (CommandBase command in commands)
                {
                    for (int i = 0; i < command.Actions.Count; i++)
                    {
                        ActionBase action = command.Actions[i];
#pragma warning disable CS0612 // Type or member is obsolete
                        if (action is OBSStudioAction || action is XSplitAction || action is StreamlabsOBSAction)
                        {
                            StreamingSoftwareTypeEnum type = StreamingSoftwareTypeEnum.OBSStudio;
                            string scene    = null;
                            string source   = null;
                            bool   visible  = false;
                            string text     = null;
                            string textPath = null;
                            string url      = null;
                            StreamingSourceDimensions dimensions = null;

                            if (action is OBSStudioAction)
                            {
                                type = StreamingSoftwareTypeEnum.OBSStudio;
                                OBSStudioAction obsAction = (OBSStudioAction)action;
                                scene      = obsAction.SceneName;
                                source     = obsAction.SourceName;
                                visible    = obsAction.SourceVisible;
                                text       = obsAction.SourceText;
                                url        = obsAction.SourceURL;
                                dimensions = obsAction.SourceDimensions;
                                if (!string.IsNullOrEmpty(source))
                                {
                                    textPath = GetDefaultReferenceFilePath(OBSStudioReferenceTextFilesDirectory, source);
                                }
                            }
                            else if (action is XSplitAction)
                            {
                                type = StreamingSoftwareTypeEnum.XSplit;
                                XSplitAction xsplitAction = (XSplitAction)action;
                                scene   = xsplitAction.SceneName;
                                source  = xsplitAction.SourceName;
                                visible = xsplitAction.SourceVisible;
                                text    = xsplitAction.SourceText;
                                url     = xsplitAction.SourceURL;
                                if (!string.IsNullOrEmpty(source))
                                {
                                    textPath = GetDefaultReferenceFilePath(XSplitReferenceTextFilesDirectory, source);
                                }
                            }
                            else if (action is StreamlabsOBSAction)
                            {
                                type = StreamingSoftwareTypeEnum.StreamlabsOBS;
                                StreamlabsOBSAction slobsAction = (StreamlabsOBSAction)action;
                                scene   = slobsAction.SceneName;
                                source  = slobsAction.SourceName;
                                visible = slobsAction.SourceVisible;
                                text    = slobsAction.SourceText;
                                if (!string.IsNullOrEmpty(source))
                                {
                                    textPath = GetDefaultReferenceFilePath(StreamlabsOBSStudioReferenceTextFilesDirectory, source);
                                }
                            }
#pragma warning restore CS0612 // Type or member is obsolete

                            StreamingSoftwareAction sAction = null;
                            if (!string.IsNullOrEmpty(scene))
                            {
                                sAction = StreamingSoftwareAction.CreateSceneAction(type, scene);
                            }
                            else if (!string.IsNullOrEmpty(text))
                            {
                                sAction = StreamingSoftwareAction.CreateTextSourceAction(type, source, visible, text, textPath);
                            }
                            else if (!string.IsNullOrEmpty(url))
                            {
                                sAction = StreamingSoftwareAction.CreateWebBrowserSourceAction(type, source, visible, url);
                            }
                            else if (dimensions != null)
                            {
                                sAction = StreamingSoftwareAction.CreateSourceDimensionsAction(type, source, visible, dimensions);
                            }
                            else
                            {
                                sAction = StreamingSoftwareAction.CreateSourceVisibilityAction(type, source, visible);
                            }

                            command.Actions[i] = sAction;
                        }
                    }
                }

                await ChannelSession.Services.Settings.Save(settings);
            }
        }
 public Task SetSourceDimensions(string sceneName, string sourceName, StreamingSourceDimensions dimensions)
 {
     return(Task.FromResult(0));
 }