From 59cecd0950ea4d8b386e874dcf649dda9f309caf Mon Sep 17 00:00:00 2001 From: lovelyyoung <1002639516@qq.com> Date: Sat, 20 Jun 2020 11:04:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=A0=B9=E6=8D=AE=E5=8D=8F=E8=AE=AE=E5=80=BC?= =?UTF-8?q?=E6=9B=B4=E6=96=B0UI=20=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=8C=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81=E2=80=98=202.?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8D=E5=90=8C=E7=B3=BB=E5=88=97=E4=BA=A7?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E6=9D=A1=E4=BB=B6=E7=BC=96=E8=AF=91=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E4=BB=A3=E7=A0=81=E7=89=88=E6=9C=AC=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- huagao/CBasicPage.cpp | 49 +++++++- huagao/CBasicPage.h | 1 + huagao/CBrightnessPage.cpp | 6 + huagao/CBrightnessPage.h | 2 + huagao/CFeedPaperPage.cpp | 23 +++- huagao/CSaveConfigDlg.cpp | 11 +- huagao/CTwainUI.cpp | 249 ++++++++++++++++++++++--------------- huagao/CTwainUI.h | 62 +++++++-- huagao/huagaotwds.rc | Bin 35004 -> 35864 bytes huagao/resource.h | Bin 10618 -> 10986 bytes huagao/stdafx.cpp | Bin 1006 -> 218 bytes huagao/stdafx.h | Bin 4788 -> 5088 bytes 12 files changed, 285 insertions(+), 118 deletions(-) diff --git a/huagao/CBasicPage.cpp b/huagao/CBasicPage.cpp index a1bf77d4..b9cb21d3 100644 --- a/huagao/CBasicPage.cpp +++ b/huagao/CBasicPage.cpp @@ -8,7 +8,6 @@ #include "CAboutDlg.h" #include "CTwainUI.h" #include "CDiscardBlankSetting.h" -#include "Device/JsonConfig.h" #include static std::vector color_Modes = { @@ -17,8 +16,10 @@ static std::vector color_Modes = { _T("黑白") }; + +#ifdef G200 static std::vector surportStyles = { - _T("A3"), + _T("A3"),//pass _T("A4"), _T("A4横向"), _T("A5"), @@ -32,14 +33,50 @@ static std::vector surportStyles = { _T("B6横向"), _T("Letter"), _T("Letter横向"), - _T("Double Letter"), + _T("Double Letter"),//pass _T("LEGAL"), _T("匹配原始尺寸"), -#ifdef G200 _T("最大扫描尺寸自动裁切"), _T("最大扫描尺寸"), -#endif // G200 }; +#endif + +#ifdef G300 +static std::vector surportStyles = { + _T("A4"), + _T("A5"), + _T("A6"), + _T("B4"), + _T("B5"), + _T("B6"), + _T("Letter"), + _T("LEGAL"), + _T("匹配原始尺寸"), +}; +#endif + +#ifdef G400 +static std::vector surportStyles = { + _T("A3"),//pass + _T("A4"), + _T("A4横向"), + _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("匹配原始尺寸"), +}; +#endif // G400 + static std::vector reslutions{ _T("100"), @@ -68,6 +105,7 @@ CBasicPage::CBasicPage(std::function dataChange, CWnd* pParent /*=nullpt , m_dataChange(dataChange) , AreaNum(8) , DevnMax(200) + , m_bswitchfrontback(FALSE) { } @@ -79,6 +117,7 @@ CBasicPage::~CBasicPage() void CBasicPage::DoDataExchange(CDataExchange* pDX) { CTabPageSSL::DoDataExchange(pDX); + DDX_Check(pDX, IDC_CKBSWITCHFRONTBACK, m_bswitchfrontback); } BOOL CBasicPage::OnInitDialog() diff --git a/huagao/CBasicPage.h b/huagao/CBasicPage.h index db4fa755..4776ff72 100644 --- a/huagao/CBasicPage.h +++ b/huagao/CBasicPage.h @@ -27,6 +27,7 @@ public: public: int AreaNum; int DevnMax; + BOOL m_bswitchfrontback; // 对话框数据 #ifdef AFX_DESIGN_TIME diff --git a/huagao/CBrightnessPage.cpp b/huagao/CBrightnessPage.cpp index c1adabe9..b5fa2abb 100644 --- a/huagao/CBrightnessPage.cpp +++ b/huagao/CBrightnessPage.cpp @@ -28,9 +28,11 @@ void CBrightnessPage::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_EDIT_BRIGHTNESS, m_Edit_Brightness); DDX_Control(pDX, IDC_EDIT_CONSTRAST, m_Edit_Contrast); DDX_Control(pDX, IDC_EDIT_GAMMA, m_Edit_Gamma); + DDX_Control(pDX, IDC_EDIT_THRE, m_Edit_Thre); DDX_Control(pDX, IDC_SLIDER_BRIGTHNESS, m_Slider_Brightness); DDX_Control(pDX, IDC_SLIDER_CONTRAST, m_Slider_Contrast); DDX_Control(pDX, IDC_SLIDER_GAMMA, m_Slider_Gamma); + DDX_Control(pDX, IDC_SLIDER_THRE, m_Slider_Thre); DDX_Check(pDX, IDC_CHKSELFCONTRAST, m_cbAutoContrast); } @@ -49,6 +51,10 @@ BOOL CBrightnessPage::OnInitDialog() m_Edit_Gamma.SetSlideLink(this, IDC_SLIDER_GAMMA); m_Edit_Gamma.SetParams(0.01, 5.0, 10, _T("%0.2f")); m_Edit_Gamma.SetValue(1.0); + + m_Edit_Thre.SetSlideLink(this, IDC_SLIDER_THRE); + m_Edit_Thre.SetParams(1, 255, 15); + m_Edit_Thre.SetValue(128); return true; } diff --git a/huagao/CBrightnessPage.h b/huagao/CBrightnessPage.h index a0dcc58b..759a2e4c 100644 --- a/huagao/CBrightnessPage.h +++ b/huagao/CBrightnessPage.h @@ -17,9 +17,11 @@ public: CSmartEdit m_Edit_Brightness; CSmartEdit m_Edit_Contrast; CSmartEdit m_Edit_Gamma; + CSmartEdit m_Edit_Thre; CLinkSlider m_Slider_Brightness; CLinkSlider m_Slider_Contrast; CLinkSlider m_Slider_Gamma; + CLinkSlider m_Slider_Thre; BOOL m_cbAutoContrast; // 对话框数据 diff --git a/huagao/CFeedPaperPage.cpp b/huagao/CFeedPaperPage.cpp index bcf50f80..3662dec2 100644 --- a/huagao/CFeedPaperPage.cpp +++ b/huagao/CFeedPaperPage.cpp @@ -5,9 +5,22 @@ #include "CFeedPaperPage.h" #include "afxdialogex.h" #include "resource.h" +#include - +std::vector g400hiden = +{ + IDC_CKBINDINGDETECT , + IDC_LBCOUNT , + IDC_RDCONSISTSCAN, + IDC_RDSPECIFYSCANNUM, + IDC_EDSCANNUM, + IDC_CKSKEWDETECT, + IDC_LBSDL, + IDC_SLDDETECTLEVEL, + IDC_LBSDR, + IDC_CKBACKROTATION +}; // CFeedPaperPage 对话框 @@ -51,6 +64,14 @@ BOOL CFeedPaperPage::OnInitDialog() OnInitcmBoxOrentation(0); m_sldSkrewDetecttion.SetSlideRange(1, 5); m_sldSkrewDetecttion.SetSlidePos(3); +#ifndef G200 + for (size_t i = 0; i < g400hiden.size(); i++) + { + GetDlgItem(g400hiden[i])->ShowWindow(FALSE); + } + +#endif // G200 + return true; } diff --git a/huagao/CSaveConfigDlg.cpp b/huagao/CSaveConfigDlg.cpp index 7ebf20cc..a405c980 100644 --- a/huagao/CSaveConfigDlg.cpp +++ b/huagao/CSaveConfigDlg.cpp @@ -5,7 +5,7 @@ #include "CSaveConfigDlg.h" #include "CTwainUI.h" #include - +#include "GscanJsonConfig.h" // CSaveConfigDlg 对话框 @@ -46,12 +46,11 @@ void CSaveConfigDlg::OnBnClickedOk() { CTwainUI* m_Parent=(CTwainUI*)GetParent(); CONFIGPARAMS citem={0}; - m_Parent->UpDateScanParam(&citem,false); + m_Parent->UpDateScanParam(&citem); CString m_sName; GetDlgItemText(IDC_EDITSAVENAME,m_sName); TCHAR szIniFile[MAX_PATH] = { 0 }; INT length=m_sName.GetLength(); - //INT length=10; if (length>0&&length<50) { char invalid_FileChars[8]={'/','\\',':','*',' ?','<', '>','|'}; @@ -77,8 +76,10 @@ void CSaveConfigDlg::OnBnClickedOk() _tcscat(szIniFile,m_sName+_TEXT(".json")); std::string s_savePath = TCHAR2STRING2(szIniFile); citem.SavePath=s_savePath; - JsonConfig cfg; - cfg.WriteToJson(&citem,s_savePath,true); + GscanJsonConfig cfg; + GScanCap caps = { 0 }; + m_Parent->GetGScanCap(caps); + cfg.SaveGscanCapConfig(caps,s_savePath); m_Parent->UpdateListConfig(); CDialog::OnOK(); } diff --git a/huagao/CTwainUI.cpp b/huagao/CTwainUI.cpp index f6c4867a..b04a4413 100644 --- a/huagao/CTwainUI.cpp +++ b/huagao/CTwainUI.cpp @@ -12,23 +12,24 @@ #include "Device/PaperSize.h" #include #include "filetools.h" +#include "GscanJsonConfig.h" // CTwainUI 对话框 IMPLEMENT_DYNAMIC(CTwainUI, CDialogEx) -CTwainUI::CTwainUI(TwGlue glue,std::string confirmtitle, std::string hardwareversion, std::string serialnum, CWnd* pParent /*=nullptr*/) +CTwainUI::CTwainUI(TwGlue glue, GScanCap caps, std::string confirmtitle, std::string hardwareversion, std::string serialnum, CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_TWAINUI, pParent) , m_tabCtrl(new CTabCtrlSSL()) , m_pageBrightness(new CBrightnessPage) , m_pageFeedPaper(new CFeedPaperPage) , m_pageImageProc(new CImageProcPage) , m_glue(glue) - , settings(new GScanCap) + , settings(new GScanCap(caps)) , m_confirmtitle(confirmtitle) { m_hardwareVersion = hardwareversion; m_serialnum = serialnum; - memset(settings.get(), 0, sizeof(GScanCap)); + //memset(settings.get(), 0, sizeof(GScanCap)); } CTwainUI::~CTwainUI() @@ -66,10 +67,9 @@ BOOL CTwainUI::OnInitDialog() m_pageFeedPaper->Create(IDD_PAGEFEEDPAPER, this); m_tabCtrl->AddSSLPage(_T("送纸"), nPageID++, m_pageFeedPaper.get()); CString title(m_confirmtitle.c_str()); - this->GetDlgItem(IDC_CONFIRM)->SetWindowTextW(title); - JsonConfig cfg; - CONFIGPARAMS configParams = cfg.ReadDefaultConfig(); - UpdateUI(configParams); + this->GetDlgItem(IDC_CONFIRM)->SetWindowText(title); + + UpdateUI(); UpdateListConfig(); UpdateUi(); return true; @@ -90,35 +90,11 @@ BEGIN_MESSAGE_MAP(CTwainUI, CDialogEx) END_MESSAGE_MAP() -// CTwainUI 消息处理程序 -std::string TCHAR2STRING1(TCHAR* STR) -{ - int iLen = WideCharToMultiByte(CP_ACP, 0, STR, -1, NULL, 0, NULL, NULL); - char* chRtn = new char[iLen * sizeof(char)]; - WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, iLen, NULL, NULL); - std::string str(chRtn); - return str; -} - void CTwainUI::OnBnClickedConfirm() { // TODO: 在此添加控件通知处理程序代码 - CString str_caption; - GetDlgItemText(IDC_CONFIRM, str_caption); - CONFIGPARAMS configItem = { 0 }; - UpDateScanParam(&configItem); - TCHAR szIniFile[MAX_PATH] = { 0 }; - SHGetSpecialFolderPath(NULL, szIniFile, CSIDL_LOCAL_APPDATA, TRUE); - _tcscat(szIniFile, HUAGAO_SCAN); - _tcscat(szIniFile, TWAIN_INIPATH); - _tcscat(szIniFile, TEXT("\\")); - _tcscat(szIniFile, TWAIN_JSON_NAME); - JsonConfig js; - vector vc; - vc.push_back(configItem); - std::string savepath = TCHAR2STRING1(szIniFile); - js.WriteJsonArrayToFile(vc, savepath); - + CONFIGPARAMS cfg = { 0 }; + UpDateScanParam(&cfg); m_glue.m_scan(*settings); } @@ -126,9 +102,10 @@ void CTwainUI::OnBnClickedConfirm() void CTwainUI::OnBnClickedBtndefault() { // TODO: 在此添加控件通知处理程序代码 - JsonConfig js; - CONFIGPARAMS cf = js.GetDefaultConfigParams(); - UpdateUI(cf); + GscanJsonConfig js; + GScanCap cf = js.GetDefaultGscancapValue(); + settings.reset(new GScanCap(cf)); + UpdateUI(); } @@ -154,44 +131,55 @@ void CTwainUI::OnBnClickedBtnhelp() this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } -void CTwainUI::UpdateUI(CONFIGPARAMS configParams) +void CTwainUI::UpdateUI() { - //!< Page Basic - m_pageBasic->m_cmBoxColorMode->SetCurSel(configParams.Pixtype);//!< 颜色模式 - m_pageBasic->m_cmBoxResultion->SetCurSel(configParams.Resolution);//!< 分辨率 - m_pageBasic->m_cmBoxDuplex->SetCurSel(configParams.Duplex);//!< 单双面 - m_pageBasic->m_cmBoxSS->SetCurSel(configParams.PaperSize); //!< 纸张类型 + //!< basic page + m_pageBasic->m_cmBoxColorMode->SetCurSel(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_cmBoxDuplex->SetCurSel(getCmbDuplexIndex());//!< 单双面 + m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< 纸张类型 + m_pageBasic->m_bswitchfrontback = settings->is_switchfrontback ? TRUE : FALSE; //!< 交换正反面 m_pageBasic->UpdateData(FALSE); //!< Page Breghtness - - m_pageBrightness->m_cbAutoContrast = configParams.EnAutoContrast; //!< 自动亮度对比度 - int brt = GetMappingBrightnessValue(configParams.Brightness); + 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(configParams.Contrast); + int crt = GetContrastLevel(settings->contrast); m_pageBrightness->m_Edit_Contrast.SetValue(crt);//!<对比度 - m_pageBrightness->m_Edit_Gamma.SetValue(configParams.Gamma); //!< gamma + m_pageBrightness->m_Edit_Gamma.SetValue(settings->gamma); //!< gamma m_pageBrightness->UpdateData(FALSE); //!< Page Proc - m_pageImageProc->m_ckbFillBlack = configParams.EnFillBlack?TRUE:FALSE;//填充黑框 - m_pageImageProc->m_ckbAutoDeskrew =configParams.EnAutoDescrew? TRUE : FALSE;//自动纠偏 - m_pageImageProc->m_cmBoxFilter.SetCurSel(configParams.Filter);//除色 - m_pageImageProc->m_cmBoxSharpen.SetCurSel(configParams.Sharpen);//锐化 - m_pageImageProc->m_ckbRemoveHole = configParams.EnOutHole;//除穿孔可用性 - m_pageImageProc->m_edit_hole.SetValue(configParams.OutHoleRatio/100.0);//穿孔搜索范围比例系数 - m_pageImageProc->m_ckbMultioutput = configParams.EnMultiOutPutR;//多流除红 + m_pageImageProc->m_ckbFillBlack = settings->fillbackground==TRUE ? TRUE : FALSE;//填充黑框 + m_pageImageProc->m_ckbAutoDeskrew = settings->autodescrew ? TRUE : FALSE;//自动纠偏 + UpdateFilterCmbx(); + 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); + if (settings->pixtype == 2) + m_pageImageProc->m_ckbMultioutput = settings->multi_output_red == TRUE ? TRUE : FALSE;//多流除红 + else + m_pageImageProc->m_ckbMultioutput = FALSE;//多流除红 + m_pageImageProc->GetDlgItem(IDC_CKMULTIOUTPUT)->EnableWindow(settings->pixtype == 2);//彩色可用 m_pageImageProc->UpdateData(FALSE); //!< Page feed paper - m_pageFeedPaper->m_cbRotation = configParams.EnBackRotate180? TRUE : FALSE;//背面旋转180 - m_pageFeedPaper->m_cbStaple = configParams.EnBindingDetect? TRUE : FALSE;//装订检测 - m_pageFeedPaper->m_cbDoublePaper = configParams.EnUltrasonicDetect? TRUE : FALSE;//双张检测 - m_pageFeedPaper->m_cbSkew = configParams.EnScrewDetect? TRUE : FALSE;//歪斜检测 - m_pageFeedPaper->m_cmBoxOrentation.SetCurSel(configParams.Orentation);//旋转方向; - m_pageFeedPaper->m_sldSkrewDetecttion.SetPos(configParams.ScrewDetectLevel);//歪斜检测等级 + if(settings->is_duplex==TRUE) + m_pageFeedPaper->m_cbRotation = settings->is_backrotate180==TRUE ? TRUE : FALSE;//背面旋转180 + 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;//歪斜检测 + m_pageFeedPaper->m_cmBoxOrentation.SetCurSel(getRotateCmbIndex(settings->imageRotateDegree));//旋转方向; + m_pageFeedPaper->m_sldSkrewDetecttion.SetPos(settings->hardwarecaps.skrewdetectlevel);//歪斜检测等级 - if (configParams.ScanCount <= 0)//连续扫描 + if (settings->scannum == 65535)//连续扫描 { m_pageFeedPaper->m_radioGroupScanMode = 0; m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(_T("1")); @@ -201,9 +189,9 @@ void CTwainUI::UpdateUI(CONFIGPARAMS configParams) { m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->EnableWindow(TRUE); m_pageFeedPaper->m_radioGroupScanMode = 1; - int tempcount = configParams.ScanCount; + int tempcount = settings->scannum; CString csCount; - csCount.Format(_T("%d"), tempcount); + csCount.Format(_T("%d"), settings->is_duplex==TRUE?tempcount/2: tempcount); m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(csCount); } @@ -211,6 +199,47 @@ void CTwainUI::UpdateUI(CONFIGPARAMS configParams) m_pageBasic->updateCmbDuplex(TRUE); } +void CTwainUI::UpdateFilterCmbx() +{ + if (settings->pixtype == TWPT_RGB) + { + 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->is_duplex==FALSE) + ret = 0; + return ret; +} + int CTwainUI::getResolutionIndex(int resolution) { int result = 0; @@ -225,9 +254,9 @@ int CTwainUI::getResolutionIndex(int resolution) return result; } -int CTwainUI::getPaparSizeIndex(int papersize,int orentation) +int CTwainUI::getPaparSizeIndex(int papersize, int orentation) { - PaperStatus ps = { papersize,orentation }; + PaperStatus ps((unsigned int)papersize, (unsigned int)orentation); int result = 0; for (std::map::iterator it = paperStatusMap.begin(); it != paperStatusMap.end(); it++) { if (it->second.Paper == ps.Paper && it->second.Orentate == ps.Orentate) { @@ -242,6 +271,18 @@ 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 CTwainUI::getConfigFiles() { vector vc_cfi; @@ -285,7 +326,7 @@ static float WndCtrl2f(const CWnd* wnd) } template -static T* GetCtrl(const CWnd* wnd, int nID) +static T* GetCtrl(const CWnd* wnd, int nID) { return wnd->GetDlgCtrlID(nID); } @@ -300,7 +341,10 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) configItem->Resolution = m_pageBasic->m_cmBoxResultion->GetCurSel();//!< 分辨率 index configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面 configItem->PaperSize = m_pageBasic->m_cmBoxSS->GetCurSel();//!< 纸张类型 index - configItem->EnAutoCrop = configItem->PaperSize == 16; + configItem->EnSwitchFrontBack = m_pageBasic->m_bswitchfrontback == TRUE ? true : false; + + 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; @@ -310,7 +354,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) //!< Page Breghtness m_pageBrightness->UpdateData(); configItem->EnAutoContrast = m_pageBrightness->m_cbAutoContrast; //!< 自动亮度对比度 - configItem->Brightness = (WndCtrl2i(&(m_pageBrightness->m_Edit_Brightness)) - 128)*(2000.0/254.0); //!< 亮度 + 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 @@ -322,7 +366,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) 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->OutHoleRatio = WndCtrl2f(&(m_pageImageProc->m_edit_hole)) * 100;//穿孔搜索范围比例系数 configItem->EnMultiOutPutR = m_pageImageProc->m_ckbMultioutput;//多流除红 //!< Page feed paper @@ -345,16 +389,16 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) if (!updateDs) return; - settings->pixtype =colorModes[configItem->Pixtype]; + settings->pixtype = colorModes[configItem->Pixtype]; settings->hardwarecaps.capturepixtype = settings->pixtype; - PaperStatus paper= paperStatusMap[configItem->PaperSize]; + PaperStatus paper = paperStatusMap[configItem->PaperSize]; settings->papertype = paper.Paper; settings->paperAlign = (PaperAlign)paper.Orentate; - + settings->resolution_dst = Resolutions[configItem->Resolution]; settings->resolution_native = 200.0f; - + settings->is_switchfrontback = configItem->EnSwitchFrontBack ? 1 : 0; //float value_Contrast = GetContrast(configItem->Contrast); settings->contrast = configItem->Contrast; settings->brightness = (configItem->Brightness); @@ -377,25 +421,26 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) } settings->is_autotext = configItem->Orentation == 4; - settings->is_backrotate180 = configItem->EnBackRotate180; + settings->is_backrotate180 =configItem->EnBackRotate180; settings->hardwarecaps.en_skrewdetect = configItem->EnScrewDetect; settings->hardwarecaps.skrewdetectlevel = (float)configItem->ScrewDetectLevel; settings->hardwarecaps.en_stapledetect = configItem->EnBindingDetect; settings->hardwarecaps.en_doublefeed = configItem->EnUltrasonicDetect; - settings->en_fold = configItem->EnFlod?1:0;//add ly - bool bVal = settings->is_duplex; - //if (configItem->ScanCount == -1) - settings->scannum = configItem->ScanCount; - //else{ - // if (settings->multi_output_red) - // configItem->ScanCount /= 2; - // settings->scannum = bVal ? configItem->ScanCount / 2 : configItem->ScanCount; - //} + 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) { if (configItem->Filter <= 3) { settings->filter = (byte)filterMaps[configItem->Filter]; - settings->enhance_color =(byte)EnchaceColor::Enhance_None; + settings->enhance_color = (byte)EnchaceColor::Enhance_None; } else { settings->filter = 3;//不除色 @@ -406,9 +451,9 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs) settings->filter = 3; settings->enhance_color = (byte)EnchaceColor::Enhance_None; } - + settings->sharpen = configItem->Sharpen; - if (configItem->Filter != 0||configItem->EnMultiOutPutR) + if (configItem->Filter != 0 || configItem->EnMultiOutPutR) settings->hardwarecaps.capturepixtype = TWPT_RGB; settings->fillhole.is_fillhole = configItem->EnOutHole; @@ -449,6 +494,11 @@ void CTwainUI::UpdateListConfig() } } +void CTwainUI::GetGScanCap(GScanCap & cap) +{ + cap = *settings; +} + void CTwainUI::UpdateUi() { m_pageImageProc->m_cmBoxFilter.EnableWindow(m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0); @@ -463,8 +513,8 @@ void CTwainUI::UpdateUi() } ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(!(dupindex == 4)); m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(!enableback); - 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_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); } @@ -487,14 +537,14 @@ void CTwainUI::OnBnClickedBtnbackupconfig() cfd.m_ofn.lpstrTitle = _T(""); cfd.m_ofn.lpstrFilter = csFilters; this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - JsonConfig js; + GscanJsonConfig js; if (IDOK == cfd.DoModal()) { - vector vc_tempOut; + vector vc_tempOut; std::vector temp_cfi = getConfigFiles(); for (int i = 0; i < temp_cfi.size(); i++) { - vector vc_item = js.ReadJsonArrayFromFile(temp_cfi[i].SavePath.c_str()); + vector vc_item = js.ReadGscanCapsVector(temp_cfi[i].SavePath.c_str()); if (vc_item.size() > 0) { vc_tempOut.push_back(vc_item[0]); @@ -542,7 +592,7 @@ void CTwainUI::OnBnClickedBtnrecoveryconfig() this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); if (MessageBox(TEXT("如果恢复,当前所有已保存配置将丢失。是否继续?"), TEXT("恢复"), MB_YESNO | MB_ICONQUESTION) == IDYES) { - JsonConfig js; + GscanJsonConfig js; CFileDialog ofd(TRUE, _T(".json"), NULL, @@ -557,11 +607,11 @@ void CTwainUI::OnBnClickedBtnrecoveryconfig() if (IDOK == ofd.DoModal()) { std::string path = (CW2A)ofd.GetPathName(); - vector vc = js.ReadJsonArrayFromFile(path); + vector vc = js.ReadGscanCapsVector(path); for (int i = 0; i < vc.size(); i++) { // js.WriteJsonArrayToFile(vc[i],vc[i].SavePath); - vector vc_item; + vector vc_item; vc_item.push_back(vc[i]); js.WriteJsonArrayToFile(vc_item, vc[i].SavePath); } @@ -579,13 +629,14 @@ void CTwainUI::OnLbnSelchangeLstconfig() index = ((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->GetCurSel(); if (index != -1) { - JsonConfig js; + GscanJsonConfig js; //std::string savepath= cfi[index].SavePath; - std::vector vc_temp; - vc_temp = js.ReadJsonArrayFromFile(cfi[index].SavePath); + std::vector vc_temp; + vc_temp = js.ReadGscanCapsVector(cfi[index].SavePath); if (vc_temp.size() > 0) { - UpdateUI(vc_temp[0]); + settings.reset(new GScanCap(vc_temp[0])); + UpdateUI(); } } } diff --git a/huagao/CTwainUI.h b/huagao/CTwainUI.h index 46fcb09c..f06b5dc1 100644 --- a/huagao/CTwainUI.h +++ b/huagao/CTwainUI.h @@ -1,12 +1,12 @@ #pragma once #include #include "twglue.hpp" -#include "Device/JsonConfig.h" #include "CSaveConfigDlg.h" #include "Device/PublicFunc.h" #include "Device/PaperSize.h" #include - +#include "MapFinder.h" +#include class CTabCtrlSSL; class CTabPageSSL; class CImageProcPage; @@ -24,6 +24,7 @@ static int Resolutions[SUPPORTRESNUMS] = {100,150,200,240,300}; #define TWPT_GRAY 1 #define TWPT_RGB 2 +#ifdef G200 static std::map paperStatusMap = { {0,{TwSS::A3,PaperAlign::Rot0}}, {1,{TwSS::A4,PaperAlign::Rot0}}, @@ -45,6 +46,45 @@ static std::map paperStatusMap = { {17,{TwSS::USStatement,PaperAlign::Rot0}}, {18,{TwSS::MaxSize,PaperAlign::Rot0}} }; +#endif + +#ifdef G300 +static std::map paperStatusMap = { + {0,{TwSS::A4,PaperAlign::Rot0}}, + {1,{TwSS::A5,PaperAlign::Rot0}}, + {2,{TwSS::A6,PaperAlign::Rot0}}, + {3,{TwSS::B4,PaperAlign::Rot0}}, + {4,{TwSS::B5,PaperAlign::Rot0}}, + {5,{TwSS::B6,PaperAlign::Rot0}}, + {6,{TwSS::USLetter,PaperAlign::Rot0}}, + {7,{TwSS::USLegal,PaperAlign::Rot0}}, + {8,{TwSS::None,PaperAlign::Rot0}}, +}; +#endif + +#ifdef G400 +static std::map paperStatusMap = { + {0,{TwSS::A3,PaperAlign::Rot0}}, + {1,{TwSS::A4,PaperAlign::Rot0}}, + {2,{TwSS::A4,PaperAlign::Rot270}}, + {3,{TwSS::A5,PaperAlign::Rot0}}, + {4,{TwSS::A5,PaperAlign::Rot270}}, + {5,{TwSS::A6,PaperAlign::Rot0}}, + {6,{TwSS::A6,PaperAlign::Rot270}}, + {7,{TwSS::B4,PaperAlign::Rot0}}, + {8,{TwSS::B5,PaperAlign::Rot0}}, + {9,{TwSS::B5,PaperAlign::Rot270}}, + {10,{TwSS::B6,PaperAlign::Rot0}}, + {11,{TwSS::B6,PaperAlign::Rot270}}, + {12,{TwSS::USLetter,PaperAlign::Rot0}}, + {13,{TwSS::USLetter,PaperAlign::Rot270}}, + {14,{TwSS::USLedger,PaperAlign::Rot0}}, + {15,{TwSS::USLegal,PaperAlign::Rot0}}, + {16,{TwSS::None,PaperAlign::Rot0}}, + {17,{TwSS::USStatement,PaperAlign::Rot0}}, + {18,{TwSS::MaxSize,PaperAlign::Rot0}} +}; +#endif static std::map filterMaps = { {0,3},//不除色 None @@ -118,13 +158,13 @@ class CTwainUI : public CDialogEx DECLARE_DYNAMIC(CTwainUI) public: - CTwainUI(TwGlue glue,std::string confirmtitle,std::string hardwareversion,std::string serialnum, CWnd* pParent = nullptr); // 标准构造函数 + CTwainUI(TwGlue glue,GScanCap caps,std::string confirmtitle,std::string hardwareversion,std::string serialnum, CWnd* pParent = nullptr); // 标准构造函数 virtual ~CTwainUI(); - void UpdateUI(CONFIGPARAMS configParams); + void UpdateUI(); void UpDateScanParam(PCONFIGPARAMS pConfigItem, bool updateDs = true); void UpdateListConfig(); - + void GetGScanCap(GScanCap& cap); void UpdateUi(); void EnableID_OKorID_Cancel(bool enable); @@ -156,15 +196,21 @@ protected: std::unique_ptr m_pageFeedPaper; std::unique_ptr m_pageBrightness; std::unique_ptr m_pageImageProc; +public: + afx_msg void OnClose(); +private: + void UpdateFilterCmbx(); + void UpdateSharpenCmbx(); + int getCmbDuplexIndex(); TwGlue m_glue; std::vector cfi; int getResolutionIndex(int resolution); - int getPaparSizeIndex(int papersize,int orentation); + int getPaparSizeIndex(int papersize, int orentation); int getColorModelIndex(int pixtype); + int getRotateCmbIndex(float res); std::vector getConfigFiles(); std::unique_ptr settings; std::string m_confirmtitle; -public: - afx_msg void OnClose(); + }; diff --git a/huagao/huagaotwds.rc b/huagao/huagaotwds.rc index 9298c4c75b947f41fdc557b00e85e229956ddacf..b3b5fc195619b01d45324afe773ca8fd27989785 100644 GIT binary patch delta 313 zcmdlpk!i*ZrVS<1lN~g*)R*`rB`0T}4NjV_#Gu3A$>74^%n%R6-V9C*!3^O*kq{uy zWAajG@5$%vB$$mDj3#G0Nlt!IFE@E#o!I6T(qc@EMw9o;-e)w}JYTM#nbRC-jv<3N zgW+UHN%PGGN>>=!je$bO3}%z}TjoyYlU3sC@v{jK3+9++6EOLLjFO-wg8@*15rY|n z36M4cDtsuZKe@n6Zj!tdYY2k}L(t@Y&6(UrKtn;w3>YjYZ&t9M{7czL6fDc&3Klm8 z+5wU`oP1Czc5;BO$Yc*kzRe3%ZYWLu6T!h6%HYQkvbouPrV^_WP@VB)#VlPYYi^e0 h=A5iGOhB$4P-0`A_~eEhvCUq&NsJJo%^UN$r2un)R3`uc delta 159 zcmbO+gK5u1rVS<1lkWwIO;*t0m^`mcWOJE}1k>b0vNDs`$=ghRCfC7exH(_GpPAc` z!H7YJ!H~h6!DOWc>o%lcm uCb4-IbD8ku9C5$N??m~KRR~PJC&tETJh_lvdGi5rE5XSQ8d{T8G{XQL?JyPq delta 50 zcmV-20L}mERr*q}J_D1^0Sb}?RvoIMt5tDoa I7L$M~YU9}vz5oCK diff --git a/huagao/stdafx.cpp b/huagao/stdafx.cpp index cc3e78f7b2f30e8f6240f26eb79be7ae5943b258..233ec0dbd60642b346c15e3f6f6fa6b3beecee88 100644 GIT binary patch delta 6 NcmaFIev5I!EdUE513Lf! literal 1006 zcmbVKJ5Rz;7(ELTOk7=UaM2iHabh!Il!2nOiX=@?ptYz05`2(o;zHuU!f5zGuEvek zl{h=9=evMy5rQ$zy=~g_?03IDDJ`Fghg_N?cy3|WY?*3%X<|ysx_(9pq5L-f@NhBdi!bl;k6TXw+bFN=v+q$ z=L#=wL;T%+C;yhMp9n|Rs?smxlCBllL`Ns`yL{tEI|}Czxrak+W0xz7B95?w+(=WD z9Hnd{f+W9Zuuq(h0+BkOGDJsUazEz2Mi1TS_o7&zqM(tRqehB;Nup;d^m{Aai_%MZ zpnE!1=8*pp3z1e^b6{I8948*9n)-`b5ClX>S&%0Kma4Q0Y<-#H2P T^PgL9QnAsAnBHRO=%3m*sCA`x diff --git a/huagao/stdafx.h b/huagao/stdafx.h index fcf85a7ce92bef2f8e13d29073111997508a607e..80951067bac62f0cd3544c33a97ee978139adf38 100644 GIT binary patch delta 281 zcmdm@`apfd5{}7Ti~{NI3?>W)K*-C$1;)w@nG9(RDGaGVQh~vp!3Zv^&!Eqs43)`b z$OEcSVDMxJ2C6ZHt3lO`Bs=*br=>Vdr4rPpRE8XeVunv6ZS0{}w9F*5)F delta 198 zcmaE$zD0Gz5)Nj42K~v6ETXwd4EaD<%uvD*1H>5&MGUD7i3}+~UO7W1Lmq=MgAtIO z%aF#9%n*;FA|5QC2^7-<>MH<3I|g0`E(V~<49Y+gQh|CvCZsYbFt`IvF<>y5ype0~ zWHoMq$p)M%;vNja47v;!KygDLR$vHV2x9POP?{{rt2nujdyB9kSPxhqgDFsr5m3&M LRdjO{Pa8V`1%@U-