Exemple #1
0
        private void page_miss(object sender, PrinterEventArgs e)
        {
            new Thread(() => { MessageBox.Show("at: " + e.time + "\nMessage from printer: " + e.worning, e.name_printer + " Page Missing !!!", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
            PrinterUserControl temp = sender as PrinterUserControl;

            next_printer();
            new Thread(() =>
            {
                Thread.Sleep(rand.r.Next(1000, 6000));
                Dispatcher.Invoke(() => { temp.add_pages(); });
                valid(temp);
            }).Start();
        }
Exemple #2
0
 public MainWindow()
 {
     InitializeComponent();
     foreach (Control item in printersGrid.Children)
     {
         if (item is PrinterUserControl)
         {
             PrinterUserControl printer = item as PrinterUserControl;
             printer.PageMissing += page_miss;
             printer.InkEmpty    += ink_empty;
             queue.Enqueue(printer);
         }
     }
     CourentPrinter = queue.Dequeue();
 }
Exemple #3
0
        private void next_printer()
        {
            PrinterUserControl temp;
            int i = 0;

            for (; i < queue.Count && !CourentPrinter.available; i++)
            {
                temp           = CourentPrinter;
                CourentPrinter = queue.Dequeue();
                queue.Enqueue(temp);
            }
            if (i == queue.Count)
            {
                printButton.IsEnabled = false;
                printButton.Content   = "Please wait";
            }
        }
Exemple #4
0
 private void valid(PrinterUserControl temp)
 {
     Dispatcher.Invoke(() =>
     {
         if (!printButton.IsEnabled)
         {
             if (temp != CourentPrinter)
             {
                 queue.Enqueue(CourentPrinter);
                 CourentPrinter = temp;
             }
             if (CourentPrinter.available)
             {
                 printButton.Content   = "Print";
                 printButton.IsEnabled = true;
             }
         }
     });
 }