twain3.0/huagao/CTwainUI.h

217 lines
5.5 KiB
C
Raw Normal View History

#pragma once
#include <memory>
#include "twglue.hpp"
#include "CSaveConfigDlg.h"
#include "Device/PublicFunc.h"
#include "Device/PaperSize.h"
#include <map>
#include "MapFinder.h"
#include <vector>
class CTabCtrlSSL;
class CTabPageSSL;
class CImageProcPage;
class CBasicPage;
class CFeedPaperPage;
class CBrightnessPage;
/*配置文件默认索引号*/
#define SUPPORTRESNUMS 6
static int Resolutions[SUPPORTRESNUMS] = {100,150,200,240,300,600};
#define TWPT_BW 0
#define TWPT_GRAY 1
#define TWPT_RGB 2
#ifdef G200
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
#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}},
{3,{TwSS::B5,PaperAlign::Rot0}},
{4,{TwSS::B6,PaperAlign::Rot0}},
{5,{TwSS::USLetter,PaperAlign::Rot0}},
{6,{TwSS::USLegal,PaperAlign::Rot0}},
{7,{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 = {
{0,3},//不除色 None
{1,0},//除红
{2,1},//除绿
{3,2},//除蓝
{4,Enchace_Color::Enhance_Red},//红色增强
{5,Enchace_Color::Enhance_Green},//绿色增强
{6,Enchace_Color::Enhance_Blue}//蓝色增强
};
//<index,res>
static std::map<int, float> resolutions = {
{0,100.0f},
{1,150.0f},
{2,200.0f},
{3,240.0f},
{4,300.0f},
{5,600.0f}
};
static std::map<int, unsigned short> colorModes = {
{0,TWPT_RGB},
{1,TWPT_GRAY},
{2,TWPT_BW}
};
static std::map<int, float> rotateDegrees = {
{0,0.0f},
{1,90.0f},
{2,180.0f},
{3,270.0f}
};
struct tagSCANCONFIGPARAM
{
UINT32 ColorModal;
UINT32 PaperSize;
FLOAT Resoulation;
UINT32 DuplexType;
BOOL IsDoubleFeeded;
BOOL IsBingdingDetectable;
BOOL SkrewDetectable;
BOOL Is10BitTure;
BOOL Is11BitTure;
BOOL Is12BitTure;
};
typedef tagSCANCONFIGPARAM SCANCONFIGPARAM, PSCANCONFIGPARAM;
struct tagIMAGEPROCESSPARAMS
{
UINT32 PaperSize;
BOOL IsDiscardBlankPage;
BOOL IsFlodPages;
INT Brightness;
INT Contrast;
INT Gamma;
INT Filter;
BOOL IsFillBlack;
BOOL IsAutoCrop;
INT ScanCount;
INT Orentation;
BOOL IsBackImageFlip180;
};
typedef tagIMAGEPROCESSPARAMS IMAGEPROCESSPARAMS, PIMAGEPROCESSPARAMS;
// CTwainUI 对话框
class CTwainUI : public CDialogEx
{
DECLARE_DYNAMIC(CTwainUI)
public:
CTwainUI(TwGlue glue,GScanCap caps,std::string confirmtitle,std::string hardwareversion,std::string serialnum, CWnd* pParent = nullptr); // 标准构造函数
virtual ~CTwainUI();
void UpdateUI();
void UpDateScanParam(PCONFIGPARAMS pConfigItem, bool updateDs = true);
void UpdateListConfig();
void GetGScanCap(GScanCap& cap);
void UpdateUi();
void EnableID_OKorID_Cancel(bool enable);
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_TWAINUI };
#endif
public:
std::string m_hardwareVersion;
std::string m_serialnum;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
afx_msg void OnBnClickedConfirm();
afx_msg void OnBnClickedBtndefault();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedBtnhelp();
afx_msg void OnBnClickedBtnbackupconfig();
afx_msg void OnBnClickedBtnsaveconfig();
afx_msg void OnBnClickedBtndeletconfig();
afx_msg void OnBnClickedBtnrecoveryconfig();
afx_msg void OnLbnSelchangeLstconfig();
std::unique_ptr<CTabCtrlSSL> m_tabCtrl;
std::unique_ptr<CBasicPage> m_pageBasic;
std::unique_ptr<CFeedPaperPage> m_pageFeedPaper;
std::unique_ptr<CBrightnessPage> m_pageBrightness;
std::unique_ptr<CImageProcPage> m_pageImageProc;
public:
afx_msg void OnClose();
private:
void UpdateFilterCmbx();
void UpdateSharpenCmbx();
int getCmbDuplexIndex();
TwGlue m_glue;
std::vector<CONFIGINFO> cfi;
int getResolutionIndex(int resolution);
int getPaparSizeIndex(int papersize, int orentation);
int getColorModelIndex(int pixtype);
int getRotateCmbIndex(float res);
std::vector<CONFIGINFO> getConfigFiles();
std::unique_ptr<GScanCap> settings;
std::string m_confirmtitle;
2020-09-21 01:25:46 +00:00
virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};