星火微课系统客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

PrintWindow.xaml.cs 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using Common.system;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Forms;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace XHWK.WKTool
  18. {
  19. /// <summary>
  20. /// 打印
  21. /// </summary>
  22. public partial class PrintWindow : Window
  23. {
  24. /// <summary>
  25. /// 下拉框数据源
  26. /// </summary>
  27. public DataTable data = new DataTable();
  28. private DataTable dtComponentsUniqueNo;
  29. public PrintWindow()
  30. {
  31. InitializeComponent();
  32. string defa = string.Empty;
  33. List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
  34. if(defaList.Count>0)
  35. {
  36. data.Columns.Add("Value");
  37. data.Columns.Add("Key");
  38. for (int i = 0; i < defaList.Count; i++)
  39. {
  40. //创建一行
  41. DataRow row = data.NewRow();
  42. //将此行添加到table中
  43. data.Rows.Add(row);
  44. data.Rows[i]["Value"] = defaList[i];
  45. data.Rows[i]["Key"] = i.ToString();
  46. }
  47. dtComponentsUniqueNo = data.DefaultView.ToTable();
  48. cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
  49. cmbClass.SelectedIndex = 0;
  50. }
  51. }
  52. public void Initialize(string _imgPath)
  53. {
  54. if(!string.IsNullOrWhiteSpace(_imgPath))
  55. {
  56. imgPri.Source = new BitmapImage(new Uri(_imgPath));
  57. }
  58. }
  59. /// <summary>
  60. /// 打印
  61. /// </summary>
  62. /// <param name="sender"></param>
  63. /// <param name="e"></param>
  64. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  65. {
  66. if(string.IsNullOrWhiteSpace(cmbClass.Text))
  67. {
  68. //MessageWindow.Show("打印机不能为空!");
  69. MessageWindow.Show("打印机不能为空!", "", MessageBoxButton.OKCancel);
  70. return;
  71. }
  72. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
  73. FileToolsCommon.CreateFile(imgPath);
  74. string pdf = imgPath + "\\101.pdf";
  75. string tpf = imgPath + "\\102.TPF";
  76. int pr = 1;
  77. string msg = string.Empty;
  78. string outPut = string.Empty;
  79. int pyte = 0; //0为方点 1为圆点
  80. //if(rbnSquarePoint.IsChecked==false)
  81. //{
  82. // pyte = 1;
  83. //}
  84. LatticeFileHelper.GeneratingPDF(pdf, tpf, out pr, out msg, out outPut/*, pyte*/);
  85. if (pr == 0)
  86. {
  87. //outPut = outPut.Replace("[", "").Replace("]", "").Replace("\"", "").Trim();
  88. //APP.OutPut = outPut.Split(',');
  89. //string []page= outPut.Split(',');
  90. //for(int i=0;i<page.Length;i++) //增加页码编号
  91. //{
  92. // APP.PageDrawList[i].PageCode = page[i];
  93. //}
  94. //string defa = string.Empty;
  95. //List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
  96. int printResult = 1;
  97. string standardError = string.Empty;
  98. string standardOutput = string.Empty;
  99. int frequency = Convert.ToInt32(txbNumberOfCopies.Text);
  100. //for (int i=0;i< frequency;i++)
  101. //{
  102. LatticeFileHelper.PrinterTPFFile(tpf, frequency, cmbClass.Text, out printResult, out standardError, out standardOutput);
  103. //}
  104. if(printResult==0)// 0为成功
  105. {
  106. MessageWindow.Show("打印成功", "", MessageBoxButton.OKCancel);
  107. }
  108. else
  109. {
  110. MessageWindow.Show(standardError, "", MessageBoxButton.OKCancel);
  111. }
  112. }
  113. else
  114. {
  115. MessageWindow.Show(msg, "", MessageBoxButton.OKCancel);
  116. }
  117. }
  118. /// <summary>
  119. /// 窗口移动
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  124. {
  125. DragMove();
  126. }
  127. /// <summary>
  128. /// 关闭
  129. /// </summary>
  130. /// <param name="sender"></param>
  131. /// <param name="e"></param>
  132. private void BtnClose_Click(object sender, RoutedEventArgs e)
  133. {
  134. this.Hide();
  135. }
  136. /// <summary>
  137. /// 减
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. private void BtnLess_Click(object sender, RoutedEventArgs e)
  142. {
  143. int num = Convert.ToInt32(txbNumberOfCopies.Text);
  144. if(num>1)
  145. {
  146. num = num - 1;
  147. txbNumberOfCopies.Text = num.ToString();
  148. }
  149. }
  150. /// <summary>
  151. /// 新增
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  156. {
  157. int num = Convert.ToInt32(txbNumberOfCopies.Text);
  158. if (num > 0)
  159. {
  160. num = num + 1;
  161. txbNumberOfCopies.Text = num.ToString();
  162. }
  163. }
  164. }
  165. }