diff --git a/PdfScribe/ActivityNotificationPresenter.cs b/PdfScribe/ActivityNotificationPresenter.cs index fc7a067..84e2d89 100644 --- a/PdfScribe/ActivityNotificationPresenter.cs +++ b/PdfScribe/ActivityNotificationPresenter.cs @@ -35,9 +35,9 @@ namespace PdfScribe { if (this.activityWindowApp == null) { + activityWindowApp = new Application(); var activityWindowThread = new Thread(new ThreadStart(() => { - activityWindowApp = new Application(); activityWindow = new ActivityNotification(); activityWindowApp.ShutdownMode = ShutdownMode.OnExplicitShutdown; activityWindowApp.Run(activityWindow); diff --git a/PdfScribe/ErrorDialogPresenter.cs b/PdfScribe/ErrorDialogPresenter.cs deleted file mode 100644 index 52fd42f..0000000 --- a/PdfScribe/ErrorDialogPresenter.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; - -using APICodePack = Microsoft.WindowsAPICodePack.Dialogs; - -namespace PdfScribe -{ - public class ErrorDialogPresenter - { - #region Ctor - /// - /// Default constructor - /// - public ErrorDialogPresenter() - {} - - /// - /// Ctor overload that shows the - /// task dialog immediately - /// - /// Text that goes in the window caption - /// Instructional text (Appears next to the icon) - /// Smaller message detail text at bottom - public ErrorDialogPresenter(String captionText, - String instructionText, - String messageText) - { - ShowSimple(captionText, instructionText, messageText); - } - - #endregion - - /// - /// Pops up a simple TaskDialog box - /// with a standard error icon, and - /// just a Close button - /// - /// Text that goes in the window's caption - /// Instructional text (Appears next to the error icon) - /// Smaller message detail text at bottom - public void ShowSimple(String captionText, - String instructionText, - String messageText) - { - using (APICodePack.TaskDialog errorDialog = new APICodePack.TaskDialog()) - { - errorDialog.Caption = captionText; - errorDialog.InstructionText = instructionText; - errorDialog.Text = messageText; - errorDialog.Icon = APICodePack.TaskDialogStandardIcon.Error; - errorDialog.StandardButtons = APICodePack.TaskDialogStandardButtons.Close; - errorDialog.Opened += new EventHandler(errorDialog_Opened); - errorDialog.Show(); - } - } - - private void errorDialog_Opened(object sender, EventArgs e) - { - // Really fucking annoying - - // There's a bug somewhere in the API Code Pack that - // causes the icon not to show - // unless you set it on the Opened event - // See: http://stackoverflow.com/questions/15645592/taskdialogstandardicon-not-working-on-task-dialog - // One of these days I'll try to find and fix it (honestly I hope - // someone else fixes first - also why isn't the API Code pack on codeplex - // or github so people can push patches), but until then... - ((APICodePack.TaskDialog)sender).Icon = APICodePack.TaskDialogStandardIcon.Error; - } - - } -} diff --git a/PdfScribeCore/ErrorDialogPresenter.cs b/PdfScribeCore/ErrorDialogPresenter.cs new file mode 100644 index 0000000..a8f1b9e --- /dev/null +++ b/PdfScribeCore/ErrorDialogPresenter.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; + +using APICodePack = Microsoft.WindowsAPICodePack.Dialogs; + +namespace PdfScribeCore +{ + public class ErrorDialogPresenter : TaskDialogPresenter + { + protected override APICodePack.TaskDialogStandardIcon DefaultTaskIcon + { + get { return APICodePack.TaskDialogStandardIcon.Error; } + } + + public ErrorDialogPresenter() + : base() + { + + } + + /// + /// Ctor that shows the + /// task dialog immediately + /// + /// Text that goes in the window caption + /// Instructional text (Appears next to the icon) + /// Smaller message detail text at bottom + public ErrorDialogPresenter(String captionText, + String instructionText, + String messageText) : + base(captionText, instructionText, messageText) + { + } + + + + } +} diff --git a/PdfScribeCore/PdfScribeCore.csproj b/PdfScribeCore/PdfScribeCore.csproj index bf2c97a..55189ef 100644 --- a/PdfScribeCore/PdfScribeCore.csproj +++ b/PdfScribeCore/PdfScribeCore.csproj @@ -86,6 +86,8 @@ ..\Lib\Microsoft.WindowsAPICodePack.dll + + @@ -99,6 +101,7 @@ PdfScribeSharedAssemblyInfo.cs + diff --git a/PdfScribeCore/PdfScribeInstaller.cs b/PdfScribeCore/PdfScribeInstaller.cs index 7c299b8..e175798 100644 --- a/PdfScribeCore/PdfScribeInstaller.cs +++ b/PdfScribeCore/PdfScribeInstaller.cs @@ -624,6 +624,7 @@ namespace PdfScribeCore public bool UninstallPdfScribePrinter() { bool printerUninstalledCleanly = true; + ErrorDialogPresenter test = new ErrorDialogPresenter(); if (!DeletePdfScribePrinter()) printerUninstalledCleanly = false; diff --git a/PdfScribeCore/TaskDialogPresenter.cs b/PdfScribeCore/TaskDialogPresenter.cs index 3d6d5e6..dbe758c 100644 --- a/PdfScribeCore/TaskDialogPresenter.cs +++ b/PdfScribeCore/TaskDialogPresenter.cs @@ -8,11 +8,29 @@ using APICodePack = Microsoft.WindowsAPICodePack.Dialogs; namespace PdfScribeCore { - abstract class TaskDialogPresenter + public abstract class TaskDialogPresenter { protected abstract APICodePack.TaskDialogStandardIcon DefaultTaskIcon { get; } // Override this to set the dialog icon you want + + public TaskDialogPresenter() + { } + + /// + /// Ctor that shows the + /// task dialog immediately + /// + /// Text that goes in the window caption + /// Instructional text (Appears next to the icon) + /// Smaller message detail text at bottom + public TaskDialogPresenter(String captionText, + String instructionText, + String messageText) + { + ShowSimple(captionText, instructionText, messageText); + } + /// /// Pops up a simple TaskDialog box /// with just a Close button and diff --git a/PdfScribeUnitTests/UnitTests.cs b/PdfScribeUnitTests/UnitTests.cs index 3ed0932..7728719 100644 --- a/PdfScribeUnitTests/UnitTests.cs +++ b/PdfScribeUnitTests/UnitTests.cs @@ -55,7 +55,7 @@ namespace PdfScribeUnitTests scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\", String.Empty, String.Empty); } - [Test] + //[Test] public void Test_UninstallPdfScribePrinter() { var scribeInstaller = new PdfScribeInstaller(); @@ -71,19 +71,20 @@ namespace PdfScribeUnitTests #endregion - //[Test] + [Test] public void Test_ShowActivityWindows() { var activityWindowTester = new PdfScribe.ActivityNotificationPresenter(); activityWindowTester.ShowActivityNotificationWindow(); - Thread.Sleep(20000); + //Thread.Sleep(20000); + //activityWindowTester.ShowErrorDialog(); activityWindowTester.CloseActivityNotificationWindow(); } //[Test] public void Test_ShowSimpleError() { - var errorDialog = new PdfScribe.ErrorDialogPresenter("Error Caption", "Error Instructions", "Message text"); + var errorDialog = new PdfScribeCore.ErrorDialogPresenter("Error Caption", "Error Instructions", "Message text"); } #endif