diff --git a/TVRename/Forms/BulkAddMovies/BulkAddMovie.cs b/TVRename/Forms/BulkAddMovies/BulkAddMovie.cs index c0f5f6f3..0c9b35c7 100644 --- a/TVRename/Forms/BulkAddMovies/BulkAddMovie.cs +++ b/TVRename/Forms/BulkAddMovies/BulkAddMovie.cs @@ -605,7 +605,7 @@ private void bwIdentify_ProgressChanged(object sender, [NotNull] ProgressChanged { lvFMNewShows.Update(); - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0,100); lblStatusLabel.Text = ((PossibleNewMovie)e.UserState).RefinedHint; UpdateListItem((PossibleNewMovie)e.UserState, false); } @@ -619,7 +619,7 @@ private void bwIdentify_RunWorkerCompleted(object sender, RunWorkerCompletedEven private void bwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatusLabel.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/CollectionsView.cs b/TVRename/Forms/Tools/CollectionsView.cs index 2456b972..377e92d6 100644 --- a/TVRename/Forms/Tools/CollectionsView.cs +++ b/TVRename/Forms/Tools/CollectionsView.cs @@ -111,7 +111,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e) private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/DuplicateMovieFinder.cs b/TVRename/Forms/Tools/DuplicateMovieFinder.cs index 7f1943b0..c4dce686 100644 --- a/TVRename/Forms/Tools/DuplicateMovieFinder.cs +++ b/TVRename/Forms/Tools/DuplicateMovieFinder.cs @@ -86,7 +86,7 @@ private void ProcessMovie([NotNull] MovieConfiguration movie) private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/MergedEpisodeFinder.cs b/TVRename/Forms/Tools/MergedEpisodeFinder.cs index 83a4a815..d99ae3a6 100644 --- a/TVRename/Forms/Tools/MergedEpisodeFinder.cs +++ b/TVRename/Forms/Tools/MergedEpisodeFinder.cs @@ -210,7 +210,7 @@ private void BwScan_DoWork([NotNull] object sender, DoWorkEventArgs e) private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/OrphanFiles.cs b/TVRename/Forms/Tools/OrphanFiles.cs index 520efa0b..5eb509e6 100644 --- a/TVRename/Forms/Tools/OrphanFiles.cs +++ b/TVRename/Forms/Tools/OrphanFiles.cs @@ -169,7 +169,7 @@ private static bool HasEpisode([NotNull] IEnumerable showSeaso private void BwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/RecommendationView.cs b/TVRename/Forms/Tools/RecommendationView.cs index 1be724d5..e639c72b 100644 --- a/TVRename/Forms/Tools/RecommendationView.cs +++ b/TVRename/Forms/Tools/RecommendationView.cs @@ -205,7 +205,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e) private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState?.ToString(); } diff --git a/TVRename/Forms/Tools/SettingsReview.cs b/TVRename/Forms/Tools/SettingsReview.cs index 6a0f9cd2..c8b7005d 100644 --- a/TVRename/Forms/Tools/SettingsReview.cs +++ b/TVRename/Forms/Tools/SettingsReview.cs @@ -103,7 +103,7 @@ private void BwScan_DoWork(object sender, DoWorkEventArgs e) private void BwScan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Forms/Tools/ShowSummary.cs b/TVRename/Forms/Tools/ShowSummary.cs index fee139de..67a77d77 100644 --- a/TVRename/Forms/Tools/ShowSummary.cs +++ b/TVRename/Forms/Tools/ShowSummary.cs @@ -737,7 +737,7 @@ private void BwRescan_DoWork(object sender, DoWorkEventArgs e) private void BwRescan_ProgressChanged(object sender, [NotNull] ProgressChangedEventArgs e) { - pbProgress.Value = e.ProgressPercentage; + pbProgress.Value = e.ProgressPercentage.Between(0, 100); lblStatus.Text = e.UserState.ToString(); } diff --git a/TVRename/Utility/Helper/Helpers.cs b/TVRename/Utility/Helper/Helpers.cs index f372049c..aa4a4480 100644 --- a/TVRename/Utility/Helper/Helpers.cs +++ b/TVRename/Utility/Helper/Helpers.cs @@ -38,6 +38,20 @@ public static class Helpers public static bool InDebug() => Debugger.IsAttached; + + public static int Between(this int value, int min, int max) + { + if (value < min) + { + return min; + } + if (value > max) + { + return max; + } + return value; + } + public static bool In([CanBeNull] this T item, [NotNull] params T[] items) { if (items == null)