using Common.system;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace XHWK.WKTool
{
///
/// 打印
///
public partial class PrintWindow : Window
{
///
/// 下拉框数据源
///
public DataTable data = new DataTable();
private DataTable dtComponentsUniqueNo;
public PrintWindow()
{
InitializeComponent();
string defa = string.Empty;
List 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));
}
}
///
/// 打印
///
///
///
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";
int pr = 1;
string msg = string.Empty;
string outPut = string.Empty;
int pyte = 0; //0为方点 1为圆点
//if(rbnSquarePoint.IsChecked==false)
//{
// pyte = 1;
//}
LatticeFileHelper.GeneratingPDF(pdf, tpf, out 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 defaList = LatticeFileHelper.GetPrinterList(out defa);
int printResult = 1;
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 printResult, out standardError, out standardOutput);
//}
if(printResult==0)// 0为成功
{
MessageWindow.Show("打印成功", "", MessageBoxButton.OKCancel);
}
else
{
MessageWindow.Show(standardError, "", MessageBoxButton.OKCancel);
}
}
else
{
MessageWindow.Show(msg, "", MessageBoxButton.OKCancel);
}
}
///
/// 窗口移动
///
///
///
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
///
/// 关闭
///
///
///
private void BtnClose_Click(object sender, RoutedEventArgs e)
{
this.Hide();
}
///
/// 减
///
///
///
private void BtnLess_Click(object sender, RoutedEventArgs e)
{
int num = Convert.ToInt32(txbNumberOfCopies.Text);
if(num>1)
{
num = num - 1;
txbNumberOfCopies.Text = num.ToString();
}
}
///
/// 新增
///
///
///
private void BtnAdd_Click(object sender, RoutedEventArgs e)
{
int num = Convert.ToInt32(txbNumberOfCopies.Text);
if (num > 0)
{
num = num + 1;
txbNumberOfCopies.Text = num.ToString();
}
}
}
}