/// <summary> /// event pageMiss /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void PageMiss(object sender, EventArgs e) { PrinterEventArgs p = e as PrinterEventArgs; // show warnning MessageBox.Show("at: " + p.Date_Time.ToString() + "\nMessage from pointer: Missing " + this.currentPrinter.CurrentAmountOfPageToPrint + " pages", p.PrinterName + p.Error_Warning_Message.ToString(), MessageBoxButton.OK, MessageBoxImage.Error); this.currentPrinter.AddPages(); // add pages currentPrinter.pageLabel.Foreground = System.Windows.Media.Brushes.Black; // paint in black again queue.Enqueue(currentPrinter); // push to queue currentPrinter = queue.Dequeue(); // take the next printer from queue }
Queue <PrinterUserControl> queue; // queue of printers public MainWindow() { InitializeComponent(); queue = new Queue <PrinterUserControl>(); foreach (Control item in printersGrid.Children) { if (item is PrinterUserControl) { PrinterUserControl printer = item as PrinterUserControl; printer.PageMissing += PageMiss; // add event pageMissing printer.InkEmpty += InkEmpt; // add event inkEmpty queue.Enqueue(printer); // push to queue } } currentPrinter = queue.Dequeue(); // take one printer this.printButton.MouseEnter += Button_MouseEnter; // add event this.printButton.MouseLeave += Button_MouseLeave; // add event }
/// <summary> /// event inkEmpt /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void InkEmpt(object sender, EventArgs e) { PrinterEventArgs p = e as PrinterEventArgs; // if ink over or under 1% if (p.CriticalWarning) { // show warnning MessageBox.Show("at: " + p.Date_Time.ToString() + "\nMessage from pointer: your ink is only " + this.currentPrinter.InkCount + " %", p.PrinterName + p.Error_Warning_Message.ToString(), MessageBoxButton.OK, MessageBoxImage.Error); this.currentPrinter.AddInk(); // add ink currentPrinter.inkLabel.Foreground = System.Windows.Media.Brushes.Black; // paint in black again queue.Enqueue(currentPrinter); // push to queue currentPrinter = queue.Dequeue(); // take the next printer from queue } // if amount is low if (!p.CriticalWarning) { // show warnning MessageBox.Show("at: " + p.Date_Time.ToString() + "\nMessage from pointer: your ink is only " + this.currentPrinter.InkCount + " %", p.PrinterName + p.Error_Warning_Message.ToString(), MessageBoxButton.OK, MessageBoxImage.Exclamation); } }