mirror of http://192.168.1.51:8099/lmh188/twain3.0
987 lines
38 KiB
C++
987 lines
38 KiB
C++
// CTwainUI.cpp: ʵÏÖÎļþ
|
||
//
|
||
#include "stdafx.h"
|
||
#include "CTwainUI.h"
|
||
#include "afxdialogex.h"
|
||
#include "resource.h"
|
||
#include "TabCtrlSSL.h"
|
||
#include "CBasicPage.h"
|
||
#include "CBrightnessPage.h"
|
||
#include "CFeedPaperPage.h"
|
||
#include "CImageProcPage.h"
|
||
#include "Device/PaperSize.h"
|
||
#include <list>
|
||
#include "Device/filetools.h"
|
||
#include "GscanJsonConfig.h"
|
||
// CTwainUI ¶Ô»°¿ò
|
||
|
||
IMPLEMENT_DYNAMIC(CTwainUI, CDialogEx)
|
||
|
||
CTwainUI::CTwainUI(TwGlue glue, GScanCap caps, std::string confirmtitle, std::string hardwareversion, std::string serialnum,std::string macadder, std::uint32_t mbversion ,CWnd* pParent /*=nullptr*/)
|
||
: CDialogEx(IDD_TWAINUI, pParent)
|
||
, m_tabCtrl(new CTabCtrlSSL())
|
||
, m_pageBrightness(new CBrightnessPage)
|
||
, m_pageFeedPaper(new CFeedPaperPage(glue))
|
||
, m_pageImageProc(new CImageProcPage)
|
||
, m_glue(glue)
|
||
, settings(new GScanCap(caps))
|
||
, m_confirmtitle(confirmtitle)
|
||
{
|
||
m_hardwareVersion = hardwareversion;
|
||
m_serialnum = serialnum;
|
||
m_mbversion = mbversion;
|
||
m_macadder = macadder;
|
||
}
|
||
|
||
CTwainUI::~CTwainUI()
|
||
{
|
||
m_pageBrightness.reset();
|
||
m_pageBasic.reset();
|
||
m_pageFeedPaper.reset();
|
||
m_pageImageProc.reset();
|
||
}
|
||
|
||
void CTwainUI::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialogEx::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_TAB, *m_tabCtrl);
|
||
}
|
||
|
||
BOOL CTwainUI::OnInitDialog()
|
||
{
|
||
CDialogEx::OnInitDialog();
|
||
// Setup the tab control
|
||
this->SetWindowText(TWAIN_NAME);
|
||
|
||
auto dataChangeFunction = [this]() {
|
||
if (m_pageBasic.get() && m_pageImageProc.get() && m_pageBrightness.get() && m_pageFeedPaper.get()) {
|
||
m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(),
|
||
(getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None), m_pageBasic->m_Slider_Dpi.m_iPosition);
|
||
m_pageFeedPaper->FeedPaperPageUpdate(m_pageBasic->m_cmBoxDuplex->GetCurSel());
|
||
m_pageImageProc->ImageAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel());
|
||
//m_pageFeedPaper->FeedAutoDescrewUpdate(m_pageBasic->m_cmBoxSS->GetCurSel());
|
||
UpdateUi();
|
||
m_pageBasic->OnNMReleasedcaptureSliderdpi(nullptr, nullptr);
|
||
}
|
||
};
|
||
|
||
int nPageID = 0;
|
||
m_pageBasic.reset(new CBasicPage(dataChangeFunction));
|
||
m_pageBasic->Create(IDD_PAGEBASIC, this);
|
||
m_pageBasic->discardblank_percent = settings->discardblank_percent;
|
||
m_pageBasic->SetScannerInfo(m_hardwareVersion, m_serialnum, m_macadder);
|
||
m_tabCtrl->AddSSLPage(_T("»ù±¾"), nPageID++, m_pageBasic.get());
|
||
m_pageBrightness->Create(IDD_PAGEBRIGHTNESS, this);
|
||
m_tabCtrl->AddSSLPage(_T("ÁÁ¶È"), nPageID++, m_pageBrightness.get());
|
||
m_pageImageProc->Create(IDD_PAGEIMGPROC, this);
|
||
m_tabCtrl->AddSSLPage(_T("ͼÏñ´¦Àí"), nPageID++, m_pageImageProc.get());
|
||
m_pageFeedPaper->Create(IDD_PAGEFEEDPAPER, this);
|
||
m_tabCtrl->AddSSLPage(_T("ËÍÖ½"), nPageID++, m_pageFeedPaper.get());
|
||
CString title(m_confirmtitle.c_str());
|
||
this->GetDlgItem(IDC_CONFIRM)->SetWindowText(title);
|
||
#ifdef G200
|
||
if (m_hardwareVersion.size() > 9 && m_hardwareVersion.substr(2,2) == "39")
|
||
{
|
||
if ((m_hardwareVersion[5] == 'A' && atoi(m_hardwareVersion.substr(6, 4).c_str()) > 1209)|| (m_hardwareVersion[5] > 'A'))
|
||
{
|
||
if (m_mbversion >= 35211210)
|
||
setvisable_autopaper(true);
|
||
else
|
||
setvisable_autopaper(false);
|
||
}
|
||
else
|
||
setvisable_autopaper(false);
|
||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 412)||(m_hardwareVersion[5] > 'B'))
|
||
setvisable_fixedpaper(true);
|
||
else
|
||
setvisable_fixedpaper(false);
|
||
setvisable_dogear(true);
|
||
setvisable_size(true);
|
||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 505) || (m_hardwareVersion[5] > 'B'))
|
||
m_pageFeedPaper->GetDlgItem(IDC_BTNFEEDMODE)->ShowWindow(SW_SHOW);
|
||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 430) || (m_hardwareVersion[5] > 'B'))
|
||
m_pageBasic->m_Edit_Dpi.SetParams(100, 600, 10);
|
||
if ((m_hardwareVersion[5] == 'C' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 103) || (m_hardwareVersion[5] > 'C'))
|
||
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_SHOW);
|
||
else
|
||
{
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKCOLORCAST))->SetCheck(FALSE);
|
||
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
else {
|
||
setvisable_dogear(false);
|
||
setvisable_size(false);
|
||
setvisable_autopaper(false);
|
||
setvisable_fixedpaper(false);
|
||
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE);
|
||
}
|
||
#else
|
||
#ifndef ANDROIDSERIAL
|
||
setvisable_dogear(true);
|
||
if (m_hardwareVersion.size() > 9 && m_hardwareVersion.substr(2,2) == "39")
|
||
{
|
||
if ((m_hardwareVersion[5] == 'B' && atoi(m_hardwareVersion.substr(6, 4).c_str()) > 422)||(m_hardwareVersion[5] > 'B')){
|
||
setvisable_autopaper(true);
|
||
}
|
||
else {
|
||
setvisable_autopaper(false);
|
||
}
|
||
if ((m_hardwareVersion[5] == 'C' && atoi(m_hardwareVersion.substr(6, 4).c_str()) >= 103) || (m_hardwareVersion[5] > 'C'))
|
||
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_SHOW);
|
||
else
|
||
{
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKCOLORCAST))->SetCheck(FALSE);
|
||
m_pageBasic->GetDlgItem(IDC_CKCOLORCAST)->ShowWindow(SW_HIDE);
|
||
}
|
||
setvisable_dogear(true);
|
||
setvisable_size(true);
|
||
setvisable_fixedpaper(false);
|
||
m_pageBasic->m_Edit_Dpi.SetParams(100, 600, 10);
|
||
}
|
||
else
|
||
{
|
||
|
||
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 230130)
|
||
{
|
||
setvisable_size(true);
|
||
}
|
||
else
|
||
{
|
||
setvisable_size(false);
|
||
}
|
||
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE);
|
||
#ifdef G400
|
||
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 220117)
|
||
{
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_SHOW);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_SHOW);
|
||
}
|
||
#elif defined(G300)
|
||
if (atoi(m_hardwareVersion.substr(4, 6).c_str()) >= 230130)
|
||
{
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_SHOW);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_SHOW);
|
||
}
|
||
#endif
|
||
setvisable_dogear(false);
|
||
setvisable_autopaper(true);
|
||
setvisable_fixedpaper(false);
|
||
}
|
||
#else
|
||
setvisable_dogear(false);
|
||
setvisable_size(false);
|
||
setvisable_autopaper(false);
|
||
setvisable_fixedpaper(false);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->ShowWindow(SW_HIDE);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->ShowWindow(SW_HIDE);
|
||
#endif
|
||
#endif // G200
|
||
//setvisable_fixedpaper(false);
|
||
|
||
|
||
UpdateUI();
|
||
UpdateListConfig();
|
||
dataChangeFunction();
|
||
setvisable_sleepmode(false);
|
||
return true;
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CTwainUI, CDialogEx)
|
||
ON_BN_CLICKED(IDC_CONFIRM, &CTwainUI::OnBnClickedConfirm)
|
||
ON_BN_CLICKED(IDC_BTNDEFAULT, &CTwainUI::OnBnClickedBtndefault)
|
||
ON_BN_CLICKED(ID_CANCEL, &CTwainUI::OnBnClickedCancel)
|
||
ON_BN_CLICKED(IDC_BTNHELP, &CTwainUI::OnBnClickedBtnhelp)
|
||
ON_BN_CLICKED(IDC_BTNBACKUPCONFIG, &CTwainUI::OnBnClickedBtnbackupconfig)
|
||
ON_BN_CLICKED(IDC_BTNSAVECONFIG, &CTwainUI::OnBnClickedBtnsaveconfig)
|
||
ON_BN_CLICKED(IDC_BTNDELETCONFIG, &CTwainUI::OnBnClickedBtndeletconfig)
|
||
ON_BN_CLICKED(IDC_BTNRECOVERYCONFIG, &CTwainUI::OnBnClickedBtnrecoveryconfig)
|
||
ON_LBN_SELCHANGE(IDC_LSTCONFIG, &CTwainUI::OnLbnSelchangeLstconfig)
|
||
ON_WM_CLOSE()
|
||
ON_NOTIFY(NM_CLICK, IDC_TAB, &CTwainUI::OnNMClickTab)
|
||
END_MESSAGE_MAP()
|
||
|
||
|
||
void CTwainUI::OnBnClickedConfirm()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
OnNMClickTab(nullptr, nullptr);
|
||
CONFIGPARAMS cfg = { 0 };
|
||
UpDateScanParam(&cfg);
|
||
m_glue.m_scan(*settings);
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedBtndefault()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
GscanJsonConfig js;
|
||
GScanCap cf = js.GetDefaultGscancapValue();
|
||
settings.reset(new GScanCap(cf));
|
||
|
||
UpdateUI();
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedCancel()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
m_glue.m_cancel();
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedBtnhelp()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
TCHAR chmPath[MAX_PATH] = { 0 };
|
||
SHGetSpecialFolderPath(NULL, chmPath, CSIDL_WINDOWS, TRUE);
|
||
_tcscat(chmPath, CHM_DEFAULT_PATH);
|
||
int ret = (int)ShellExecute(NULL, _T("Open"), chmPath, NULL, NULL, SW_SHOWMAXIMIZED);
|
||
if (ret < 32)
|
||
MessageBox(ret == ERROR_FILE_NOT_FOUND ? _T("δÕÒµ½°ïÖúÎĵµ£¡") : _T("´ò¿ª°ïÖúÎĵµÒì³££¡"),
|
||
_T("Ìáʾ"), MB_OK | MB_ICONINFORMATION);
|
||
|
||
this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
}
|
||
|
||
void CTwainUI::UpdateUI()
|
||
{
|
||
//!< basic page
|
||
m_pageBasic->m_cmBoxColorMode->SetCurSel(settings->automaticcolor ? 3 : get_map_key_by_value(colorModes, settings->pixtype));//!< ÑÕɫģʽ
|
||
//m_pageBasic->m_cmBoxResultion->SetCurSel(get_map_key_by_value(resolutions, settings->resolution_dst));//!< ·Ö±æÂÊ
|
||
//m_pageBasic->m_Slider_Dpi.SetPos(settings->resolution_dst);
|
||
m_pageBasic->m_Edit_Dpi.SetValue((int)settings->resolution_dst);
|
||
m_pageBasic->m_cmBoxDuplex->SetCurSel(getCmbDuplexIndex());//!< µ¥Ë«Ãæ
|
||
m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< Ö½ÕÅÀàÐÍ
|
||
m_pageBasic->m_enableSizeCheck = settings->en_sizecheck == 1 ? TRUE : FALSE;//!< ³ß´ç¼ì²â
|
||
m_pageBasic->m_bswitchfrontback = settings->is_switchfrontback ? TRUE : FALSE; //!< ½»»»Õý·´Ãæ
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->SetCheck(settings->is_high_imagequality);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_RDSPEEDPRIORITY))->SetCheck(!settings->is_high_imagequality);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKSPLIT))->SetCheck(settings->is_split);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->SetCheck(settings->en_fixedpaper);
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKCOLORCAST))->SetCheck(settings->pixtype == 2?settings->is_colorcast : FALSE);
|
||
#ifdef UV
|
||
m_pageBasic->m_bUV = settings->hardwarecaps.en_uv == 1 ? TRUE : FALSE;
|
||
#endif
|
||
m_pageBasic->UpdateData(FALSE);
|
||
if (getCmbDuplexIndex() == 2 || getCmbDuplexIndex() == 3)
|
||
m_pageBasic->GetDlgItem(IDC_BTNDISCARDSETTING)->EnableWindow(true);
|
||
else
|
||
m_pageBasic->GetDlgItem(IDC_BTNDISCARDSETTING)->EnableWindow(false);
|
||
//!< Page Breghtness
|
||
|
||
m_pageBrightness->m_cbAutoContrast = settings->is_autocontrast == TRUE ? TRUE : FALSE; //!< ×Ô¶¯ÁÁ¶È¶Ô±È¶È
|
||
int brt = GetMappingBrightnessValue(settings->brightness);
|
||
m_pageBrightness->m_Edit_Brightness.SetValue(brt); //!< ÁÁ¶È
|
||
int crt = GetContrastLevel(settings->contrast);
|
||
m_pageBrightness->m_Edit_Contrast.SetValue(crt);//!<¶Ô±È¶È
|
||
m_pageBrightness->m_Edit_Gamma.SetValue(settings->gamma); //!< gamma
|
||
m_pageBrightness->UpdateData(FALSE);
|
||
|
||
//!< Page Proc
|
||
//!
|
||
m_pageImageProc->noise = settings->noise;
|
||
m_pageImageProc->threshold = settings->AutoCrop_threshold;
|
||
m_pageImageProc->indent = settings->indent;
|
||
m_pageImageProc->is_convex = settings->is_convex;
|
||
m_pageBasic->discardblank_percent = settings->discardblank_percent;
|
||
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKCROPMODEL))->SetCheck(settings->normalCrop);
|
||
m_pageImageProc->m_ckbFillBlack = settings->fillbackground == TRUE ? TRUE : FALSE;//Ìî³äºÚ¿ò
|
||
m_pageImageProc->m_ckbAutoDeskrew = settings->autodescrew ? TRUE : FALSE;//×Ô¶¯¾ÀÆ«
|
||
UpdateFilterCmbx();
|
||
if (settings->fillbackground || settings->autodescrew || settings->is_autocrop) {
|
||
m_pageImageProc->GetDlgItem(IDC_ADVANCEDSET)->EnableWindow(TRUE);
|
||
}
|
||
else {
|
||
m_pageImageProc->GetDlgItem(IDC_ADVANCEDSET)->EnableWindow(FALSE);
|
||
}
|
||
m_pageImageProc->m_cmBoxSharpen.SetCurSel(settings->sharpen);
|
||
//UpdateSharpenCmbx();
|
||
m_pageImageProc->m_ckbRemoveHole = settings->fillhole.is_fillhole == TRUE ? TRUE : FALSE;//³ý´©¿×¿ÉÓÃÐÔ
|
||
m_pageImageProc->m_edit_hole.SetValue(settings->fillhole.fillholeratio / 100.0);//´©¿×ËÑË÷·¶Î§±ÈÀýϵÊý
|
||
m_pageImageProc->m_edit_hole.EnableWindow(settings->fillhole.is_fillhole == TRUE ? TRUE : FALSE);
|
||
m_pageImageProc->GetDlgItem(IDC_BTNHOLE)->EnableWindow(settings->fillhole.is_fillhole == TRUE ? TRUE : FALSE);
|
||
m_pageImageProc->m_fillhole_up = settings->fillholeratio_up;
|
||
m_pageImageProc->m_fillhole_down = settings->fillholeratio_down;
|
||
m_pageImageProc->m_fillhole_left = settings->fillholeratio_left;
|
||
m_pageImageProc->m_fillhole_right = settings->fillholeratio_right;
|
||
m_pageImageProc->m_en_fillhole_up = settings->en_fillholeratio_up;
|
||
m_pageImageProc->m_en_fillhole_down = settings->en_fillholeratio_down;
|
||
m_pageImageProc->m_en_fillhole_left = settings->en_fillholeratio_left;
|
||
m_pageImageProc->m_en_fillhole_right = settings->en_fillholeratio_right;
|
||
m_pageImageProc->GetDlgItem(IDC_SLDOUTHOLE)->EnableWindow(m_pageImageProc->m_ckbRemoveHole);
|
||
m_pageImageProc->m_ckbfadeback = settings->fadeback;
|
||
m_pageImageProc->m_ckbHSVDetechNoise = settings->hsvFilter;
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKBACKGROUNDSMOOTH))->SetCheck(m_pageImageProc->m_ckbfadeback);
|
||
//((CButton*)m_pageImageProc->GetDlgItem(IDC_CKBACKGROUNDSMOOTH))->EnableWindow(settings->pixtype == 2);
|
||
m_pageImageProc->m_edit_faderange.SetValue(settings->fadeback_range);
|
||
m_pageImageProc->m_slider_faderange.EnableWindow(settings->fadeback);
|
||
m_pageImageProc->m_edit_faderange.EnableWindow(settings->fadeback);
|
||
|
||
m_pageImageProc->m_ckbDetachNoise = settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE;//ºÚ°×½µÔëÊÇ·ñÆôÓÃ
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHECKDETACHNOISE))->SetCheck(m_pageImageProc->m_ckbDetachNoise);
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHECKDETACHNOISE))->EnableWindow(settings->pixtype != 2);
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT))->SetCheck(settings->pixtype != 2 ? FALSE : settings->en_multi_output); // ¶àÁ÷Êä³ö
|
||
m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT)->EnableWindow(settings->pixtype != 2);
|
||
|
||
((CComboBox*)m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT))->SetCurSel(settings->pixtype != 2 ? 0 : (settings->en_multi_output ? (settings->multioutput < 0 ? 0 : settings->multioutput) : 0));
|
||
m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT)->EnableWindow(settings->pixtype != 2 ? FALSE : settings->en_multi_output);
|
||
m_pageImageProc->m_edit_detachnoise.SetValue(settings->detachnoise.detachnoise);
|
||
m_pageImageProc->m_slider_detachnoise.EnableWindow(settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE);
|
||
m_pageImageProc->m_edit_detachnoise.EnableWindow(settings->detachnoise.is_detachnoise == TRUE ? TRUE : FALSE);
|
||
if (settings->pixtype == 2)
|
||
m_pageImageProc->m_ckbMultioutput = settings->multi_output_red == TRUE ? TRUE : FALSE;//¶àÁ÷³ýºì
|
||
else
|
||
m_pageImageProc->m_ckbMultioutput = FALSE;//¶àÁ÷³ýºì
|
||
|
||
m_pageImageProc->m_ckbHSVCorrect = settings->hsvcorrect == TRUE ? TRUE : FALSE;//´ðÌ⿨³ýºì
|
||
m_pageImageProc->m_ckbHSVDetechNoise = settings->hsvFilter == TRUE ? TRUE : FALSE;
|
||
|
||
m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(settings->pixtype == 2);//²ÊÉ«¿ÉÓÃ
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT))->SetCheck(settings->pixtype == 2);
|
||
m_pageImageProc->UpdateData(FALSE);
|
||
m_pageFeedPaper->dogear.SetCheck(settings->is_dogeardetection);
|
||
//!< Page feed paper
|
||
if (settings->is_duplex || settings->is_autodiscradblank_normal || settings->is_autodiscradblank_vince)
|
||
{
|
||
m_pageFeedPaper->m_cbRotation = settings->is_backrotate180 == TRUE ? TRUE : FALSE;//±³ÃæÐýת180
|
||
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(settings->is_autotext ? FALSE : TRUE);
|
||
}
|
||
else
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(FALSE);
|
||
m_pageFeedPaper->m_cbRotation = FALSE;
|
||
}
|
||
m_pageFeedPaper->m_cbStaple = settings->hardwarecaps.en_stapledetect == TRUE ? TRUE : FALSE;//×°¶©¼ì²â
|
||
m_pageFeedPaper->m_cbDoublePaper = settings->hardwarecaps.en_doublefeed == TRUE ? TRUE : FALSE;//Ë«Õżì²â
|
||
m_pageFeedPaper->m_cbSkew = settings->hardwarecaps.en_skrewdetect == TRUE ? TRUE : FALSE;//Íáб¼ì²â
|
||
((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKAUTOPAPER))->SetCheck(settings->hardwarecaps.is_autopaper);
|
||
auto tmp_init_autopaper_timeout = {10,15,30,60};
|
||
auto tmp_autopaper_cmbindex = std::distance(tmp_init_autopaper_timeout.begin(),
|
||
std::find(tmp_init_autopaper_timeout.begin(), tmp_init_autopaper_timeout.end(), settings->autopaper_timeout));
|
||
((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CMBAUTOPAPER))->SetCurSel(tmp_autopaper_cmbindex == tmp_init_autopaper_timeout.size() ? 0 : tmp_autopaper_cmbindex);
|
||
m_pageFeedPaper->m_cmBoxOrentation.SetCurSel(settings->is_autotext?4:getRotateCmbIndex(settings->imageRotateDegree));//Ðýת·½Ïò;
|
||
m_pageFeedPaper->m_sldSkrewDetecttion.SetPos(m_pageFeedPaper->m_cbSkew?settings->hardwarecaps.skrewdetectlevel:3);//Íáб¼ì²âµÈ¼¶
|
||
m_pageFeedPaper->m_sldSkrewDetecttion.EnableWindow(m_pageFeedPaper->m_cbSkew);
|
||
m_pageFeedPaper->m_slider_dogear.SetPos(settings->dogeardistance);
|
||
m_pageFeedPaper->m_slider_dogear.EnableWindow(((CButton*)m_pageFeedPaper->GetDlgItem(IDC_DogEarDetection))->GetCheck());
|
||
((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE))->SetCurSel(settings->hardwarecaps.lowpowermode);
|
||
if (settings->scannum == 65535 || settings->hardwarecaps.is_autopaper)//Á¬ÐøɨÃè
|
||
{
|
||
m_pageFeedPaper->m_radioGroupScanMode = 0;
|
||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(_T("1"));
|
||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->EnableWindow(FALSE);
|
||
}
|
||
else//Ö¸¶¨ÊýÄ¿
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->EnableWindow(TRUE);
|
||
m_pageFeedPaper->m_radioGroupScanMode = 1;
|
||
int tempcount = settings->scannum;
|
||
CString csCount;
|
||
csCount.Format(_T("%d"), settings->is_duplex==TRUE?tempcount/2: tempcount);
|
||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(csCount);
|
||
}
|
||
if (settings->hardwarecaps.is_autopaper)
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_CMBAUTOPAPER)->EnableWindow(TRUE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_STATICAUTOPAPER)->EnableWindow(TRUE);
|
||
}
|
||
else
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_CMBAUTOPAPER)->EnableWindow(FALSE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_STATICAUTOPAPER)->EnableWindow(FALSE);
|
||
}
|
||
|
||
m_pageFeedPaper->UpdateData(FALSE);
|
||
m_pageBasic->updateCmbDuplex(TRUE);
|
||
m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(),
|
||
(getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None),m_pageBasic->m_Slider_Dpi.m_iPosition);
|
||
}
|
||
|
||
void CTwainUI::UpdateFilterCmbx()
|
||
{
|
||
if (settings->pixtype == 2)
|
||
{
|
||
m_pageImageProc->m_cmBoxFilter.SetCurSel(0);
|
||
m_pageImageProc->m_cmBoxFilter.EnableWindow(FALSE);
|
||
}
|
||
else
|
||
{
|
||
m_pageImageProc->m_cmBoxFilter.EnableWindow(TRUE);
|
||
int selectindex = 0;
|
||
if (settings->filter != 3)
|
||
{
|
||
selectindex = settings->filter == 0 ? 1 : (settings->filter == 1 ? 2 : 3);
|
||
}
|
||
else if(settings->enhance_color != Enchace_Color::Enhance_None)
|
||
{
|
||
selectindex = settings->enhance_color == Enchace_Color::Enhance_Red ? 4:(settings->enhance_color == Enchace_Color::Enhance_Green?5:6);
|
||
}
|
||
m_pageImageProc->m_cmBoxFilter.SetCurSel(selectindex);
|
||
}
|
||
}
|
||
|
||
void CTwainUI::UpdateSharpenCmbx()
|
||
{
|
||
m_pageImageProc->m_cmBoxSharpen.EnableWindow(settings->pixtype != 0);
|
||
m_pageImageProc->m_cmBoxSharpen.SetCurSel(settings->pixtype == 0?0: settings->sharpen);
|
||
}
|
||
|
||
int CTwainUI::getCmbDuplexIndex()
|
||
{
|
||
int ret = 1;
|
||
if (settings->is_autodiscradblank_normal)
|
||
ret = 2;
|
||
else if (settings->is_autodiscradblank_vince)
|
||
ret = 3;
|
||
else if (settings->en_fold)
|
||
ret = 4;
|
||
else if(settings->is_duplex==FALSE)
|
||
ret = 0;
|
||
return ret;
|
||
}
|
||
|
||
//int CTwainUI::getResolutionIndex(int resolution)
|
||
//{
|
||
// int result = 0;
|
||
// for (size_t i = 0; i < SUPPORTRESNUMS; i++)
|
||
// {
|
||
// if (Resolutions[i] == resolution)
|
||
// {
|
||
// result = i;
|
||
// break;
|
||
// }
|
||
// }
|
||
// return result;
|
||
//}
|
||
|
||
int CTwainUI::getPaparSizeIndex(int papersize, int orentation)
|
||
{
|
||
PaperStatus ps((unsigned int)papersize, (unsigned int)orentation);
|
||
int result = 0;
|
||
for (std::map<int, PaperStatus>::iterator it = paperStatusMap.begin(); it != paperStatusMap.end(); it++) {
|
||
if (it->second.Paper == ps.Paper && it->second.Orentate == ps.Orentate) {
|
||
return it->first;
|
||
}
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
TwSS CTwainUI::getcombox_ss(int index)
|
||
{
|
||
for (std::map<int, PaperStatus>::iterator it = paperStatusMap.begin(); it != paperStatusMap.end(); it++) {
|
||
if (it->first == index) {
|
||
return (TwSS)it->second.Paper;
|
||
}
|
||
}
|
||
return TwSS::A3;
|
||
}
|
||
|
||
int CTwainUI::getColorModelIndex(int pixtype)
|
||
{
|
||
return pixtype == 2 ? 0 : (pixtype == 1 ? 1 : 2);
|
||
}
|
||
|
||
int CTwainUI::getRotateCmbIndex(float res)
|
||
{
|
||
int ret = 0;
|
||
if (res == 90.0f)
|
||
ret = 1;
|
||
else if (res == 180.0f)
|
||
ret = 2;
|
||
else if (res == 270.0f)
|
||
ret = 3;
|
||
return ret;
|
||
}
|
||
|
||
vector<CONFIGINFO> CTwainUI::getConfigFiles()
|
||
{
|
||
vector<CONFIGINFO> vc_cfi;
|
||
CFileFind find;
|
||
TCHAR cfFilePath[MAX_PATH] = { 0 };
|
||
SHGetSpecialFolderPath(NULL, cfFilePath, CSIDL_LOCAL_APPDATA, TRUE);
|
||
_tcscat(cfFilePath, HUAGAO_SCAN);
|
||
_tcscat(cfFilePath, TWAIN_DATA_PATH);
|
||
CString filePath(cfFilePath);
|
||
BOOL isFind = find.FindFile(filePath + _TEXT("/*.json"));
|
||
while (isFind)
|
||
{
|
||
isFind = find.FindNextFile();
|
||
if (find.IsDots())
|
||
{
|
||
continue;
|
||
}
|
||
else
|
||
{
|
||
CONFIGINFO cfi;
|
||
cfi.Caption = CW2A(find.GetFileTitle());
|
||
cfi.SavePath = CW2A(find.GetFilePath());
|
||
vc_cfi.push_back(cfi);
|
||
}
|
||
}
|
||
return vc_cfi;
|
||
}
|
||
|
||
static int WndCtrl2i(const CWnd* wnd)
|
||
{
|
||
CString valText;
|
||
wnd->GetWindowText(valText);
|
||
return _ttoi(valText);
|
||
}
|
||
|
||
static float WndCtrl2f(const CWnd* wnd)
|
||
{
|
||
CString valText;
|
||
wnd->GetWindowText(valText);
|
||
return (float)_ttof(valText);
|
||
}
|
||
|
||
template<typename T>
|
||
static T* GetCtrl(const CWnd* wnd, int nID)
|
||
{
|
||
return wnd->GetDlgCtrlID(nID);
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
/*´ÓUI»ñÈ¡²ÎÊý*/
|
||
void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
|
||
{
|
||
//!< Page Basic
|
||
m_pageBasic->UpdateData();
|
||
configItem->Pixtype = m_pageBasic->m_cmBoxColorMode->GetCurSel() == 3 ? 0 : m_pageBasic->m_cmBoxColorMode->GetCurSel();//!< ÑÕɫģʽ index
|
||
configItem->EnSizeCheck = m_pageBasic->m_enableSizeCheck;
|
||
//configItem->Resolution = m_pageBasic->m_cmBoxResultion->GetCurSel();//!< ·Ö±æÂÊ index
|
||
configItem->Resolution = m_pageBasic->m_Slider_Dpi.m_iPosition;
|
||
configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< µ¥Ë«Ãæ
|
||
configItem->PaperSize = m_pageBasic->m_cmBoxSS->GetCurSel();//!< Ö½ÕÅÀàÐÍ index
|
||
configItem->EnSwitchFrontBack = m_pageBasic->m_bswitchfrontback == TRUE ? true : false;
|
||
settings->is_high_imagequality = ((CButton*)m_pageBasic->GetDlgItem(IDC_RDQUALITYPRIORITY))->GetCheck();
|
||
configItem->LowPowerMode = ((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE))->GetCurSel();//!<ÐÝÃßģʽ
|
||
PaperStatus page = paperStatusMap[configItem->PaperSize];
|
||
configItem->EnAutoCrop = page.Paper == TwSS::None;
|
||
configItem->EnDiscardBlank = configItem->Duplex == 2;//×Ô¶¯Ìø¹Ç¿Õ°×ҳͨÓÃ
|
||
configItem->EnDiscardBlankVince = configItem->Duplex == 3;//×Ô¶¯Ìø¹Ç¿Õ°×Ò³·¢Æ±
|
||
configItem->EnFlod = configItem->Duplex == 4;
|
||
#ifdef UV
|
||
configItem->EnUVModel = m_pageBasic->m_bUV;
|
||
#endif
|
||
//configItem->DBlank_AreaNum = m_pageBasic->AreaNum;//!< ·ÖÇøÊý
|
||
//configItem->DBlank_DevnMax = m_pageBasic->DevnMax;//!< Ìø¹ýãÐÖµ
|
||
|
||
//!< Page Breghtness
|
||
m_pageBrightness->UpdateData();
|
||
configItem->EnAutoContrast = m_pageBrightness->m_cbAutoContrast; //!< ×Ô¶¯ÁÁ¶È¶Ô±È¶È
|
||
configItem->Brightness = (WndCtrl2i(&(m_pageBrightness->m_Edit_Brightness)) - 128)*(2000.0 / 254.0); //!< ÁÁ¶È
|
||
int crtvalue = WndCtrl2i(&(m_pageBrightness->m_Edit_Contrast)) - 4;
|
||
configItem->Contrast = GetContrast(crtvalue);//!<¶Ô±È¶È
|
||
configItem->Gamma = WndCtrl2f(&(m_pageBrightness->m_Edit_Gamma)); //!< gamma
|
||
|
||
//!< Page Proc
|
||
m_pageImageProc->UpdateData();
|
||
configItem->EnFillBlack = m_pageImageProc->m_ckbFillBlack;//Ìî³äºÚ¿ò
|
||
configItem->EnAutoDescrew = m_pageImageProc->m_ckbAutoDeskrew;//×Ô¶¯¾ÀÆ«
|
||
configItem->Filter = m_pageImageProc->m_cmBoxFilter.GetCurSel();//³ýÉ«
|
||
configItem->Sharpen = m_pageImageProc->m_cmBoxSharpen.GetCurSel();//Èñ»¯
|
||
configItem->EnOutHole = m_pageImageProc->m_ckbRemoveHole;//³ý´©¿×¿ÉÓÃÐÔ
|
||
configItem->OutHoleRatio = WndCtrl2f(&(m_pageImageProc->m_edit_hole)) * 100;//´©¿×ËÑË÷·¶Î§±ÈÀýϵÊý
|
||
|
||
configItem->EnMultiOutPutR = m_pageImageProc->m_ckbMultioutput;//¶àÁ÷³ýºì
|
||
configItem->EnHsvCorrect = m_pageImageProc->m_ckbHSVCorrect;//´ðÌ⿨³ýºì
|
||
configItem->EnHsvFilterDetechNoise = m_pageImageProc->m_ckbHSVDetechNoise;
|
||
|
||
//!< Page feed paper
|
||
m_pageFeedPaper->UpdateData();
|
||
configItem->EnBackRotate180 = m_pageFeedPaper->m_cbRotation;//±³ÃæÐýת180
|
||
configItem->EnBindingDetect = m_pageFeedPaper->m_cbStaple;//×°¶©¼ì²â
|
||
configItem->EnUltrasonicDetect = m_pageFeedPaper->m_cbDoublePaper;//Ë«Õżì²â
|
||
configItem->EnScrewDetect = m_pageFeedPaper->m_cbSkew;//Íáб¼ì²â
|
||
configItem->Orentation = m_pageFeedPaper->m_cmBoxOrentation.GetCurSel();//Ðýת·½Ïò
|
||
|
||
int count = WndCtrl2i(&(m_pageFeedPaper->m_editNum));
|
||
if (count == 0)
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(_T("1"));
|
||
count = 1;
|
||
}
|
||
configItem->ScanCount = (m_pageFeedPaper->m_radioGroupScanMode == 0) ? -1 : count;
|
||
configItem->ScrewDetectLevel = m_pageFeedPaper->m_sldSkrewDetecttion.GetPos();//Íáб¼ì²âµÈ¼¶
|
||
|
||
if (!updateDs)
|
||
return;
|
||
|
||
settings->automaticcolor = m_pageBasic->m_cmBoxColorMode->GetCurSel() == 3 ? 1 : 0;
|
||
settings->pixtype = colorModes[configItem->Pixtype];
|
||
settings->hardwarecaps.capturepixtype = settings->pixtype == 2 ? 2 : settings->pixtype;
|
||
|
||
PaperStatus paper = paperStatusMap[configItem->PaperSize];
|
||
settings->papertype = paper.Paper;
|
||
settings->paperAlign = (PaperAlign)paper.Orentate;
|
||
|
||
settings->en_sizecheck = configItem->EnSizeCheck;
|
||
settings->en_fixedpaper = ((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->GetCheck();
|
||
//settings->resolution_dst = Resolutions[configItem->Resolution];
|
||
settings->resolution_dst = configItem->Resolution;
|
||
settings->resolution_native = 200.0f;
|
||
settings->is_split = ((CButton*)m_pageBasic->GetDlgItem(IDC_CKSPLIT))->GetCheck();
|
||
settings->is_colorcast = ((CButton*)m_pageBasic->GetDlgItem(IDC_CKCOLORCAST))->GetCheck();
|
||
settings->is_switchfrontback = configItem->EnSwitchFrontBack ? 1 : 0;
|
||
//float value_Contrast = GetContrast(configItem->Contrast);
|
||
settings->contrast = configItem->Contrast;
|
||
settings->brightness = (configItem->Brightness);
|
||
settings->gamma = (configItem->Gamma);
|
||
settings->normalCrop = ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKCROPMODEL))->GetCheck();
|
||
settings->is_autocrop = paper.Paper == TwSS::None;
|
||
settings->is_duplex = configItem->Duplex >= 1;
|
||
settings->is_autodiscradblank_normal = configItem->Duplex == 2;
|
||
settings->is_autodiscradblank_vince = configItem->Duplex == 3;
|
||
//settings->areanum = configItem->DBlank_AreaNum;
|
||
//settings->devnmax = configItem->DBlank_DevnMax;
|
||
settings->discardblank_percent = m_pageBasic->discardblank_percent;
|
||
#ifdef UV
|
||
settings->hardwarecaps.en_uv = configItem->EnUVModel;
|
||
#endif
|
||
//Ìî³äºÚ¿ò
|
||
settings->fillbackground = configItem->EnFillBlack;
|
||
settings->autodescrew = configItem->EnAutoDescrew;
|
||
if (configItem->Orentation <= 3) {
|
||
settings->imageRotateDegree = rotateDegrees[configItem->Orentation];
|
||
}
|
||
else {
|
||
settings->imageRotateDegree = 0.0f;
|
||
}
|
||
settings->AutoCrop_threshold = m_pageImageProc->threshold;
|
||
settings->noise = m_pageImageProc->noise;
|
||
settings->indent = m_pageImageProc->indent;
|
||
settings->is_convex = m_pageImageProc->is_convex;
|
||
settings->is_autotext = configItem->Orentation == 4;
|
||
settings->is_backrotate180 =configItem->EnBackRotate180;
|
||
settings->is_dogeardetection = m_pageFeedPaper->dogear.GetCheck();
|
||
settings->hardwarecaps.lowpowermode = (LowPowerMode)configItem->LowPowerMode;
|
||
settings->hardwarecaps.en_skrewdetect = configItem->EnScrewDetect;
|
||
settings->hardwarecaps.skrewdetectlevel = (int)configItem->ScrewDetectLevel;
|
||
settings->hardwarecaps.en_stapledetect = configItem->EnBindingDetect;
|
||
settings->hardwarecaps.is_autopaper = ((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKAUTOPAPER))->GetCheck();
|
||
CString tmp_autopaper_timeout;
|
||
m_pageFeedPaper->GetDlgItem(IDC_CMBAUTOPAPER)->GetWindowTextW(tmp_autopaper_timeout);
|
||
settings->autopaper_timeout = _wtoi(tmp_autopaper_timeout);
|
||
settings->hardwarecaps.en_doublefeed = configItem->EnUltrasonicDetect;
|
||
settings->dogeardistance = m_pageFeedPaper->m_slider_dogear.GetPos();
|
||
settings->en_fold = configItem->EnFlod ? 1 : 0;
|
||
if (configItem->ScanCount == -1)
|
||
settings->scannum = configItem->ScanCount;
|
||
else {
|
||
if (configItem->Duplex == 0)//µ¥Ãæ
|
||
settings->scannum = configItem->ScanCount;
|
||
else {
|
||
settings->scannum = configItem->ScanCount * 2;
|
||
}
|
||
}
|
||
|
||
if (configItem->Filter) {
|
||
if (configItem->Filter <= 3) {
|
||
settings->filter = (byte)filterMaps[configItem->Filter];
|
||
settings->enhance_color = (byte)EnchaceColor::Enhance_None;
|
||
}
|
||
else {
|
||
settings->filter = 3;//²»³ýÉ«
|
||
settings->enhance_color = (byte)filterMaps[configItem->Filter];
|
||
}
|
||
}
|
||
else {
|
||
settings->filter = 3;
|
||
settings->enhance_color = (byte)EnchaceColor::Enhance_None;
|
||
}
|
||
|
||
settings->sharpen = configItem->Sharpen;
|
||
if (configItem->Filter != 0 || configItem->EnMultiOutPutR)
|
||
settings->hardwarecaps.capturepixtype = TWPT_RGB;
|
||
settings->detachnoise.is_detachnoise = m_pageImageProc->m_ckbDetachNoise;
|
||
settings->detachnoise.detachnoise = m_pageImageProc->m_slider_detachnoise.m_iPosition;
|
||
settings->fadeback = m_pageImageProc->m_ckbfadeback;
|
||
settings->fadeback_range = m_pageImageProc->m_slider_faderange.m_iPosition;
|
||
settings->fillhole.is_fillhole = configItem->EnOutHole;
|
||
settings->fillhole.fillholeratio = configItem->OutHoleRatio;
|
||
settings->fillholeratio_up = m_pageImageProc->m_fillhole_up;
|
||
settings->fillholeratio_down = m_pageImageProc->m_fillhole_down;
|
||
settings->fillholeratio_left = m_pageImageProc->m_fillhole_left;
|
||
settings->fillholeratio_right = m_pageImageProc->m_fillhole_right;
|
||
settings->en_fillholeratio_up = m_pageImageProc->m_en_fillhole_up;
|
||
settings->en_fillholeratio_down = m_pageImageProc->m_en_fillhole_down;
|
||
settings->en_fillholeratio_left = m_pageImageProc->m_en_fillhole_left;
|
||
settings->en_fillholeratio_right = m_pageImageProc->m_en_fillhole_right;
|
||
settings->multi_output_red = configItem->EnMultiOutPutR;
|
||
settings->en_multi_output = ((CButton*)m_pageImageProc->GetDlgItem(IDC_CHMULTIPUT))->GetCheck();
|
||
settings->multioutput = ((CComboBox*)m_pageImageProc->GetDlgItem(IDC_CMBMULTIOUT))->GetCurSel();
|
||
settings->hsvcorrect = configItem->EnHsvCorrect;
|
||
settings->hsvFilter = configItem->EnHsvFilterDetechNoise;
|
||
#ifdef REAL300DPI
|
||
settings->resolution_native = settings->resolution_dst > 240.0f ? 300.0f : 200.0f;
|
||
#else // REAL300DPI
|
||
settings->resolution_native = 200.0f;
|
||
#endif
|
||
if (settings->pixtype == TWPT_BW)
|
||
//{
|
||
// if (settings->filter == 3 && settings->enhance_color <=1)
|
||
// {
|
||
// settings->enhance_color = Enchace_Color::Enhance_Red;
|
||
// settings->filter = 3;//none
|
||
// }
|
||
//}
|
||
UpdateUi();
|
||
}
|
||
|
||
void CTwainUI::UpdateListConfig()
|
||
{
|
||
((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->ResetContent();
|
||
if (cfi.size() > 0)
|
||
{
|
||
cfi.clear();
|
||
}
|
||
cfi = getConfigFiles();
|
||
for (int i = 0; i < cfi.size(); i++)
|
||
{
|
||
CString a;
|
||
a = cfi[i].Caption.c_str();
|
||
((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->AddString(a);
|
||
}
|
||
if (cfi.size() <= 0)
|
||
{
|
||
((CButton*)(GetDlgItem(IDC_BTNDELETCONFIG)))->EnableWindow(FALSE);
|
||
((CButton*)(GetDlgItem(IDC_BTNBACKUPCONFIG)))->EnableWindow(FALSE);
|
||
}
|
||
else
|
||
{
|
||
((CButton*)(GetDlgItem(IDC_BTNDELETCONFIG)))->EnableWindow(TRUE);
|
||
((CButton*)(GetDlgItem(IDC_BTNBACKUPCONFIG)))->EnableWindow(TRUE);
|
||
}
|
||
}
|
||
|
||
void CTwainUI::GetGScanCap(GScanCap & cap)
|
||
{
|
||
cap = *settings;
|
||
}
|
||
|
||
void CTwainUI::UpdateUi()
|
||
{
|
||
m_pageImageProc->m_cmBoxFilter.EnableWindow((m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0) && (m_pageBasic->m_cmBoxColorMode->GetCurSel() != 3));
|
||
INT dupindex = m_pageBasic->m_cmBoxDuplex->GetCurSel();
|
||
BOOL enableback = dupindex == 0 || dupindex == 4;
|
||
if ((dupindex==0)||(dupindex==4))
|
||
{
|
||
((CButton*)(m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(FALSE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(FALSE);
|
||
}
|
||
else
|
||
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(m_pageFeedPaper->m_cmBoxOrentation.GetCurSel()==4? FALSE:TRUE);
|
||
if (dupindex == 4) {
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->SetCheck(TRUE);
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(FALSE);
|
||
}
|
||
else
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(TRUE);
|
||
|
||
m_pageImageProc->GetDlgItem(IDC_SLDOUTHOLE)->EnableWindow(((CButton*)m_pageImageProc->GetDlgItem(IDC_CKREMOVEHOLE))->GetCheck() == TRUE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_SLDDETECTLEVEL)->EnableWindow(((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKSKEWDETECT))->GetCheck() == TRUE);
|
||
m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(m_pageBasic->m_cmBoxColorMode->GetCurSel() == 0);
|
||
if(m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0)
|
||
((CButton*)m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT))->SetCheck(FALSE);
|
||
}
|
||
|
||
void CTwainUI::setvisable_size(bool flag)
|
||
{
|
||
m_pageBasic->GetDlgItem(IDC_CKBSIZEDETECT)->ShowWindow(flag?SW_SHOW:SW_HIDE);
|
||
if(!flag)
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKBSIZEDETECT))->SetCheck(false);
|
||
}
|
||
|
||
void CTwainUI::setvisable_sleepmode(bool flag)
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_STATICLOWPM)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
if (!flag)
|
||
((CComboBox*)m_pageFeedPaper->GetDlgItem(IDC_CBLOWPOWERMODE))->SetCurSel(0);
|
||
}
|
||
|
||
void CTwainUI::setvisable_dogear(bool flag)
|
||
{
|
||
m_pageFeedPaper->GetDlgItem(IDC_DogEarDetection)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_SLIDER_DOGEAR)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_LBSDL2)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_LBSDR2)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
if (!flag)
|
||
((CButton*)m_pageFeedPaper->GetDlgItem(IDC_DogEarDetection))->SetCheck(false);
|
||
}
|
||
|
||
void CTwainUI::setvisable_autopaper(bool flag)
|
||
{
|
||
((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKAUTOPAPER))->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_STATICAUTOPAPER)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
m_pageFeedPaper->GetDlgItem(IDC_CMBAUTOPAPER)->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
if (!flag)
|
||
((CButton*)m_pageFeedPaper->GetDlgItem(IDC_CKAUTOPAPER))->SetCheck(false);
|
||
}
|
||
|
||
void CTwainUI::setvisable_fixedpaper(bool flag)
|
||
{
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->ShowWindow(flag ? SW_SHOW : SW_HIDE);
|
||
if (!flag)
|
||
((CButton*)m_pageBasic->GetDlgItem(IDC_CKFIXEDPAPER))->SetCheck(false);
|
||
}
|
||
|
||
void CTwainUI::EnableID_OKorID_Cancel(bool enable)
|
||
{
|
||
GetDlgItem(IDC_CONFIRM)->EnableWindow(enable);
|
||
GetDlgItem(ID_CANCEL)->EnableWindow(enable);
|
||
GetDlgItem(IDC_BTNHELP)->EnableWindow(enable);
|
||
GetDlgItem(IDC_BTNDEFAULT)->EnableWindow(enable);
|
||
GetDlgItem(IDC_TAB)->EnableWindow(enable);
|
||
GetDlgItem(IDC_GROUP)->EnableWindow(enable);
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedBtnbackupconfig()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
CString csFilters = _T("Json file(*.json)\0");
|
||
CFileDialog cfd(FALSE, _T("json"), _T("Áí´æΪ"));
|
||
cfd.m_ofn.lpstrTitle = _T("");
|
||
cfd.m_ofn.lpstrFilter = csFilters;
|
||
this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
GscanJsonConfig js;
|
||
if (IDOK == cfd.DoModal())
|
||
{
|
||
vector<GScanCap> vc_tempOut;
|
||
std::vector<CONFIGINFO> temp_cfi = getConfigFiles();
|
||
for (int i = 0; i < temp_cfi.size(); i++)
|
||
{
|
||
vector<GScanCap> vc_item = js.ReadGscanCapsVector(temp_cfi[i].SavePath.c_str());
|
||
if (vc_item.size() > 0)
|
||
{
|
||
vc_tempOut.push_back(vc_item[0]);
|
||
}
|
||
}
|
||
if (vc_tempOut.size() > 0)
|
||
{
|
||
std::string path = (CW2A)cfd.GetPathName();
|
||
js.WriteJsonArrayToFile(vc_tempOut, path);
|
||
}
|
||
}
|
||
this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedBtnsaveconfig()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
CSaveConfigDlg sfd(this);
|
||
sfd.DoModal();
|
||
}
|
||
|
||
|
||
void CTwainUI::OnBnClickedBtndeletconfig()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
if (MessageBox(TEXT("È·ÈÏҪɾ³ý´ËÓû§Ê×Ñ¡ÏîÅäÖÃÂð£¿"), TEXT("Óû§Ê×Ñ¡Ïî"), MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||
{
|
||
int cursel = -1;
|
||
cursel = ((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->GetCurSel();
|
||
if (cursel != -1)
|
||
{
|
||
CFile file;
|
||
CString csFile;
|
||
csFile = cfi[cursel].SavePath.c_str();
|
||
file.Remove(csFile);
|
||
UpdateListConfig();
|
||
}
|
||
}
|
||
}
|
||
|
||
void CTwainUI::OnBnClickedBtnrecoveryconfig()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
if (MessageBox(TEXT("Èç¹û»Ö¸´,µ±Ç°ËùÓÐÒѱ£´æÅäÖý«¶ªÊ§¡£ÊÇ·ñ¼ÌÐø£¿"), TEXT("»Ö¸´"), MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||
{
|
||
GscanJsonConfig js;
|
||
CFileDialog ofd(TRUE,
|
||
_T(".json"),
|
||
NULL,
|
||
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||
_TEXT("Json Files (*.json)|*.json||)"),
|
||
NULL);
|
||
for (int i = 0; i < cfi.size(); i++)
|
||
{
|
||
DeleteFile((LPCWSTR)cfi[i].SavePath.c_str());
|
||
}
|
||
cfi.clear();
|
||
if (IDOK == ofd.DoModal())
|
||
{
|
||
std::string path = (CW2A)ofd.GetPathName();
|
||
vector<GScanCap> vc = js.ReadGscanCapsVector(path);
|
||
for (int i = 0; i < vc.size(); i++)
|
||
{
|
||
// js.WriteJsonArrayToFile(vc[i],vc[i].SavePath);
|
||
vector<GScanCap> vc_item;
|
||
vc_item.push_back(vc[i]);
|
||
js.WriteJsonArrayToFile(vc_item, vc[i].SavePath);
|
||
}
|
||
UpdateListConfig();
|
||
}
|
||
}
|
||
this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||
}
|
||
|
||
|
||
void CTwainUI::OnLbnSelchangeLstconfig()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
int index = -1;
|
||
index = ((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->GetCurSel();
|
||
if (index != -1)
|
||
{
|
||
GscanJsonConfig js;
|
||
//std::string savepath= cfi[index].SavePath;
|
||
std::vector<GScanCap> vc_temp;
|
||
vc_temp = js.ReadGscanCapsVector(cfi[index].SavePath);
|
||
if (vc_temp.size() > 0)
|
||
{
|
||
settings.reset(new GScanCap(vc_temp[0]));
|
||
UpdateUI();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void CTwainUI::OnClose()
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
|
||
m_glue.m_cancel();
|
||
}
|
||
|
||
|
||
LRESULT CTwainUI::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼ÓרÓôúÂëºÍ/»òµ÷ÓûùÀà
|
||
|
||
return CDialogEx::WindowProc(message, wParam, lParam);
|
||
}
|
||
|
||
|
||
|
||
void CTwainUI::OnNMClickTab(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
|
||
//*pResult = 0;
|
||
m_pageImageProc->ImageProcPageUpdate(m_pageBasic->m_cmBoxColorMode->GetCurSel(), m_pageBasic->m_cmBoxSS->GetCurSel(), m_pageBasic->m_cmBoxDuplex->GetCurSel(),
|
||
(getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::USStatement) || (getcombox_ss(m_pageBasic->m_cmBoxSS->GetCurSel()) == TwSS::None),
|
||
m_pageBasic->m_Slider_Dpi.m_iPosition);
|
||
|
||
}
|