Skip to content

Commit

Permalink
Fix #852
Browse files Browse the repository at this point in the history
  • Loading branch information
SirSparkles committed Feb 2, 2022
1 parent 3278eed commit b3c67e9
Show file tree
Hide file tree
Showing 6 changed files with 1,527 additions and 1,544 deletions.
2,128 changes: 1,064 additions & 1,064 deletions TVRename/Forms/Preferences/Preferences.Designer.cs

Large diffs are not rendered by default.

862 changes: 431 additions & 431 deletions TVRename/Forms/UI.Designer.cs

Large diffs are not rendered by default.

54 changes: 19 additions & 35 deletions TVRename/Forms/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace TVRename
// ReSharper disable once InconsistentNaming
public partial class UI : Form, IRemoteActions, IDialogParent
{
public const string EXPLORE_PROXY = "http://www.tvrename.com/EXPLOREPROXY";
public const string WATCH_PROXY = "http://www.tvrename.com/WATCHPROXY";
public const string EXPLORE_PROXY = "https://www.tvrename.com/EXPLOREPROXY";
public const string WATCH_PROXY = "https://www.tvrename.com/WATCHPROXY";

#region Delegates

Expand Down Expand Up @@ -201,7 +201,7 @@ private void WaitFor([NotNull] Func<bool> func, int maxSeconds, string textMessa
}
}

public void Wait(int milliseconds)
private void Wait(int milliseconds)
{
Timer timer1 = new();
if (milliseconds == 0 || milliseconds < 0)
Expand Down Expand Up @@ -269,8 +269,7 @@ public void ShowChildDialog(Form childForm)
}
}

// ReSharper disable once UnusedMember.Global
public void ShowChild(Form childForm)
private void ShowChild(Form childForm)
{
if (InvokeRequired)
{
Expand Down Expand Up @@ -2714,7 +2713,7 @@ private void AddMovieToTree([NotNull] MovieConfiguration si)
}

// ReSharper disable once InconsistentNaming
public static string GenerateShowUIName(ProcessedEpisode? episode) => GenerateShowUIName(episode?.TheCachedSeries, episode?.Show);
private static string GenerateShowUIName(ProcessedEpisode? episode) => GenerateShowUIName(episode?.TheCachedSeries, episode?.Show);

// ReSharper disable once InconsistentNaming
private static string GenerateShowUIName([NotNull] ShowConfiguration si)
Expand Down Expand Up @@ -4057,8 +4056,8 @@ private void UpdateActionCheckboxes()
ItemList all = mDoc.TheActionList;
List<Item> chk = mDoc.TheActionList.Checked;

SetCheckbox(mcbRename, RenameActions(all), RenameActions(chk));
SetCheckbox(mcbCopyMove, all.OfType<ActionCopyMoveRename>().Where(a => a.Operation != ActionCopyMoveRename.Op.rename), chk.OfType<ActionCopyMoveRename>().Where(a => a.Operation != ActionCopyMoveRename.Op.rename));
SetCheckbox(mcbRename, all.Where(IsRenameAction), chk.Where(IsRenameAction));
SetCheckbox(mcbCopyMove, all.Where(IsCopyMoveAction), chk.Where(IsCopyMoveAction));
SetCheckbox(mcbDeleteFiles, all.OfType<ActionDelete>(), chk.OfType<ActionDelete>());
SetCheckbox(mcbSaveImages, all.OfType<ActionDownloadImage>(), chk.OfType<ActionDownloadImage>());
SetCheckbox(mcbWriteMetadata, all.OfType<ActionWriteMetadata>(), chk.OfType<ActionWriteMetadata>());
Expand All @@ -4068,13 +4067,11 @@ private void UpdateActionCheckboxes()
SetCheckbox(mcbAll, all.Actions, chk.OfType<Action>());
}

[NotNull]
private static IEnumerable<Item> RenameActions([NotNull] IEnumerable<Item> all)
{
return all.Where(a =>
a is ActionCopyMoveRename { Operation: ActionCopyMoveRename.Op.rename } ||
a is ActionMoveRenameDirectory);
}
private static bool IsCopyMoveAction(Item i) =>
i is ActionCopyMoveRename a && a.Operation != ActionCopyMoveRename.Op.rename
|| i is ActionMoveRenameDirectory;

private static bool IsRenameAction(Item a) => a is ActionCopyMoveRename { Operation: ActionCopyMoveRename.Op.rename };

private static void SetCheckbox([NotNull] ToolStripMenuItem box, [NotNull] IEnumerable<Item> all, [NotNull] IEnumerable<Item> chk)
{
Expand All @@ -4094,10 +4091,6 @@ private static void SetCheckbox([NotNull] ToolStripMenuItem box, [NotNull] IEnum
box.Enabled = btn.Any();
}

private void olvAction_ItemCheck(object sender, [NotNull] ItemCheckEventArgs e)
{
}

private void bnActionOptions_Click(object sender, EventArgs e) => DoPrefs(true);

private void lvAction_MouseDoubleClick(object sender, MouseEventArgs e)
Expand Down Expand Up @@ -4494,12 +4487,12 @@ private void McbAll_Click(object sender, EventArgs e)

private void McbRename_Click(object sender, EventArgs e)
{
UpdateCheckboxGroup(mcbRename, i => i is ActionCopyMoveRename { Operation: ActionCopyMoveRename.Op.rename } || i is ActionMoveRenameDirectory);
UpdateCheckboxGroup(mcbRename, IsRenameAction);
}

private void McbCopyMove_Click(object sender, EventArgs e)
{
UpdateCheckboxGroup(mcbCopyMove, i => i is ActionCopyMoveRename copymove && copymove.Operation != ActionCopyMoveRename.Op.rename);
UpdateCheckboxGroup(mcbCopyMove, IsCopyMoveAction);
}

private void McbDeleteFiles_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -5108,7 +5101,7 @@ private void btnMovieRefresh_Click(object sender, EventArgs e)
}
}

internal void ForceMovieRefresh(bool unattended)
private void ForceMovieRefresh(bool unattended)
{
ForceMovieRefresh((List<MovieConfiguration>)null, unattended);
}
Expand Down Expand Up @@ -5199,17 +5192,9 @@ private void movieSearchEnginesToolStripMenuItem_Click(object sender, EventArgs
LessBusy();
}

private MovieConfiguration? CurrentlySelectedMovie()
{
MovieConfiguration currentMovie = TreeNodeToMovieItem(movieTree.SelectedNode);

if (currentMovie != null)
{
return currentMovie;
}

return mDoc.FilmLibrary.Movies.FirstOrDefault();
}
private MovieConfiguration? CurrentlySelectedMovie() =>
TreeNodeToMovieItem(movieTree.SelectedNode)
?? mDoc.FilmLibrary.Movies.FirstOrDefault();

private void scanMovieFolderToolStripMenuItem_Click(object sender, EventArgs e)
{
Expand All @@ -5230,8 +5215,7 @@ private void scanMovieFolderToolStripMenuItem_Click(object sender, EventArgs e)
Logger.Info("Finished looking for new movies.");
}

// ReSharper disable once UnusedParameter.Local
private string AskUserForFolder()
private static string AskUserForFolder()
{
using (FolderBrowserDialog fbd = new())
{
Expand Down
5 changes: 2 additions & 3 deletions TVRename/ItemsAndActions/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public sealed override bool CheckedItem
set
{
checkedItemValue = value;
NotifyPropertyChanged("CheckedItem");
NotifyPropertyChanged();
}
}
protected Action()
Expand All @@ -45,8 +45,7 @@ public double PercentDone // 0.0 to 100.0
protected set => percent = value;
}

public abstract long
SizeOfWork
public abstract long SizeOfWork
{
get;
} // for file copy/move, number of bytes in file. for simple tasks, 1, or something proportional to how slow it is to copy files around.
Expand Down
5 changes: 3 additions & 2 deletions TVRename/ItemsAndActions/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using JetBrains.Annotations;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace TVRename
{
Expand All @@ -34,7 +35,7 @@ public abstract class Item : IComparable, INotifyPropertyChanged // something sh
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
protected void NotifyPropertyChanged(string propertyName = "")
protected void NotifyPropertyChanged([CallerMemberName] [CanBeNull] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
Expand Down Expand Up @@ -68,7 +69,7 @@ public string ErrorText {
get => errorTextValue;
protected internal set {
errorTextValue = value;
NotifyPropertyChanged("ErrorText");
NotifyPropertyChanged();
} } // Human-readable error message, for when Error is true

public int CompareTo(object obj) => CompareTo((Item)obj);
Expand Down
17 changes: 8 additions & 9 deletions TVRename/TVRename/TVDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,15 +1864,15 @@ public void MovieFolderScan(UI ui,string downloadFolder)
{
if (!Directory.Exists(downloadFolder))
{
Logger.Error($"Please update 'Download Folders' '{downloadFolder}' does not exist");
Logger.Error($"Stopping 'Scan Movie Folder' '{downloadFolder}' does not exist");
return;
}
TheActionList.Clear();

try
{
IEnumerable<string> x = Directory.GetFiles(downloadFolder, "*", System.IO.SearchOption.AllDirectories).OrderBy(s => s).ToList();
Logger.Info($"Processing {x.Count()} files for shows that need to be scanned");
Logger.Info($"Processing {x.Count()} files for movies in '{downloadFolder}' that need to be analysed.");

foreach (string filePath in x)
{
Expand All @@ -1889,7 +1889,7 @@ public void MovieFolderScan(UI ui,string downloadFolder)
continue;
}

Logger.Info($"Checking to see whether {filePath} is a file for a show that needs to be scanned");
Logger.Info($"Checking to see whether {filePath} is a file for a movie that needs to be added or updated");

List<MovieConfiguration> existingMatchingShows = GetMatchingMovies(fi);

Expand All @@ -1904,21 +1904,20 @@ public void MovieFolderScan(UI ui,string downloadFolder)
DialogResult decision = askUser.ShowDialog(ui);

//if user cancelled then move on
if (decision == DialogResult.Abort)
if (decision != DialogResult.OK)
{
Logger.Info($"User chose to ignore {filePath}");
continue;
}

//if user selected a new show then
if (decision == DialogResult.OK && askUser.ChosenShow == null)
if (askUser.ChosenShow == null)
{
//if user selected a new show then
BonusAutoAdd(fi, ui);
}

//if user selected a show
if (decision == DialogResult.OK && askUser.ChosenShow != null)
else
{
//if user selected a show
MergeMovieFileIntoMovieConfig(fi, askUser.ChosenShow, ui);
}
}
Expand Down

0 comments on commit b3c67e9

Please sign in to comment.