/// <summary>
        /// This method sets up data binding sources and performs other initialization tasks.
        /// </summary>
        /// <param name="eventArgs"></param>
        public void Initialize(PrinterExtensionEventArgs eventArgs)
        {
            //
            // Populate the data binding sources.
            //

            DataContext = this;

            printerExtensionEventArgs = eventArgs;
            PrinterQueue = eventArgs.Queue;
            displayedPrintTicket = eventArgs.Ticket;

            //
            // Send a bidi query requesting ink levels.
            //
            // Please note: As this event will fire many times, it is recommended to maintain event
            // listeners for the life time of the application. Furthermore, the relationship to this
            // being invoked and the calling SendBidiQuery() is not 1:1; in fact, it is *:N, where the 
            // listener may be called several times with bidi updates.
            // 
            //

            PrinterQueue.OnBidiResponseReceived += OnBidiResponseReceived;
            PrinterQueue.SendBidiQuery("\\Printer.consumables");
        }
        /// <summary>
        /// This method sets up data binding sources and performs other initialization tasks.
        /// </summary>
        /// <param name="eventArgs"></param>
        public void Initialize(PrinterExtensionEventArgs eventArgs)
        {
            //
            // Populate the data binding sources.
            //

            DataContext = this;

            printerExtensionEventArgs = eventArgs;
            PrinterQueue         = eventArgs.Queue;
            displayedPrintTicket = eventArgs.Ticket;

            //
            // Send a bidi query requesting ink levels.
            //
            // Please note: As this event will fire many times, it is recommended to maintain event
            // listeners for the life time of the application. Furthermore, the relationship to this
            // being invoked and the calling SendBidiQuery() is not 1:1; in fact, it is *:N, where the
            // listener may be called several times with bidi updates.
            //
            //

            PrinterQueue.OnBidiResponseReceived += OnBidiResponseReceived;
            PrinterQueue.SendBidiQuery("\\Printer.consumables");
        }
        /// <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();

                    // 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.
                //
            }
        }
Esempio n. 5
0
        /// <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.
                //
            }
        }
Esempio n. 6
0
        /// <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.
                //
            }
        }