// printertext.cpp : 实现文件
//

#include "stdafx.h"
#include "MFC_TSPL.h"
#include "printertext.h"
#include "afxdialogex.h"
#include "tspl_printer_base.h"


// printertext 对话框

IMPLEMENT_DYNAMIC(printertext, CDialogEx)

printertext::printertext(CWnd* pParent /*=NULL*/)
	: CDialogEx(printertext::IDD, pParent)
{

}

printertext::~printertext()
{
}

void printertext::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, x_start);
	DDX_Control(pDX, IDC_EDIT3, y_start);
	DDX_Control(pDX, IDC_EDIT4, font);
	DDX_Control(pDX, IDC_EDIT5, rotation);
	DDX_Control(pDX, IDC_EDIT6, x_mul);
	DDX_Control(pDX, IDC_EDIT7, y_mul);
	DDX_Control(pDX, IDC_EDIT8, data);
	x_start.SetWindowText(_T("50"));
	y_start.SetWindowText(_T("50"));
	font.SetWindowText(_T("3"));
	rotation.SetWindowText(_T("0"));
	x_mul.SetWindowText(_T("1"));
	y_mul.SetWindowText(_T("1"));
	data.SetWindowText(_T("中国  NO.1"));
}


BEGIN_MESSAGE_MAP(printertext, CDialogEx)
	ON_BN_CLICKED(IDOK, &printertext::OnBnClickedOk)
END_MESSAGE_MAP()


// printertext 消息处理程序


void printertext::OnBnClickedOk()
{
	// TODO:  在此添加控件通知处理程序代码
	CString x, y, txtfont, txtrotation, txt_x_mul, txt_y_mul, txt_data;
	int result = -1;
	GetDlgItemText(IDC_EDIT1, x);
	if (!(x!=""))
		AfxMessageBox(_T("横坐标起始位置不能为空！"));

	GetDlgItemText(IDC_EDIT3, y);
	if (!(y!= ""))
		AfxMessageBox(_T("纵坐标起始位置不能为空！"));

	GetDlgItemText(IDC_EDIT4, txtfont);
	if (!(txtfont != ""))
		AfxMessageBox(_T("字体选择不能为空！"));

	GetDlgItemText(IDC_EDIT5, txtrotation);
	if (!(txtrotation != ""))
		AfxMessageBox(_T("旋转选择不能为空！"));

	GetDlgItemText(IDC_EDIT6, txt_x_mul);
	if (!(txt_x_mul != ""))
		AfxMessageBox(_T("水平放大不能为空！"));

	GetDlgItemText(IDC_EDIT7, txt_y_mul);
	if (!(txt_y_mul != ""))
		AfxMessageBox(_T("垂直放大不能为空！"));

	GetDlgItemText(IDC_EDIT8, txt_data);
	if (!(txt_data != ""))
		AfxMessageBox(_T("文本内容不能为空！"));

	DemClearBuffer(hprinter);
	DemSetup(hprinter, 100, 80, 2, 6, 1, 2, 0);
	DemText(hprinter, _ttoi(x), _ttoi(y), _ttoi(txtfont), _ttoi(txtrotation), _ttoi(txt_x_mul), _ttoi(txt_y_mul), cstringtocharstring(txt_data));
	result = DemPrint(hprinter, 1, 1);
	
	//DirectIO 使用示例
	//unsigned char write[] = { 0x53, 0x45, 0x4c, 0x46, 0x54, 0x45, 0x53, 0x54, 0x0d, 0x0a };
	//unsigned int * inum;
	//result = DemDirectIO(hprinter, write, sizeof(write) / sizeof(write[0]), write, 0, inum);
	
}
