diff --git a/sane/DlgCfgMgr.cpp b/sane/DlgCfgMgr.cpp index 5b35962..5ff5cd0 100644 --- a/sane/DlgCfgMgr.cpp +++ b/sane/DlgCfgMgr.cpp @@ -9,7 +9,7 @@ // CDlgIndicator 对话框 -dlg_cfg_mgr::dlg_cfg_mgr(gb::scanner_cfg* cfg, HWND parent) : cfg_(cfg), dlg_base(parent, IDD_CFG_MGR) +dlg_cfg_mgr::dlg_cfg_mgr(gb::scanner_cfg* cfg, HWND parent) : cfg_(cfg), dlg_base(parent, IDD_CFG_MGR), schm_changed_(false) { create(); @@ -199,10 +199,18 @@ void dlg_cfg_mgr::on_del_selected(void) { changed = true; ListView_DeleteItem(lwnd, sels[i]); + schm_changed_ = true; } } } void dlg_cfg_mgr::on_del_all(void) { cfg_->remove_all_schemes(); + ListView_DeleteAllItems(get_item(IDC_LIST1)); // clear list + schm_changed_ = true; + dlg_base::set_item_text(IDC_EDIT1, L""); +} +bool dlg_cfg_mgr::is_scheme_changed(void) +{ + return schm_changed_; } diff --git a/sane/DlgCfgMgr.h b/sane/DlgCfgMgr.h index 04accf3..ef66783 100644 --- a/sane/DlgCfgMgr.h +++ b/sane/DlgCfgMgr.h @@ -15,6 +15,7 @@ class dlg_cfg_mgr: public dlg_base { gb::scanner_cfg* cfg_; std::wstring label_; + bool schm_changed_; // to notify parent refreshing UI and settings BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp) override; void handle_command(WORD code, WORD id, HANDLE ctrl); @@ -32,4 +33,5 @@ public: ~dlg_cfg_mgr(); public: + bool is_scheme_changed(void); }; diff --git a/sane/DlgSetting.cpp b/sane/DlgSetting.cpp index 645574d..ebbae8c 100644 --- a/sane/DlgSetting.cpp +++ b/sane/DlgSetting.cpp @@ -130,6 +130,7 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl) } n->release(); } + s->end_setting(true); // discard changes in prev-scheme s->release(); } } @@ -143,7 +144,7 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl) gb::sane_config_schm* s = cfg_->get_scheme(); if (s) { - s->end_setting(true); + s->end_setting(false); // save changes s->release(); } @@ -180,7 +181,7 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl) gb::sane_config_schm* schm = cfg_->get_scheme(); if (schm) { - schm->end_setting(true); + schm->end_setting(false); schm->release(); } cfg_->select_scheme(nullptr); @@ -195,6 +196,14 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl) { dlg_cfg_mgr dlg(cfg_, hwnd()); dlg.do_modal(hwnd()); + if (dlg.is_scheme_changed()) // refresh settings and UI + { + gb::sane_config_schm* schm = cfg_->get_scheme(); + apply_scheme_(schm, apply_param_); + if (schm) + schm->release(); + refresh_controls(-1); + } } else if (id == IDC_BUTTON_CONFIG_MENU) { diff --git a/sane/gb_json.cpp b/sane/gb_json.cpp index 0964150..a9aa402 100644 --- a/sane/gb_json.cpp +++ b/sane/gb_json.cpp @@ -236,23 +236,23 @@ namespace gb cj = cj->next; } - if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0) - { - json* child = arr_val_[0]; - - if (!child->key_.empty()) // array - { - arr_val_.clear(); - type_ = child->type_; - key_ = child->key_; - simple_val_.dval = child->simple_val_.dval; - strval_ = child->strval_; - for (auto& v : child->arr_val_) - arr_val_.push_back(v); - child->arr_val_.clear(); - child->release(); - } - } + //if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0) + //{ + // json* child = arr_val_[0]; + // + // if (!child->key_.empty()) // array + // { + // arr_val_.clear(); + // type_ = child->type_; + // key_ = child->key_; + // simple_val_.dval = child->simple_val_.dval; + // strval_ = child->strval_; + // for (auto& v : child->arr_val_) + // arr_val_.push_back(v); + // child->arr_val_.clear(); + // child->release(); + // } + //} if (arr_val_.size()) { @@ -510,9 +510,9 @@ namespace gb } json* json::first_child(void) { + cur_child_ = 0; if (type_ == VAL_TYPE_OBJECT || type_ == VAL_TYPE_ARRAY) { - cur_child_ = 0; if (arr_val_.size()) { arr_val_[0]->add_ref(); @@ -522,6 +522,10 @@ namespace gb } return nullptr; + // leaf node, return self + //add_ref(); + + //return this; } json* json::next_child(void) { @@ -1597,7 +1601,15 @@ namespace gb jsn_->set_value("ver", ver); } - std::string cont(jsn_->to_string()); + std::string cont(""); + //if (jsn_->is_leaf_node()) + //{ + // jsn_->value(cont); + // cont.insert(0, "{\"" + jsn_->key() + "\":\""); + // cont += "\"}"; + //} + //else + cont = jsn_->to_string(); if (b64) { gb::base64 b64; diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index 570f858..95c41f0 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -28,6 +28,8 @@ using namespace std::placeholders; extern HMODULE me_; +// WIA COM: IStiUSD & IWiaMiniDrv + //custom define caps enum enum CapTypeEx : unsigned short { CAP_TYPE_EX_FILL_BLACK_BKG = 0x8004,