/// <summary> /// Perform an update check at application start, but only daily, weekly or monthly depending on the users settings. /// </summary> /// <param name="callback"> /// The callback. /// </param> public void PerformStartupUpdateCheck(Action <UpdateCheckInformation> callback) { if (Portable.IsPortable() && !Portable.IsUpdateCheckEnabled()) { return; // Disable Update Check for Portable Mode. } // Make sure it's running on the calling thread if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.UpdateStatus)) { // If a previous update check detected an update, don't bother calling out to the HandBrake website again. Just return the result. int lastLatestBuildNumberCheck = this.userSettingService.GetUserSetting <int>(UserSettingConstants.IsUpdateAvailableBuild); if (lastLatestBuildNumberCheck != 0 && lastLatestBuildNumberCheck > HandBrakeVersionHelper.Build) { callback(new UpdateCheckInformation { NewVersionAvailable = true, Error = null }); return; } DateTime lastUpdateCheck = this.userSettingService.GetUserSetting <DateTime>(UserSettingConstants.LastUpdateCheckDate); int checkFrequency = this.userSettingService.GetUserSetting <int>(UserSettingConstants.DaysBetweenUpdateCheck) == 0 ? 7 : 30; if (DateTime.Now.Subtract(lastUpdateCheck).TotalDays > checkFrequency) { this.userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now); this.CheckForUpdates(callback); } } }
/// <summary> /// Perform an update check at application start, but only daily, weekly or monthly depending on the users settings. /// </summary> /// <param name="callback"> /// The callback. /// </param> public void PerformStartupUpdateCheck(Action <UpdateCheckInformation> callback) { if (UwpDetect.IsUWP()) { return; // Disable Update checker if we are in a UWP container. } if (Portable.IsPortable() && !Portable.IsUpdateCheckEnabled()) { return; // Disable Update Check for Portable Mode. } // Make sure it's running on the calling thread if (this.userSettingService.GetUserSetting <bool>(UserSettingConstants.UpdateStatus)) { DateTime lastUpdateCheck = this.userSettingService.GetUserSetting <DateTime>(UserSettingConstants.LastUpdateCheckDate); int checkFrequency = this.userSettingService.GetUserSetting <int>(UserSettingConstants.DaysBetweenUpdateCheck) == 0 ? 7 : 30; if (DateTime.Now.Subtract(lastUpdateCheck).TotalDays > checkFrequency) { this.userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now); this.CheckForUpdates(callback); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { OptionsTab[] tabs = value as OptionsTab[]; if (tabs != null && !Portable.IsUpdateCheckEnabled()) { return(tabs.Where(s => s != OptionsTab.Updates).ToArray()); } return(value); }
private static void CheckForUpdateCheckPermission(IUserSettingService userSettingService) { if (Portable.IsPortable() && !Portable.IsUpdateCheckEnabled()) { return; // If Portable Mode has disabled it, don't bother the user. Just accept it's disabled. } MessageBoxResult result = MessageBox.Show(HandBrakeWPF.Properties.Resources.FirstRun_EnableUpdateCheck, HandBrakeWPF.Properties.Resources.FirstRun_EnableUpdateCheckHeader, MessageBoxButton.YesNo, MessageBoxImage.Question); // Be explicit setting it to true/false as it may have been turned on during first-run. userSettingService.SetUserSetting(UserSettingConstants.UpdateStatus, result == MessageBoxResult.Yes); }