private void printProgress(string[] taskarray, List <string> listCode) { ComboboxItem ci = skinComboBox2.SelectedItem as ComboboxItem; if (ci == null) { MessageBox.Show("选择打码机"); } string[] printer = (string [])ci.Value;//打印机名称,ip以及端口信息; if (printer[2].Length < 8) { MessageBox.Show(string.Format("ip error {0},{1}", printer[2], printer[1])); //normalPrinter print_N = new normalPrinter(); //print_N.init(); //print_N.PrintThree(taskarray, listCode); //listView1.Items.Remove(this.listView1.SelectedItems[0]); } else { //string printer_type = ci.Value.ToString(); // circularProgressBar1.Visible = true; string printer_name = ci.Text; PrintStatus one = new PrintStatus(); one.printTtoSo[0] = printer[0]; one.printTtoSo[1] = printer[2]; one.printTtoSo[2] = printer[3]; one.totalNum = Convert.ToInt32(this.info[2]); one.print_task = info[0]; TtoPrinter tp = new TtoPrinter(taskarray, listCode, one); if (printer[1].IndexOf("duo") > -1) //打码机类型 { BeginPrinting(taskarray, listCode, one, 0); skinLabel1.Text = "打印中"; } else if (printer[1].IndexOf("wdj") > -1) { BeginPrinting(taskarray, listCode, one, 1); skinLabel1.Text = "打印中"; } else if (printer[1].IndexOf("markem") > -1) { BeginPrinting(taskarray, listCode, one, 2); skinLabel1.Text = "打印中"; } Control.CheckForIllegalCrossThreadCalls = false; thread_set_progress = new Thread(new ParameterizedThreadStart(PrintNum)); thread_set_progress.IsBackground = true; thread_set_progress.Start(one); } }
public IAsyncResult BeginPrinting(string [] taskarray, List <string> listCode, PrintStatus one, int printer_type) { AysnPrintDelegate PrintDelegate = null; printer = new TtoPrinter(); printer.initPrintData(taskarray, listCode, one); if (printer_type == 0) { PrintDelegate = new AysnPrintDelegate(printer.DuoMiNuo); } else if (printer_type == 1) { PrintDelegate = new AysnPrintDelegate(printer.WDJ); } else { PrintDelegate = new AysnPrintDelegate(printer.Markem); } return(PrintDelegate.BeginInvoke(Printed, PrintDelegate)); }