Fix a few more code issues

This commit is contained in:
Ben Olden-Cooligan 2017-05-24 00:05:40 -04:00
parent 6c22e06f1e
commit aea31028a4
6 changed files with 11 additions and 29 deletions

View File

@ -9,7 +9,7 @@ namespace NAPS2.Automation
{
public void DisplayError(string errorMessage)
{
System.Console.WriteLine(errorMessage);
Console.WriteLine(errorMessage);
}
public void DisplayError(string errorMessage, string details)

View File

@ -57,10 +57,7 @@ namespace NAPS2.Host
throw;
}
if (_hostProcess != null)
{
_hostProcess.StandardOutput.Read();
}
_hostProcess?.StandardOutput.Read();
}
public static IX86HostService Connect()

View File

@ -106,9 +106,9 @@ namespace NAPS2.ImportExport
{
firstFileSaved = subPath;
}
if (op.Status.Success && notify != null)
if (op.Status.Success)
{
notify.PdfSaved(subPath);
notify?.PdfSaved(subPath);
}
return op.Status.Success;
}
@ -124,9 +124,9 @@ namespace NAPS2.ImportExport
{
firstFileSaved = op.FirstFileSaved;
}
if (op.Status.Success && notify != null)
if (op.Status.Success)
{
notify.ImagesSaved(images.Count, op.FirstFileSaved);
notify?.ImagesSaved(images.Count, op.FirstFileSaved);
}
return op.Status.Success;
}

View File

@ -26,28 +26,19 @@ namespace NAPS2.Operation
protected void InvokeFinished()
{
if (Finished != null)
{
Finished.Invoke(this, new EventArgs());
}
Finished?.Invoke(this, new EventArgs());
}
protected void InvokeStatusChanged()
{
if (StatusChanged != null)
{
StatusChanged.Invoke(this, new EventArgs());
}
StatusChanged?.Invoke(this, new EventArgs());
}
protected void InvokeError(string message, Exception exception)
{
var args = new OperationErrorEventArgs(message, exception);
LastError = args;
if (Error != null)
{
Error.Invoke(this, args);
}
Error?.Invoke(this, args);
}
}
}

View File

@ -128,10 +128,7 @@ namespace NAPS2.Scan.Images
public void SetThumbnail(Bitmap bitmap)
{
if (thumbnail != null)
{
thumbnail.Dispose();
}
thumbnail?.Dispose();
thumbnail = bitmap;
}

View File

@ -105,10 +105,7 @@ namespace NAPS2.Util
Registry.LocalMachine.DeleteSubKey(REGKEY_AUTOPLAY_HANDLER_NAPS2, false);
using (var key2 = Registry.LocalMachine.OpenSubKey(REGKEY_STI_APP, true))
{
if (key2 != null)
{
key2.DeleteValue("NAPS2", false);
}
key2?.DeleteValue("NAPS2", false);
}
Registry.LocalMachine.DeleteSubKey(REGKEY_STI_EVENT_NAPS2, false);