Пример #1
0
        public override ActionBase GetAction()
        {
            if (this.StreamingSoftwareComboBox.SelectedIndex >= 0 && this.StreamingActionTypeComboBox.SelectedIndex >= 0)
            {
                StreamingSoftwareTypeEnum software = EnumHelper.GetEnumValueFromString <StreamingSoftwareTypeEnum>((string)this.StreamingSoftwareComboBox.SelectedItem);
                StreamingActionTypeEnum   type     = EnumHelper.GetEnumValueFromString <StreamingActionTypeEnum>((string)this.StreamingActionTypeComboBox.SelectedItem);

                if (type == StreamingActionTypeEnum.Scene && !string.IsNullOrEmpty(this.SceneNameTextBox.Text))
                {
                    return(StreamingSoftwareAction.CreateSceneAction(software, this.SceneNameTextBox.Text));
                }
                else if (type == StreamingActionTypeEnum.StartStopStream)
                {
                    return(StreamingSoftwareAction.CreateStartStopStreamAction(software));
                }
                else if (type == StreamingActionTypeEnum.SaveReplayBuffer)
                {
                    return(StreamingSoftwareAction.CreateSaveReplayBufferAction(software));
                }
                else if (type == StreamingActionTypeEnum.SceneCollection && !string.IsNullOrEmpty(this.SceneCollectionNameTextBox.Text))
                {
                    return(StreamingSoftwareAction.CreateSceneCollectionAction(software, this.SceneCollectionNameTextBox.Text));
                }
                else if (!string.IsNullOrEmpty(this.SourceNameTextBox.Text))
                {
                    if (type == StreamingActionTypeEnum.TextSource)
                    {
                        if (!string.IsNullOrEmpty(this.SourceTextTextBox.Text) && !string.IsNullOrEmpty(this.SourceLoadTextFromTextBox.Text))
                        {
                            StreamingSoftwareAction action = StreamingSoftwareAction.CreateTextSourceAction(software, this.SourceSceneNameTextBox.Text,
                                                                                                            this.SourceNameTextBox.Text, this.SourceVisibleCheckBox.IsChecked.GetValueOrDefault(), this.SourceTextTextBox.Text, this.SourceLoadTextFromTextBox.Text);
                            action.UpdateReferenceTextFile(string.Empty);
                            return(action);
                        }
                    }
                    else if (type == StreamingActionTypeEnum.WebBrowserSource)
                    {
                        if (!string.IsNullOrEmpty(this.SourceWebPageTextBox.Text))
                        {
                            return(StreamingSoftwareAction.CreateWebBrowserSourceAction(software, this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text,
                                                                                        this.SourceVisibleCheckBox.IsChecked.GetValueOrDefault(), this.SourceWebPageTextBox.Text));
                        }
                    }
                    else if (type == StreamingActionTypeEnum.SourceDimensions)
                    {
                        int   x, y, rotation;
                        float xScale, yScale;
                        if (int.TryParse(this.SourceDimensionsXPositionTextBox.Text, out x) && int.TryParse(this.SourceDimensionsYPositionTextBox.Text, out y) &&
                            int.TryParse(this.SourceDimensionsRotationTextBox.Text, out rotation) && float.TryParse(this.SourceDimensionsXScaleTextBox.Text, out xScale) &&
                            float.TryParse(this.SourceDimensionsYScaleTextBox.Text, out yScale))
                        {
                            return(StreamingSoftwareAction.CreateSourceDimensionsAction(software, this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text,
                                                                                        this.SourceVisibleCheckBox.IsChecked.GetValueOrDefault(),
                                                                                        new StreamingSourceDimensions()
                            {
                                X = x, Y = y, Rotation = rotation, XScale = xScale, YScale = yScale
                            }));
                        }
                    }
                    else
                    {
                        return(StreamingSoftwareAction.CreateSourceVisibilityAction(software, this.SourceSceneNameTextBox.Text, this.SourceNameTextBox.Text,
                                                                                    this.SourceVisibleCheckBox.IsChecked.GetValueOrDefault()));
                    }
                }
            }
            return(null);
        }
        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 static async Task <StreamingSoftwareSourceDimensionsModel> GetSourceDimensions(StreamingSoftwareTypeEnum softwareType, string sceneName, string sourceName)
        {
            StreamingSoftwareSourceDimensionsModel dimensions = null;

            if (softwareType == StreamingSoftwareTypeEnum.DefaultSetting)
            {
                softwareType = ChannelSession.Settings.DefaultStreamingSoftware;
            }

            if (softwareType == StreamingSoftwareTypeEnum.OBSStudio)
            {
                if (ChannelSession.Services.OBSStudio.IsConnected || (await ChannelSession.Services.OBSStudio.Connect()).Success)
                {
                    dimensions = await ChannelSession.Services.OBSStudio.GetSourceDimensions(sceneName, sourceName);
                }
            }
            else if (softwareType == StreamingSoftwareTypeEnum.StreamlabsOBS)
            {
                if (ChannelSession.Services.StreamlabsOBS.IsConnected || (await ChannelSession.Services.StreamlabsOBS.Connect()).Success)
                {
                    dimensions = await ChannelSession.Services.StreamlabsOBS.GetSourceDimensions(sceneName, sourceName);
                }
            }

            return(dimensions);
        }
Пример #4
0
        private async void StreamingActionTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.FeatureNotSupportedGrid.Visibility = Visibility.Collapsed;
            this.SceneGrid.Visibility            = Visibility.Collapsed;
            this.SceneCollectionGrid.Visibility  = Visibility.Collapsed;
            this.SourceGrid.Visibility           = Visibility.Collapsed;
            this.SourceTextGrid.Visibility       = Visibility.Collapsed;
            this.SourceWebBrowserGrid.Visibility = Visibility.Collapsed;
            this.SourceDimensionsGrid.Visibility = Visibility.Collapsed;
            this.ReplayBufferNotEnabledInSettingsGrid.Visibility = Visibility.Collapsed;

            if (this.StreamingActionTypeComboBox.SelectedIndex >= 0)
            {
                StreamingSoftwareTypeEnum software = this.GetSelectedSoftware();
                StreamingActionTypeEnum   type     = EnumHelper.GetEnumValueFromString <StreamingActionTypeEnum>((string)this.StreamingActionTypeComboBox.SelectedItem);
                if (type == StreamingActionTypeEnum.Scene)
                {
                    this.SceneGrid.Visibility = Visibility.Visible;
                }
                else if (type == StreamingActionTypeEnum.StartStopStream)
                {
                    if (software == StreamingSoftwareTypeEnum.XSplit)
                    {
                        this.FeatureNotSupportedGrid.Visibility = Visibility.Visible;
                        return;
                    }
                    else
                    {
                        // Do nothing...
                    }
                }
                else if (type == StreamingActionTypeEnum.SaveReplayBuffer)
                {
                    if (software != StreamingSoftwareTypeEnum.OBSStudio)
                    {
                        this.FeatureNotSupportedGrid.Visibility = Visibility.Visible;
                        return;
                    }
                    else
                    {
                        if (ChannelSession.Services.OBSWebsocket != null)
                        {
                            if (!(await ChannelSession.Services.OBSWebsocket.StartReplayBuffer()))
                            {
                                this.ReplayBufferNotEnabledInSettingsGrid.Visibility = Visibility.Visible;
                                return;
                            }
                        }
                    }
                }
                else if (type == StreamingActionTypeEnum.SceneCollection)
                {
                    if (software != StreamingSoftwareTypeEnum.OBSStudio)
                    {
                        this.FeatureNotSupportedGrid.Visibility = Visibility.Visible;
                        return;
                    }
                    else
                    {
                        this.SceneCollectionGrid.Visibility = Visibility.Visible;
                    }
                }
                else
                {
                    if (type == StreamingActionTypeEnum.TextSource)
                    {
                        this.SourceTextGrid.Visibility = Visibility.Visible;
                    }
                    else if (type == StreamingActionTypeEnum.WebBrowserSource)
                    {
                        this.SourceWebBrowserGrid.Visibility = Visibility.Visible;
                    }
                    else if (type == StreamingActionTypeEnum.SourceDimensions)
                    {
                        if (software == StreamingSoftwareTypeEnum.XSplit)
                        {
                            this.FeatureNotSupportedGrid.Visibility = Visibility.Visible;
                            return;
                        }
                        else
                        {
                            this.SourceDimensionsGrid.Visibility = Visibility.Visible;
                        }
                    }
                    this.SourceGrid.Visibility = Visibility.Visible;
                }
            }
        }
 public StreamingSoftwareActionModel(StreamingSoftwareTypeEnum softwareType, StreamingSoftwareActionTypeEnum actionType)
     : base(ActionTypeEnum.StreamingSoftware)
 {
     this.StreamingSoftwareType = softwareType;
     this.ActionType            = actionType;
 }
        public static StreamingSoftwareActionModel CreateSourceFilterVisibilityAction(StreamingSoftwareTypeEnum softwareType, string sourceName, string filterName, bool sourceVisible)
        {
            StreamingSoftwareActionModel action = new StreamingSoftwareActionModel(softwareType, StreamingSoftwareActionTypeEnum.SourceFilterVisibility);

            action.ParentName = sourceName;
            action.ItemName   = filterName;
            action.Visible    = sourceVisible;
            return(action);
        }
 public StreamingSoftwareAction(StreamingSoftwareTypeEnum softwareType, StreamingActionTypeEnum actionType)
     : this()
 {
     this.SoftwareType = softwareType;
     this.ActionType   = actionType;
 }
 public static StreamingSoftwareAction CreateSaveReplayBufferAction(StreamingSoftwareTypeEnum softwareType)
 {
     return(new StreamingSoftwareAction(softwareType, StreamingActionTypeEnum.SaveReplayBuffer));
 }
 public static StreamingSoftwareAction CreateStartStopStreamAction(StreamingSoftwareTypeEnum softwareType)
 {
     return(new StreamingSoftwareAction(softwareType, StreamingActionTypeEnum.StartStopStream));
 }