调整设置界面关闭通知
This commit is contained in:
parent
8c1474ab3d
commit
cf2c03e3cd
|
@ -117,7 +117,7 @@ void dlg_indicator::handle_command(WORD code, WORD id, HANDLE ctrl)
|
||||||
}
|
}
|
||||||
void dlg_indicator::notify_over(bool cancel)
|
void dlg_indicator::notify_over(bool cancel)
|
||||||
{
|
{
|
||||||
notify_ui_event(cancel ? SANE_EVENT_UI_CLOSE_CANCEL : SANE_EVENT_SCAN_FINISHED);
|
notify_ui_event(cancel ? SANE_EVENT_UI_CLOSE_CANCEL : SANE_EVENT_UI_CLOSE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND dlg_indicator::window(void)
|
HWND dlg_indicator::window(void)
|
||||||
|
|
|
@ -101,7 +101,7 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl)
|
||||||
}
|
}
|
||||||
void dlg_setting::notify_over(void)
|
void dlg_setting::notify_over(void)
|
||||||
{
|
{
|
||||||
notify_ui_event(SANE_EVENT_UI_CLOSE_NORMAL);
|
notify_ui_event(SANE_EVENT_UI_CLOSE_SETTING);
|
||||||
}
|
}
|
||||||
void dlg_setting::on_init_dialog(void)
|
void dlg_setting::on_init_dialog(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,6 +80,7 @@ COM_API_IMPLEMENT(refer, long, release(void))
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// class mapping_buf
|
// class mapping_buf
|
||||||
const unsigned int max_mem_block = 2 * 1024 * 1024;
|
const unsigned int max_mem_block = 2 * 1024 * 1024;
|
||||||
|
extern void __stdcall log_info(const wchar_t* info, int level);
|
||||||
|
|
||||||
mapping_buf::mapping_buf() : bytes_(0), offset_(0), mapped_bytes_(0), map_(NULL), buf_(NULL), file_(""), rmv_file_(true), page_size_(0), is_mem_(false)
|
mapping_buf::mapping_buf() : bytes_(0), offset_(0), mapped_bytes_(0), map_(NULL), buf_(NULL), file_(""), rmv_file_(true), page_size_(0), is_mem_(false)
|
||||||
{
|
{
|
||||||
|
@ -117,6 +118,14 @@ void mapping_buf::init_map(const char* file, unsigned long long size)
|
||||||
if (!map_)
|
if (!map_)
|
||||||
DeleteFileA(file);
|
DeleteFileA(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::wstring info(local_trans::a2u(file));
|
||||||
|
wchar_t buf[80] = { 0 };
|
||||||
|
|
||||||
|
swprintf_s(buf, _countof(buf) - 1, L"Mapping %u bytes to file: ", size);
|
||||||
|
log_info((buf + info + L"\r\n").c_str(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -251,18 +251,23 @@ void scanner::apply_config(void)
|
||||||
}
|
}
|
||||||
void scanner::on_ui_event(int uev, void* sender)
|
void scanner::on_ui_event(int uev, void* sender)
|
||||||
{
|
{
|
||||||
if (prev_start_result_ != SANE_STATUS_GOOD && sender == indicator_.get())
|
bool indicator = sender == indicator_.get();
|
||||||
|
if (prev_start_result_ != SANE_STATUS_GOOD && indicator)
|
||||||
indicator_.reset();
|
indicator_.reset();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
events_.save(uev);
|
|
||||||
if (/*events_.count() > 5 && !is_ui_wait_img_ &&*/
|
if (/*events_.count() > 5 && !is_ui_wait_img_ &&*/
|
||||||
(uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL))
|
(uev == SANE_EVENT_UI_CLOSE_CANCEL || uev == SANE_EVENT_UI_CLOSE_NORMAL))
|
||||||
{
|
{
|
||||||
events_.clear();
|
events_.clear();
|
||||||
ui_hide();
|
ui_hide();
|
||||||
events_.save(SANE_EVENT_SCAN_FINISHED);
|
if(indicator)
|
||||||
|
events_.save(SANE_EVENT_SCAN_FINISHED);
|
||||||
|
else
|
||||||
|
events_.save(SANE_EVENT_UI_CLOSE_SETTING);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
events_.save(uev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int scanner::open(void)
|
int scanner::open(void)
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "load_sane.h"
|
#include "load_sane.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <shellapi.h> // for SHFileOperationW
|
||||||
#include "../../sdk/include/huagao/brand.h"
|
#include "../../sdk/include/huagao/brand.h"
|
||||||
|
|
||||||
|
#pragma comment(lib, "shell32.lib")
|
||||||
|
|
||||||
namespace load_sane_util
|
namespace load_sane_util
|
||||||
{
|
{
|
||||||
static std::wstring sane_path(L"");
|
static std::wstring sane_path(L"");
|
||||||
|
@ -192,4 +195,31 @@ namespace load_sane_util
|
||||||
{
|
{
|
||||||
return m2u(ansi, CP_ACP);
|
return m2u(ansi, CP_ACP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int move_file(const char* from, const char* to)
|
||||||
|
{
|
||||||
|
return move_file(ansi2unic(from).c_str(), ansi2unic(to).c_str());
|
||||||
|
}
|
||||||
|
int move_file(const wchar_t* from, const wchar_t* to)
|
||||||
|
{
|
||||||
|
SHFILEOPSTRUCTW fo = { 0 };
|
||||||
|
int ret = 0;
|
||||||
|
std::wstring _from(from), _to(to ? to : L"");
|
||||||
|
|
||||||
|
if (wcsicmp(from, to) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
_from += std::wstring((wchar_t*)&ret, 2); // ended with double '\0'
|
||||||
|
fo.pFrom = &_from[0];
|
||||||
|
_to += std::wstring((wchar_t*)&ret, 2); // ended with double '\0'
|
||||||
|
fo.pTo = &_to[0];
|
||||||
|
fo.fFlags = FOF_NO_UI | FOF_NO_CONNECTED_ELEMENTS; // 614 | 2000
|
||||||
|
fo.wFunc = FO_MOVE;
|
||||||
|
|
||||||
|
ret = SHFileOperationW(&fo);
|
||||||
|
if (ret == /*DE_SAMEFILE*/0x71)
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,5 +17,8 @@ namespace load_sane_util
|
||||||
std::string utf82ansi(const char* utf8);
|
std::string utf82ansi(const char* utf8);
|
||||||
std::string ansi2utf8(const char* ansi);
|
std::string ansi2utf8(const char* ansi);
|
||||||
std::wstring ansi2unic(const char* ansi);
|
std::wstring ansi2unic(const char* ansi);
|
||||||
|
|
||||||
|
int move_file(const char* from, const char* to);
|
||||||
|
int move_file(const wchar_t* from, const wchar_t* to);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -746,6 +746,9 @@ Result huagao_ds::eventProcess(const Identity&, Event& event)
|
||||||
case SANE_EVENT_SCAN_FINISHED:
|
case SANE_EVENT_SCAN_FINISHED:
|
||||||
notifyCloseOk();
|
notifyCloseOk();
|
||||||
break;
|
break;
|
||||||
|
case SANE_EVENT_UI_CLOSE_SETTING:
|
||||||
|
notifyCloseCancel();
|
||||||
|
break;
|
||||||
case SANE_EVENT_UI_SCAN_COMMAND:
|
case SANE_EVENT_UI_SCAN_COMMAND:
|
||||||
scanner_->ui_show_progress(NULL);
|
scanner_->ui_show_progress(NULL);
|
||||||
scanner_->start();
|
scanner_->start();
|
||||||
|
@ -1135,6 +1138,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
|
||||||
if (img)
|
if (img)
|
||||||
{
|
{
|
||||||
std::string file(img->file());
|
std::string file(img->file());
|
||||||
|
int cv_e = 0;
|
||||||
if (file.empty())
|
if (file.empty())
|
||||||
{
|
{
|
||||||
dst = fopen(m_fileXfer.filePath().string().c_str(), "wb");
|
dst = fopen(m_fileXfer.filePath().string().c_str(), "wb");
|
||||||
|
@ -1177,13 +1181,13 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
|
||||||
|
|
||||||
img->keep_file(true);
|
img->keep_file(true);
|
||||||
img->release();
|
img->release();
|
||||||
if (MoveFileA(file.c_str(), m_fileXfer.filePath().string().c_str()))
|
cv_e = load_sane_util::move_file(file.c_str(), m_fileXfer.filePath().string().c_str());
|
||||||
|
if (cv_e == 0)
|
||||||
ret = Result(ReturnCode::XferDone, ConditionCode::Success);
|
ret = Result(ReturnCode::XferDone, ConditionCode::Success);
|
||||||
else
|
else
|
||||||
DeleteFileA(file.c_str());
|
DeleteFileA(file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv_e = 0;
|
|
||||||
if (ret.status() == ConditionCode::Success && m_fileXfer.format() != ImageFileFormat::Bmp)
|
if (ret.status() == ConditionCode::Success && m_fileXfer.format() != ImageFileFormat::Bmp)
|
||||||
{
|
{
|
||||||
SANE_ImageFormatConvert conv;
|
SANE_ImageFormatConvert conv;
|
||||||
|
@ -1221,7 +1225,7 @@ Twpp::Result huagao_ds::imageFileXferGet(const Twpp::Identity& origin)
|
||||||
{
|
{
|
||||||
std::wstring info(load_sane_util::ansi2unic(m_fileXfer.filePath().string().c_str()));
|
std::wstring info(load_sane_util::ansi2unic(m_fileXfer.filePath().string().c_str()));
|
||||||
wchar_t r[80] = { 0 };
|
wchar_t r[80] = { 0 };
|
||||||
swprintf_s(r, _countof(r) - 1, L": status = %d(convert: 0x%x)\r\n", ret.status(), cv_e);
|
swprintf_s(r, _countof(r) - 1, L": status = %d(Fail: 0x%x)\r\n", ret.status(), cv_e);
|
||||||
load_sane_util::log_info((info + r).c_str(), 0);
|
load_sane_util::log_info((info + r).c_str(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue