private CommandState GetCommandState(string commandName, CommandBarControl control) { foreach (CommandState commandState in this.states) { if (commandName == commandState.CommandName) { return(commandState); } } CommandBarButton button = control as CommandBarButton; if (button != null) { CommandButtonState commandState = new CommandButtonState(commandName); this.states.Add(commandState); return(commandState); } CommandBarCheckBox checkBox = control as CommandBarCheckBox; if (checkBox != null) { CommandCheckBoxState commandState = new CommandCheckBoxState(commandName); this.states.Add(commandState); return(commandState); } CommandBarComboBox comboBox = control as CommandBarComboBox; if (comboBox != null) { CommandComboBoxState commandState = new CommandComboBoxState(commandName); this.states.Add(commandState); return(commandState); } throw new NotSupportedException(); }
private CommandState GetCommandState(string commandName, CommandBarControl control) { foreach (CommandState commandState in this.states) { if (commandName == commandState.CommandName) { return commandState; } } CommandBarButton button = control as CommandBarButton; if (button != null) { CommandButtonState commandState = new CommandButtonState(commandName); this.states.Add(commandState); return commandState; } CommandBarCheckBox checkBox = control as CommandBarCheckBox; if (checkBox != null) { CommandCheckBoxState commandState = new CommandCheckBoxState(commandName); this.states.Add(commandState); return commandState; } CommandBarComboBox comboBox = control as CommandBarComboBox; if (comboBox != null) { CommandComboBoxState commandState = new CommandComboBoxState(commandName); this.states.Add(commandState); return commandState; } throw new NotSupportedException(); }