123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- using Common.system;
-
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media.Imaging;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 打印
- /// </summary>
- public partial class PrintWindow : Window
- {
- /// <summary>
- /// 下拉框数据源
- /// </summary>
- public DataTable data = new DataTable();
- private DataTable dtComponentsUniqueNo;
- public PrintWindow()
- {
- InitializeComponent();
- string defa = string.Empty;
- List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
- if (defaList.Count > 0)
- {
- data.Columns.Add("Value");
- data.Columns.Add("Key");
- for (int i = 0; i < defaList.Count; i++)
- {
- //创建一行
- DataRow row = data.NewRow();
- //将此行添加到table中
- data.Rows.Add(row);
- data.Rows[i]["Value"] = defaList[i];
- data.Rows[i]["Key"] = i.ToString();
- }
- dtComponentsUniqueNo = data.DefaultView.ToTable();
- cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
- cmbClass.SelectedIndex = 0;
- }
- }
- public void Initialize(string _imgPath)
- {
- if (!string.IsNullOrWhiteSpace(_imgPath))
- {
- imgPri.Source = new BitmapImage(new Uri(_imgPath));
- }
- }
- /// <summary>
- /// 打印
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnPrint_Click(object sender, RoutedEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(cmbClass.Text))
- {
- //MessageWindow.Show("打印机不能为空!");
- MessageWindow.Show("打印机不能为空!", "", MessageBoxButton.OKCancel);
- return;
- }
- string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
- FileToolsCommon.CreateFile(imgPath);
- string pdf = imgPath + "\\101.pdf";
- string tpf = imgPath + "\\102.TPF";
- string msg = string.Empty;
- string outPut = string.Empty;
- //if(rbnSquarePoint.IsChecked==false)
- //{
- // pyte = 1;
- //}
- LatticeFileHelper.GeneratingPDF(pdf, tpf, out int pr, out msg, out outPut/*, pyte*/);
- if (pr == 0)
- {
- //outPut = outPut.Replace("[", "").Replace("]", "").Replace("\"", "").Trim();
- //APP.OutPut = outPut.Split(',');
- //string []page= outPut.Split(',');
- //for(int i=0;i<page.Length;i++) //增加页码编号
- //{
- // APP.PageDrawList[i].PageCode = page[i];
- //}
-
- //string defa = string.Empty;
- //List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
-
- string standardError = string.Empty;
- string standardOutput = string.Empty;
- int frequency = Convert.ToInt32(txbNumberOfCopies.Text);
- //for (int i=0;i< frequency;i++)
- //{
- LatticeFileHelper.PrinterTPFFile(tpf, frequency, cmbClass.Text, out int printResult, out standardError, out standardOutput);
- //}
- if (printResult == 0)// 0为成功
- {
- MessageWindow.Show("打印成功");
- }
- else
- {
- MessageWindow.Show(standardError);
- }
- }
- else
- {
- MessageWindow.Show(msg);
- }
- }
- /// <summary>
- /// 窗口移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnClose_Click(object sender, RoutedEventArgs e)
- {
- Hide();
- }
- /// <summary>
- /// 减
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnLess_Click(object sender, RoutedEventArgs e)
- {
- int num = Convert.ToInt32(txbNumberOfCopies.Text);
- if (num > 1)
- {
- num = num - 1;
- txbNumberOfCopies.Text = num.ToString();
- }
- }
- /// <summary>
- /// 新增
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnAdd_Click(object sender, RoutedEventArgs e)
- {
- int num = Convert.ToInt32(txbNumberOfCopies.Text);
- if (num > 0)
- {
- num = num + 1;
- txbNumberOfCopies.Text = num.ToString();
- }
- }
- }
- }
|