示例#1
0
        public override ActionBase GetAction()
        {
            if (this.TypeComboBox.SelectedIndex >= 0)
            {
                OvrStreamActionTypeEnum actionType = EnumHelper.GetEnumValueFromString <OvrStreamActionTypeEnum>((string)this.TypeComboBox.SelectedItem);

                if (actionType == OvrStreamActionTypeEnum.UpdateVariables ||
                    actionType == OvrStreamActionTypeEnum.PlayTitle)
                {
                    // Must have a title name and cannot have duplicate variables names
                    if (!string.IsNullOrEmpty(this.TitleNameTextBox.Text) && this.variablePairs.Select(v => v.Name).Distinct().Count() == this.variablePairs.Count)
                    {
                        foreach (VariablePair pair in this.variablePairs)
                        {
                            // Don't allow empty variable names either
                            if (string.IsNullOrEmpty(pair.Name))
                            {
                                return(null);
                            }
                        }
                        return(OvrStreamAction.CreateVariableTitleAction(actionType, this.TitleNameTextBox.Text, this.variablePairs.ToDictionary(p => p.Name, p => p.Value)));
                    }
                }
                else if (actionType == OvrStreamActionTypeEnum.HideTitle ||
                         actionType == OvrStreamActionTypeEnum.EnableTitle ||
                         actionType == OvrStreamActionTypeEnum.DisableTitle)
                {
                    if (!string.IsNullOrEmpty(this.TitleNameTextBox.Text))
                    {
                        return(OvrStreamAction.CreateTitleAction(actionType, this.TitleNameTextBox.Text));
                    }
                }
            }
            return(null);
        }