periodic commit

This commit is contained in:
S T Chan 2014-01-07 21:08:13 -05:00
parent f3920e100d
commit 8268e0dab7
7 changed files with 70 additions and 80 deletions

View File

@ -35,9 +35,9 @@ namespace PdfScribe
{ {
if (this.activityWindowApp == null) if (this.activityWindowApp == null)
{ {
activityWindowApp = new Application();
var activityWindowThread = new Thread(new ThreadStart(() => var activityWindowThread = new Thread(new ThreadStart(() =>
{ {
activityWindowApp = new Application();
activityWindow = new ActivityNotification(); activityWindow = new ActivityNotification();
activityWindowApp.ShutdownMode = ShutdownMode.OnExplicitShutdown; activityWindowApp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
activityWindowApp.Run(activityWindow); activityWindowApp.Run(activityWindow);

View File

@ -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
/// <summary>
/// Default constructor
/// </summary>
public ErrorDialogPresenter()
{}
/// <summary>
/// Ctor overload that shows the
/// task dialog immediately
/// </summary>
/// <param name="captionText">Text that goes in the window caption</param>
/// <param name="instructionText">Instructional text (Appears next to the icon)</param>
/// <param name="messageText">Smaller message detail text at bottom</param>
public ErrorDialogPresenter(String captionText,
String instructionText,
String messageText)
{
ShowSimple(captionText, instructionText, messageText);
}
#endregion
/// <summary>
/// Pops up a simple TaskDialog box
/// with a standard error icon, and
/// just a Close button
/// </summary>
/// <param name="captionText">Text that goes in the window's caption</param>
/// <param name="instructionText">Instructional text (Appears next to the error icon)</param>
/// <param name="messageText">Smaller message detail text at bottom</param>
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;
}
}
}

View File

@ -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()
{
}
/// <summary>
/// Ctor that shows the
/// task dialog immediately
/// </summary>
/// <param name="captionText">Text that goes in the window caption</param>
/// <param name="instructionText">Instructional text (Appears next to the icon)</param>
/// <param name="messageText">Smaller message detail text at bottom</param>
public ErrorDialogPresenter(String captionText,
String instructionText,
String messageText) :
base(captionText, instructionText, messageText)
{
}
}
}

View File

@ -86,6 +86,8 @@
<Reference Include="Microsoft.WindowsAPICodePack"> <Reference Include="Microsoft.WindowsAPICodePack">
<HintPath>..\Lib\Microsoft.WindowsAPICodePack.dll</HintPath> <HintPath>..\Lib\Microsoft.WindowsAPICodePack.dll</HintPath>
</Reference> </Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -99,6 +101,7 @@
<Compile Include="..\Common\PdfScribeSharedAssemblyInfo.cs"> <Compile Include="..\Common\PdfScribeSharedAssemblyInfo.cs">
<Link>PdfScribeSharedAssemblyInfo.cs</Link> <Link>PdfScribeSharedAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="ErrorDialogPresenter.cs" />
<Compile Include="TaskDialogPresenter.cs" /> <Compile Include="TaskDialogPresenter.cs" />
<Compile Include="PdfScribeInstaller.cs" /> <Compile Include="PdfScribeInstaller.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@ -624,6 +624,7 @@ namespace PdfScribeCore
public bool UninstallPdfScribePrinter() public bool UninstallPdfScribePrinter()
{ {
bool printerUninstalledCleanly = true; bool printerUninstalledCleanly = true;
ErrorDialogPresenter test = new ErrorDialogPresenter();
if (!DeletePdfScribePrinter()) if (!DeletePdfScribePrinter())
printerUninstalledCleanly = false; printerUninstalledCleanly = false;

View File

@ -8,11 +8,29 @@ using APICodePack = Microsoft.WindowsAPICodePack.Dialogs;
namespace PdfScribeCore namespace PdfScribeCore
{ {
abstract class TaskDialogPresenter public abstract class TaskDialogPresenter
{ {
protected abstract APICodePack.TaskDialogStandardIcon DefaultTaskIcon { get; } // Override this to set the dialog icon you want protected abstract APICodePack.TaskDialogStandardIcon DefaultTaskIcon { get; } // Override this to set the dialog icon you want
public TaskDialogPresenter()
{ }
/// <summary>
/// Ctor that shows the
/// task dialog immediately
/// </summary>
/// <param name="captionText">Text that goes in the window caption</param>
/// <param name="instructionText">Instructional text (Appears next to the icon)</param>
/// <param name="messageText">Smaller message detail text at bottom</param>
public TaskDialogPresenter(String captionText,
String instructionText,
String messageText)
{
ShowSimple(captionText, instructionText, messageText);
}
/// <summary> /// <summary>
/// Pops up a simple TaskDialog box /// Pops up a simple TaskDialog box
/// with just a Close button and /// with just a Close button and

View File

@ -55,7 +55,7 @@ namespace PdfScribeUnitTests
scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\", String.Empty, String.Empty); scribeInstaller.InstallPdfScribePrinter(@"C:\Code\PdfScribe\Lib\", String.Empty, String.Empty);
} }
[Test] //[Test]
public void Test_UninstallPdfScribePrinter() public void Test_UninstallPdfScribePrinter()
{ {
var scribeInstaller = new PdfScribeInstaller(); var scribeInstaller = new PdfScribeInstaller();
@ -71,19 +71,20 @@ namespace PdfScribeUnitTests
#endregion #endregion
//[Test] [Test]
public void Test_ShowActivityWindows() public void Test_ShowActivityWindows()
{ {
var activityWindowTester = new PdfScribe.ActivityNotificationPresenter(); var activityWindowTester = new PdfScribe.ActivityNotificationPresenter();
activityWindowTester.ShowActivityNotificationWindow(); activityWindowTester.ShowActivityNotificationWindow();
Thread.Sleep(20000); //Thread.Sleep(20000);
//activityWindowTester.ShowErrorDialog();
activityWindowTester.CloseActivityNotificationWindow(); activityWindowTester.CloseActivityNotificationWindow();
} }
//[Test] //[Test]
public void Test_ShowSimpleError() 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 #endif