调整JSON配置文件格式
This commit is contained in:
parent
8fc40dca47
commit
071b8c5e8f
|
@ -82,3 +82,4 @@ void CDlgInput::OnEnChangeEdit1()
|
|||
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
}
|
||||
|
||||
|
|
|
@ -33,33 +33,70 @@ static void set_checked(CDialogEx* dlg, UINT id, bool checked)
|
|||
IMPLEMENT_DYNAMIC(CDlgItemMgr, CDialogEx)
|
||||
|
||||
CDlgItemMgr::CDlgItemMgr(CWnd* pParent /*=nullptr*/)
|
||||
: CDialogEx(IDD_TEST_ITEM, pParent)
|
||||
: CDialogEx(IDD_TEST_ITEM, pParent), test_tmpl_(NULL), lst_trigger_sel_change_(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDlgItemMgr::~CDlgItemMgr()
|
||||
{
|
||||
if (test_tmpl_)
|
||||
test_tmpl_->release();
|
||||
}
|
||||
|
||||
void CDlgItemMgr::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialogEx::DoDataExchange(pDX);
|
||||
DDX_Control(pDX, IDC_LIST1, list_);
|
||||
DDX_Control(pDX, IDC_LIST_VAL, lst_param_);
|
||||
DDX_Control(pDX, IDC_COMBO_PARAM_NAME, combo_param_);
|
||||
DDX_Control(pDX, IDC_COMBO_PARAM_VAL0, combo_param_val_);
|
||||
}
|
||||
|
||||
BOOL CDlgItemMgr::OnInitDialog()
|
||||
{
|
||||
CDialogEx::OnInitDialog();
|
||||
|
||||
int ind = list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("\u5E8F\u53F7"), 0, 40);
|
||||
list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("ID"), 0, 60);
|
||||
list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("\u540D\u79F0"), 0, 102);
|
||||
list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("\u5FC5\u987B\u8054\u673A\u6D4B\u8BD5"), 0, 87);
|
||||
list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("\u4E0D\u901A\u8FC7\u5219\u505C\u6B62"), 0, 87);
|
||||
list_.InsertColumn(list_.GetHeaderCtrl()->GetItemCount(), TEXT("\u63CF\u8FF0"), 0, 120);
|
||||
list_.SetExtendedStyle((list_.GetExStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES) & (~LVS_EX_CHECKBOXES));
|
||||
list_.ModifyStyle(0, LVS_SINGLESEL);
|
||||
std::vector<LSTCOL> cols;
|
||||
LSTCOL col;
|
||||
|
||||
col.align = 0;
|
||||
col.title = L"\u5E8F\u53F7";
|
||||
col.width = 40;
|
||||
cols.push_back(col);
|
||||
col.title = L"\uFF29\uFF24";
|
||||
col.width = 80;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u6807\u9898";
|
||||
col.width = 80;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u6D4B\u8BD5\u5DE5\u4F4D";
|
||||
col.width = 60;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u5458\u5DE5\u6743\u9650";
|
||||
col.width = 60;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u8054\u673A";
|
||||
col.width = 40;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u5931\u8D25\u5219\u505C\u6B62";
|
||||
col.width = 80;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u63CF\u8FF0";
|
||||
col.width = 200;
|
||||
cols.push_back(col);
|
||||
init_list_ctrl(&list_, cols);
|
||||
|
||||
cols.clear();
|
||||
col.title = L"\u53C2\u6570\u540D\u79F0";
|
||||
col.width = 160;
|
||||
cols.push_back(col);
|
||||
col.title = L"\u53C2\u6570\u503C";
|
||||
col.width = 200;
|
||||
cols.push_back(col);
|
||||
init_list_ctrl(&lst_param_, cols);
|
||||
|
||||
init_sane_cfg();
|
||||
load_stored_config();
|
||||
|
||||
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
||||
|
@ -69,6 +106,12 @@ BEGIN_MESSAGE_MAP(CDlgItemMgr, CDialogEx)
|
|||
ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgItemMgr::OnBnClickedButtonAdd)
|
||||
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgItemMgr::OnNMDblclkList1)
|
||||
ON_WM_DROPFILES()
|
||||
ON_BN_CLICKED(IDC_BUTTON_ADD2, &CDlgItemMgr::OnBnClickedButtonAdd2)
|
||||
ON_CBN_SELCHANGE(IDC_COMBO_PARAM_NAME, &CDlgItemMgr::OnCbnSelchangeComboParamName)
|
||||
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_VAL, &CDlgItemMgr::OnLvnItemchangedListVal)
|
||||
ON_NOTIFY(NM_CLICK, IDC_LIST1, &CDlgItemMgr::OnNMClickList1)
|
||||
ON_BN_CLICKED(IDC_BUTTON_SAVE_TEMPLATE, &CDlgItemMgr::OnBnClickedButtonSaveTemplate)
|
||||
ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CDlgItemMgr::OnBnClickedButtonClear)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
@ -78,126 +121,199 @@ END_MESSAGE_MAP()
|
|||
void CDlgItemMgr::OnBnClickedButtonAdd()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
wchar_t text[1024] = { 0 }, name[1024] = { 0 }, desc[1024] = { 0 };
|
||||
bool online = is_checked(this, IDC_CHECK_ONLINE), fatal = is_checked(this, IDC_CHECK_FATAL);
|
||||
wchar_t text[128] = { 0 };
|
||||
int ind = -1;
|
||||
known_file_util::IJsonW* jsn = NULL;
|
||||
|
||||
if (::GetWindowTextW(GetDlgItem(IDC_EDIT_TITLE)->m_hWnd, text, _countof(text) - 1) == 0 ||
|
||||
::GetWindowTextW(GetDlgItem(IDC_EDIT_NAME)->m_hWnd, name, _countof(name) - 1) == 0)
|
||||
if (GetDlgItemTextW(IDC_EDIT_NAME, text, _countof(text) - 1) == 0)
|
||||
{
|
||||
::MessageBoxW(m_hWnd, L"\u5FC5\u987B\u8F93\u5165NAME\uFF01", L"Error", MB_OK | MB_ICONSTOP);
|
||||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_NAME));
|
||||
return;
|
||||
if (::GetWindowTextW(GetDlgItem(IDC_EDIT_DESC)->m_hWnd, name, _countof(name) - 1) == 0)
|
||||
{
|
||||
wcscpy(desc, text);
|
||||
}
|
||||
for (int i = 0; i < list_.GetItemCount(); ++i)
|
||||
{
|
||||
wchar_t val[1024] = { 0 };
|
||||
list_.GetItemText(i, 1, val, _countof(val) - 1);
|
||||
if (wcscmp(name, val) == 0)
|
||||
{
|
||||
ind = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ind = find_test_item(text, &jsn);
|
||||
if (ind == -1)
|
||||
{
|
||||
wchar_t sn[20] = { 0 };
|
||||
swprintf_s(sn, _countof(sn) - 1, L"%u", list_.GetItemCount() + 1);
|
||||
ind = list_.InsertItem(list_.GetItemCount(), sn);
|
||||
list_.SetItemText(ind, 1, name);
|
||||
jsn = known_file_util::create_jsonW();
|
||||
jsn->set_value(L"name", text);
|
||||
ind = list_.InsertItem(list_.GetItemCount(), std::to_wstring(list_.GetItemCount() + 1).c_str());
|
||||
list_.SetItemText(ind, 1, text);
|
||||
list_.SetItemData(ind, (DWORD_PTR)jsn);
|
||||
jsn->add_ref();
|
||||
}
|
||||
GetDlgItemTextW(IDC_EDIT_TITLE, text, _countof(text) - 1);
|
||||
jsn->set_value(L"title", text);
|
||||
list_.SetItemText(ind, 2, text);
|
||||
|
||||
GetDlgItemTextW(IDC_COMBO_STATION, text, _countof(text) - 1);
|
||||
jsn->set_value(L"station", text);
|
||||
list_.SetItemText(ind, 3, text);
|
||||
|
||||
GetDlgItemTextW(IDC_EDIT_PRIV, text, _countof(text) - 1);
|
||||
jsn->set_value(L"authority", text);
|
||||
list_.SetItemText(ind, 4, text);
|
||||
|
||||
bool bv = ((CButton*)GetDlgItem(IDC_CHECK_ONLINE))->GetCheck() == BST_CHECKED;
|
||||
jsn->set_value(L"man", !bv);
|
||||
list_.SetItemText(ind, 5, bv ? L"true" : L"false");
|
||||
|
||||
bv = ((CButton*)GetDlgItem(IDC_CHECK_FATAL))->GetCheck() == BST_CHECKED;
|
||||
jsn->set_value(L"err-level", bv ? L"fatal" : L"ignore");
|
||||
list_.SetItemText(ind, 6, bv ? L"true" : L"false");
|
||||
|
||||
std::wstring desc(get_window_text(GetDlgItem(IDC_EDIT_DESC)->m_hWnd));
|
||||
replace(desc, L"\r", L"\\r");
|
||||
replace(desc, L"\n", L"\\n");
|
||||
jsn->set_value(L"desc", desc.c_str());
|
||||
list_.SetItemText(ind, 7, desc.c_str());
|
||||
|
||||
// param ...
|
||||
jsn->remove_value(L"param");
|
||||
if (lst_param_.GetItemCount())
|
||||
{
|
||||
known_file_util::IJsonW* param = known_file_util::create_jsonW();
|
||||
for (int i = 0; i < lst_param_.GetItemCount(); ++i)
|
||||
{
|
||||
known_file_util::IJsonW* sane = (known_file_util::IJsonW*)lst_param_.GetItemData(i);
|
||||
const wchar_t* type = NULL;
|
||||
|
||||
sane->get_value(L"type", &type);
|
||||
desc = get_list_item_text(&lst_param_, i, 1);
|
||||
if (wcscmp(type, L"bool") == 0)
|
||||
{
|
||||
param->set_value(sane->key(), desc == L"true");
|
||||
}
|
||||
else if (wcscmp(type, L"int") == 0)
|
||||
{
|
||||
param->set_value(sane->key(), _wtoi(desc.c_str()));
|
||||
}
|
||||
else if (wcscmp(type, L"float") == 0)
|
||||
{
|
||||
param->set_value(sane->key(), _wtof(desc.c_str()));
|
||||
}
|
||||
else // string
|
||||
{
|
||||
param->set_value(sane->key(), desc.c_str());
|
||||
}
|
||||
}
|
||||
jsn->set_value(L"param", param);
|
||||
}
|
||||
|
||||
list_.SetItemText(ind, 2, text);
|
||||
list_.SetItemText(ind, 3, online ? L"true" : L"false");
|
||||
list_.SetItemText(ind, 4, fatal ? L"true" : L"false");
|
||||
list_.SetItemText(ind, 5, desc);
|
||||
list_.SetItemState(ind, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
|
||||
item_changed();
|
||||
test_tmpl_->set_value(jsn->key(), jsn);
|
||||
jsn->release();
|
||||
|
||||
save_test_template(STORE_FILE_TEMP);
|
||||
}
|
||||
void CDlgItemMgr::OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
POINT pos = { 0 };
|
||||
RECT r = { 0 };
|
||||
|
||||
GetCursorPos(&pos);
|
||||
list_.ScreenToClient(&pos);
|
||||
r.left = list_.HitTest(pos);
|
||||
if (r.left != -1)
|
||||
if (pNMItemActivate->iItem != -1)
|
||||
{
|
||||
std::vector<int> width;
|
||||
int ind = r.left, hpos = list_.GetScrollPos(SB_HORZ);
|
||||
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)list_.GetItemData(pNMItemActivate->iItem);
|
||||
const wchar_t* val = NULL;
|
||||
|
||||
for (int i = 0; i < list_.GetHeaderCtrl()->GetItemCount(); ++i)
|
||||
jsn->get_value(L"title", &val);
|
||||
if (::MessageBoxW(m_hWnd, (std::wstring(L"\u60A8\u786E\u8BA4\u8981\u5220\u9664\u6D4B\u8BD5\u9879\u201C") + val + L"\u201D\u5417\uFF1F").c_str(), L"\u786E\u8BA4", MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||
{
|
||||
RECT r = { 0 };
|
||||
list_.GetHeaderCtrl()->GetItemRect(i, &r);
|
||||
width.push_back(r.right - r.left);
|
||||
}
|
||||
pos.x += hpos;
|
||||
for (int i = 0; i < width.size(); ++i)
|
||||
{
|
||||
if (pos.x <= width[i])
|
||||
test_tmpl_->remove_value(jsn->key());
|
||||
jsn->release();
|
||||
list_.DeleteItem(pNMItemActivate->iItem);
|
||||
for (int i = pNMItemActivate->iItem; i < list_.GetItemCount(); ++i)
|
||||
{
|
||||
wchar_t text[1024] = { 0 };
|
||||
if (i < 3)
|
||||
{
|
||||
std::wstring tips(L"\u5220\u9664\u6D4B\u8BD5\u9879\uFF1A");
|
||||
|
||||
list_.GetItemText(ind, 1, text, _countof(text) - 1);
|
||||
tips += text;
|
||||
tips += L"\uFF1F";
|
||||
if (::MessageBoxW(m_hWnd, tips.c_str(), L"\u786E\u8BA4", MB_YESNO | MB_ICONQUESTION) == IDYES)
|
||||
{
|
||||
list_.DeleteItem(ind);
|
||||
for (; ind < list_.GetItemCount(); ++ind)
|
||||
{
|
||||
swprintf_s(text, _countof(text) - 1, L"%u", ind + 1);
|
||||
list_.SetItemText(ind, 0, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(i < 5)
|
||||
{
|
||||
list_.GetItemText(ind, i, text, _countof(text) - 1);
|
||||
if (wcscmp(text, L"true"))
|
||||
list_.SetItemText(ind, i, L"true");
|
||||
else
|
||||
list_.SetItemText(ind, i, L"false");
|
||||
}
|
||||
else
|
||||
{
|
||||
CDlgInput input;
|
||||
wchar_t val[1024] = { 0 };
|
||||
std::wstring def(L"");
|
||||
|
||||
list_.GetItemText(ind, 2, val, _countof(val) - 1);
|
||||
def = val;
|
||||
input.set_title((std::wstring(L"\u4FEE\u6539 ") + val + L" \u63CF\u8FF0").c_str());
|
||||
list_.GetItemText(ind, 5, val, _countof(val) - 1);
|
||||
input.val_ = val;
|
||||
if (input.DoModal() == IDOK)
|
||||
{
|
||||
if(input.val_.empty())
|
||||
list_.SetItemText(ind, 5, def.c_str());
|
||||
else
|
||||
list_.SetItemText(ind, 5, input.val_.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
list_.SetItemText(i, 0, std::to_wstring(i + 1).c_str());
|
||||
}
|
||||
|
||||
pos.x -= width[i];
|
||||
save_test_template(STORE_FILE_TEMP);
|
||||
}
|
||||
}
|
||||
|
||||
*pResult = 0;
|
||||
item_changed();
|
||||
}
|
||||
|
||||
std::wstring CDlgItemMgr::get_stored_config_file(void)
|
||||
void CDlgItemMgr::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
if (pNMItemActivate->iItem != -1)
|
||||
{
|
||||
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)list_.GetItemData(pNMItemActivate->iItem), * param = NULL;
|
||||
const wchar_t* sv = NULL;
|
||||
std::wstring str(L"");
|
||||
bool bv = true;
|
||||
int nv = 0;
|
||||
double dv = .0f;
|
||||
|
||||
jsn->get_value(L"name", &sv);
|
||||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_NAME, sv);
|
||||
|
||||
sv = NULL;
|
||||
jsn->get_value(L"title", &sv);
|
||||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_TITLE, sv);
|
||||
|
||||
jsn->get_value(L"man", bv);
|
||||
((CButton*)GetDlgItem(IDC_CHECK_ONLINE))->SetCheck(bv ? BST_UNCHECKED : BST_CHECKED);
|
||||
|
||||
sv = NULL;
|
||||
jsn->get_value(L"station", &sv);
|
||||
::SetDlgItemTextW(m_hWnd, IDC_COMBO_STATION, sv);
|
||||
|
||||
jsn->get_value(L"authority", nv);
|
||||
SetDlgItemInt(IDC_EDIT_PRIV, nv);
|
||||
|
||||
jsn->get_value(L"err-level", &sv);
|
||||
((CButton*)GetDlgItem(IDC_CHECK_FATAL))->SetCheck(wcscmp(sv, L"fatal") ? BST_UNCHECKED : BST_CHECKED);
|
||||
|
||||
if (jsn->get_value(L"desc", &sv) && sv)
|
||||
{
|
||||
str = sv;
|
||||
replace(str, L"\\r", L"\r");
|
||||
replace(str, L"\\n", L"\n");
|
||||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_DESC, str.c_str());
|
||||
str.clear();
|
||||
}
|
||||
|
||||
jsn->get_value(L"param", ¶m);
|
||||
lst_param_.DeleteAllItems();
|
||||
if (param)
|
||||
{
|
||||
known_file_util::JSONMEMW jm = param->first_member();
|
||||
while (jm.type != known_file_util::JV_UNKNOWN)
|
||||
{
|
||||
known_file_util::IJsonW* sane = NULL;
|
||||
nv = find_sane_item(jm.key, &sane);
|
||||
if (sane)
|
||||
{
|
||||
sane->get_value(L"title", &sv);
|
||||
nv = lst_param_.InsertItem(lst_param_.GetItemCount(), sv);
|
||||
sane->get_value(L"type", &sv);
|
||||
if (wcscmp(sv, L"bool") == 0)
|
||||
{
|
||||
lst_param_.SetItemText(nv, 1, jm.bool_val ? L"true" : L"false");
|
||||
}
|
||||
else if (wcscmp(sv, L"int") == 0)
|
||||
{
|
||||
lst_param_.SetItemText(nv, 1, std::to_wstring(jm.int_val).c_str());
|
||||
}
|
||||
else if (wcscmp(sv, L"float") == 0)
|
||||
{
|
||||
lst_param_.SetItemText(nv, 1, std::to_wstring(jm.double_val).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
lst_param_.SetItemText(nv, 1, jm.str_val);
|
||||
}
|
||||
sane->release();
|
||||
}
|
||||
jm = param->next_member();
|
||||
}
|
||||
param->release();
|
||||
}
|
||||
}
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
std::wstring CDlgItemMgr::get_stored_config_file(int type)
|
||||
{
|
||||
wchar_t path[MAX_PATH] = { 0 };
|
||||
std::wstring file(L"");
|
||||
|
@ -209,30 +325,19 @@ std::wstring CDlgItemMgr::get_stored_config_file(void)
|
|||
if (pos++ != std::wstring::npos)
|
||||
file.erase(pos);
|
||||
|
||||
file += L"config\\stored.txt";
|
||||
|
||||
if(type == STORE_FILE_BACKUP)
|
||||
file += L"config\\stored_bkp.txt";
|
||||
else if(type == STORE_FILE_TEMP)
|
||||
file += L"config\\stored_tmp.txt";
|
||||
else
|
||||
file += L"config\\stored.txt";
|
||||
|
||||
return file;
|
||||
}
|
||||
void CDlgItemMgr::get_item(int ind, page_config::ITEM* item)
|
||||
{
|
||||
size_t len = 1024;
|
||||
wchar_t *text = (wchar_t*)malloc(len + 1);
|
||||
|
||||
list_.GetItemText(ind, 1, text, len);
|
||||
item->name = text;
|
||||
list_.GetItemText(ind, 2, text, len);
|
||||
item->title = text;
|
||||
list_.GetItemText(ind, 3, text, len);
|
||||
item->man = wcscmp(text, L"false") == 0;
|
||||
list_.GetItemText(ind, 4, text, len);
|
||||
item->fatal = wcscmp(text, L"true") == 0;
|
||||
list_.GetItemText(ind, 5, text, len);
|
||||
item->desc = text;
|
||||
free(text);
|
||||
}
|
||||
void CDlgItemMgr::load_from_file(const wchar_t* file)
|
||||
{
|
||||
wchar_t *path = (wchar_t*)malloc(MAX_PATH * 4),
|
||||
int size = 2048, cnt = 0;
|
||||
wchar_t *path = (wchar_t*)malloc(size),
|
||||
*sn = path,
|
||||
*n = sn + 40,
|
||||
*t = n + 40,
|
||||
|
@ -246,32 +351,79 @@ void CDlgItemMgr::load_from_file(const wchar_t* file)
|
|||
list_.DeleteAllItems();
|
||||
file_util::load_file(file, got_str, &bom);
|
||||
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &cont);
|
||||
cont += L"\r\n";
|
||||
while ((pos = cont.find(L"\r\n")) != std::wstring::npos)
|
||||
bom.clear();
|
||||
|
||||
if (test_tmpl_)
|
||||
test_tmpl_->release();
|
||||
test_tmpl_ = known_file_util::create_jsonW();
|
||||
if (!test_tmpl_->attach(cont.c_str()))
|
||||
{
|
||||
int cnt = swscanf(cont.substr(0, pos).c_str(), L"%s %s %s %s %s", n, t, m, f, d);
|
||||
if (cnt >= 2)
|
||||
test_tmpl_->clear();
|
||||
cont += L"\r\n";
|
||||
while ((pos = cont.find(L"\r\n")) != std::wstring::npos)
|
||||
{
|
||||
bool man = false, fatal = true;
|
||||
if (cnt >= 3)
|
||||
man = wcscmp(m, L"false") == 0;
|
||||
if (cnt >= 4)
|
||||
fatal = wcscmp(f, L"true") == 0;
|
||||
int num = swscanf(cont.substr(0, pos).c_str(), L"%s %s %s %s %s", n, t, m, f, d);
|
||||
if (num >= 2)
|
||||
{
|
||||
known_file_util::IJsonW* child = known_file_util::create_jsonW();
|
||||
child->set_value(L"name", n);
|
||||
child->set_value(L"title", t);
|
||||
if (!m)
|
||||
m = L"false";
|
||||
child->set_value(L"man", wcscmp(m, L"true") != 0);
|
||||
if (!f)
|
||||
f = L"true";
|
||||
child->set_value(L"err-level", wcscmp(f, L"true") ? L"ignore" : L"fatal");
|
||||
if (!d)
|
||||
d = L"";
|
||||
child->set_value(L"desc", d);
|
||||
test_tmpl_->set_value(n, child);
|
||||
child->release();
|
||||
}
|
||||
memset(path, 0, size);
|
||||
|
||||
swprintf_s(sn, 20, L"%u", list_.GetItemCount() + 1);
|
||||
cnt = list_.InsertItem(list_.GetItemCount(), sn);
|
||||
list_.SetItemText(cnt, 1, n);
|
||||
list_.SetItemText(cnt, 2, t);
|
||||
list_.SetItemText(cnt, 3, man ? L"false" : L"true");
|
||||
list_.SetItemText(cnt, 4, f ? L"true" : L"false");
|
||||
if(*d)
|
||||
list_.SetItemText(cnt, 5, d);
|
||||
else
|
||||
list_.SetItemText(cnt, 5, t);
|
||||
cont.erase(0, pos + 2);
|
||||
}
|
||||
memset(path, 0, sizeof(path));
|
||||
cont.clear();
|
||||
test_tmpl_->to_string(got_wstr, &cont);
|
||||
file_util::force_move_file(file, (std::wstring(file) + L".bkp").c_str());
|
||||
coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bom);
|
||||
file_util::save_2_file(bom.c_str(), bom.length(), file);
|
||||
bom.clear();
|
||||
cont.clear();
|
||||
}
|
||||
|
||||
cont.erase(0, pos + 2);
|
||||
cnt = 1;
|
||||
known_file_util::IJsonW* child = test_tmpl_->first_child();
|
||||
while (child)
|
||||
{
|
||||
const wchar_t* sv = NULL;
|
||||
bool bv = true;
|
||||
int nv = 0;
|
||||
int ind = list_.InsertItem(list_.GetItemCount(), std::to_wstring(list_.GetItemCount() + 1).c_str());
|
||||
child->get_value(L"name", &sv);
|
||||
list_.SetItemText(ind, 1, sv);
|
||||
|
||||
if(child->get_value(L"title", &sv))
|
||||
list_.SetItemText(ind, 2, sv);
|
||||
|
||||
if(child->get_value(L"station", &sv))
|
||||
list_.SetItemText(ind, 3, sv);
|
||||
|
||||
if(child->get_value(L"authority", nv))
|
||||
list_.SetItemText(ind, 4, std::to_wstring(nv).c_str());
|
||||
|
||||
if(child->get_value(L"man", bv))
|
||||
list_.SetItemText(ind, 5, bv ? L"false" : L"true");
|
||||
|
||||
if(child->get_value(L"err-level", &sv))
|
||||
list_.SetItemText(ind, 6, wcscmp(sv, L"fatal") == 0 ? L"true" : L"false");
|
||||
|
||||
child->get_value(L"desc", &sv);
|
||||
list_.SetItemText(ind, 7, sv);
|
||||
list_.SetItemData(ind, (DWORD_PTR)child);
|
||||
|
||||
child = test_tmpl_->next_child();
|
||||
}
|
||||
::PostMessage(GetParent()->m_hWnd, WM_TEST_ITEM_CHANGED, 0, 0);
|
||||
free(path);
|
||||
|
@ -282,68 +434,110 @@ void CDlgItemMgr::load_stored_config(void)
|
|||
|
||||
load_from_file(file.c_str());
|
||||
}
|
||||
void CDlgItemMgr::item_changed(void)
|
||||
void CDlgItemMgr::init_sane_cfg(void)
|
||||
{
|
||||
std::vector<page_config::ITEM> items;
|
||||
std::wstring text(L"");
|
||||
std::string bom("");
|
||||
const wchar_t *val = NULL;
|
||||
int ind = -1;
|
||||
known_file_util::IJsonW* jsn = NULL, * child = NULL;
|
||||
|
||||
get_all_items(items);
|
||||
for (size_t i = 0; i < items.size(); ++i)
|
||||
for (int i = 0; i < combo_param_.GetCount(); ++i)
|
||||
{
|
||||
text += items[i].name + L" " + items[i].title + L" ";
|
||||
text += items[i].man ? L"false " : L"true ";
|
||||
text += items[i].fatal ? L"true " : L"false ";
|
||||
text += items[i].desc + L"\r\n";
|
||||
((known_file_util::IJsonW*)combo_param_.GetItemData(i))->release();
|
||||
}
|
||||
coding_util::bom::from_unicode(text.c_str(), text.length() * 2, got_str, &bom);
|
||||
file_util::save_2_file(bom.c_str(), bom.length(), get_stored_config_file().c_str());
|
||||
::PostMessage(GetParent()->m_hWnd, WM_TEST_ITEM_CHANGED, 0, 0);
|
||||
}
|
||||
bool CDlgItemMgr::get_name(const wchar_t* title, page_config::ITEM* item)
|
||||
{
|
||||
wchar_t text[1024] = { 0 };
|
||||
combo_param_.ResetContent();
|
||||
|
||||
for (size_t i = 0; i < list_.GetItemCount(); ++i)
|
||||
get_sane_config(text);
|
||||
jsn = known_file_util::create_jsonW(text.c_str());
|
||||
if (jsn)
|
||||
{
|
||||
list_.GetItemText(i, 2, text, _countof(text) - 1);
|
||||
if (wcscmp(text, title) == 0)
|
||||
child = jsn->first_child();
|
||||
if (child)
|
||||
{
|
||||
get_item(i, item);
|
||||
return true;
|
||||
child->release();
|
||||
while ((child = jsn->next_child()))
|
||||
{
|
||||
child->get_value(L"type", &val);
|
||||
if (wcscmp(val, L"button") && wcscmp(val, L"group"))
|
||||
{
|
||||
child->get_value(L"title", &val);
|
||||
while (*val == L' ' || *val == L'\t')
|
||||
val++;
|
||||
ind = combo_param_.AddString(val);
|
||||
combo_param_.SetItemData(ind, (DWORD_PTR)child);
|
||||
}
|
||||
}
|
||||
}
|
||||
text[0] = 0;
|
||||
jsn->release();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
bool CDlgItemMgr::get_title(const wchar_t* name, page_config::ITEM* item)
|
||||
int CDlgItemMgr::find_test_item(const wchar_t* name, known_file_util::IJsonW** jsn)
|
||||
{
|
||||
wchar_t text[1024] = { 0 };
|
||||
|
||||
for (size_t i = 0; i < list_.GetItemCount(); ++i)
|
||||
for (int i = 0; i < list_.GetItemCount(); ++i)
|
||||
{
|
||||
list_.GetItemText(i, 1, text, _countof(text) - 1);
|
||||
if (wcscmp(text, name) == 0)
|
||||
known_file_util::IJsonW* js = (known_file_util::IJsonW*)list_.GetItemData(i);
|
||||
const wchar_t* val = 0;
|
||||
js->get_value(L"name", &val);
|
||||
if (wcscmp(val, name) == 0)
|
||||
{
|
||||
get_item(i, item);
|
||||
return true;
|
||||
if (jsn)
|
||||
{
|
||||
*jsn = js;
|
||||
js->add_ref();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
text[0] = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
void CDlgItemMgr::get_all_items(std::vector<page_config::ITEM>& items)
|
||||
int CDlgItemMgr::find_sane_item(const wchar_t* name, known_file_util::IJsonW** jsn)
|
||||
{
|
||||
wchar_t text[1024] = { 0 };
|
||||
|
||||
for (size_t i = 0; i < list_.GetItemCount(); ++i)
|
||||
for (int i = 0; i < combo_param_.GetCount(); ++i)
|
||||
{
|
||||
page_config::ITEM item;
|
||||
get_item(i, &item);
|
||||
items.push_back(item);
|
||||
known_file_util::IJsonW* js = (known_file_util::IJsonW*)combo_param_.GetItemData(i);
|
||||
if (wcscmp(js->key(), name) == 0)
|
||||
{
|
||||
if (jsn)
|
||||
{
|
||||
*jsn = js;
|
||||
js->add_ref();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
void CDlgItemMgr::save_test_template(int type)
|
||||
{
|
||||
if (test_tmpl_)
|
||||
{
|
||||
std::wstring cont(L""), file(get_stored_config_file(type));
|
||||
std::string bom("");
|
||||
|
||||
test_tmpl_->to_string(got_wstr, &cont);
|
||||
coding_util::bom::from_unicode(cont.c_str(), cont.length() * 2, got_str, &bom);
|
||||
cont.clear();
|
||||
file_util::save_2_file(bom.c_str(), bom.length(), file.c_str());
|
||||
}
|
||||
}
|
||||
known_file_util::IJsonW* CDlgItemMgr::get_all_items(void)
|
||||
{
|
||||
if (test_tmpl_)
|
||||
{
|
||||
std::wstring text(L"");
|
||||
|
||||
test_tmpl_->to_string(got_wstr, &text);
|
||||
|
||||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(text.c_str());
|
||||
|
||||
return jsn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -361,3 +555,61 @@ void CDlgItemMgr::OnDropFiles(HDROP hDropInfo)
|
|||
CDialogEx::OnDropFiles(hDropInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDlgItemMgr::OnBnClickedButtonAdd2()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码 添加测试参数
|
||||
add_param(m_hWnd, &combo_param_, &combo_param_val_, &lst_param_, IDC_EDIT_PARAM_VAL1);
|
||||
}
|
||||
|
||||
|
||||
void CDlgItemMgr::OnCbnSelchangeComboParamName()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
on_combo_param_changed(m_hWnd, &combo_param_, &combo_param_val_, &lst_param_, IDC_EDIT_PARAM_VAL1, lst_trigger_sel_change_);
|
||||
}
|
||||
|
||||
void CDlgItemMgr::notify_combo_param_changed(void* param)
|
||||
{
|
||||
struct _cb_chg
|
||||
{
|
||||
CDlgItemMgr* dlg;
|
||||
void(CDlgItemMgr::* cb_sel_change)(void);
|
||||
};
|
||||
struct _cb_chg* chg = (struct _cb_chg*)param;
|
||||
|
||||
chg->dlg->lst_trigger_sel_change_ = true;
|
||||
(chg->dlg->*chg->cb_sel_change)();
|
||||
chg->dlg->lst_trigger_sel_change_ = false;
|
||||
}
|
||||
|
||||
void CDlgItemMgr::OnLvnItemchangedListVal(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
struct _cb_chg
|
||||
{
|
||||
CDlgItemMgr* dlg;
|
||||
void(CDlgItemMgr::* cb_sel_change)(void);
|
||||
}param = { this, &CDlgItemMgr::OnCbnSelchangeComboParamName };
|
||||
on_list_param_sel_changed(&combo_param_, &lst_param_, pNMLV->iItem, &CDlgItemMgr::notify_combo_param_changed, ¶m);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CDlgItemMgr::OnBnClickedButtonSaveTemplate()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
save_test_template(STORE_FILE_SELF);
|
||||
file_util::force_delete_file(get_stored_config_file(STORE_FILE_TEMP).c_str());
|
||||
}
|
||||
|
||||
|
||||
void CDlgItemMgr::OnBnClickedButtonClear()
|
||||
{
|
||||
// TODO: 在此添加控件通知处理程序代码
|
||||
lst_param_.DeleteAllItems();
|
||||
}
|
||||
|
|
|
@ -23,19 +23,38 @@ protected:
|
|||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
std::wstring get_stored_config_file(void);
|
||||
void get_item(int ind, page_config::ITEM* item);
|
||||
enum
|
||||
{
|
||||
STORE_FILE_SELF = 0,
|
||||
STORE_FILE_BACKUP,
|
||||
STORE_FILE_TEMP,
|
||||
};
|
||||
std::wstring get_stored_config_file(int type = STORE_FILE_SELF);
|
||||
void load_from_file(const wchar_t* file);
|
||||
void load_stored_config(void);
|
||||
void item_changed(void);
|
||||
void init_sane_cfg(void);
|
||||
int find_test_item(const wchar_t* name, known_file_util::IJsonW** jsn = NULL);
|
||||
int find_sane_item(const wchar_t* name, known_file_util::IJsonW** jsn = NULL);
|
||||
void save_test_template(int type = STORE_FILE_SELF);
|
||||
|
||||
known_file_util::IJsonW* test_tmpl_;
|
||||
bool lst_trigger_sel_change_;
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CListCtrl list_;
|
||||
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBnClickedButtonAdd();
|
||||
bool get_name(const wchar_t* title, page_config::ITEM* item);
|
||||
bool get_title(const wchar_t* name, page_config::ITEM* item);
|
||||
void get_all_items(std::vector<page_config::ITEM>& items);
|
||||
known_file_util::IJsonW* get_all_items(void);
|
||||
afx_msg void OnDropFiles(HDROP hDropInfo);
|
||||
afx_msg void OnBnClickedButtonAdd2();
|
||||
CListCtrl lst_param_;
|
||||
CComboBox combo_param_;
|
||||
CComboBox combo_param_val_;
|
||||
afx_msg void OnCbnSelchangeComboParamName();
|
||||
static void notify_combo_param_changed(void* param);
|
||||
afx_msg void OnLvnItemchangedListVal(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBnClickedButtonSaveTemplate();
|
||||
afx_msg void OnBnClickedButtonClear();
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,8 +20,12 @@ protected:
|
|||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
||||
virtual BOOL OnInitDialog();
|
||||
void reload(std::wstring& cont);
|
||||
bool load_sane_config(std::wstring& jsn_txt);
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
known_file_util::IJsonW* sane_cfg_;
|
||||
|
||||
public:
|
||||
CListCtrl list_;
|
||||
afx_msg void OnBnClickedCheckReport();
|
||||
|
@ -30,10 +34,17 @@ public:
|
|||
afx_msg void OnBnClickedButtonAdd();
|
||||
afx_msg void OnCbnSelchangeComboItem();
|
||||
afx_msg void OnNMDblclkList1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnNMDblclkListParam(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
CComboBox combo_;
|
||||
afx_msg void OnBnClickedButtonAddAll();
|
||||
|
||||
void init_test_items(std::vector<page_config::ITEM>& items);
|
||||
void init_test_items(known_file_util::IJsonW* json);
|
||||
void add_param(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id);
|
||||
void add_param_from_config(CComboBox* param_ctrl, CComboBox* val_ctrl, UINT edit_id, known_file_util::IJsonW* sane, known_file_util::IJsonW* cfg, const wchar_t* key, void(CDlgMgr::* cb_change)(void), void(CDlgMgr::* add_func)(void));
|
||||
void on_combo_param_changed(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id);
|
||||
static void notify_combo_param_changed(void* param);
|
||||
void on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(CDlgMgr::* cb_sel_change)(void));
|
||||
bool remove_prompt(CListCtrl* lst, int item, int sub, const wchar_t* title, DWORD_PTR* data = NULL);
|
||||
|
||||
public:
|
||||
virtual std::wstring export_config(bool* ok, bool used_in_code = false, int code_ver = 1) override;
|
||||
|
@ -43,4 +54,23 @@ public:
|
|||
afx_msg void OnListPasteClipboard();
|
||||
afx_msg void OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnListClear();
|
||||
afx_msg void OnBnClickedButtonAddParam();
|
||||
CListCtrl lst_write_down_;
|
||||
CListCtrl lst_param_;
|
||||
afx_msg void OnBnClickedButtonClearAll();
|
||||
CComboBox combo_param_;
|
||||
CComboBox combo_param_val_;
|
||||
afx_msg void OnCbnSelchangeComboParam();
|
||||
afx_msg void OnLvnItemchangedListParam(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
bool lst_param_trigger_sel_chg_;
|
||||
afx_msg void OnBnClickedButtonAddParam2();
|
||||
afx_msg void OnBnClickedButtonAddParam3();
|
||||
CComboBox combo_param2_;
|
||||
CComboBox combo_param_val2_;
|
||||
afx_msg void OnCbnSelchangeComboParam2();
|
||||
afx_msg void OnNMClickListParamTest(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnNMDblclkListParamTest(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
CComboBox combo_device_;
|
||||
afx_msg void OnBnClickedButtonRefresh();
|
||||
};
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
#include <utility/known_file.h>
|
||||
#pragma comment(lib, "base_util.lib")
|
||||
|
||||
#define WM_GET_TEST_ITEM_NAME WM_USER + 100 // WPARAM: (wchar_t*)title, LPARAM: (ITEM*)item
|
||||
#define WM_GET_TEST_ITEM_TITLE WM_USER + 101 // WPARAM: (wchar_t*)name, LPARAM: (ITEM*)item
|
||||
//#define WM_GET_TEST_ITEM_NAME WM_USER + 100 // WPARAM: (wchar_t*)title, LPARAM: (ITEM*)item
|
||||
//#define WM_GET_TEST_ITEM_TITLE WM_USER + 101 // WPARAM: (wchar_t*)name, LPARAM: (ITEM*)item
|
||||
#define WM_TO_ITEM_MGR_TAB WM_USER + 102
|
||||
#define WM_TEST_ITEM_CHANGED WM_USER + 103
|
||||
#define WM_REFRESH_TEST_ITEM WM_USER + 104
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
@ -38,8 +39,27 @@ public:
|
|||
virtual std::wstring export_config(bool *ok/*return error message if this returned false*/, bool used_in_code = false, int code_ver = 1) = 0;
|
||||
};
|
||||
|
||||
typedef struct _lst_col
|
||||
{
|
||||
std::wstring title;
|
||||
int width;
|
||||
int align;
|
||||
}LSTCOL;
|
||||
|
||||
extern INTER_MODULE_CALLBACK(got_wstr);
|
||||
extern INTER_MODULE_CALLBACK(got_str);
|
||||
extern void init_list_ctrl(CListCtrl* lst, const std::vector<LSTCOL>& cols);
|
||||
extern std::wstring get_list_item_text(CListCtrl* lst, int item, int col);
|
||||
extern std::wstring get_list_column_title(CListCtrl* lst, int col);
|
||||
extern int find_list_item(CListCtrl* lst, const wchar_t* find, int col = 0);
|
||||
extern int get_list_selected_item(CListCtrl* lst);
|
||||
extern void select_list_item(CListCtrl* lst, int item);
|
||||
extern WORD vid_pid_from_hex(const wchar_t* hex, bool* ok);
|
||||
extern void set_sane_config(known_file_util::IJsonW* sane, known_file_util::IJsonW* cfg, std::wstring& val);
|
||||
extern void get_sane_config(std::wstring& cfg);
|
||||
|
||||
|
||||
|
||||
extern void on_combo_param_changed(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id, bool lst_trigger);
|
||||
extern int add_param(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id);
|
||||
extern void on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(*cb_change_notify)(void*), void* param);
|
||||
extern std::wstring get_window_text(HWND wnd);
|
||||
extern void replace(std::wstring& str, const wchar_t* now, const wchar_t* to_be);
|
|
@ -22,23 +22,44 @@
|
|||
#define IDC_EDIT_DB 1009
|
||||
#define IDC_LIST1 1010
|
||||
#define IDC_COMBO_ITEM 1011
|
||||
#define IDC_LIST_VAL 1011
|
||||
#define IDC_CHECK_ONLINE 1012
|
||||
#define IDC_CHECK_FATAL 1013
|
||||
#define IDC_BUTTON_ADD 1014
|
||||
#define IDC_EDIT_IP 1015
|
||||
#define IDC_BUTTON_EXPORT 1015
|
||||
#define IDC_BUTTON_ADD2 1015
|
||||
#define IDC_BUTTON_MAINTAIN 1016
|
||||
#define IDC_COMBO1 1016
|
||||
#define IDC_BUTTON_SAVE_TEMPLATE 1016
|
||||
#define IDC_BUTTON_ADD_ALL 1017
|
||||
#define IDC_STATIC_VER 1017
|
||||
#define IDC_COMBO_PARAM_NAME 1017
|
||||
#define IDC_EDIT_VER 1018
|
||||
#define IDC_COMBO_DEVICE 1018
|
||||
#define IDC_COMBO_PARAM_VAL0 1018
|
||||
#define IDC_EDIT_NAME 1019
|
||||
#define IDC_EDIT_VID_TO2 1019
|
||||
#define IDC_EDIT_SLEEP 1019
|
||||
#define IDC_BUTTON_CLEAR_ALL 1019
|
||||
#define IDC_EDIT_TITLE 1020
|
||||
#define IDC_EDIT1 1020
|
||||
#define IDC_EDIT_SPEED 1020
|
||||
#define IDC_BUTTON_REFRESH 1020
|
||||
#define IDC_EDIT_DESC 1021
|
||||
#define IDC_COMBO_PARAM 1021
|
||||
#define IDC_COMBO_PARAM_VAL 1022
|
||||
#define IDC_EDIT_PARAM_VAL1 1022
|
||||
#define IDC_EDIT_PARAM_VAL 1023
|
||||
#define IDC_EDIT_PRIV 1023
|
||||
#define IDC_BUTTON_ADD_PARAM 1024
|
||||
#define IDC_COMBO_STATION 1024
|
||||
#define IDC_LIST_PARAM 1025
|
||||
#define IDC_BUTTON_ADD3 1025
|
||||
#define IDC_BUTTON_CLEAR 1025
|
||||
#define IDC_LIST_PARAM_TEST 1026
|
||||
#define IDC_COMBO_PARAM2 1027
|
||||
#define IDC_COMBO_PARAM3 1028
|
||||
#define IDC_BUTTON_ADD_PARAM2 1029
|
||||
#define IDC_BUTTON_ADD_PARAM3 1030
|
||||
#define IDC_EDIT_PARAM_VAL2 1031
|
||||
#define ID_LIST_32771 32771
|
||||
#define ID_LIST_PASTE_CLIPBOARD 32772
|
||||
#define ID_LIST_32773 32773
|
||||
|
@ -48,9 +69,9 @@
|
|||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 136
|
||||
#define _APS_NEXT_RESOURCE_VALUE 137
|
||||
#define _APS_NEXT_COMMAND_VALUE 32775
|
||||
#define _APS_NEXT_CONTROL_VALUE 1021
|
||||
#define _APS_NEXT_CONTROL_VALUE 1025
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -46,9 +46,8 @@ BEGIN_MESSAGE_MAP(CscannercheckDlg, CDialogEx)
|
|||
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CscannercheckDlg::OnTcnSelchangeTab1)
|
||||
ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, &CscannercheckDlg::OnTcnSelchangingTab1)
|
||||
ON_MESSAGE(WM_TO_ITEM_MGR_TAB, &CscannercheckDlg::on_to_item_manager_tab)
|
||||
ON_MESSAGE(WM_GET_TEST_ITEM_NAME, &CscannercheckDlg::on_name_from_title)
|
||||
ON_MESSAGE(WM_GET_TEST_ITEM_TITLE, &CscannercheckDlg::on_name_to_title)
|
||||
ON_MESSAGE(WM_TEST_ITEM_CHANGED, &CscannercheckDlg::on_test_item_changed)
|
||||
ON_MESSAGE(WM_REFRESH_TEST_ITEM, &CscannercheckDlg::on_refresh_test_items)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void CscannercheckDlg::add_page(const wchar_t* title, CDialogEx* child)
|
||||
|
@ -248,30 +247,21 @@ LRESULT CscannercheckDlg::on_to_item_manager_tab(WPARAM, LPARAM)
|
|||
|
||||
return 0;
|
||||
}
|
||||
LRESULT CscannercheckDlg::on_name_from_title(WPARAM wp, LPARAM lp)
|
||||
{
|
||||
std::wstring title((wchar_t*)wp);
|
||||
page_config::ITEM* item = (page_config::ITEM*)lp;
|
||||
|
||||
items_->get_name(title.c_str(), item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
LRESULT CscannercheckDlg::on_name_to_title(WPARAM wp, LPARAM lp)
|
||||
{
|
||||
std::wstring name((wchar_t*)wp);
|
||||
page_config::ITEM* item = (page_config::ITEM*)lp;
|
||||
|
||||
items_->get_title(name.c_str(), item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
LRESULT CscannercheckDlg::on_test_item_changed(WPARAM wp, LPARAM lp)
|
||||
{
|
||||
std::vector<page_config::ITEM> items;
|
||||
items_->get_all_items(items);
|
||||
mgr_->init_test_items(items);
|
||||
known_file_util::IJsonW* jsn = items_->get_all_items();
|
||||
if (jsn)
|
||||
{
|
||||
mgr_->init_test_items(jsn);
|
||||
|
||||
jsn->release();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
LRESULT CscannercheckDlg::on_refresh_test_items(WPARAM wp, LPARAM lp)
|
||||
{
|
||||
on_test_item_changed(wp, lp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,7 @@ public:
|
|||
afx_msg void OnCbnSelchangeCombo1();
|
||||
afx_msg void OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg LRESULT on_to_item_manager_tab(WPARAM, LPARAM);
|
||||
afx_msg LRESULT on_name_from_title(WPARAM wp, LPARAM lp);
|
||||
afx_msg LRESULT on_name_to_title(WPARAM wp, LPARAM lp);
|
||||
afx_msg LRESULT on_test_item_changed(WPARAM wp, LPARAM lp);
|
||||
afx_msg LRESULT on_refresh_test_items(WPARAM wp, LPARAM lp);
|
||||
afx_msg void OnTcnSelchangingTab1(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -166,6 +166,20 @@ namespace process_util
|
|||
PORT_API(WORD) set_console_attribute(WORD attr);
|
||||
PORT_API(ICmd*) from_console(const wchar_t* tips = L"input");
|
||||
PORT_API(ICmd*) from_console(const char* tips = "input");
|
||||
|
||||
__declspec(novtable) struct IDebugMemLeaker : public ref_util::IRef
|
||||
{
|
||||
COM_API_DECLARE(void, start(void));
|
||||
|
||||
// parameter of result:
|
||||
// data: leaked memory address
|
||||
// len: bytes of data
|
||||
// total: unused, be ZERO
|
||||
// flag: DATA_FLAG_FINAL
|
||||
// param: like 'param'
|
||||
COM_API_DECLARE(void, report(inter_module_data::set_data result = NULL, void* param = NULL));
|
||||
};
|
||||
PORT_API(IDebugMemLeaker*) create_debug_memory_leaking_reporter(void);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -193,6 +193,36 @@ namespace sys_util
|
|||
CPU_CACHE_UNIFIED, // 3 = Unified Cache.
|
||||
CPU_CACHE_COUNT,
|
||||
};
|
||||
typedef union _ecx_80000001
|
||||
{
|
||||
unsigned int dword_val;
|
||||
struct
|
||||
{
|
||||
unsigned int bit_00_lahf : 1; // LAHF/SAHF available in 64-bits
|
||||
unsigned int bit_01_resv : 4; // reserved
|
||||
unsigned int bit_05_lzcnt : 1; // LZCNT
|
||||
unsigned int bit_06_resv : 2; // reserved
|
||||
unsigned int bit_08_prefetch : 1; // PREFETCHW
|
||||
unsigned int bit_09_resv : 23; // reserved
|
||||
};
|
||||
}CPU_ECX_80000001;
|
||||
typedef union _edx_80000001
|
||||
{
|
||||
unsigned int dword_val;
|
||||
struct
|
||||
{
|
||||
unsigned int bit_00_resv : 11; // reserved
|
||||
unsigned int bit_11_syscall : 1; // SYSCALL/SYSRET
|
||||
unsigned int bit_12_resv : 8; // reserved
|
||||
unsigned int bit_20_edb : 1; // execute disable bit available
|
||||
unsigned int bit_21_resv : 5; // reserved
|
||||
unsigned int bit_26_1Gpage : 1; // 1GB-pages are available
|
||||
unsigned int bit_27_rdtscp : 1; // RDTSCP & IA32_TSC_AUX are available
|
||||
unsigned int bit_28_resv : 1; // reserved
|
||||
unsigned int bit_29_ia64 : 1; // Intel-64 architecture available
|
||||
unsigned int bit_30_resv : 2; // reserved
|
||||
};
|
||||
}CPU_EDX_80000001;
|
||||
typedef struct _cpu_cache
|
||||
{
|
||||
cpu_cache_type type;
|
||||
|
@ -205,6 +235,7 @@ namespace sys_util
|
|||
int cores;
|
||||
int speed_base; // in MHz, 0 - not got; < 0 is unreliable
|
||||
int speed_max; // in MHz, 0 - not got; < 0 is unreliable
|
||||
int speed_bus; // in MHz, 0 - not got; < 0 is unreliable
|
||||
char *manufactor;
|
||||
char *product;
|
||||
int cache_num;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue