private void QuickActions_SelectedIndexChanged(object sender, EventArgs e) { ComboBoxItemPair <QuickActionType> c = QuickActions.SelectedItem as ComboBoxItemPair <QuickActionType>; if (c != null) { switch (c.Value) { case QuickActionType.Pause: Program.LiveControl.Pause(); break; case QuickActionType.Resume: Program.LiveControl.Resume(); break; case QuickActionType.Pause5Min: Program.LiveControl.Pause("5m"); break; case QuickActionType.Pause10Min: Program.LiveControl.Pause("10m"); break; case QuickActionType.Pause15Min: Program.LiveControl.Pause("15m"); break; case QuickActionType.Pause30Min: Program.LiveControl.Pause("30m"); break; case QuickActionType.Pause60Min: Program.LiveControl.Pause("60m"); break; case QuickActionType.StopBackup: Program.Runner.Stop(CloseReason.UserClosing); break; case QuickActionType.ThrottleDialog: new ThrottleControl().ShowDialog(Program.DisplayHelper); break; case QuickActionType.QuitDuplicati: Program.DisplayHelper.Quit(); break; } } QuickActions.SelectedIndex = 0; }
/// <summary> /// Helper function that removes the QuickState item for Pause/Resume and inserts the right one /// </summary> private void SetQuickActionsPauseState() { int index = -1; for (int i = 0; i < QuickActions.Items.Count; i++) { if (QuickActions.Items[i] is ComboBoxItemPair <QuickActionType> ) { QuickActionType action = ((ComboBoxItemPair <QuickActionType>)QuickActions.Items[i]).Value; if (action == QuickActionType.Pause || action == QuickActionType.Resume) { //If it is already correct, return now if (action == QuickActionType.Resume && Program.LiveControl.State == LiveControls.LiveControlState.Paused) { return; } if (action == QuickActionType.Pause && Program.LiveControl.State == LiveControls.LiveControlState.Running) { return; } index = i; break; } } } ComboBoxItemPair <QuickActionType> newitem; if (Program.LiveControl.State == LiveControls.LiveControlState.Paused) { newitem = new ComboBoxItemPair <QuickActionType>(Strings.ServiceStatus.QuickActionResume, QuickActionType.Resume); } else { newitem = new ComboBoxItemPair <QuickActionType>(Strings.ServiceStatus.QuickActionPause, QuickActionType.Pause); } QuickActions.Items.RemoveAt(index); QuickActions.Items.Insert(index, newitem); }
/// <summary> /// Helper function that removes the QuickState item for Pause/Resume and inserts the right one /// </summary> private void SetQuickActionsPauseState() { int index = -1; for(int i = 0; i < QuickActions.Items.Count; i++) if (QuickActions.Items[i] is ComboBoxItemPair<QuickActionType>) { QuickActionType action = ((ComboBoxItemPair<QuickActionType>)QuickActions.Items[i]).Value; if (action == QuickActionType.Pause || action == QuickActionType.Resume) { //If it is already correct, return now if (action == QuickActionType.Resume && Program.LiveControl.State == LiveControls.LiveControlState.Paused) return; if (action == QuickActionType.Pause && Program.LiveControl.State == LiveControls.LiveControlState.Running) return; index = i; break; } } ComboBoxItemPair<QuickActionType> newitem; if (Program.LiveControl.State == LiveControls.LiveControlState.Paused) newitem = new ComboBoxItemPair<QuickActionType>(Strings.ServiceStatus.QuickActionResume, QuickActionType.Resume); else newitem = new ComboBoxItemPair<QuickActionType>(Strings.ServiceStatus.QuickActionPause, QuickActionType.Pause); QuickActions.Items.RemoveAt(index); QuickActions.Items.Insert(index, newitem); }