1.根据协议值更新UI 逻辑调整,简化代码‘

2.增加不同系列产品,条件编译,提高代码版本控制;
This commit is contained in:
lovelyyoung 2020-06-20 11:04:32 +08:00
parent 5f8576b688
commit 59cecd0950
12 changed files with 285 additions and 118 deletions

View File

@ -8,7 +8,6 @@
#include "CAboutDlg.h" #include "CAboutDlg.h"
#include "CTwainUI.h" #include "CTwainUI.h"
#include "CDiscardBlankSetting.h" #include "CDiscardBlankSetting.h"
#include "Device/JsonConfig.h"
#include <vector> #include <vector>
static std::vector<CString> color_Modes = { static std::vector<CString> color_Modes = {
@ -17,8 +16,10 @@ static std::vector<CString> color_Modes = {
_T("黑白") _T("黑白")
}; };
#ifdef G200
static std::vector<CString> surportStyles = { static std::vector<CString> surportStyles = {
_T("A3"), _T("A3"),//pass
_T("A4"), _T("A4"),
_T("A4横向"), _T("A4横向"),
_T("A5"), _T("A5"),
@ -32,14 +33,50 @@ static std::vector<CString> surportStyles = {
_T("B6横向"), _T("B6横向"),
_T("Letter"), _T("Letter"),
_T("Letter横向"), _T("Letter横向"),
_T("Double Letter"), _T("Double Letter"),//pass
_T("LEGAL"), _T("LEGAL"),
_T("匹配原始尺寸"), _T("匹配原始尺寸"),
#ifdef G200
_T("最大扫描尺寸自动裁切"), _T("最大扫描尺寸自动裁切"),
_T("最大扫描尺寸"), _T("最大扫描尺寸"),
#endif // G200
}; };
#endif
#ifdef G300
static std::vector<CString> surportStyles = {
_T("A4"),
_T("A5"),
_T("A6"),
_T("B4"),
_T("B5"),
_T("B6"),
_T("Letter"),
_T("LEGAL"),
_T("匹配原始尺寸"),
};
#endif
#ifdef G400
static std::vector<CString> 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<CString> reslutions{ static std::vector<CString> reslutions{
_T("100"), _T("100"),
@ -68,6 +105,7 @@ CBasicPage::CBasicPage(std::function<void()> dataChange, CWnd* pParent /*=nullpt
, m_dataChange(dataChange) , m_dataChange(dataChange)
, AreaNum(8) , AreaNum(8)
, DevnMax(200) , DevnMax(200)
, m_bswitchfrontback(FALSE)
{ {
} }
@ -79,6 +117,7 @@ CBasicPage::~CBasicPage()
void CBasicPage::DoDataExchange(CDataExchange* pDX) void CBasicPage::DoDataExchange(CDataExchange* pDX)
{ {
CTabPageSSL::DoDataExchange(pDX); CTabPageSSL::DoDataExchange(pDX);
DDX_Check(pDX, IDC_CKBSWITCHFRONTBACK, m_bswitchfrontback);
} }
BOOL CBasicPage::OnInitDialog() BOOL CBasicPage::OnInitDialog()

View File

@ -27,6 +27,7 @@ public:
public: public:
int AreaNum; int AreaNum;
int DevnMax; int DevnMax;
BOOL m_bswitchfrontback;
// 对话框数据 // 对话框数据
#ifdef AFX_DESIGN_TIME #ifdef AFX_DESIGN_TIME

View File

@ -28,9 +28,11 @@ void CBrightnessPage::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_EDIT_BRIGHTNESS, m_Edit_Brightness); DDX_Control(pDX, IDC_EDIT_BRIGHTNESS, m_Edit_Brightness);
DDX_Control(pDX, IDC_EDIT_CONSTRAST, m_Edit_Contrast); DDX_Control(pDX, IDC_EDIT_CONSTRAST, m_Edit_Contrast);
DDX_Control(pDX, IDC_EDIT_GAMMA, m_Edit_Gamma); 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_BRIGTHNESS, m_Slider_Brightness);
DDX_Control(pDX, IDC_SLIDER_CONTRAST, m_Slider_Contrast); DDX_Control(pDX, IDC_SLIDER_CONTRAST, m_Slider_Contrast);
DDX_Control(pDX, IDC_SLIDER_GAMMA, m_Slider_Gamma); 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); 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.SetSlideLink(this, IDC_SLIDER_GAMMA);
m_Edit_Gamma.SetParams(0.01, 5.0, 10, _T("%0.2f")); m_Edit_Gamma.SetParams(0.01, 5.0, 10, _T("%0.2f"));
m_Edit_Gamma.SetValue(1.0); 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; return true;
} }

View File

@ -17,9 +17,11 @@ public:
CSmartEdit m_Edit_Brightness; CSmartEdit m_Edit_Brightness;
CSmartEdit m_Edit_Contrast; CSmartEdit m_Edit_Contrast;
CSmartEdit m_Edit_Gamma; CSmartEdit m_Edit_Gamma;
CSmartEdit m_Edit_Thre;
CLinkSlider m_Slider_Brightness; CLinkSlider m_Slider_Brightness;
CLinkSlider m_Slider_Contrast; CLinkSlider m_Slider_Contrast;
CLinkSlider m_Slider_Gamma; CLinkSlider m_Slider_Gamma;
CLinkSlider m_Slider_Thre;
BOOL m_cbAutoContrast; BOOL m_cbAutoContrast;
// 对话框数据 // 对话框数据

View File

@ -5,9 +5,22 @@
#include "CFeedPaperPage.h" #include "CFeedPaperPage.h"
#include "afxdialogex.h" #include "afxdialogex.h"
#include "resource.h" #include "resource.h"
#include <vector>
std::vector<int> g400hiden =
{
IDC_CKBINDINGDETECT ,
IDC_LBCOUNT ,
IDC_RDCONSISTSCAN,
IDC_RDSPECIFYSCANNUM,
IDC_EDSCANNUM,
IDC_CKSKEWDETECT,
IDC_LBSDL,
IDC_SLDDETECTLEVEL,
IDC_LBSDR,
IDC_CKBACKROTATION
};
// CFeedPaperPage 对话框 // CFeedPaperPage 对话框
@ -51,6 +64,14 @@ BOOL CFeedPaperPage::OnInitDialog()
OnInitcmBoxOrentation(0); OnInitcmBoxOrentation(0);
m_sldSkrewDetecttion.SetSlideRange(1, 5); m_sldSkrewDetecttion.SetSlideRange(1, 5);
m_sldSkrewDetecttion.SetSlidePos(3); m_sldSkrewDetecttion.SetSlidePos(3);
#ifndef G200
for (size_t i = 0; i < g400hiden.size(); i++)
{
GetDlgItem(g400hiden[i])->ShowWindow(FALSE);
}
#endif // G200
return true; return true;
} }

View File

@ -5,7 +5,7 @@
#include "CSaveConfigDlg.h" #include "CSaveConfigDlg.h"
#include "CTwainUI.h" #include "CTwainUI.h"
#include <io.h> #include <io.h>
#include "GscanJsonConfig.h"
// CSaveConfigDlg 对话框 // CSaveConfigDlg 对话框
@ -46,12 +46,11 @@ void CSaveConfigDlg::OnBnClickedOk()
{ {
CTwainUI* m_Parent=(CTwainUI*)GetParent(); CTwainUI* m_Parent=(CTwainUI*)GetParent();
CONFIGPARAMS citem={0}; CONFIGPARAMS citem={0};
m_Parent->UpDateScanParam(&citem,false); m_Parent->UpDateScanParam(&citem);
CString m_sName; CString m_sName;
GetDlgItemText(IDC_EDITSAVENAME,m_sName); GetDlgItemText(IDC_EDITSAVENAME,m_sName);
TCHAR szIniFile[MAX_PATH] = { 0 }; TCHAR szIniFile[MAX_PATH] = { 0 };
INT length=m_sName.GetLength(); INT length=m_sName.GetLength();
//INT length=10;
if (length>0&&length<50) if (length>0&&length<50)
{ {
char invalid_FileChars[8]={'/','\\',':','*',' ?','<', '>','|'}; char invalid_FileChars[8]={'/','\\',':','*',' ?','<', '>','|'};
@ -77,8 +76,10 @@ void CSaveConfigDlg::OnBnClickedOk()
_tcscat(szIniFile,m_sName+_TEXT(".json")); _tcscat(szIniFile,m_sName+_TEXT(".json"));
std::string s_savePath = TCHAR2STRING2(szIniFile); std::string s_savePath = TCHAR2STRING2(szIniFile);
citem.SavePath=s_savePath; citem.SavePath=s_savePath;
JsonConfig cfg; GscanJsonConfig cfg;
cfg.WriteToJson(&citem,s_savePath,true); GScanCap caps = { 0 };
m_Parent->GetGScanCap(caps);
cfg.SaveGscanCapConfig(caps,s_savePath);
m_Parent->UpdateListConfig(); m_Parent->UpdateListConfig();
CDialog::OnOK(); CDialog::OnOK();
} }

View File

@ -12,23 +12,24 @@
#include "Device/PaperSize.h" #include "Device/PaperSize.h"
#include <list> #include <list>
#include "filetools.h" #include "filetools.h"
#include "GscanJsonConfig.h"
// CTwainUI 对话框 // CTwainUI 对话框
IMPLEMENT_DYNAMIC(CTwainUI, CDialogEx) 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) : CDialogEx(IDD_TWAINUI, pParent)
, m_tabCtrl(new CTabCtrlSSL()) , m_tabCtrl(new CTabCtrlSSL())
, m_pageBrightness(new CBrightnessPage) , m_pageBrightness(new CBrightnessPage)
, m_pageFeedPaper(new CFeedPaperPage) , m_pageFeedPaper(new CFeedPaperPage)
, m_pageImageProc(new CImageProcPage) , m_pageImageProc(new CImageProcPage)
, m_glue(glue) , m_glue(glue)
, settings(new GScanCap) , settings(new GScanCap(caps))
, m_confirmtitle(confirmtitle) , m_confirmtitle(confirmtitle)
{ {
m_hardwareVersion = hardwareversion; m_hardwareVersion = hardwareversion;
m_serialnum = serialnum; m_serialnum = serialnum;
memset(settings.get(), 0, sizeof(GScanCap)); //memset(settings.get(), 0, sizeof(GScanCap));
} }
CTwainUI::~CTwainUI() CTwainUI::~CTwainUI()
@ -66,10 +67,9 @@ BOOL CTwainUI::OnInitDialog()
m_pageFeedPaper->Create(IDD_PAGEFEEDPAPER, this); m_pageFeedPaper->Create(IDD_PAGEFEEDPAPER, this);
m_tabCtrl->AddSSLPage(_T("送纸"), nPageID++, m_pageFeedPaper.get()); m_tabCtrl->AddSSLPage(_T("送纸"), nPageID++, m_pageFeedPaper.get());
CString title(m_confirmtitle.c_str()); CString title(m_confirmtitle.c_str());
this->GetDlgItem(IDC_CONFIRM)->SetWindowTextW(title); this->GetDlgItem(IDC_CONFIRM)->SetWindowText(title);
JsonConfig cfg;
CONFIGPARAMS configParams = cfg.ReadDefaultConfig(); UpdateUI();
UpdateUI(configParams);
UpdateListConfig(); UpdateListConfig();
UpdateUi(); UpdateUi();
return true; return true;
@ -90,35 +90,11 @@ BEGIN_MESSAGE_MAP(CTwainUI, CDialogEx)
END_MESSAGE_MAP() 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() void CTwainUI::OnBnClickedConfirm()
{ {
// TODO: 在此添加控件通知处理程序代码 // TODO: 在此添加控件通知处理程序代码
CString str_caption; CONFIGPARAMS cfg = { 0 };
GetDlgItemText(IDC_CONFIRM, str_caption); UpDateScanParam(&cfg);
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<CONFIGPARAMS> vc;
vc.push_back(configItem);
std::string savepath = TCHAR2STRING1(szIniFile);
js.WriteJsonArrayToFile(vc, savepath);
m_glue.m_scan(*settings); m_glue.m_scan(*settings);
} }
@ -126,9 +102,10 @@ void CTwainUI::OnBnClickedConfirm()
void CTwainUI::OnBnClickedBtndefault() void CTwainUI::OnBnClickedBtndefault()
{ {
// TODO: 在此添加控件通知处理程序代码 // TODO: 在此添加控件通知处理程序代码
JsonConfig js; GscanJsonConfig js;
CONFIGPARAMS cf = js.GetDefaultConfigParams(); GScanCap cf = js.GetDefaultGscancapValue();
UpdateUI(cf); settings.reset(new GScanCap(cf));
UpdateUI();
} }
@ -154,44 +131,55 @@ void CTwainUI::OnBnClickedBtnhelp()
this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); this->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
} }
void CTwainUI::UpdateUI(CONFIGPARAMS configParams) void CTwainUI::UpdateUI()
{ {
//!< Page Basic //!< basic page
m_pageBasic->m_cmBoxColorMode->SetCurSel(configParams.Pixtype);//!< 颜色模式 m_pageBasic->m_cmBoxColorMode->SetCurSel(get_map_key_by_value(colorModes, settings->pixtype));//!< 颜色模式
m_pageBasic->m_cmBoxResultion->SetCurSel(configParams.Resolution);//!< 分辨率 m_pageBasic->m_cmBoxResultion->SetCurSel(get_map_key_by_value(resolutions, settings->resolution_dst));//!< 分辨率
m_pageBasic->m_cmBoxDuplex->SetCurSel(configParams.Duplex);//!< 单双面 m_pageBasic->m_cmBoxDuplex->SetCurSel(getCmbDuplexIndex());//!< 单双面
m_pageBasic->m_cmBoxSS->SetCurSel(configParams.PaperSize); //!< 纸张类型 m_pageBasic->m_cmBoxSS->SetCurSel(getPaparSizeIndex(settings->papertype, settings->paperAlign)); //!< 纸张类型
m_pageBasic->m_bswitchfrontback = settings->is_switchfrontback ? TRUE : FALSE; //!< 交换正反面
m_pageBasic->UpdateData(FALSE); m_pageBasic->UpdateData(FALSE);
//!< Page Breghtness //!< Page Breghtness
m_pageBrightness->m_cbAutoContrast = settings->is_autocontrast==TRUE?TRUE:FALSE; //!< 自动亮度对比度
m_pageBrightness->m_cbAutoContrast = configParams.EnAutoContrast; //!< 自动亮度对比度 int brt = GetMappingBrightnessValue(settings->brightness);
int brt = GetMappingBrightnessValue(configParams.Brightness);
m_pageBrightness->m_Edit_Brightness.SetValue(brt); //!< 亮度 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_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); m_pageBrightness->UpdateData(FALSE);
//!< Page Proc //!< Page Proc
m_pageImageProc->m_ckbFillBlack = configParams.EnFillBlack?TRUE:FALSE;//填充黑框 m_pageImageProc->m_ckbFillBlack = settings->fillbackground==TRUE ? TRUE : FALSE;//填充黑框
m_pageImageProc->m_ckbAutoDeskrew =configParams.EnAutoDescrew? TRUE : FALSE;//自动纠偏 m_pageImageProc->m_ckbAutoDeskrew = settings->autodescrew ? TRUE : FALSE;//自动纠偏
m_pageImageProc->m_cmBoxFilter.SetCurSel(configParams.Filter);//除色 UpdateFilterCmbx();
m_pageImageProc->m_cmBoxSharpen.SetCurSel(configParams.Sharpen);//锐化 UpdateSharpenCmbx();
m_pageImageProc->m_ckbRemoveHole = configParams.EnOutHole;//除穿孔可用性 m_pageImageProc->m_ckbRemoveHole = settings->fillhole.is_fillhole==TRUE?TRUE:FALSE;//除穿孔可用性
m_pageImageProc->m_edit_hole.SetValue(configParams.OutHoleRatio/100.0);//穿孔搜索范围比例系数 m_pageImageProc->m_edit_hole.SetValue(settings->fillhole.fillholeratio/ 100.0);//穿孔搜索范围比例系数
m_pageImageProc->m_ckbMultioutput = configParams.EnMultiOutPutR;//多流除红 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); m_pageImageProc->UpdateData(FALSE);
//!< Page feed paper //!< Page feed paper
m_pageFeedPaper->m_cbRotation = configParams.EnBackRotate180? TRUE : FALSE;//背面旋转180 if(settings->is_duplex==TRUE)
m_pageFeedPaper->m_cbStaple = configParams.EnBindingDetect? TRUE : FALSE;//装订检测 m_pageFeedPaper->m_cbRotation = settings->is_backrotate180==TRUE ? TRUE : FALSE;//背面旋转180
m_pageFeedPaper->m_cbDoublePaper = configParams.EnUltrasonicDetect? TRUE : FALSE;//双张检测 else
m_pageFeedPaper->m_cbSkew = configParams.EnScrewDetect? TRUE : FALSE;//歪斜检测 {
m_pageFeedPaper->m_cmBoxOrentation.SetCurSel(configParams.Orentation);//旋转方向; m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(FALSE);
m_pageFeedPaper->m_sldSkrewDetecttion.SetPos(configParams.ScrewDetectLevel);//歪斜检测等级 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->m_radioGroupScanMode = 0;
m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(_T("1")); 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->GetDlgItem(IDC_EDSCANNUM)->EnableWindow(TRUE);
m_pageFeedPaper->m_radioGroupScanMode = 1; m_pageFeedPaper->m_radioGroupScanMode = 1;
int tempcount = configParams.ScanCount; int tempcount = settings->scannum;
CString csCount; 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); m_pageFeedPaper->GetDlgItem(IDC_EDSCANNUM)->SetWindowText(csCount);
} }
@ -211,6 +199,47 @@ void CTwainUI::UpdateUI(CONFIGPARAMS configParams)
m_pageBasic->updateCmbDuplex(TRUE); 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 CTwainUI::getResolutionIndex(int resolution)
{ {
int result = 0; int result = 0;
@ -225,9 +254,9 @@ int CTwainUI::getResolutionIndex(int resolution)
return result; 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; int result = 0;
for (std::map<int, PaperStatus>::iterator it = paperStatusMap.begin(); it != paperStatusMap.end(); it++) { for (std::map<int, PaperStatus>::iterator it = paperStatusMap.begin(); it != paperStatusMap.end(); it++) {
if (it->second.Paper == ps.Paper && it->second.Orentate == ps.Orentate) { 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); 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> CTwainUI::getConfigFiles()
{ {
vector<CONFIGINFO> vc_cfi; vector<CONFIGINFO> vc_cfi;
@ -285,7 +326,7 @@ static float WndCtrl2f(const CWnd* wnd)
} }
template<typename T> template<typename T>
static T* GetCtrl(const CWnd* wnd, int nID) static T* GetCtrl(const CWnd* wnd, int nID)
{ {
return wnd->GetDlgCtrlID(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->Resolution = m_pageBasic->m_cmBoxResultion->GetCurSel();//!< 分辨率 index
configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面 configItem->Duplex = m_pageBasic->m_cmBoxDuplex->GetCurSel();//!< 单双面
configItem->PaperSize = m_pageBasic->m_cmBoxSS->GetCurSel();//!< 纸张类型 index 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->EnDiscardBlank = configItem->Duplex == 2;//自动跳骨空白页通用
configItem->EnDiscardBlankVince = configItem->Duplex == 3;//自动跳骨空白页发票 configItem->EnDiscardBlankVince = configItem->Duplex == 3;//自动跳骨空白页发票
configItem->EnFlod = configItem->Duplex == 4; configItem->EnFlod = configItem->Duplex == 4;
@ -310,7 +354,7 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
//!< Page Breghtness //!< Page Breghtness
m_pageBrightness->UpdateData(); m_pageBrightness->UpdateData();
configItem->EnAutoContrast = m_pageBrightness->m_cbAutoContrast; //!< 自动亮度对比度 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; int crtvalue = WndCtrl2i(&(m_pageBrightness->m_Edit_Contrast)) - 4;
configItem->Contrast = GetContrast(crtvalue);//!<对比度 configItem->Contrast = GetContrast(crtvalue);//!<对比度
configItem->Gamma = WndCtrl2f(&(m_pageBrightness->m_Edit_Gamma)); //!< gamma 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->Filter = m_pageImageProc->m_cmBoxFilter.GetCurSel();//除色
configItem->Sharpen = m_pageImageProc->m_cmBoxSharpen.GetCurSel();//锐化 configItem->Sharpen = m_pageImageProc->m_cmBoxSharpen.GetCurSel();//锐化
configItem->EnOutHole = m_pageImageProc->m_ckbRemoveHole;//除穿孔可用性 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;//多流除红 configItem->EnMultiOutPutR = m_pageImageProc->m_ckbMultioutput;//多流除红
//!< Page feed paper //!< Page feed paper
@ -345,16 +389,16 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
if (!updateDs) if (!updateDs)
return; return;
settings->pixtype =colorModes[configItem->Pixtype]; settings->pixtype = colorModes[configItem->Pixtype];
settings->hardwarecaps.capturepixtype = settings->pixtype; settings->hardwarecaps.capturepixtype = settings->pixtype;
PaperStatus paper= paperStatusMap[configItem->PaperSize]; PaperStatus paper = paperStatusMap[configItem->PaperSize];
settings->papertype = paper.Paper; settings->papertype = paper.Paper;
settings->paperAlign = (PaperAlign)paper.Orentate; settings->paperAlign = (PaperAlign)paper.Orentate;
settings->resolution_dst = Resolutions[configItem->Resolution]; settings->resolution_dst = Resolutions[configItem->Resolution];
settings->resolution_native = 200.0f; settings->resolution_native = 200.0f;
settings->is_switchfrontback = configItem->EnSwitchFrontBack ? 1 : 0;
//float value_Contrast = GetContrast(configItem->Contrast); //float value_Contrast = GetContrast(configItem->Contrast);
settings->contrast = configItem->Contrast; settings->contrast = configItem->Contrast;
settings->brightness = (configItem->Brightness); settings->brightness = (configItem->Brightness);
@ -377,25 +421,26 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
} }
settings->is_autotext = configItem->Orentation == 4; settings->is_autotext = configItem->Orentation == 4;
settings->is_backrotate180 = configItem->EnBackRotate180; settings->is_backrotate180 =configItem->EnBackRotate180;
settings->hardwarecaps.en_skrewdetect = configItem->EnScrewDetect; settings->hardwarecaps.en_skrewdetect = configItem->EnScrewDetect;
settings->hardwarecaps.skrewdetectlevel = (float)configItem->ScrewDetectLevel; settings->hardwarecaps.skrewdetectlevel = (float)configItem->ScrewDetectLevel;
settings->hardwarecaps.en_stapledetect = configItem->EnBindingDetect; settings->hardwarecaps.en_stapledetect = configItem->EnBindingDetect;
settings->hardwarecaps.en_doublefeed = configItem->EnUltrasonicDetect; settings->hardwarecaps.en_doublefeed = configItem->EnUltrasonicDetect;
settings->en_fold = configItem->EnFlod?1:0;//add ly settings->en_fold = configItem->EnFlod ? 1 : 0;
bool bVal = settings->is_duplex; if (configItem->ScanCount == -1)
//if (configItem->ScanCount == -1) settings->scannum = configItem->ScanCount;
settings->scannum = configItem->ScanCount; else {
//else{ if (configItem->Duplex == 0)//单面
// if (settings->multi_output_red) settings->scannum = configItem->ScanCount;
// configItem->ScanCount /= 2; else {
// settings->scannum = bVal ? configItem->ScanCount / 2 : configItem->ScanCount; settings->scannum = configItem->ScanCount * 2;
//} }
}
if (configItem->Filter){ if (configItem->Filter) {
if (configItem->Filter <= 3) { if (configItem->Filter <= 3) {
settings->filter = (byte)filterMaps[configItem->Filter]; settings->filter = (byte)filterMaps[configItem->Filter];
settings->enhance_color =(byte)EnchaceColor::Enhance_None; settings->enhance_color = (byte)EnchaceColor::Enhance_None;
} }
else { else {
settings->filter = 3;//不除色 settings->filter = 3;//不除色
@ -406,9 +451,9 @@ void CTwainUI::UpDateScanParam(PCONFIGPARAMS configItem, bool updateDs)
settings->filter = 3; settings->filter = 3;
settings->enhance_color = (byte)EnchaceColor::Enhance_None; settings->enhance_color = (byte)EnchaceColor::Enhance_None;
} }
settings->sharpen = configItem->Sharpen; settings->sharpen = configItem->Sharpen;
if (configItem->Filter != 0||configItem->EnMultiOutPutR) if (configItem->Filter != 0 || configItem->EnMultiOutPutR)
settings->hardwarecaps.capturepixtype = TWPT_RGB; settings->hardwarecaps.capturepixtype = TWPT_RGB;
settings->fillhole.is_fillhole = configItem->EnOutHole; settings->fillhole.is_fillhole = configItem->EnOutHole;
@ -449,6 +494,11 @@ void CTwainUI::UpdateListConfig()
} }
} }
void CTwainUI::GetGScanCap(GScanCap & cap)
{
cap = *settings;
}
void CTwainUI::UpdateUi() void CTwainUI::UpdateUi()
{ {
m_pageImageProc->m_cmBoxFilter.EnableWindow(m_pageBasic->m_cmBoxColorMode->GetCurSel() != 0); 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)); ((CButton*)m_pageImageProc->GetDlgItem(IDC_CKAUTODESKREW))->EnableWindow(!(dupindex == 4));
m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(!enableback); m_pageFeedPaper->GetDlgItem(IDC_CKBACKROTATION)->EnableWindow(!enableback);
m_pageImageProc->GetDlgItem(IDC_SLDOUTHOLE)->EnableWindow(((CButton*)m_pageImageProc->GetDlgItem(IDC_CKREMOVEHOLE))->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_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); 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.lpstrTitle = _T("");
cfd.m_ofn.lpstrFilter = csFilters; cfd.m_ofn.lpstrFilter = csFilters;
this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
JsonConfig js; GscanJsonConfig js;
if (IDOK == cfd.DoModal()) if (IDOK == cfd.DoModal())
{ {
vector<CONFIGPARAMS> vc_tempOut; vector<GScanCap> vc_tempOut;
std::vector<CONFIGINFO> temp_cfi = getConfigFiles(); std::vector<CONFIGINFO> temp_cfi = getConfigFiles();
for (int i = 0; i < temp_cfi.size(); i++) for (int i = 0; i < temp_cfi.size(); i++)
{ {
vector<CONFIGPARAMS> vc_item = js.ReadJsonArrayFromFile(temp_cfi[i].SavePath.c_str()); vector<GScanCap> vc_item = js.ReadGscanCapsVector(temp_cfi[i].SavePath.c_str());
if (vc_item.size() > 0) if (vc_item.size() > 0)
{ {
vc_tempOut.push_back(vc_item[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); this->SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
if (MessageBox(TEXT("如果恢复,当前所有已保存配置将丢失。是否继续?"), TEXT("恢复"), MB_YESNO | MB_ICONQUESTION) == IDYES) if (MessageBox(TEXT("如果恢复,当前所有已保存配置将丢失。是否继续?"), TEXT("恢复"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{ {
JsonConfig js; GscanJsonConfig js;
CFileDialog ofd(TRUE, CFileDialog ofd(TRUE,
_T(".json"), _T(".json"),
NULL, NULL,
@ -557,11 +607,11 @@ void CTwainUI::OnBnClickedBtnrecoveryconfig()
if (IDOK == ofd.DoModal()) if (IDOK == ofd.DoModal())
{ {
std::string path = (CW2A)ofd.GetPathName(); std::string path = (CW2A)ofd.GetPathName();
vector<CONFIGPARAMS> vc = js.ReadJsonArrayFromFile(path); vector<GScanCap> vc = js.ReadGscanCapsVector(path);
for (int i = 0; i < vc.size(); i++) for (int i = 0; i < vc.size(); i++)
{ {
// js.WriteJsonArrayToFile(vc[i],vc[i].SavePath); // js.WriteJsonArrayToFile(vc[i],vc[i].SavePath);
vector<CONFIGPARAMS> vc_item; vector<GScanCap> vc_item;
vc_item.push_back(vc[i]); vc_item.push_back(vc[i]);
js.WriteJsonArrayToFile(vc_item, vc[i].SavePath); js.WriteJsonArrayToFile(vc_item, vc[i].SavePath);
} }
@ -579,13 +629,14 @@ void CTwainUI::OnLbnSelchangeLstconfig()
index = ((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->GetCurSel(); index = ((CListBox*)(GetDlgItem(IDC_LSTCONFIG)))->GetCurSel();
if (index != -1) if (index != -1)
{ {
JsonConfig js; GscanJsonConfig js;
//std::string savepath= cfi[index].SavePath; //std::string savepath= cfi[index].SavePath;
std::vector<CONFIGPARAMS> vc_temp; std::vector<GScanCap> vc_temp;
vc_temp = js.ReadJsonArrayFromFile(cfi[index].SavePath); vc_temp = js.ReadGscanCapsVector(cfi[index].SavePath);
if (vc_temp.size() > 0) if (vc_temp.size() > 0)
{ {
UpdateUI(vc_temp[0]); settings.reset(new GScanCap(vc_temp[0]));
UpdateUI();
} }
} }
} }

View File

@ -1,12 +1,12 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include "twglue.hpp" #include "twglue.hpp"
#include "Device/JsonConfig.h"
#include "CSaveConfigDlg.h" #include "CSaveConfigDlg.h"
#include "Device/PublicFunc.h" #include "Device/PublicFunc.h"
#include "Device/PaperSize.h" #include "Device/PaperSize.h"
#include <map> #include <map>
#include "MapFinder.h"
#include <vector>
class CTabCtrlSSL; class CTabCtrlSSL;
class CTabPageSSL; class CTabPageSSL;
class CImageProcPage; class CImageProcPage;
@ -24,6 +24,7 @@ static int Resolutions[SUPPORTRESNUMS] = {100,150,200,240,300};
#define TWPT_GRAY 1 #define TWPT_GRAY 1
#define TWPT_RGB 2 #define TWPT_RGB 2
#ifdef G200
static std::map<int, PaperStatus> paperStatusMap = { static std::map<int, PaperStatus> paperStatusMap = {
{0,{TwSS::A3,PaperAlign::Rot0}}, {0,{TwSS::A3,PaperAlign::Rot0}},
{1,{TwSS::A4,PaperAlign::Rot0}}, {1,{TwSS::A4,PaperAlign::Rot0}},
@ -45,6 +46,45 @@ static std::map<int, PaperStatus> paperStatusMap = {
{17,{TwSS::USStatement,PaperAlign::Rot0}}, {17,{TwSS::USStatement,PaperAlign::Rot0}},
{18,{TwSS::MaxSize,PaperAlign::Rot0}} {18,{TwSS::MaxSize,PaperAlign::Rot0}}
}; };
#endif
#ifdef G300
static std::map<int, PaperStatus> 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<int, PaperStatus> 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<int, int> filterMaps = { static std::map<int, int> filterMaps = {
{0,3},//不除色 None {0,3},//不除色 None
@ -118,13 +158,13 @@ class CTwainUI : public CDialogEx
DECLARE_DYNAMIC(CTwainUI) DECLARE_DYNAMIC(CTwainUI)
public: 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(); virtual ~CTwainUI();
void UpdateUI(CONFIGPARAMS configParams); void UpdateUI();
void UpDateScanParam(PCONFIGPARAMS pConfigItem, bool updateDs = true); void UpDateScanParam(PCONFIGPARAMS pConfigItem, bool updateDs = true);
void UpdateListConfig(); void UpdateListConfig();
void GetGScanCap(GScanCap& cap);
void UpdateUi(); void UpdateUi();
void EnableID_OKorID_Cancel(bool enable); void EnableID_OKorID_Cancel(bool enable);
@ -156,15 +196,21 @@ protected:
std::unique_ptr<CFeedPaperPage> m_pageFeedPaper; std::unique_ptr<CFeedPaperPage> m_pageFeedPaper;
std::unique_ptr<CBrightnessPage> m_pageBrightness; std::unique_ptr<CBrightnessPage> m_pageBrightness;
std::unique_ptr<CImageProcPage> m_pageImageProc; std::unique_ptr<CImageProcPage> m_pageImageProc;
public:
afx_msg void OnClose();
private:
void UpdateFilterCmbx();
void UpdateSharpenCmbx();
int getCmbDuplexIndex();
TwGlue m_glue; TwGlue m_glue;
std::vector<CONFIGINFO> cfi; std::vector<CONFIGINFO> cfi;
int getResolutionIndex(int resolution); int getResolutionIndex(int resolution);
int getPaparSizeIndex(int papersize,int orentation); int getPaparSizeIndex(int papersize, int orentation);
int getColorModelIndex(int pixtype); int getColorModelIndex(int pixtype);
int getRotateCmbIndex(float res);
std::vector<CONFIGINFO> getConfigFiles(); std::vector<CONFIGINFO> getConfigFiles();
std::unique_ptr<GScanCap> settings; std::unique_ptr<GScanCap> settings;
std::string m_confirmtitle; std::string m_confirmtitle;
public:
afx_msg void OnClose();
}; };

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.