periodic commit
This commit is contained in:
parent
55c5e9aeec
commit
e130b5f07f
@ -2,7 +2,7 @@
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="ActivityNotification" Height="300" Width="300"
|
||||
Title="PDF Scribe" Height="300" Width="300"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
Background="Transparent"
|
||||
|
@ -12,29 +12,6 @@ namespace PdfScribe
|
||||
{
|
||||
public class ActivityNotificationPresenter
|
||||
{
|
||||
public ActivityNotificationPresenter(Application guiApplication)
|
||||
{
|
||||
this.activityWindowApp = guiApplication;
|
||||
this.activityWindow = new ActivityNotification();
|
||||
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);
|
||||
/*
|
||||
if (guiApplication.Dispatcher.CheckAccess())
|
||||
{
|
||||
this.activityWindow = new ActivityNotification();
|
||||
}
|
||||
else
|
||||
{
|
||||
guiApplication.Dispatcher.Invoke((Action)delegate()
|
||||
{
|
||||
this.activityWindow = new ActivityNotification();
|
||||
}
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public ActivityNotificationPresenter()
|
||||
{
|
||||
@ -42,7 +19,7 @@ namespace PdfScribe
|
||||
this.progressTimer.Enabled = false;
|
||||
this.progressTimer.Interval = 250; // Quarter second is default
|
||||
this.progressTimer.Elapsed += new SysTimers.ElapsedEventHandler(progressTimer_Elapsed);
|
||||
this.activityWindow = new ActivityNotification();
|
||||
//this.activityWindow = new ActivityNotification();
|
||||
}
|
||||
|
||||
|
||||
@ -58,11 +35,12 @@ namespace PdfScribe
|
||||
/// </summary>
|
||||
public void ShowActivityNotificationWindow()
|
||||
{
|
||||
if (this.activityWindow != null)
|
||||
if (this.activityWindow == null)
|
||||
{
|
||||
|
||||
if (this.activityWindow.Dispatcher.CheckAccess())
|
||||
{
|
||||
this.activityWindow = new ActivityNotification();
|
||||
this.activityWindow.Show();
|
||||
this.progressTimer.Start();
|
||||
}
|
||||
@ -70,6 +48,7 @@ namespace PdfScribe
|
||||
{
|
||||
this.activityWindow.Dispatcher.Invoke((Action)delegate()
|
||||
{
|
||||
this.activityWindow = new ActivityNotification();
|
||||
this.activityWindow.Show();
|
||||
this.progressTimer.Start();
|
||||
}
|
||||
@ -157,18 +136,18 @@ namespace PdfScribe
|
||||
|
||||
if (activityWindow.labelProgress.Dispatcher.CheckAccess())
|
||||
{
|
||||
EventLog.WriteEntry("PdfScribe", "Timer_No_Invoke");
|
||||
//EventLog.WriteEntry("PdfScribe", "Timer_No_Invoke");
|
||||
this.activityWindow.labelProgress.Content = this.progressString.Substring(0, progressCounter + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventLog.WriteEntry("PdfScribe", "Timer_Invoke");
|
||||
this.activityWindow.labelProgress.Dispatcher.BeginInvoke((Action)delegate()
|
||||
//EventLog.WriteEntry("PdfScribe", "Timer_Invoke");
|
||||
this.activityWindow.labelProgress.Dispatcher.Invoke((Action)delegate()
|
||||
{
|
||||
this.activityWindow.labelProgress.Content = this.progressString.Substring(0, progressCounter + 1);
|
||||
}
|
||||
);
|
||||
EventLog.WriteEntry("PdfScribe", "Timer_Invoked");
|
||||
//EventLog.WriteEntry("PdfScribe", "Timer_Invoked");
|
||||
}
|
||||
progressCounter++;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
using System.Windows.Threading;
|
||||
using PdfScribeCore;
|
||||
|
||||
namespace PdfScribe
|
||||
@ -23,7 +23,7 @@ namespace PdfScribe
|
||||
|
||||
const string errorDialogInstructionPDFGeneration = "There was a PDF generation error.";
|
||||
const string errorDialogInstructionCouldNotWrite = "Could not create the output file.";
|
||||
const string errorDialogInstructionUnexpectedError = "There was an unexpected, and unhandled error in PDF Scribe.";
|
||||
const string errorDialogInstructionUnexpectedError = "There was an unhandled error in PDF Scribe. Enable tracing for details.";
|
||||
|
||||
const string errorDialogTextFileInUse = "{0} is being used by another process.";
|
||||
const string errorDialogTextGhostScriptConversion = "Ghostscript error code {0}.";
|
||||
@ -49,14 +49,12 @@ namespace PdfScribe
|
||||
// Install the global exception handler
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Application_UnhandledException);
|
||||
|
||||
// Setup and start the WPF application that will
|
||||
// handle Windows and other displayables
|
||||
//Dispatcher.Run();
|
||||
LaunchApplication();
|
||||
userDisplay = new ActivityNotificationPresenter(guiApplication);
|
||||
userDisplay.ShowActivityNotificationWindow();
|
||||
Thread.Sleep(10000);
|
||||
//LaunchActivityNotification();
|
||||
|
||||
//Thread.Sleep(10000);
|
||||
|
||||
String standardInputFilename = Path.GetTempFileName();
|
||||
String outputFilename = Path.Combine(Path.GetTempPath(), defaultOutputFilename);
|
||||
|
||||
@ -88,9 +86,17 @@ namespace PdfScribe
|
||||
errorDialogInstructionCouldNotWrite +
|
||||
Environment.NewLine +
|
||||
"Exception message: " + ioEx.Message);
|
||||
ErrorDialogPresenter errorDialog = new ErrorDialogPresenter(errorDialogCaption,
|
||||
/*ErrorDialogPresenter errorDialog = new ErrorDialogPresenter(errorDialogCaption,
|
||||
errorDialogInstructionCouldNotWrite,
|
||||
String.Empty);
|
||||
String.Format("{0} is in use.", outputFilename));*/
|
||||
|
||||
DispatchToGUIApp((Action)delegate()
|
||||
{
|
||||
ErrorDialogPresenter errorDialog = new ErrorDialogPresenter(errorDialogCaption,
|
||||
errorDialogInstructionCouldNotWrite,
|
||||
String.Format("{0} is in use.", outputFilename));
|
||||
}
|
||||
);
|
||||
}
|
||||
catch (UnauthorizedAccessException unauthorizedEx)
|
||||
{
|
||||
@ -105,7 +111,7 @@ namespace PdfScribe
|
||||
"Exception message: " + unauthorizedEx.Message);
|
||||
ErrorDialogPresenter errorDialog = new ErrorDialogPresenter(errorDialogCaption,
|
||||
errorDialogInstructionCouldNotWrite,
|
||||
String.Empty);
|
||||
String.Format("Insufficient privileges to either create or delete {0}", outputFilename));
|
||||
}
|
||||
catch (ExternalException ghostscriptEx)
|
||||
{
|
||||
@ -132,7 +138,6 @@ namespace PdfScribe
|
||||
(int)TraceEventType.Warning,
|
||||
String.Format(warnFileNotDeleted, standardInputFilename));
|
||||
}
|
||||
if (userDisplay != null) userDisplay.CloseActivityNotificationWindow();
|
||||
ShutdownApplication();
|
||||
}
|
||||
}
|
||||
@ -153,9 +158,7 @@ namespace PdfScribe
|
||||
((Exception)e.ExceptionObject).StackTrace);
|
||||
ErrorDialogPresenter errorDialog = new ErrorDialogPresenter(errorDialogCaption,
|
||||
errorDialogInstructionUnexpectedError,
|
||||
((Exception)e.ExceptionObject).Message +
|
||||
Environment.NewLine +
|
||||
((Exception)e.ExceptionObject).StackTrace);
|
||||
String.Empty);
|
||||
}
|
||||
|
||||
static void LaunchActivityNotification()
|
||||
@ -164,8 +167,10 @@ namespace PdfScribe
|
||||
{
|
||||
guiApplication.Dispatcher.Invoke((Action)delegate()
|
||||
{
|
||||
ActivityNotificationPresenter notificationPresenter = new ActivityNotificationPresenter();
|
||||
notificationPresenter.ShowActivityNotificationWindow();
|
||||
//ActivityNotificationPresenter notificationPresenter = new ActivityNotificationPresenter();
|
||||
//notificationPresenter.ShowActivityNotificationWindow();
|
||||
ActivityNotification testWindow = new ActivityNotification();
|
||||
testWindow.Show();
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -176,9 +181,9 @@ namespace PdfScribe
|
||||
|
||||
if (guiApplication == null)
|
||||
{
|
||||
guiApplication = new Application();
|
||||
var guiApplicationThread = new Thread(new ThreadStart(() =>
|
||||
{
|
||||
guiApplication = new Application();
|
||||
guiApplication.ShutdownMode = ShutdownMode.OnExplicitShutdown;
|
||||
guiApplication.Run();
|
||||
}
|
||||
@ -189,6 +194,14 @@ namespace PdfScribe
|
||||
}
|
||||
}
|
||||
|
||||
static void DispatchToGUIApp(Action guiAction)
|
||||
{
|
||||
if (guiApplication != null)
|
||||
{
|
||||
guiApplication.Dispatcher.Invoke(guiAction);
|
||||
}
|
||||
}
|
||||
|
||||
static void ShutdownApplication()
|
||||
{
|
||||
if (guiApplication != null)
|
||||
@ -202,11 +215,15 @@ namespace PdfScribe
|
||||
appWindow.Close();
|
||||
}
|
||||
}
|
||||
guiApplication.Shutdown();
|
||||
//guiApplication.Dispatcher.InvokeShutdown();
|
||||
|
||||
}
|
||||
);
|
||||
guiApplication.Dispatcher.InvokeShutdown();
|
||||
|
||||
//guiApplication.Dispatcher.BeginInvokeShutdown(System.Windows.Threading.DispatcherPriority.Send);
|
||||
//guiApplication.Shutdown();
|
||||
//guiApplication = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user