private void CommandTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.CommandNameComboBox.Visibility = Visibility.Collapsed; this.SingleActionNameComboBox.Visibility = Visibility.Collapsed; this.ActionControlContentControl.Visibility = Visibility.Collapsed; if (this.CommandTypeComboBox.SelectedIndex >= 0) { string selection = (string)this.CommandTypeComboBox.SelectedItem; if (selection.Equals(SingleActionCommandType)) { this.Command = null; this.SingleActionNameComboBox.SelectedIndex = -1; this.SingleActionNameComboBox.Visibility = Visibility.Visible; } else { this.SingleActionNameComboBox.SelectedIndex = -1; this.ActionControlContentControl.Content = this.actionContentContainerControl = null; CommandTypeEnum commandType = EnumHelper.GetEnumValueFromString <CommandTypeEnum>((string)this.CommandTypeComboBox.SelectedItem); IEnumerable <CommandBase> commands = ChannelSession.AllEnabledCommands.Where(c => c.Type == commandType); if (commandType == CommandTypeEnum.Chat) { commands = commands.Where(c => !(c is PreMadeChatCommand)); } this.CommandNameComboBox.ItemsSource = commands.OrderBy(c => c.Name); this.CommandNameComboBox.Visibility = Visibility.Visible; } } }
private void SingleActionNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.SingleActionNameComboBox.SelectedIndex >= 0) { ActionTypeEnum actionType = (ActionTypeEnum)this.SingleActionNameComboBox.SelectedItem; this.ActionControlContentControl.Visibility = Visibility.Visible; this.ActionControlContentControl.Content = this.actionContentContainerControl = new ActionContentContainerControl(actionType); } }
public ActionContainerControl(CommandWindow window, CommandEditorControlBase editorControl, ActionTypeEnum type) { this.Window = window; this.EditorControl = editorControl; this.type = type; InitializeComponent(); this.ActionContentContainerControl = (ActionContentContainerControl)this.GetByUid("ActionContentContainerControl"); this.ActionContentContainerControl.AssignAction(this.type); this.Loaded += ActionContainerControl_Loaded; }
public override Task OnLoaded() { this.ActionControlContentControl = (ContentControl)this.GetByUid("ActionControlContentControl"); var commandTypeStrings = System.Enum.GetValues(typeof(CommandTypeEnum)) .Cast <CommandTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v) && v != CommandTypeEnum.Game && v != CommandTypeEnum.Remote && v != CommandTypeEnum.Custom) .Select(v => EnumHelper.GetEnumName(v)) .ToList(); commandTypeStrings.Add("SingleAction"); this.CommandTypeComboBox.ItemsSource = commandTypeStrings; var actionTypes = System.Enum.GetValues(typeof(ActionTypeEnum)) .Cast <ActionTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v) && v != ActionTypeEnum.Custom) .OrderBy(v => v); this.SingleActionNameComboBox.ItemsSource = actionTypes; var operatorTypes = System.Enum.GetValues(typeof(ConditionalOperatorTypeEnum)) .Cast <ConditionalOperatorTypeEnum>() .Where(v => !EnumHelper.IsObsolete(v)); this.OperatorTypeComboBox.ItemsSource = operatorTypes; if (this.action != null) { this.CaseSensitiveToggleButton.IsChecked = !this.action.IgnoreCase; this.OperatorTypeComboBox.SelectedItem = this.action.Operator; foreach (ConditionalClauseModel clause in this.action.Clauses) { this.Clauses.Add(new ConditionalClauseViewModel(clause, this)); } if (this.Clauses.Count > 0) { this.Clauses.First().CanBeRemoved = false; } this.Command = this.action.GetCommand(); if (this.action.Action != null) { this.CommandTypeComboBox.SelectedItem = SingleActionCommandType; this.SingleActionNameComboBox.SelectedItem = this.action.Action.Type; this.ActionControlContentControl.Visibility = Visibility.Visible; this.ActionControlContentControl.Content = this.actionContentContainerControl = new ActionContentContainerControl(this.action.Action); } } else { this.OperatorTypeComboBox.SelectedItem = ConditionalOperatorTypeEnum.And; this.Clauses.Add(new ConditionalClauseViewModel(new ConditionalClauseModel(), this) { CanBeRemoved = false }); } this.ClausesItemsControl.ItemsSource = this.Clauses; return(Task.FromResult(0)); }