private void Invalidate(CommandKey key) { ToolStripButton button; if (_commandButtonMap.TryGetValue(key, out button)) { button.Enabled = CanPerformCommand(key); button.Checked = IsCommandSelected(key); } }