星火微课系统客户端
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.2KB

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