periodic commit

This commit is contained in:
S T Chan 2014-01-09 11:12:37 -05:00
parent 4d2fdb79c4
commit 55c5e9aeec
4 changed files with 46 additions and 19 deletions

View File

@ -7,7 +7,7 @@
WindowStyle="None" WindowStyle="None"
Background="Transparent" Background="Transparent"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Topmost="True"> Topmost="True" ShowInTaskbar="False">
<Grid> <Grid>
<Image Name="QuillPenBackground" Source="Adobe_CreatePDF_icon.PNG" HorizontalAlignment="Center" VerticalAlignment="Top" Height="200" Width="200" ></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" /> <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" />

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
@ -14,11 +15,11 @@ namespace PdfScribe
public ActivityNotificationPresenter(Application guiApplication) public ActivityNotificationPresenter(Application guiApplication)
{ {
this.activityWindowApp = guiApplication; this.activityWindowApp = guiApplication;
this.activityWindow = new ActivityNotification();
this.progressTimer = new SysTimers.Timer(); this.progressTimer = new SysTimers.Timer();
this.progressTimer.Enabled = false; this.progressTimer.Enabled = false;
this.progressTimer.Interval = 250; // Quarter second is default this.progressTimer.Interval = 250; // Quarter second is default
this.progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed); this.progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
this.activityWindow = new ActivityNotification();
/* /*
if (guiApplication.Dispatcher.CheckAccess()) if (guiApplication.Dispatcher.CheckAccess())
{ {
@ -29,22 +30,26 @@ namespace PdfScribe
guiApplication.Dispatcher.Invoke((Action)delegate() guiApplication.Dispatcher.Invoke((Action)delegate()
{ {
this.activityWindow = new ActivityNotification(); this.activityWindow = new ActivityNotification();
progressTimer = new SysTimers.Timer();
progressTimer.Enabled = false;
progressTimer.Interval = 250; // Quarter second is default
progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
} }
); );
} }
*/ */
} }
public ActivityNotificationPresenter()
{
this.progressTimer = new SysTimers.Timer();
this.progressTimer.Enabled = false;
this.progressTimer.Interval = 250; // Quarter second is default
this.progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
this.activityWindow = new ActivityNotification();
}
private Application activityWindowApp; private Application activityWindowApp;
private ActivityNotification activityWindow = null; private ActivityNotification activityWindow = null;
private SysTimers.Timer progressTimer; private SysTimers.Timer progressTimer;
readonly String progressString = "CAPTURING"; private readonly String progressString = "CAPTURING";
/// <summary> /// <summary>
/// Displays the floating frameless /// Displays the floating frameless
@ -55,19 +60,21 @@ namespace PdfScribe
{ {
if (this.activityWindow != null) if (this.activityWindow != null)
{ {
if (this.activityWindow.Dispatcher.CheckAccess()) if (this.activityWindow.Dispatcher.CheckAccess())
{ {
this.activityWindow.Show(); this.activityWindow.Show();
this.progressTimer.Start();
} }
else else
{ {
this.activityWindow.Dispatcher.Invoke((Action)delegate() this.activityWindow.Dispatcher.Invoke((Action)delegate()
{ {
this.activityWindow.Show(); this.activityWindow.Show();
this.progressTimer.Start();
} }
); );
} }
this.progressTimer.Start();
} }
} }
@ -97,7 +104,8 @@ namespace PdfScribe
/// </summary> /// </summary>
public void CloseActivityNotificationWindow() public void CloseActivityNotificationWindow()
{ {
this.progressTimer.Enabled = false; //this.progressTimer.Elapsed -= new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
this.progressTimer.Stop();
if (this.activityWindow != null) if (this.activityWindow != null)
{ {
if (this.activityWindow.Dispatcher.CheckAccess()) if (this.activityWindow.Dispatcher.CheckAccess())
@ -114,7 +122,6 @@ namespace PdfScribe
} }
this.activityWindow = null; this.activityWindow = null;
} }
/* /*
if (activityWindowApp != null) if (activityWindowApp != null)
{ {
@ -139,9 +146,10 @@ namespace PdfScribe
private int progressCounter = 0; private int progressCounter = 0;
static Object timerElapsedLock = new Object();
private void progressTimer_Elapsed(object sender, SysTimers.ElapsedEventArgs e) private void progressTimer_Elapsed(object sender, SysTimers.ElapsedEventArgs e)
{ {
((SysTimers.Timer)sender).Enabled = false; ((SysTimers.Timer)sender).Stop();
if (activityWindow != null) if (activityWindow != null)
{ {
if (this.progressCounter >= progressString.Length) if (this.progressCounter >= progressString.Length)
@ -149,19 +157,22 @@ namespace PdfScribe
if (activityWindow.labelProgress.Dispatcher.CheckAccess()) if (activityWindow.labelProgress.Dispatcher.CheckAccess())
{ {
activityWindow.labelProgress.Content = progressString.Substring(0, progressCounter + 1); EventLog.WriteEntry("PdfScribe", "Timer_No_Invoke");
this.activityWindow.labelProgress.Content = this.progressString.Substring(0, progressCounter + 1);
} }
else else
{ {
activityWindow.labelProgress.Dispatcher.Invoke((Action)delegate() EventLog.WriteEntry("PdfScribe", "Timer_Invoke");
this.activityWindow.labelProgress.Dispatcher.BeginInvoke((Action)delegate()
{ {
activityWindow.labelProgress.Content = progressString.Substring(0, progressCounter + 1); this.activityWindow.labelProgress.Content = this.progressString.Substring(0, progressCounter + 1);
} }
); );
EventLog.WriteEntry("PdfScribe", "Timer_Invoked");
} }
progressCounter++; progressCounter++;
((SysTimers.Timer)sender).Enabled = true;
} }
((SysTimers.Timer)sender).Start();
} }
} }

View File

@ -54,7 +54,8 @@ namespace PdfScribe
LaunchApplication(); LaunchApplication();
userDisplay = new ActivityNotificationPresenter(guiApplication); userDisplay = new ActivityNotificationPresenter(guiApplication);
userDisplay.ShowActivityNotificationWindow(); userDisplay.ShowActivityNotificationWindow();
//Thread.Sleep(20000); Thread.Sleep(10000);
//LaunchActivityNotification();
String standardInputFilename = Path.GetTempFileName(); String standardInputFilename = Path.GetTempFileName();
String outputFilename = Path.Combine(Path.GetTempPath(), defaultOutputFilename); String outputFilename = Path.Combine(Path.GetTempPath(), defaultOutputFilename);
@ -131,7 +132,7 @@ namespace PdfScribe
(int)TraceEventType.Warning, (int)TraceEventType.Warning,
String.Format(warnFileNotDeleted, standardInputFilename)); String.Format(warnFileNotDeleted, standardInputFilename));
} }
userDisplay.CloseActivityNotificationWindow(); if (userDisplay != null) userDisplay.CloseActivityNotificationWindow();
ShutdownApplication(); ShutdownApplication();
} }
} }
@ -157,6 +158,19 @@ namespace PdfScribe
((Exception)e.ExceptionObject).StackTrace); ((Exception)e.ExceptionObject).StackTrace);
} }
static void LaunchActivityNotification()
{
if (guiApplication != null)
{
guiApplication.Dispatcher.Invoke((Action)delegate()
{
ActivityNotificationPresenter notificationPresenter = new ActivityNotificationPresenter();
notificationPresenter.ShowActivityNotificationWindow();
}
);
}
}
static void LaunchApplication() static void LaunchApplication()
{ {
@ -170,6 +184,7 @@ namespace PdfScribe
} }
)); ));
guiApplicationThread.SetApartmentState(ApartmentState.STA); guiApplicationThread.SetApartmentState(ApartmentState.STA);
guiApplicationThread.IsBackground = true;
guiApplicationThread.Start(); guiApplicationThread.Start();
} }
} }
@ -191,7 +206,7 @@ namespace PdfScribe
} }
); );
guiApplication.Dispatcher.InvokeShutdown(); guiApplication.Dispatcher.InvokeShutdown();
guiApplication = null; //guiApplication.Shutdown();
} }
} }
} }

View File

@ -51,6 +51,7 @@ namespace PdfScribeCore
simpleTaskDialog.Icon = this.DefaultTaskIcon; simpleTaskDialog.Icon = this.DefaultTaskIcon;
simpleTaskDialog.StandardButtons = APICodePack.TaskDialogStandardButtons.Close; simpleTaskDialog.StandardButtons = APICodePack.TaskDialogStandardButtons.Close;
simpleTaskDialog.Opened += new EventHandler(simpleTaskDialog_Opened); simpleTaskDialog.Opened += new EventHandler(simpleTaskDialog_Opened);
simpleTaskDialog.StartupLocation = APICodePack.TaskDialogStartupLocation.CenterScreen;
simpleTaskDialog.Show(); simpleTaskDialog.Show();
} }
} }