/// <summary>
 /// Handles OnDownloadCompleted
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="AsyncCompletedEventArgs"/> instance containing the event data.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 private void AppUpdaterOnDownloadCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (Properties.Settings.Default.UpdateMode == 1 && MessageBox.Show("An update has been downloaded", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
     {
         AppUpdater.InstallLatestVersion();
     }
     else if (Properties.Settings.Default.UpdateMode == 2)
     {
         AppUpdater.InstallLatestVersion();
     }
 }
        /// <summary>
        /// Initializes all related to the Update service
        /// </summary>
        private void InitializeUpdateService()
        {
            AppUpdater.DownloadProgressChanged += AppUpdaterOnDownloadProgressChanged;
            AppUpdater.DownloadCompleted       += AppUpdaterOnDownloadCompleted;

            // Handle New version found
            AppUpdater.CheckVersionsCompleted += async(sender, args) =>
            {
                if (args.AskToDownloadHandled ||
                    (!args.AskToDownloadHandled && args.TargetSubscriberType != typeof(UpdateMenuViewModel)))
                {
                    return;
                }

                // TODO: refactor this, it's f*****g messy
                if (args.HasNewVersionAvailable)
                {
                    // 0 = Ask to download and install
                    // 1 = Ask to install
                    // 2 = Auto download and install

                    if (UpdateModeIndex == 0)
                    {
                        // Independt ifs since the user might refuse to download
                        if (!AppUpdater.IsUpdatePackageAvailable() &&
                            MessageBox.Show("There's a new version available. Would you like to download it?",
                                            "Update available", MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                            MessageBoxResult.Yes)
                        {
                            IsUpdating = true;
                            await AppUpdater.DownloadLatestVersion();
                        }
                        if (
                            MessageBox.Show("Would you like to install the update?", "Update available",
                                            MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                            MessageBoxResult.Yes)
                        {
                            AppUpdater.InstallLatestVersion();
                        }
                    }
                    else // No need to check since the possible values are 0 to 2
                    {
                        IsUpdating = true;
                        await AppUpdater.DownloadLatestVersion();

                        if (UpdateModeIndex == 1)
                        {
                            if (
                                MessageBox.Show("Would you like to install the update?", "Update available",
                                                MessageBoxButton.YesNo, MessageBoxImage.Question) ==
                                MessageBoxResult.Yes)
                            {
                                AppUpdater.InstallLatestVersion();
                            }
                        }
                        else
                        {
                            await AppUpdater.DownloadLatestVersion();

                            AutoClosingMessageBox.Show("The update will be installed in 3 seconds...",
                                                       "Closing in 3 seconds!", 3000);
                            AppUpdater.InstallLatestVersion();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("The latest version is already installed!", "No update available",
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                }

                IsUpdating = false;
                args.AskToDownloadHandled = true;
            };
        }