This commit is contained in:
13038267101 2023-03-06 11:36:53 +08:00
commit 4d09295584
5 changed files with 55 additions and 22 deletions

View File

@ -9,7 +9,7 @@
// CDlgIndicator 对话框 // 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(); create();
@ -199,10 +199,18 @@ void dlg_cfg_mgr::on_del_selected(void)
{ {
changed = true; changed = true;
ListView_DeleteItem(lwnd, sels[i]); ListView_DeleteItem(lwnd, sels[i]);
schm_changed_ = true;
} }
} }
} }
void dlg_cfg_mgr::on_del_all(void) void dlg_cfg_mgr::on_del_all(void)
{ {
cfg_->remove_all_schemes(); 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_;
} }

View File

@ -15,6 +15,7 @@ class dlg_cfg_mgr: public dlg_base
{ {
gb::scanner_cfg* cfg_; gb::scanner_cfg* cfg_;
std::wstring label_; std::wstring label_;
bool schm_changed_; // to notify parent refreshing UI and settings
BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp) override; BOOL handle_message(UINT msg, WPARAM wp, LPARAM lp) override;
void handle_command(WORD code, WORD id, HANDLE ctrl); void handle_command(WORD code, WORD id, HANDLE ctrl);
@ -32,4 +33,5 @@ public:
~dlg_cfg_mgr(); ~dlg_cfg_mgr();
public: public:
bool is_scheme_changed(void);
}; };

View File

@ -130,6 +130,7 @@ void dlg_setting::handle_command(WORD code, WORD id, HANDLE ctrl)
} }
n->release(); n->release();
} }
s->end_setting(true); // discard changes in prev-scheme
s->release(); 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(); gb::sane_config_schm* s = cfg_->get_scheme();
if (s) if (s)
{ {
s->end_setting(true); s->end_setting(false); // save changes
s->release(); 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(); gb::sane_config_schm* schm = cfg_->get_scheme();
if (schm) if (schm)
{ {
schm->end_setting(true); schm->end_setting(false);
schm->release(); schm->release();
} }
cfg_->select_scheme(nullptr); 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_cfg_mgr dlg(cfg_, hwnd());
dlg.do_modal(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) else if (id == IDC_BUTTON_CONFIG_MENU)
{ {

View File

@ -236,23 +236,23 @@ namespace gb
cj = cj->next; cj = cj->next;
} }
if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0) //if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0)
{ //{
json* child = arr_val_[0]; // json* child = arr_val_[0];
//
if (!child->key_.empty()) // array // if (!child->key_.empty()) // array
{ // {
arr_val_.clear(); // arr_val_.clear();
type_ = child->type_; // type_ = child->type_;
key_ = child->key_; // key_ = child->key_;
simple_val_.dval = child->simple_val_.dval; // simple_val_.dval = child->simple_val_.dval;
strval_ = child->strval_; // strval_ = child->strval_;
for (auto& v : child->arr_val_) // for (auto& v : child->arr_val_)
arr_val_.push_back(v); // arr_val_.push_back(v);
child->arr_val_.clear(); // child->arr_val_.clear();
child->release(); // child->release();
} // }
} //}
if (arr_val_.size()) if (arr_val_.size())
{ {
@ -510,9 +510,9 @@ namespace gb
} }
json* json::first_child(void) json* json::first_child(void)
{ {
cur_child_ = 0;
if (type_ == VAL_TYPE_OBJECT || type_ == VAL_TYPE_ARRAY) if (type_ == VAL_TYPE_OBJECT || type_ == VAL_TYPE_ARRAY)
{ {
cur_child_ = 0;
if (arr_val_.size()) if (arr_val_.size())
{ {
arr_val_[0]->add_ref(); arr_val_[0]->add_ref();
@ -522,6 +522,10 @@ namespace gb
} }
return nullptr; return nullptr;
// leaf node, return self
//add_ref();
//return this;
} }
json* json::next_child(void) json* json::next_child(void)
{ {
@ -1597,7 +1601,15 @@ namespace gb
jsn_->set_value("ver", ver); 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) if (b64)
{ {
gb::base64 b64; gb::base64 b64;

View File

@ -28,6 +28,8 @@ using namespace std::placeholders;
extern HMODULE me_; extern HMODULE me_;
// WIA COM: IStiUSD & IWiaMiniDrv
//custom define caps enum //custom define caps enum
enum CapTypeEx : unsigned short { enum CapTypeEx : unsigned short {
CAP_TYPE_EX_FILL_BLACK_BKG = 0x8004, CAP_TYPE_EX_FILL_BLACK_BKG = 0x8004,