/// <summary> /// This is the event handler invoked on various driver events. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private static void OnDriverEvent(object sender, PrinterExtensionEventArgs eventArgs) { // // Display the print preferences window. // if (eventArgs.ReasonId.Equals(PrinterExtensionReason.PrintPreferences)) { PrintPreferenceWindow printPreferenceWindow = new PrintPreferenceWindow(); printPreferenceWindow.Initialize(eventArgs); // // Set the caller application's window as parent/owner of the newly created printing preferences window. // WindowInteropHelper wih = new WindowInteropHelper(printPreferenceWindow); wih.Owner = eventArgs.WindowParent; // // Display a modal/non-modal window based on the 'WindowModal' parameter. // if (eventArgs.WindowModal) { printPreferenceWindow.ShowDialog(); } else { printPreferenceWindow.Show(); // Flash the window to draw the user's attention. This is required // because the printer extension may be drawn behind the parent window. // The return value of FlashWindow can be safely ignored if there is no need // to know if the window has focus or not. WindowHelper.FlashWindow(wih.Handle); } } else if (eventArgs.ReasonId.Equals(PrinterExtensionReason.DriverEvent)) { // // Handle driver events here. // } }
/// <summary> /// This is the event handler invoked on various driver events. /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private static void OnDriverEvent(object sender, PrinterExtensionEventArgs eventArgs) { // // Display the print preferences window. // if (eventArgs.ReasonId.Equals(PrinterExtensionReason.PrintPreferences)) { PrintPreferenceWindow printPreferenceWindow = new PrintPreferenceWindow(); printPreferenceWindow.Initialize(eventArgs); // // Set the caller application's window as parent/owner of the newly created printing preferences window. // WindowInteropHelper wih = new WindowInteropHelper(printPreferenceWindow); wih.Owner = eventArgs.WindowParent; // // Display a modal/non-modal window based on the 'WindowModal' parameter. // if (eventArgs.WindowModal) { printPreferenceWindow.ShowDialog(); } else { printPreferenceWindow.Show(); } } else if (eventArgs.ReasonId.Equals(PrinterExtensionReason.DriverEvent)) { // // Handle driver events here. // } }