星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

PrintWindow.xaml.cs 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace XHWK.WKTool
  17. {
  18. /// <summary>
  19. /// 打印
  20. /// </summary>
  21. public partial class PrintWindow : Window
  22. {
  23. /// <summary>
  24. /// 下拉框数据源
  25. /// </summary>
  26. public DataTable data = new DataTable();
  27. public PrintWindow()
  28. {
  29. InitializeComponent();
  30. string defa = string.Empty;
  31. List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
  32. if(defaList.Count>0)
  33. {
  34. data.Columns.Add("Value");
  35. data.Columns.Add("Key");
  36. for (int i = 0; i < defaList.Count; i++)
  37. {
  38. //创建一行
  39. DataRow row = data.NewRow();
  40. //将此行添加到table中
  41. data.Rows.Add(row);
  42. data.Rows[i]["Value"] = defaList[i];
  43. data.Rows[i]["Key"] = i.ToString();
  44. }
  45. //dtComponentsUniqueNo = data.DefaultView.ToTable();
  46. //cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
  47. cmbClass.SelectedIndex = 0;
  48. }
  49. }
  50. public void Initialize(string _imgPath)
  51. {
  52. }
  53. /// <summary>
  54. /// 打印机下拉框改变事件
  55. /// </summary>
  56. /// <param name="sender"></param>
  57. /// <param name="e"></param>
  58. private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e)
  59. {
  60. }
  61. /// <summary>
  62. /// 打印
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  67. {
  68. int pr = 1;
  69. string msg = string.Empty;
  70. string outPut = string.Empty;
  71. LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF", out pr, out msg, out outPut);
  72. if (pr == 0)
  73. {
  74. outPut = outPut.Replace("[", "").Replace("]", "").Replace("\"", "").Trim();
  75. APP.OutPut = outPut.Split(',');
  76. string defa = string.Empty;
  77. List<string> defaList = LatticeFileHelper.GetPrinterList(out defa);
  78. int printResult = 1;
  79. string standardError = string.Empty;
  80. string standardOutput = string.Empty;
  81. LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF", 1, /*defa*/"导出为WPS PDF", out printResult, out standardError, out standardOutput);
  82. }
  83. }
  84. }
  85. }