private void buttonDisableHa_Click(object sender, EventArgs e) { if (pool == null) { return; } if (!pool.ha_enabled) { // Start HA wizard EditHA(pool); return; } if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct { using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( SystemIcons.Error, string.Format(Messages.HA_DISABLE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)), Messages.DISABLE_HA), "HADisable", ThreeButtonDialog.ButtonOK)) { dlg.ShowDialog(this); return; } } // Confirm the user wants to disable HA using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)), Messages.DISABLE_HA), "HADisable", ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)) { if (dlg.ShowDialog(this) != DialogResult.Yes) { return; } } DisableHAAction action = new DisableHAAction(pool); // We will need to re-enable buttons when the action completes action.Completed += Program.MainWindow.action_Completed; action.RunAsync(); }
protected override void ExecuteCore(SelectedItemCollection selection) { Pool pool = selection.Count == 1 ? selection[0].PoolAncestor : null; if (pool == null || !pool.ha_enabled) { return; } if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct { using (var dlg = new ErrorDialog(string.Format(Messages.HA_DISABLE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)), ThreeButtonDialog.ButtonOK) { WindowTitle = Messages.DISABLE_HA }) { dlg.ShowDialog(Parent); return; } } // Confirm the user wants to disable HA using (var dlg = new NoIconDialog(string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)), ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo) { HelpNameSetter = "HADisable", WindowTitle = Messages.DISABLE_HA }) { if (dlg.ShowDialog(Parent) != DialogResult.Yes) { return; } } var action = new DisableHAAction(pool); // We will need to re-enable buttons when the action completes action.Completed += Program.MainWindow.action_Completed; action.RunAsync(); }
private void buttonEnableDisableHa_Click(object sender, EventArgs e) { if (pool == null) { return; } if (!pool.ha_enabled) { // Start HA wizard EditHA(pool); return; } // Offer to disable HA DialogResult dr; using (var dlg = new ThreeButtonDialog( new ThreeButtonDialog.Details( null, string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)), Messages.DISABLE_HA), "HADisable", ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)) { dr = dlg.ShowDialog(this); } if (dr != DialogResult.Yes) { return; } DisableHAAction action = new DisableHAAction(pool); // We will need to re-enable buttons when the action completes action.Completed += Program.MainWindow.action_Completed; action.RunAsync(); Program.MainWindow.UpdateToolbars(); }