private void OnJobCompleted(PrintJobDataEventArgs e) { EventHandler <PrintJobDataEventArgs> handler = JobCompleted; if (handler != null) { handler(this, e); } }
private void OnPrintJobCancelled(PrintJobDataEventArgs e) { EventHandler <PrintJobDataEventArgs> handler = PrintJobCancelled; if (handler != null) { handler(this, e); } }
private void OnAllowedTitleAdded(PrintJobDataEventArgs e) { EventHandler <PrintJobDataEventArgs> handler = AllowedTitleAdded; if (handler != null) { handler(this, e); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalWatcherPrintJobCompleted(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug(); if (e != null && e.Data != null) { if (_watchers != null && _watchers.Count > 0) { _watchers.RemoveWatcher(e.Data); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LocalPrintEventWatcherPrintJobStarted(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug(); // check the event args if (e != null && e.Data != null && e.Data.PrintJobTitle != null) { // add watcher for the specified data _watchers.AddWatcher(new PrintJobWatcher(e.Data.PrintJobTitle)); } }
/// Watcher Subscriptions #region Watcher Subscriptions /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalPrintEventWatcherPrintJobPaused(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug(); // check the event args if (e != null && e.Data != null) { // launch UI for the specified data LaunchPrintControl(e.Data); } }
private void LocalPrintEventWatcher_AllowedTitleAdded(object sender, PrintJobDataEventArgs e) { // check event arguments and data if (e != null && e.Data != null) { // check if it's virtual printer if (ConfigData.PrinterName.Equals(e.Data.PrintJobTitle.PrinterName) || ConfigData.PrinterName2.Equals(e.Data.PrintJobTitle.PrinterName)) { // show preparing progress ShowProgressWindow("Preparing", "Your document is being prepared for printing, please wait..."); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalPrintEventWatcherPrintJobCompleted(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug(); // check the event args if (e != null && e.Data != null) { // check the watchers and remove the watcher for the specified data if (_watchers != null && _watchers.Count > 0) { _watchers.RemoveWatcher(e.Data); } } }
void LocalWatcherPrintJobCancelled(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug("Cancelled 2! " + e.Data.PrintJobTitle.MegaToString()); if (_watchers != null && _watchers.Count > 0) { _watchers.RemoveWatcher(e.Data); } if (!cancelledShowing) { cancelledShowing = true; Notifier.Warning(string.Format("You are not allowed to choose this printer.{0}You have to use {1} or {2} instead.{0}Printing cancelled.", Environment.NewLine, ConfigData.PrinterName, ConfigData.PrinterName2)); cancelledShowing = false; } }
/// <summary> /// Notify user on PrintQueue error /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void printer_PrintQueueError(object sender, PrintJobDataEventArgs e) { // Check added for object type if (null != sender) { Printer.Printer printer = sender as Printer.Printer; Thread confirmationMsgBoxThread = new Thread(new ThreadStart(CheckUserConfirmation)); TimeSpan timeOut = new TimeSpan(0, 30, 0); confirmationMsgBoxThread.Start(); DateTime startTime = DateTime.Now; do { // Case 1: Wait for timeOut and kill the thread if no response from the user if (startTime.Add(timeOut) <= DateTime.Now) { // Used to notify that PrintQueue error was not cleared _abort = true; KillMessageBox(confirmationMsgBoxThread); return; } // Wait from 30 seconds and check the status of PrintQueue Thread.Sleep(TimeSpan.FromSeconds(30)); // Case 2: If PrintQueue error is rectified from user or if PrintQueue recovers from error, kill message box if (!printer.IsPrintQueueInError) { KillMessageBox(confirmationMsgBoxThread); return; } } while (!_abort); // If user has clicked Cancel button, abort the thread if (!_abort) { confirmationMsgBoxThread.Abort(); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalWatcherPrintJobStarted(object sender, PrintJobDataEventArgs e) { /* * LogHelper.LogDebug(); * try * { * if (e != null) * { * if (e.Data != null) * { * if (e.Data.PrintJobTitle != null) * { * _watchers.AddWatcher(new PrintJobWatcher(e.Data.PrintJobTitle)); * } * } * } * } * catch (Exception ex) * { * Notifier.Error(ex); * }*/ }
private void UpdateJobCount(object sender, PrintJobDataEventArgs e) { if (e.Job.Status.HasFlag(JobStatus.Deleted)) { if (!string.IsNullOrEmpty(e.Job.PrinterName)) { string key = e.Job.PrinterName.ToUpperInvariant(); if (_jobCountCache.ContainsKey(key)) { // Protect from overflow. if (_jobCountCache[key].JobsPrinted != int.MaxValue) { _jobCountCache[key].JobsPrinted++; } } else { TraceFactory.Logger.Debug("Key not found: " + key); } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalPrintEventWatcherPrintJobCancelled(object sender, PrintJobDataEventArgs e) { // check the event args if (e != null && e.Data != null) { LogHelper.LogDebug("Cancelled WPF! " + e.Data.PrintJobTitle.MegaToString()); // check the watchers and remove the watcher for the specified data if (_watchers != null && _watchers.Count > 0) { _watchers.RemoveWatcher(e.Data); } // check if able to show job cancelled message if (!cancelledShowing) { // show only one message about cancelling the job cancelledShowing = true; WPFNotifier.Warning(string.Format("You are not allowed to choose this printer.{0}You have to use {1} or {2} instead.{0}Printing cancelled.", Environment.NewLine, ConfigData.PrinterName, ConfigData.PrinterName2)); cancelledShowing = false; } } }
/// Watcher Subscriptions #region Watcher Subscriptions /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LocalWatcherPrintJobPaused(object sender, PrintJobDataEventArgs e) { LogHelper.LogDebug(); LaunchPrintControl(e.Data); }
/// Event Handlers #region Event Handlers /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void watcher_JobCompleted(object sender, PrintJobDataEventArgs e) { OnJobCompleted(e); }
private void _printJobMonitor_PrintJobMonitoringFinished(object sender, PrintJobDataEventArgs e) { LogPrintJob(e.Job); UpdateJobCount(sender, e); PrintJobEnded?.Invoke(sender, e); }
/// Watcher SSS Event Handlers #region Watcher SSS Event Handlers /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _watchers_JobCompleted(object sender, PrintJobDataEventArgs e) { }