/// <summary> /// Perform initialization tasks for the printer extension in this event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_Startup(object sender, StartupEventArgs e) { // // It is recommended that exactly one instance of the PrinterExtensionManager be created per instance of // the printer extension. // if (manager != null) { return; } manager = new PrinterExtensionManager(); // // Enable events to be received on one printer driver id. // // Note: The order of adding the delegate to PrinterExtensionManager.OnDriverEvent // and invoking PrinterExtensionManager::EnableEvents is important. // Adding the delegate should be done first. // manager.OnDriverEvent += OnDriverEvent; // // It is recommended that an instance of a printer extension invoke PrinterExtensionManager::EnableEvents // for exactly one printer driver id. The printer driver id could come in from a command line argument, // thereby allowing one application binary to dynamically invoke PrinterExtensionManager::EnableEvents against // the appropriate printer driver id. // manager.EnableEvents(Guid.Parse(PrinterDriverID)); }
/// <summary> /// Perform initialization tasks for the printer extension in this event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_Startup(object sender, StartupEventArgs e) { // // It is recommended that exactly one instance of the PrinterExtensionManager be created per instance of // the printer extension. // if (manager != null) { return; } manager = new PrinterExtensionManager(); // // Enable events to be received on one printer driver id. // // Note: The order of adding the delegate to PrinterExtensionManager.OnDriverEvent // and invoking PrinterExtensionManager::EnableEvents is important. // Adding the delegate should be done first. // manager.OnDriverEvent += OnDriverEvent; // // It is recommended that an instance of a printer extension invoke PrinterExtensionManager::EnableEvents // for exactly one printer driver id. The printer driver id could come in from a command line argument, // thereby allowing one application binary to dynamically invoke PrinterExtensionManager::EnableEvents against // the appropriate printer driver id. // manager.EnableEvents(Guid.Parse(PrinterDriverID)); }
/// <summary> /// Perform uninitialization tasks for the printer extension in this event handler. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Application_Exit(object sender, ExitEventArgs e) { manager.OnDriverEvent -= OnDriverEvent; manager.DisableEvents(); manager = null; }