private void Reboot() { // ダイアログで確認 // 次回起動する OS を指定 if (BcdManager.UpdateNextBootOperatingSystem(this.SelectedOperatingSystem.Identifier)) { BcdManager.Reboot(); } }
private void ItemOnCheckedChanged(object sender, EventArgs eventArgs) { var item = sender as ToolStripMenuItem; if (item == null) { return; } var operatingSystemModel = item.Tag as OperatingSystemModel; if (operatingSystemModel == null) { return; } var success = false; var botMenuItems = this._BootMenus; try { // 他のアイテムのチェック変更が発動しないようイベントを解除 foreach (var menuItem in botMenuItems) { menuItem.CheckedChanged -= this.ItemOnCheckedChanged; } if (item.Checked) { // 他のチェックを全て外す foreach (var menuItem in botMenuItems) { if (menuItem != item) { menuItem.Checked = false; } } } else { // チェックの解除は認めない item.Checked = true; } success = BcdManager.UpdateNextBootOperatingSystem(operatingSystemModel.Identifier); if (success) { foreach (var menuItem in botMenuItems) { if (menuItem == null) { continue; } var model = menuItem.Tag as OperatingSystemModel; if (model == null) { return; } model.IsNext = false; } operatingSystemModel.IsNext = true; } } finally { foreach (var menuItem in botMenuItems) { menuItem.CheckedChanged += this.ItemOnCheckedChanged; } } if (success) { if (this._CheckMenu.Checked && item.Checked) { BcdManager.Reboot(); } } }