twain3.0/huagao/CBasicPage.cpp

474 lines
12 KiB
C++
Raw Normal View History

// CBasicPage.cpp: 实现文件
//
#include "stdafx.h"
#include "CBasicPage.h"
#include "afxdialogex.h"
#include "resource.h"
#include "CAboutDlg.h"
2021-11-20 03:09:04 +00:00
#include "CAttributeDlg.h"
#include "CTwainUI.h"
#include "CDiscardBlankSetting.h"
#include "CcardblankDlg.h"
#include <vector>
static std::vector<CString> color_Modes = {
_T("24位彩色"),
_T("256级灰度"),
_T("黑白"),
_T("颜色自动识别")
};
#ifdef G200
static std::vector<CString> surportStyles = {
_T("A3"),//pass
_T("8开"),
_T("A4"),
_T("A4横向"),
_T("16开"),
_T("16开横向"),
_T("A5"),
_T("A5横向"),
_T("A6"),
_T("A6横向"),
_T("B4"),
_T("B5"),
_T("B5横向"),
_T("B6"),
_T("B6横向"),
_T("Letter"),
_T("Letter横向"),
_T("Double Letter"),//pass
_T("LEGAL"),
_T("匹配原始尺寸"),
_T("最大扫描尺寸自动裁切"),
_T("最大扫描尺寸"),
_T("三联试卷"),
};
#endif
#ifdef G300
static std::vector<CString> surportStyles = {
_T("A4"),
_T("16开"),
_T("A5"),
_T("A6"),
//_T("B4"),
_T("B5"),
_T("B6"),
_T("Letter"),
_T("LEGAL"),
_T("匹配原始尺寸"),
2022-05-24 12:05:47 +00:00
#ifndef ANDROIDSERIAL
_T("最大扫描尺寸自动裁切"),
_T("最大扫描尺寸"),
#endif // !ANDROIDSERIAL
};
#endif
#ifdef G400
static std::vector<CString> surportStyles = {
_T("A3"),//pass
_T("8开"),
_T("A4"),
_T("A4横向"),
_T("16开"),
_T("16开横向"),
_T("A5"),
_T("A5横向"),
_T("A6"),
_T("A6横向"),
_T("B4"),
_T("B5"),
_T("B5横向"),
_T("B6"),
_T("B6横向"),
_T("Letter"),
_T("Letter横向"),
_T("Double Letter"),//pass
_T("LEGAL"),
_T("匹配原始尺寸"),
2021-11-20 03:09:04 +00:00
#ifndef ANDROIDSERIAL
_T("最大扫描尺寸自动裁切"),
_T("最大扫描尺寸"),
_T("三联试卷"),
2021-11-20 03:09:04 +00:00
#endif // !ANDROIDSERIAL
};
#endif // G400
//static std::vector<CString> reslutions{
// _T("100"),
// _T("150"),
// _T("200"),
// _T("240"),
// _T("300"),
//#ifndef LANXUM
// //_T("600")
//#endif // LANXUM
//};
static std::vector<CString> duplexs
{
_T("单面"),
_T("双面"),
_T("跳过空白页(通用)"),
_T("跳过空白页(发票纸)"),
_T("对折")
};
// CBasicPage 对话框
IMPLEMENT_DYNAMIC(CBasicPage, CTabPageSSL)
CBasicPage::CBasicPage(std::function<void()> dataChange, CWnd* pParent /*=nullptr*/)
: CTabPageSSL(IDD_PAGEBASIC, pParent)
, m_dataChange(dataChange)
, AreaNum(8)
, DevnMax(200)
, m_bswitchfrontback(FALSE)
, discardblank_percent(10)
{
}
CBasicPage::~CBasicPage()
{
}
void CBasicPage::DoDataExchange(CDataExchange* pDX)
{
CTabPageSSL::DoDataExchange(pDX);
DDX_Check(pDX, IDC_CKBSWITCHFRONTBACK, m_bswitchfrontback);
DDX_Check(pDX, IDC_CKBSIZEDETECT, m_enableSizeCheck);
DDX_Control(pDX, IDC_SLIDERDPI, m_Slider_Dpi);
DDX_Control(pDX, IDC_EDITDPI, m_Edit_Dpi);
DDX_Check(pDX, IDC_CKBENABLEUV, m_bUV);
}
BOOL CBasicPage::OnInitDialog()
{
CTabPageSSL::OnInitDialog();
m_cmBoxColorMode = (CComboBox*)GetDlgItem(IDC_CMBCOLORTYPE);
m_cmBoxSS = (CComboBox*)GetDlgItem(IDC_CMBSS);
m_cmBoxDuplex = (CComboBox*)GetDlgItem(IDC_CMBDUPLEX);
m_Edit_Dpi.SetSlideLink(this, IDC_SLIDERDPI);
2022-06-29 12:24:24 +00:00
m_Edit_Dpi.SetParams(100, 300, 10);
m_Edit_Dpi.SetValue(200);
for (const CString& colorMode : color_Modes)
m_cmBoxColorMode->AddString(colorMode);
for (int i = 0; i < surportStyles.size(); i++)
m_cmBoxSS->InsertString(i, surportStyles[i]);
for (int i = 0; i < duplexs.size(); i++)
m_cmBoxDuplex->InsertString(i,duplexs[i]);
m_cmBoxSS->SetCurSel(0);
m_cmBoxColorMode->SetCurSel(0);
m_cmBoxDuplex->SetCurSel(0);
2022-05-24 12:05:47 +00:00
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(FALSE);
#ifndef UV
GetDlgItem(IDC_CKBENABLEUV)->ShowWindow(FALSE);
#endif
2021-11-20 03:09:04 +00:00
GetDlgItem(IDC_BTN_ATTRIBYTE)->ShowWindow(SW_HIDE);
return true;
}
BEGIN_MESSAGE_MAP(CBasicPage, CTabPageSSL)
ON_BN_CLICKED(IDC_BTNABOUT, &CBasicPage::OnBnClickedBtnabout)
ON_CBN_SELCHANGE(IDC_CMBCOLORTYPE, &CBasicPage::OnCbnSelchangeCmbcolortype)
ON_CBN_SELCHANGE(IDC_CMBSS, &CBasicPage::OnCbnSelchangeCmbss)
ON_CBN_SELCHANGE(IDC_CMBRESLUTION, &CBasicPage::OnCbnSelchangeCmbreslution)
ON_CBN_SELCHANGE(IDC_CMBDUPLEX, &CBasicPage::OnCbnSelchangeCmbduplex)
ON_BN_CLICKED(IDC_BTNDISCARDSETTING, &CBasicPage::OnClickedBtndiscardsetting)
2021-09-23 01:19:47 +00:00
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDERDPI, &CBasicPage::OnNMReleasedcaptureSliderdpi)
2021-11-20 03:09:04 +00:00
ON_BN_CLICKED(IDC_BTN_ATTRIBYTE, &CBasicPage::OnBnClickedBtnAttribyte)
2022-05-24 12:05:47 +00:00
ON_EN_CHANGE(IDC_EDITDPI, &CBasicPage::OnEnChangeEditdpi)
ON_BN_CLICKED(IDC_RDSPEEDPRIORITY, &CBasicPage::OnBnClickedRdspeedpriority)
ON_BN_CLICKED(IDC_RDQUALITYPRIORITY, &CBasicPage::OnBnClickedRdqualitypriority)
END_MESSAGE_MAP()
// CBasicPage 消息处理程序
void CBasicPage::OnBnClickedBtnabout()
{
2022-05-24 12:05:47 +00:00
#ifndef NOLOGO
CAboutDlg dlg(m_hdVersion, m_serialNum, m_macadder, this);
dlg.DoModal();
2022-05-24 12:05:47 +00:00
#else
#ifdef G300
std::string text = "扫描仪名称:\t\tG300 \n固件版本:\t\t\t";
#elif defined G400
std::string text = "扫描仪名称:\t\tG400 \n固件版本:\t\t\t";
#elif defined G200 && defined ISG100
std::string text = "扫描仪名称:\t\tG100 \n固件版本:\t\t\t";
#else
std::string text = "扫描仪名称:\t\tG200 \n固件版本:\t\t\t";
#endif
text += m_hdVersion.c_str();
text += "\n序列号:\t\t\t";
text += m_serialNum.c_str();
::MessageBox(this->GetSafeHwnd(), CString(text.c_str()), L"关于",0);
#endif // !NOLOGO
}
void CBasicPage::OnCbnSelchangeCmbcolortype()
{
// TODO: 在此添加控件通知处理程序代码
updateCmbDuplex(TRUE);
m_dataChange();
}
void CBasicPage::OnCbnSelchangeCmbss()
{
// TODO: 在此添加控件通知处理程序代码
int sleIndex = m_cmBoxSS->GetCurSel();
if (sleIndex == -1)
{
sleIndex = 0;
}
updateCmbDuplex(TRUE);
m_dataChange();
}
void CBasicPage::OnCbnSelchangeCmbreslution()
{
// TODO: 在此添加控件通知处理程序代码
updateCmbDuplex(TRUE);
}
void CBasicPage::OnCbnSelchangeCmbduplex()
{
// TODO: 在此添加控件通知处理程序代码
int index = m_cmBoxDuplex->GetCurSel();
//if (index > 1) {
//AreaNum = index == 2? 8 : 20 ;
//DevnMax = index == 2 ? 200 : 300;
m_dataChange();
//}
if (m_cmBoxDuplex->GetCurSel() == 2 || m_cmBoxDuplex->GetCurSel() == 3)
this->GetDlgItem(IDC_BTNDISCARDSETTING)->EnableWindow(true);
else
this->GetDlgItem(IDC_BTNDISCARDSETTING)->EnableWindow(false);
updateCmbDuplex(TRUE);
}
//跳过空白页设置页面
void CBasicPage::OnClickedBtndiscardsetting()
{
// TODO: 在此添加控件通知处理程序代码
//JsonConfig jc;
//CONFIGPARAMS params = jc.ReadDefaultConfig();
//CDiscardBlankSetting dbs(this, params.DBlank_AreaNum, params.DBlank_DevnMax);
//int nRet = dbs.DoModal();
//if (nRet == IDOK) {
// dbs.GetParams(AreaNum, DevnMax);
//}
CcardblankDlg settingdlg(discardblank_percent,this);
settingdlg.DoModal();
discardblank_percent = settingdlg.discardblank_percent;
}
void CBasicPage::SetScannerInfo(std::string hdVersion, std::string serialNum,std::string macadder)
{
m_hdVersion = hdVersion;
m_serialNum = serialNum;
m_macadder = macadder;
}
void CBasicPage::updateCmbDuplex(BOOL insert)
{
//m_cmBoxDuplex->GetCurSel();
int tmp_colorindex=m_cmBoxColorMode->GetCurSel();
int tmp_paperindex = m_cmBoxSS->GetCurSel();
int tmp_duplexindex = m_cmBoxDuplex->GetCurSel();
//int tmp_resindex = m_cmBoxResultion->GetCurSel();
int tmp_resindex = m_Slider_Dpi.m_iPosition;
int totalcount = m_cmBoxDuplex->GetCount();
2021-09-23 01:19:47 +00:00
if (tmp_duplexindex == 0)
{
GetDlgItem(IDC_CKBSWITCHFRONTBACK)->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CKBSWITCHFRONTBACK))->SetCheck(FALSE);
}
else
{
GetDlgItem(IDC_CKBSWITCHFRONTBACK)->EnableWindow(TRUE);
}
2022-05-24 12:05:47 +00:00
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
#ifndef G300
if (tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1|| tmp_paperindex == 4|| tmp_paperindex == 5){
#else
2022-05-24 12:05:47 +00:00
if (tmp_paperindex == 8|| tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10) {
#endif // G200
(((CButton*)GetDlgItem(IDC_CKBSIZEDETECT)))->SetCheck(false);
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(false);
2022-05-24 12:05:47 +00:00
(((CButton*)GetDlgItem(IDC_CKFIXEDPAPER)))->SetCheck(false);
GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(false);
}
else {
2022-06-29 12:24:24 +00:00
if (m_Slider_Dpi.m_iPosition >= 500) {
if (m_hdVersion.size() > 9 && m_hdVersion.substr(2, 2) == "39")
{
if ((m_hdVersion[5] == 'B' && atoi(m_hdVersion.substr(6, 4).c_str()) > 429) || (m_hdVersion[5] > 'B')) {
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
}
}
}
else {
GetDlgItem(IDC_CKBSIZEDETECT)->EnableWindow(true);
}
2022-05-24 12:05:47 +00:00
GetDlgItem(IDC_CKFIXEDPAPER)->EnableWindow(true);
}
2022-05-24 12:05:47 +00:00
}
2021-09-23 01:19:47 +00:00
void CBasicPage::OnNMReleasedcaptureSliderdpi(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: 在此添加控件通知处理程序代码
if(pResult!=nullptr)
*pResult = 0;
2022-06-29 12:24:24 +00:00
if (m_Slider_Dpi.m_iPosition >= 500) {
if (m_hdVersion.size() > 9 && m_hdVersion.substr(2, 2) == "39")
{
if ((m_hdVersion[5] == 'B' && atoi(m_hdVersion.substr(6, 4).c_str()) > 429) || (m_hdVersion[5] > 'B')) {
int tmp_paperindex = m_cmBoxSS->GetCurSel();
#ifndef G300
if (!(tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1 || tmp_paperindex == 4 || tmp_paperindex == 5)) {
#else
if (!(tmp_paperindex == 8 || tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10)) {
#endif // G200
((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(TRUE);
}
}
else
{
((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->SetCheck(FALSE);
}
}
}
else
{
int tmp_paperindex = m_cmBoxSS->GetCurSel();
#ifndef G300
if (!(tmp_paperindex == 19 || tmp_paperindex == 20 || tmp_paperindex == 21 || tmp_paperindex == 22 || tmp_paperindex == 1 || tmp_paperindex == 4 || tmp_paperindex == 5)) {
#else
if (!(tmp_paperindex == 8 || tmp_paperindex == 1 || tmp_paperindex == 9 || tmp_paperindex == 10)) {
#endif // G200
((CButton*)GetDlgItem(IDC_CKBSIZEDETECT))->EnableWindow(TRUE);
}
}
2022-05-24 12:05:47 +00:00
if (m_Slider_Dpi.m_iPosition >= 500) {
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(FALSE);
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(TRUE);
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->SetCheck(FALSE);
}
else
{
((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->EnableWindow(TRUE);
((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->EnableWindow(TRUE);
}
2021-09-23 01:19:47 +00:00
2022-06-29 12:24:24 +00:00
if (((m_Slider_Dpi.m_iPosition > 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) ||
(m_Slider_Dpi.m_iPosition > 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) &&
2022-05-24 12:05:47 +00:00
#ifdef G300
m_cmBoxSS->GetCount() > 9)
{
if (m_cmBoxSS->GetCurSel() >= 9)
m_cmBoxSS->SetCurSel(8);
m_cmBoxSS->DeleteString(9);
m_cmBoxSS->DeleteString(10);
#else
m_cmBoxSS->GetCount() > 20)
2021-09-23 01:19:47 +00:00
{
if (m_cmBoxSS->GetCurSel() >= 20)
m_cmBoxSS->SetCurSel(19);
m_cmBoxSS->DeleteString(22);
m_cmBoxSS->DeleteString(21);
m_cmBoxSS->DeleteString(20);
2022-05-24 12:05:47 +00:00
#endif // G300
2021-09-23 01:19:47 +00:00
}
2022-06-29 12:24:24 +00:00
else if (((m_Slider_Dpi.m_iPosition <= 300 && ((CButton*)GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck()) ||
(m_Slider_Dpi.m_iPosition <= 500 && ((CButton*)GetDlgItem(IDC_RDSPEEDPRIORITY))->GetCheck())) &&
2022-05-24 12:05:47 +00:00
#ifdef G300
m_cmBoxSS->GetCount() <= 9)
{
m_cmBoxSS->InsertString(9, _T("最大扫描尺寸自动裁切"));
m_cmBoxSS->InsertString(10, _T("最大扫描尺寸"));
#else
m_cmBoxSS->GetCount() <= 20)
2021-09-23 01:19:47 +00:00
{
m_cmBoxSS->InsertString(20,_T("最大扫描尺寸自动裁切"));
m_cmBoxSS->InsertString(21,_T("最大扫描尺寸"));
m_cmBoxSS->InsertString(22,_T("三联试卷"));
2022-05-24 12:05:47 +00:00
#endif // G300
2021-09-23 01:19:47 +00:00
}
if (m_Slider_Dpi.m_iPosition > 300 && m_cmBoxDuplex->GetCount() > 4)
{
if (m_cmBoxDuplex->GetCurSel() == 4)
m_cmBoxDuplex->SetCurSel(1);
m_cmBoxDuplex->DeleteString(4);
}
else if (m_Slider_Dpi.m_iPosition <= 300 && m_cmBoxDuplex->GetCount() <= 4)
{
m_cmBoxDuplex->InsertString(4, _T("对折"));
}
}
2021-11-20 03:09:04 +00:00
void CBasicPage::OnBnClickedBtnAttribyte()
{
// TODO: 在此添加控件通知处理程序代码
CAttributeDlg attributedlg(this);
attributedlg.DoModal();
}
2022-05-24 12:05:47 +00:00
void CBasicPage::OnEnChangeEditdpi()
{
// TODO: 如果该控件是 RICHEDIT 控件,它将不
// 发送此通知,除非重写 CTabPageSSL::OnInitDialog()
// 函数并调用 CRichEditCtrl().SetEventMask()
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
// TODO: 在此添加控件通知处理程序代码
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
}
void CBasicPage::OnBnClickedRdspeedpriority()
{
// TODO: 在此添加控件通知处理程序代码
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
}
void CBasicPage::OnBnClickedRdqualitypriority()
{
// TODO: 在此添加控件通知处理程序代码
OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
}