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 (!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.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.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.SourceNameTextBox.Text, this.SourceVisibleCheckBox.IsChecked.GetValueOrDefault(), new StreamingSourceDimensions() { X = x, Y = y, Rotation = rotation, XScale = xScale, YScale = yScale })); } } else { return(StreamingSoftwareAction.CreateSourceVisibilityAction(software, 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); } }