Beispiel #1
0
        /// <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;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// The on queue completed.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected virtual void OnQueueCompleted(QueueCompletedEventArgs e)
        {
            QueueCompletedEventDelegate handler = this.QueueCompleted;

            if (handler != null)
            {
                handler(this, e);
            }

            this.IsProcessing = false;
        }
        private void QueueCompleted(object sender, QueueCompletedEventArgs args)
        {
            _queueProcessor.QueueCompleted       -= QueueCompleted;
            _queueProcessor.QueueProgressChanged -= QueueProgressChanged;
            _queueProcessor.QueueStarted         -= QueueStarted;

            Execute.OnUIThread(() =>
            {
                var finishedList = JobCollection.Where(encodeInfo => encodeInfo.NextStep == EncodingStep.Done).ToList();
                foreach (var encodeInfo in finishedList)
                {
                    JobCollection.Remove(encodeInfo);
                }
            });
            Close();
        }
Beispiel #4
0
        /// <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<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.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void QueueProcessor_QueueCompleted(object sender, QueueCompletedEventArgs e)
 {
     this.Task        = "Not Encoding.";
     this.Progress    = string.Empty;
     this.QueueStatus = string.Format("{0} jobs pending", this.queueProcessor.Count);
 }
        /// <summary>
        /// Invoke the Encode Completed Event
        /// </summary>
        /// <param name="e">
        /// The QueueCompletedEventArgs.
        /// </param>
        public void InvokeQueueCompleted(QueueCompletedEventArgs e)
        {
            var handler = QueueCompleted;

            handler?.Invoke(this, e);
        }
Beispiel #8
0
 /// <summary>
 /// The queue processor_ queue completed.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The e.
 /// </param>
 private void QueueProcessor_QueueCompleted(object sender, QueueCompletedEventArgs e)
 {
     this.Task = "Not Encoding.";
     this.Progress = string.Empty;
     this.QueueStatus = string.Format("{0} jobs pending", this.queueProcessor.Count);
 }
Beispiel #9
0
        /// <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;
                }
            }
        }