public override ActionBase GetAction()
 {
     if (this.ActionTypeComboBox.SelectedIndex >= 0)
     {
         StreamingPlatformActionType actionType = EnumHelper.GetEnumValueFromString <StreamingPlatformActionType>((string)this.ActionTypeComboBox.SelectedItem);
         if (actionType == StreamingPlatformActionType.Host)
         {
             if (!string.IsNullOrEmpty(this.HostChannelNameTextBox.Text))
             {
                 return(StreamingPlatformAction.CreateHostAction(this.HostChannelNameTextBox.Text));
             }
         }
         else if (actionType == StreamingPlatformActionType.Raid)
         {
             if (!string.IsNullOrEmpty(this.HostChannelNameTextBox.Text))
             {
                 return(StreamingPlatformAction.CreateRaidAction(this.HostChannelNameTextBox.Text));
             }
         }
         else if (actionType == StreamingPlatformActionType.RunAd)
         {
             if (this.AdLengthComboBox.SelectedIndex >= 0)
             {
                 return(StreamingPlatformAction.CreateRunAdAction((int)this.AdLengthComboBox.SelectedItem));
             }
         }
     }
     return(null);
 }
        private void ActionTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.ActionTypeComboBox.SelectedIndex >= 0)
            {
                this.HostChannelNameTextBox.Visibility = Visibility.Collapsed;
                this.AdLengthComboBox.Visibility       = Visibility.Collapsed;

                StreamingPlatformActionType actionType = EnumHelper.GetEnumValueFromString <StreamingPlatformActionType>((string)this.ActionTypeComboBox.SelectedItem);
                if (actionType == StreamingPlatformActionType.Host || actionType == StreamingPlatformActionType.Raid)
                {
                    this.HostChannelNameTextBox.Visibility = Visibility.Visible;
                }
                else if (actionType == StreamingPlatformActionType.RunAd)
                {
                    this.AdLengthComboBox.Visibility = Visibility.Visible;
                }
            }
        }
        private void ActionTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.ActionTypeComboBox.SelectedIndex >= 0)
            {
                this.HostGrid.Visibility = Visibility.Collapsed;
                this.PollGrid.Visibility = Visibility.Collapsed;

                StreamingPlatformActionType actionType = EnumHelper.GetEnumValueFromString <StreamingPlatformActionType>((string)this.ActionTypeComboBox.SelectedItem);
                if (actionType == StreamingPlatformActionType.Host)
                {
                    this.HostGrid.Visibility = Visibility.Visible;
                }
                else if (actionType == StreamingPlatformActionType.Poll)
                {
                    this.PollGrid.Visibility = Visibility.Visible;
                }
            }
        }
        public override ActionBase GetAction()
        {
            if (this.ActionTypeComboBox.SelectedIndex >= 0)
            {
                StreamingPlatformActionType actionType = EnumHelper.GetEnumValueFromString <StreamingPlatformActionType>((string)this.ActionTypeComboBox.SelectedItem);
                if (actionType == StreamingPlatformActionType.Host)
                {
                    if (!string.IsNullOrEmpty(this.HostChannelNameTextBox.Text))
                    {
                        return(StreamingPlatformAction.CreateHostAction(this.HostChannelNameTextBox.Text));
                    }
                }
                else if (actionType == StreamingPlatformActionType.Poll)
                {
                    if (!string.IsNullOrEmpty(this.PollQuestionTextBox.Text) && !string.IsNullOrEmpty(this.PollLengthTextBox.Text) &&
                        uint.TryParse(this.PollLengthTextBox.Text, out uint length) && length > 0)
                    {
                        List <string> answers = new List <string>();
                        answers.Add(this.PollAnswer1TextBox.Text);
                        answers.Add(this.PollAnswer2TextBox.Text);
                        answers.Add(this.PollAnswer3TextBox.Text);
                        answers.Add(this.PollAnswer4TextBox.Text);

                        IEnumerable <string> validAnswers = answers.Where(a => !string.IsNullOrEmpty(a));
                        if (validAnswers.Count() >= 2)
                        {
                            CommandBase command = null;
                            if (this.PollCommandNameComboBox.SelectedIndex >= 0)
                            {
                                command = (CommandBase)this.PollCommandNameComboBox.SelectedItem;
                            }

                            return(StreamingPlatformAction.CreatePollAction(this.PollQuestionTextBox.Text, length, validAnswers, command));
                        }
                    }
                }
            }
            return(null);
        }
 private StreamingPlatformAction(StreamingPlatformActionType type)
     : this()
 {
     this.ActionType = type;
 }