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"
Topmost="True">
<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>
</Window>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using SysTimers = System.Timers;
using System.Windows;
@ -12,11 +13,18 @@ namespace PdfScribe
{
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>
/// Displays the floating frameless
@ -25,18 +33,19 @@ namespace PdfScribe
/// </summary>
public void ShowActivityNotificationWindow()
{
if (activityWindow == null)
if (this.activityWindowApp == null)
{
this.activityWindow = new Application();
var activityWindowThread = new Thread(new ThreadStart(() =>
{
activityWindow = new Application();
activityWindow.ShutdownMode = ShutdownMode.OnExplicitShutdown;
activityWindow.Run(new ActivityNotification());
activityWindowApp = new Application();
activityWindow = new ActivityNotification();
activityWindowApp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
activityWindowApp.Run(activityWindow);
}
));
activityWindowThread.SetApartmentState(ApartmentState.STA);
activityWindowThread.Start();
this.progressTimer.Enabled = true;
}
}
@ -46,8 +55,40 @@ namespace PdfScribe
/// </summary>
public void CloseActivityNotificationWindow()
{
if (activityWindow != null)
activityWindow.Dispatcher.InvokeShutdown();
if (activityWindowApp != null)
{
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>
<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="messageText">Smaller message detail text at bottom</param>
public ErrorDialogPresenter(String captionText,
String instructionText,
String messageText)
String instructionText,
String messageText)
{
ShowSimple(captionText, instructionText, messageText);
}

View File

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

View File

@ -127,7 +127,8 @@ namespace PdfScribe
}
/// <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>
/// <param name="sender"></param>
/// <param name="e"></param>

View File

@ -8,10 +8,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace PdfScribe.Properties
{
namespace PdfScribe.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@ -22,48 +22,40 @@ namespace PdfScribe.Properties
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PdfScribe.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}

View File

@ -8,21 +8,17 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace PdfScribe.Properties
{
namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[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())));
public static Settings Default
{
get
{
public static Settings Default {
get {
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>
<AssemblyName>PdfScribeCore</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">

View File

@ -243,7 +243,9 @@ namespace PdfScribeCore
/// <summary>
/// Disables WOW64 system directory file redirection
/// 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>
/// <returns>A Handle, which should be retained to reenable redirection</returns>
private IntPtr DisableWow64Redirection()
@ -258,7 +260,9 @@ namespace PdfScribeCore
/// <summary>
/// Reenables WOW64 system directory file redirection
/// 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>
/// <param name="oldValue">A Handle value - should be retained from call to <see cref="DisableWow64Redirection"/></param>
private void RevertWow64Redirection(IntPtr oldValue)

View File

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

View File

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

View File

@ -56,13 +56,16 @@ namespace PdfScribeUnitTests
#endregion
//[Test]
[Test]
public void Test_ShowActivityWindows()
{
var activityWindowTester = new PdfScribe.ActivityNotificationPresenter();
activityWindowTester.ShowActivityNotificationWindow();
Thread.Sleep(20000);
activityWindowTester.CloseActivityNotificationWindow();
}
[Test]
//[Test]
public void Test_ShowSimpleError()
{
var errorDialog = new PdfScribe.ErrorDialogPresenter("Error Caption", "Error Instructions", "Message text");