/// <summary> /// The queue processor queue completed event handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void QueueProcessorQueueCompleted(object sender, QueueCompletedEventArgs e) { if (e.WasManuallyStopped) { return; } if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PlaySoundWhenQueueDone)) { this.PlayWhenDoneSound(); } if (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction) == "Do nothing") { return; } // Give the user the ability to cancel the shutdown. Default 60 second timer. ICountdownAlertViewModel titleSpecificView = IoC.Get <ICountdownAlertViewModel>(); Execute.OnUIThread( () => { titleSpecificView.SetAction(this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)); this.windowManager.ShowDialog(titleSpecificView); }); if (!titleSpecificView.IsCancelled) { // Do something whent he encode ends. switch (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)) { case "Shutdown": Process.Start("Shutdown", "-s -t 60"); break; case "Log off": Win32.ExitWindowsEx(0, 0); break; case "Suspend": Application.SetSuspendState(PowerState.Suspend, true, true); break; case "Hibernate": Application.SetSuspendState(PowerState.Hibernate, true, true); break; case "Lock System": Win32.LockWorkStation(); break; case "Quit HandBrake": Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; } } }
/// <summary> /// The queue processor queue completed event handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void QueueProcessorQueueCompleted(object sender, QueueCompletedEventArgs e) { if (e.WasManuallyStopped) { return; } if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PlaySoundWhenQueueDone)) { this.PlayWhenDoneSound(); } if (this.userSettingService.GetUserSetting <int>(UserSettingConstants.WhenCompleteAction) == (int)WhenDone.DoNothing) { return; } // Give the user the ability to cancel the shutdown. Default 60 second timer. bool isCancelled = false; if (!this.userSettingService.GetUserSetting <bool>(UserSettingConstants.WhenDonePerformActionImmediately)) { ICountdownAlertViewModel titleSpecificView = IoC.Get <ICountdownAlertViewModel>(); Execute.OnUIThread( () => { titleSpecificView.SetAction((WhenDone)this.userSettingService.GetUserSetting <int>(UserSettingConstants.WhenCompleteAction)); this.windowManager.ShowDialog(titleSpecificView); isCancelled = titleSpecificView.IsCancelled; }); } if (!isCancelled) { this.ServiceLogMessage(string.Format("Performing 'When Done' Action: {0}", this.userSettingService.GetUserSetting <int>(UserSettingConstants.WhenCompleteAction))); // Do something when the encode ends. switch ((WhenDone)this.userSettingService.GetUserSetting <int>(UserSettingConstants.WhenCompleteAction)) { case WhenDone.Shutdown: ProcessStartInfo shutdown = new ProcessStartInfo("Shutdown", "-s -t 60"); shutdown.UseShellExecute = false; Process.Start(shutdown); Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; case WhenDone.LogOff: this.scanService.Dispose(); Win32.ExitWindowsEx(0, 0); break; case WhenDone.Sleep: Application.SetSuspendState(PowerState.Suspend, true, true); break; case WhenDone.Hibernate: Application.SetSuspendState(PowerState.Hibernate, true, true); break; case WhenDone.LockSystem: Win32.LockWorkStation(); break; case WhenDone.QuickHandBrake: Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; } } // Allow the system to sleep again. Execute.OnUIThread(() => { if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PreventSleep)) { Win32.AllowSleep(); } }); }
/// <summary> /// The queue processor queue completed event handler. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void QueueProcessorQueueCompleted(object sender, QueueCompletedEventArgs e) { if (e.WasManuallyStopped) { return; } if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.PlaySoundWhenQueueDone)) { this.PlayWhenDoneSound(); } if (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction) == "Do nothing") { return; } // Give the user the ability to cancel the shutdown. Default 60 second timer. bool isCancelled = false; if (!this.userSettingService.GetUserSetting <bool>(UserSettingConstants.WhenDonePerformActionImmediately)) { ICountdownAlertViewModel titleSpecificView = IoC.Get <ICountdownAlertViewModel>(); Execute.OnUIThread( () => { titleSpecificView.SetAction(this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)); this.windowManager.ShowDialog(titleSpecificView); isCancelled = titleSpecificView.IsCancelled; }); } if (!isCancelled) { this.ServiceLogMessage(string.Format("Performing 'When Done' Action: {0}", this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction))); // Do something when the encode ends. switch (this.userSettingService.GetUserSetting <string>(UserSettingConstants.WhenCompleteAction)) { case "Shutdown": case "Herunterfahren": ProcessStartInfo shutdown = new ProcessStartInfo("Shutdown", "-s -t 60"); shutdown.UseShellExecute = false; Process.Start(shutdown); Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; case "Log off": case "Ausloggen": this.scanService.Dispose(); Win32.ExitWindowsEx(0, 0); break; case "Suspend": Application.SetSuspendState(PowerState.Suspend, true, true); break; case "Hibernate": case "Ruhezustand": Application.SetSuspendState(PowerState.Hibernate, true, true); break; case "Lock System": case "System sperren": Win32.LockWorkStation(); break; case "Quit HandBrake": case "HandBrake beenden": Execute.OnUIThread(() => System.Windows.Application.Current.Shutdown()); break; } } }