This commit is contained in:
S T Chan 2013-12-21 18:04:41 -05:00
commit a0048698e7
15 changed files with 156 additions and 63 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -8,6 +8,7 @@
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Topmost="True"> Topmost="True">
<Grid> <Grid>
<Image Name="QuillPenBackground" Source="Adobe_CreatePDF_icon.PNG" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="9,0" ></Image> <Image Name="QuillPenBackground" Source="Adobe_CreatePDF_icon.PNG" HorizontalAlignment="Center" VerticalAlignment="Top" Height="200" Width="200" ></Image>
<Label Height="29" HorizontalAlignment="Left" Margin="12,203,0,0" Name="labelProgress" VerticalAlignment="Top" Width="254" Foreground="Red" FontFamily="Arial Rounded MT" FontSize="16" HorizontalContentAlignment="Center" FontWeight="Bold" VerticalContentAlignment="Top" Content="CAPTURING" />
</Grid> </Grid>
</Window> </Window>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using SysTimers = System.Timers;
using System.Windows; using System.Windows;
@ -12,11 +13,18 @@ namespace PdfScribe
{ {
public ActivityNotificationPresenter() public ActivityNotificationPresenter()
{ {
progressTimer = new SysTimers.Timer();
progressTimer.Enabled = false;
progressTimer.Interval = 250; // Quarter second is default
progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
} }
private Application activityWindow = null;
private Application activityWindowApp = null;
private ActivityNotification activityWindow;
private SysTimers.Timer progressTimer;
readonly String progressString = "CAPTURING";
/// <summary> /// <summary>
/// Displays the floating frameless /// Displays the floating frameless
@ -25,18 +33,19 @@ namespace PdfScribe
/// </summary> /// </summary>
public void ShowActivityNotificationWindow() public void ShowActivityNotificationWindow()
{ {
if (activityWindow == null) if (this.activityWindowApp == null)
{ {
this.activityWindow = new Application();
var activityWindowThread = new Thread(new ThreadStart(() => var activityWindowThread = new Thread(new ThreadStart(() =>
{ {
activityWindow = new Application(); activityWindowApp = new Application();
activityWindow.ShutdownMode = ShutdownMode.OnExplicitShutdown; activityWindow = new ActivityNotification();
activityWindow.Run(new ActivityNotification()); activityWindowApp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
activityWindowApp.Run(activityWindow);
} }
)); ));
activityWindowThread.SetApartmentState(ApartmentState.STA); activityWindowThread.SetApartmentState(ApartmentState.STA);
activityWindowThread.Start(); activityWindowThread.Start();
this.progressTimer.Enabled = true;
} }
} }
@ -46,8 +55,40 @@ namespace PdfScribe
/// </summary> /// </summary>
public void CloseActivityNotificationWindow() public void CloseActivityNotificationWindow()
{ {
if (activityWindow != null) if (activityWindowApp != null)
activityWindow.Dispatcher.InvokeShutdown(); {
this.progressTimer.Stop();
// Close windows rather than
// just bashing the WPF application
activityWindowApp.Dispatcher.Invoke((Action)delegate()
{
foreach (Window appWindow in activityWindowApp.Windows)
{
appWindow.Close();
}
}
);
activityWindowApp.Dispatcher.InvokeShutdown();
activityWindowApp = null;
this.progressTimer.Dispose();
this.progressTimer = null;
}
}
private int progressCounter = 0;
private void progressTimer_Elapsed(object sender, SysTimers.ElapsedEventArgs e)
{
((SysTimers.Timer)sender).Enabled = false;
activityWindowApp.Dispatcher.Invoke((Action)delegate()
{
if (this.progressCounter >= progressString.Length)
this.progressCounter = 0;
activityWindow.labelProgress.Content = progressString.Substring(0, progressCounter + 1);
progressCounter++;
}
);
((SysTimers.Timer)sender).Enabled = true;
} }
} }

View File

@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0"?>
<configuration> <configuration>
</configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View File

@ -25,8 +25,8 @@ namespace PdfScribe
/// <param name="instructionText">Instructional text (Appears next to the icon)</param> /// <param name="instructionText">Instructional text (Appears next to the icon)</param>
/// <param name="messageText">Smaller message detail text at bottom</param> /// <param name="messageText">Smaller message detail text at bottom</param>
public ErrorDialogPresenter(String captionText, public ErrorDialogPresenter(String captionText,
String instructionText, String instructionText,
String messageText) String messageText)
{ {
ShowSimple(captionText, instructionText, messageText); ShowSimple(captionText, instructionText, messageText);
} }

View File

@ -11,7 +11,8 @@
<RootNamespace>PdfScribe</RootNamespace> <RootNamespace>PdfScribe</RootNamespace>
<AssemblyName>PdfScribe</AssemblyName> <AssemblyName>PdfScribe</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
@ -70,6 +71,9 @@
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.WindowsAPICodePack"> <Reference Include="Microsoft.WindowsAPICodePack">
<HintPath>..\Lib\Microsoft.WindowsAPICodePack.dll</HintPath> <HintPath>..\Lib\Microsoft.WindowsAPICodePack.dll</HintPath>
@ -118,6 +122,7 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="App.config" /> <None Include="App.config" />
<None Include="app.manifest" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>

View File

@ -127,7 +127,8 @@ namespace PdfScribe
} }
/// <summary> /// <summary>
/// All unhandled exceptions will bubble their way up here /// All unhandled exceptions will bubble their way up here -
/// a final error dialog will be displayed before the crash and burn
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>

View File

@ -8,8 +8,8 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace PdfScribe.Properties namespace PdfScribe.Properties {
{ using System;
/// <summary> /// <summary>
@ -22,28 +22,23 @@ namespace PdfScribe.Properties
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources internal class Resources {
{
private static global::System.Resources.ResourceManager resourceMan; private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture; private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() internal Resources() {
{
} }
/// <summary> /// <summary>
/// Returns the cached ResourceManager instance used by this class. /// Returns the cached ResourceManager instance used by this class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager internal static global::System.Resources.ResourceManager ResourceManager {
{ get {
get if (object.ReferenceEquals(resourceMan, null)) {
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfScribe.Properties.Resources", typeof(Resources).Assembly); global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfScribe.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp; resourceMan = temp;
} }
@ -56,14 +51,11 @@ namespace PdfScribe.Properties
/// resource lookups using this strongly typed resource class. /// resource lookups using this strongly typed resource class.
/// </summary> /// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture internal static global::System.Globalization.CultureInfo Culture {
{ get {
get
{
return resourceCulture; return resourceCulture;
} }
set set {
{
resourceCulture = value; resourceCulture = value;
} }
} }

View File

@ -8,21 +8,17 @@
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace PdfScribe.Properties namespace PdfScribe.Properties {
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default public static Settings Default {
{ get {
get
{
return defaultInstance; return defaultInstance;
} }
} }

48
PdfScribe/app.manifest Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false" /> -->
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with. Windows will automatically select the most compatible environment.-->
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</asmv1:assembly>

View File

@ -11,7 +11,8 @@
<RootNamespace>PdfScribeCore</RootNamespace> <RootNamespace>PdfScribeCore</RootNamespace>
<AssemblyName>PdfScribeCore</AssemblyName> <AssemblyName>PdfScribeCore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

View File

@ -243,7 +243,9 @@ namespace PdfScribeCore
/// <summary> /// <summary>
/// Disables WOW64 system directory file redirection /// Disables WOW64 system directory file redirection
/// if the current process is both /// if the current process is both
/// 32-bit, and running on a 64-bit OS /// 32-bit, and running on a 64-bit OS -
/// Compiling for 64-bit OS, and setting the install dir to "ProgramFiles64"
/// should ensure this code never runs in production
/// </summary> /// </summary>
/// <returns>A Handle, which should be retained to reenable redirection</returns> /// <returns>A Handle, which should be retained to reenable redirection</returns>
private IntPtr DisableWow64Redirection() private IntPtr DisableWow64Redirection()
@ -258,7 +260,9 @@ namespace PdfScribeCore
/// <summary> /// <summary>
/// Reenables WOW64 system directory file redirection /// Reenables WOW64 system directory file redirection
/// if the current process is both /// if the current process is both
/// 32-bit, and running on a 64-bit OS /// 32-bit, and running on a 64-bit OS -
/// Compiling for 64-bit OS, and setting the install dir to "ProgramFiles64"
/// should ensure this code never runs in production
/// </summary> /// </summary>
/// <param name="oldValue">A Handle value - should be retained from call to <see cref="DisableWow64Redirection"/></param> /// <param name="oldValue">A Handle value - should be retained from call to <see cref="DisableWow64Redirection"/></param>
private void RevertWow64Redirection(IntPtr oldValue) private void RevertWow64Redirection(IntPtr oldValue)

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0"?>
<configuration> <configuration>
<startup useLegacyV2RuntimeActivationPolicy="true"> <startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup> </startup>
</configuration> </configuration>

View File

@ -11,7 +11,8 @@
<RootNamespace>PdfScribeUnitTests</RootNamespace> <RootNamespace>PdfScribeUnitTests</RootNamespace>
<AssemblyName>PdfScribeUnitTests</AssemblyName> <AssemblyName>PdfScribeUnitTests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>

View File

@ -56,13 +56,16 @@ namespace PdfScribeUnitTests
#endregion #endregion
//[Test] [Test]
public void Test_ShowActivityWindows() public void Test_ShowActivityWindows()
{ {
var activityWindowTester = new PdfScribe.ActivityNotificationPresenter();
activityWindowTester.ShowActivityNotificationWindow();
Thread.Sleep(20000);
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 PdfScribe.ErrorDialogPresenter("Error Caption", "Error Instructions", "Message text");