Skip to content

Commit

Permalink
Merge pull request #382 from MarkSummerville/25
Browse files Browse the repository at this point in the history
Incremental update - 3x bug fix
  • Loading branch information
SirSparkles authored May 3, 2018
2 parents f3e200f + b0d10dd commit 501156c
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 8 deletions.
4 changes: 2 additions & 2 deletions TVRename#/App/ApplicationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override void OnCreateSplashScreen()
this.SplashScreen = new TVRenameSplash();

CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);
if ((clargs.Unattended) || (clargs.Hide)) this.SplashScreen.Visible = false;
if (clargs.Hide) this.SplashScreen.Visible = false;

}

Expand All @@ -33,7 +33,7 @@ protected override void OnCreateSplashScreen()
protected override void OnCreateMainForm()
{
CommandLineArgs clargs = new CommandLineArgs(this.CommandLineArgs);
if ((clargs.Unattended) || (clargs.Hide))
if (clargs.Hide)
this.SplashScreen.SafeInvoke(
() => ((TVRenameSplash)this.SplashScreen).Visible = false,true);

Expand Down
5 changes: 3 additions & 2 deletions TVRename#/App/CommandLineArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ public CommandLineArgs(ReadOnlyCollection<string> args)
public static string Helptext()
{
StringBuilder output = new StringBuilder();
output.AppendLine();
output.AppendLine("/scan will Tell TV Rename to run a scan");
output.AppendLine("/quickscan will scan shows most likely to need an update: http://www.tvrename.com/userguide#scan");
output.AppendLine("/recentscan will scan recent shows: http://www.tvrename.com/userguide#scan");
output.AppendLine("/doall Tell TV Rename execute all the actions it can.");
output.AppendLine("/quit Tell a running TV Rename session to exit.");
output.AppendLine("");
output.AppendLine("/hide will hide the UI");
output.AppendLine("/unattended same as /hide");
output.AppendLine("/hide will hide the UI for all UI elements");
output.AppendLine("/unattended will hide the UI for all blocking UI elements");
output.AppendLine("");
output.AppendLine("/recover will load a dialog box that enables the user to recover a prior TVDB.xml or TVRenameSettings.xml file");
output.AppendLine("/userfilepath:BLAH Sets a custom folder path for the settings files.");
Expand Down
14 changes: 13 additions & 1 deletion TVRename#/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,19 @@ private static void Main(string[] args)
if (args.Contains("/?", StringComparer.OrdinalIgnoreCase))
{
Logger.Info(CommandLineArgs.Helptext());
Console.Out.WriteLine(CommandLineArgs.Helptext());

//redirect console output to parent process;
//must be before any calls to Console.WriteLine()
//MS: Never got this to work quite right - seems there is no simple way to output
//to the command line console if you are a winforms app
if (NativeMethods.AttachParentConsole())
{
Console.WriteLine(CommandLineArgs.Helptext());
}
else
{
Logger.Info("Could not attach to console");
}
return;
}
// Check if an application instance is already running
Expand Down
2 changes: 1 addition & 1 deletion TVRename#/ItemsAndActions/ActionDateTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ActionDateTouch(DirectoryInfo dir, ShowItem si, DateTime date)

#region Action Members

public override string Name => "Touch Update Time";
public override string Name => "Update Timestamp";

public override string ProgressText => this.WhereFile?.Name??this.WhereDirectory?.Name;

Expand Down
4 changes: 2 additions & 2 deletions TVRename#/TVRename/TVDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,10 +2109,10 @@ public bool CheckAllFoldersExist(List<ShowItem> showlist)
{
try
{
logger.Info("Creating directory as it is missing: {0}", folder);
Directory.CreateDirectory(folder);
logger.Info("Creating directory as it is missing: {0}",folder);
}
catch (System.IO.IOException ioe)
catch (Exception ioe)
{
logger.Info("Could not directory: {0}", folder);
logger.Info(ioe);
Expand Down
29 changes: 29 additions & 0 deletions TVRename#/Utility/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,35 @@ internal static partial class NativeMethods
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);

[DllImport("kernel32.dll")]
static extern bool AttachConsole(UInt32 dwProcessId);
private const UInt32 ATTACH_PARENT_PROCESS = 0xFFFFFFFF;

// Attach to console window – this may modify the standard handles
public static bool AttachParentConsole() =>AttachConsole(ATTACH_PARENT_PROCESS);


public static void NewConsoleOutput(string text)
{
if (AllocConsole())
{
Console.Out.WriteLine(text);
Console.In.ReadLine();

FreeConsole();
}
}


[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AllocConsole();

[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool FreeConsole();

}


Expand Down

0 comments on commit 501156c

Please sign in to comment.