tx-gxx-linux/pc/code_twain/sln/usb_tools/DlgScanner.h

105 lines
2.5 KiB
C++

#pragma once
// CDlgScanner 对话框
#include "./scanner/scanner_handler.h"
#include <libusb-1.0/libusb.h>
#include "scanner/opt_ui/DlgSetting.h"
class CDlgScanner;
namespace usb
{
typedef struct _end_point
{
BYTE iface = -1;
BYTE type = -1;
BYTE addr = -1;
size_t packet = 0;
}USBEP;
typedef struct _usb_pnp
{
libusb_context* ctx = NULL;
libusb_device* device = NULL;
libusb_device_handle* handle = NULL;
CDlgScanner* dlg = NULL;
WORD vid = 0;
WORD pid = 0;
bool arrive = true;
std::vector<USBEP> eps;
}USBPNP, * LPUSBPNP;
std::wstring now(void);
const wchar_t* error_name(int err, wchar_t* unk = NULL);
std::wstring a2u(const char* ansi);
std::string u2a(const wchar_t* unic);
void enum_endpoints(libusb_device* device, std::vector<USBEP>& eps);
const wchar_t* ep_type(BYTE type);
BYTE ep_type(const wchar_t* str);
}
enum
{
WM_USB_PNP = WM_USER + 1001,
WM_RCV_MSG,
WM_OPENNING_DLG_CLOSED,
WM_TRAY_MSG,
WM_TIMER_CANCEL_TOPMOST,
};
class CDlgScanner : public CDialogEx
{
DECLARE_DYNAMIC(CDlgScanner)
HWND parent_;
scanner_handler* scanner_;
thread_pool<CDlgScanner> *threads_;
volatile bool auto_tx_;
uint32_t auto_tx_file_;
HANDLE auto_wait_;
dlg_setting *setting_ui_;
SANEAPI sane_api_;
std::wstring img_root_;
uint32_t img_cnt_;
public:
CDlgScanner(CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDlgScanner();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_SCANNER };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
DECLARE_MESSAGE_MAP()
int refresh_bulk_status(void);
void thread_auto_tx_file(void);
void enable_buttons(bool enable);
public:
void set_device(usb::LPUSBPNP pnp);
void get_option(const char* name, void* value, size_t size);
public:
CTabCtrl tab_opt_;
CTabCtrl tab_oper_;
afx_msg void OnTcnSelchangeTabOper(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedButtonResetBulk();
afx_msg void OnBnClickedButtonBrowseSavingPath();
afx_msg void OnBnClickedButtonScan();
afx_msg void OnBnClickedButtonBrowseFile();
afx_msg void OnBnClickedButtonSendFile();
afx_msg void OnBnClickedButtonRecvFile();
afx_msg void OnBnClickedButtonStartProgram();
afx_msg void OnBnClickedButtonSendEp0();
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnBnClickedCheckAuto();
afx_msg void OnBnClickedButtonRefresh();
afx_msg void OnBnClickedCheckRepeat();
};