private static void UpdateState(CheckBoxMenuItemCollection menuItems, CheckBoxMenuItemState state) { if (state.Vector.Count > 0) { UpdateState(menuItems, 0, state); } }
private static void UpdateState(CheckBoxMenuItemCollection menuItems, int index, CheckBoxMenuItemState state) { var coordinate = state.Vector[index]; if (coordinate >= menuItems.Count) { return; } var menuItem = menuItems[coordinate]; if (index == state.Vector.Count - 1) { // Reached the end so set it. menuItem.Checked = state.Checked; } else { // Keep going. UpdateState(menuItem.ChildMenuItems, index + 1, state); } }