private void InkEmptyFunc(object sender, PrinterEventArgs e)//event handler for ink
 {
     if (e.IsCritic)
     {
         MessageBox.Show("at:" + e.ErrorTime + "\nMessage from printer: " + e.Message, e.PrinterName + " Ink Missing!!!!!!", MessageBoxButton.OK, MessageBoxImage.Error);
         CurrentPrinter.addInk();
         queue.Enqueue(CurrentPrinter);
         CurrentPrinter = queue.Dequeue();
     }
     else
     {
         MessageBox.Show("at:" + e.ErrorTime + "\nMessage from printer: " + e.Message, e.PrinterName + " Ink Missing!!!!!!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
 private void PageMissingFunc(object sender, PrinterEventArgs e)
 {
     MessageBox.Show("at:" + e.ErrorTime + "\nMessage from printer: " + e.Message, e.PrinterName + " Page Missing!!!!!!", MessageBoxButton.OK, MessageBoxImage.Error);
     CurrentPrinter.addPages();
     if (CurrentPrinter.InkCount <= 0)//in case the ink is also missing the program activate the second event
     {
         return;
     }
     else
     {
         queue.Enqueue(CurrentPrinter);
         CurrentPrinter = queue.Dequeue();
     }
 }
        public MainWindow()//constructor for the printers
        {
            InitializeComponent();

            queue = new Queue <PrinterUserControl>();


            foreach (Control item in printersGrid.Children)//scan the grid for peinters and add them to a queue
            {
                if (item is PrinterUserControl)
                {
                    PrinterUserControl printer = item as PrinterUserControl;
                    //register to events:
                    printer.PageMissing += PageMissingFunc;
                    printer.InkEmpty    += InkEmptyFunc;
                    queue.Enqueue(printer);
                }
            }
            CurrentPrinter = queue.Dequeue();//assign the firstprinter into queue
        }