2022-12-09 07:31:09 +00:00
|
|
|
|
// CDlgMgr.cpp: 实现文件
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
|
#include "scanner-check.h"
|
|
|
|
|
#include "CDlgMgr.h"
|
|
|
|
|
#include "afxdialogex.h"
|
2023-01-04 10:23:36 +00:00
|
|
|
|
#include "CDlgInput.h"
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include <file/file_util.h>
|
|
|
|
|
#include <coding/coding.h>
|
|
|
|
|
|
|
|
|
|
// CDlgMgr 对话框
|
|
|
|
|
static std::wstring vid_pid_edit_org_proc = L"vid_pid_edit_org_proc";
|
2023-01-04 10:23:36 +00:00
|
|
|
|
static wchar_t* hex = L"\uFF10\uFF11\uFF12\uFF13\uFF14\uFF15\uFF16\uFF17\uFF18\uFF19\uFF21\uFF22\uFF23\uFF24\uFF25\uFF26";
|
|
|
|
|
static std::string jsontext1("{\"global\":{\"device_type\":\"G139-G239\",\"option_count\":75},\"restore\":{\"category\":\"base\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"type\":\"button\",\"cur\":\"button\",\"default\":\"button\",\"size\":0},\"help\":{\"category\":\"advanced\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"type\":\"button\",\"cur\":\"true\",\"default\":\"true\",\"size\":4},\"grp-1\":{\"category\":\"base\",\"title\":\"\\u57fa\\u672c\\u8bbe\\u7f6e\",\"type\":\"group\"},\"is-multiout\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"multiout-type\":{\"category\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"type\":\"string\",\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"size\":32,\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend_or\":[\"is-multiout==true\"]},\"mode\":{\"category\":\"base\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"type\":\"string\",\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"size\":32,\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend_or\":[\"is-multiout!=true\"]},\"binary-threshold\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u9608\\u503c\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a1\\uff08\\u767d\\uff09\\uff0c\\u4f4e\\u4e8e\\u8be5\\u9608\\u503c\\u4e3a0\\uff08\\u9ed1\\uff09\",\"type\":\"int\",\"cur\":127,\"default\":127,\"size\":4,\"range\":{\"min\":0,\"max\":255},\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"reverse-bw\":{\"category\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u53cd\\u8272\\u8f93\\u51fa\",\"desc\":\"\\u8f93\\u51fa\\u7684\\u9ed1\\u767d\\u56fe\\u50cf\\u4ee5\\u201c1\\u201d\\u4ee3\\u8868\\u9ed1\\u8272\\uff0c\\u201c0\\u201d\\u4ee3\\u8868\\u767d\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_or\":[\"is-multiout==true\",\"mode==\\u9ed1\\u767d\"]},\"filter\":{\"category\":\"base\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"type\":\"string\",\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"size\":24,\"range\":[\"\\u4e0d\\u9664\\u8272\",\"\\u9664\\u7ea2\\u8272\",\"\\u9664\\u7eff\\u8272\",\"\\u9664\\u84dd\\u8272\",\"\\u7ea2\\u8272\\u589e\\u5f3a\",\"\\u7eff\\u8272\\u589e\\u5f3a\",\"\\u84dd\\u8272\\u589e\\u5f3a\"],\"depend_and\":[\"is-multiout!=true\",\"mode!=24\\u4f4d\\u5f69\\u8272\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-multiout-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u591a\\u6d41\\u8f93\\u51fa\\u9664\\u7ea2\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u5f69\\u8272\\u56fe\\u50cf\\u548c\\u7070\\u5ea6\\u9664\\u7ea2\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\",\"!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"]},\"is-rid-answer-sheet-red\":{\"category\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-multiout!=true\",\"mode!=256\\u7ea7\\u7070\\u5ea6\",\"!=\\u9ed1\\u767d\
|
|
|
|
|
static std::string jsontext2("ase\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\"]},\"is-erase-black-frame\":{\"category\":\"base\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"type\":\"bool\",\"cur\":true,\"default\":true,\"size\":4},\"bkg-fill-mode\":{\"category\":\"advanced\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"type\":\"string\",\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"size\":40,\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend_or\":[\"is-erase-black-frame==true\"]},\"is-fill-color\":{\"category\":\"base\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"is-erase-black-frame==true\"]},\"threshold\":{\"category\":\"advanced\",\"title\":\"\\u9608\\u503c\",\"desc\":\"\\u6587\\u7a3f\\u5e95\\u8272\\u4e0e\\u9ed1\\u8272\\u80cc\\u666f\\u7070\\u5ea6\\u503c\\u7684\\u5dee\\u503c\\u5927\\u4e8e\\u8be5\\u503c\\uff0c\\u624d\\u4f1a\\u88ab\\u8bc6\\u522b\\u4e3a\\u6587\\u7a3f\",\"type\":\"int\",\"cur\":40,\"default\":40,\"size\":4,\"range\":{\"min\":30,\"max\":50},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"anti-noise-level\":{\"category\":\"advanced\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"type\":\"int\",\"cur\":8,\"default\":8,\"size\":4,\"range\":{\"min\":1,\"max\":20},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew==true\"]},\"margin\":{\"category\":\"advanced\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"type\":\"int\",\"cur\":5,\"default\":5,\"size\":4,\"range\":{\"min\":5,\"max\":30},\"depend_or\":[\"is-erase-black-frame==true\",\"paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"is-anti-skew==true\"]},\"is-dark-sample\":{\"category\":\"base\",\"title\":\"\\u6df1\\u8272\\u6837\\u5f20\",\"desc\":\"\\u542f\\u7528\\u8be5\\u6a21\\u5f0f\\u9632\\u6b62\\u6df1\\u8272\\u5e95\\u8272\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\\u88ab\\u8bef\\u5904\\u7406\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4,\"depend_and\":[\"page!=\\u5bf9\\u6298\",\"is-erase-black-frame!=true\",\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"is-anti-skew!=true\"]},\"is-anti-permeate\":{\"category\":\"base\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\\u9632\\u6b62\\u80cc\\u9762\\u56fe\\u6848\\u6e17\\u900f\",\"type\":\"bool\",\"cur\":false,\"default\":false,\"size\":4},\"permeate-level\":{\"category\":\"base\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\\u9009\\u62e9\\u9632\\u6b62\\u6e17\\u900f\\u7684\\u7b49\\u7ea7\",\"type\":\"string\",\"cur\":\"\\u8f83\\u5f31\",\"d
|
|
|
|
|
|
|
|
|
|
#define PARAM_VID ((DWORD_PTR)1)
|
|
|
|
|
#define PARAM_PID ((DWORD_PTR)2)
|
|
|
|
|
#define PARAM_SPEED ((DWORD_PTR)3)
|
|
|
|
|
#define FIND_DATA(ctrl, count, data, ind) \
|
|
|
|
|
{ \
|
|
|
|
|
ind = -1; \
|
|
|
|
|
for(int i = 0; i < (ctrl).##count(); ++i) \
|
|
|
|
|
{ \
|
|
|
|
|
if((ctrl).GetItemData(i) == DWORD_PTR(data))\
|
|
|
|
|
{ \
|
|
|
|
|
ind = i; \
|
|
|
|
|
break; \
|
|
|
|
|
} \
|
|
|
|
|
} \
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CDlgMgr, CDialogEx)
|
|
|
|
|
|
|
|
|
|
CDlgMgr::CDlgMgr(CWnd* pParent /*=nullptr*/)
|
|
|
|
|
: CDialogEx(IDD_MANAGER, pParent)
|
2023-01-04 10:23:36 +00:00
|
|
|
|
, lst_param_trigger_sel_chg_(false)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CDlgMgr::~CDlgMgr()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool is_checked(CWnd* ctrl)
|
|
|
|
|
{
|
|
|
|
|
return ((CButton*)ctrl)->GetCheck() == BST_CHECKED;
|
|
|
|
|
}
|
|
|
|
|
static bool is_checked(CDialogEx* dlg, UINT id)
|
|
|
|
|
{
|
|
|
|
|
return is_checked(dlg->GetDlgItem(id));
|
|
|
|
|
}
|
|
|
|
|
static void set_checked(CWnd* ctrl, bool checked)
|
|
|
|
|
{
|
|
|
|
|
((CButton*)ctrl)->SetCheck(checked ? BST_CHECKED : BST_UNCHECKED);
|
|
|
|
|
}
|
|
|
|
|
static void set_checked(CDialogEx* dlg, UINT id, bool checked)
|
|
|
|
|
{
|
|
|
|
|
return set_checked(dlg->GetDlgItem(id), checked);
|
|
|
|
|
}
|
|
|
|
|
static LRESULT vid_pid_edit_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
|
|
|
|
{
|
|
|
|
|
wchar_t now[40] = { 0 };
|
|
|
|
|
int len = 0, sel = 0, max_len = 4;
|
|
|
|
|
bool all_digit = true;
|
|
|
|
|
WNDPROC wndproc = (WNDPROC)GetPropW(hwnd, vid_pid_edit_org_proc.c_str());
|
|
|
|
|
std::wstring buf(L"");
|
|
|
|
|
|
|
|
|
|
if (!wndproc)
|
|
|
|
|
wndproc = DefWindowProcW;
|
|
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
|
{
|
|
|
|
|
case WM_CHAR:
|
|
|
|
|
GetWindowTextW(hwnd, now, _countof(now));
|
|
|
|
|
len = lstrlenW(now);
|
|
|
|
|
sel = SendMessage(hwnd, EM_GETSEL, 0, 0);
|
|
|
|
|
sel = ((sel >> 16) & 0x0ff) - (sel & 0x0ffff);
|
|
|
|
|
if (wp >= ' ' && len - sel >= max_len)
|
|
|
|
|
return 0;
|
|
|
|
|
if (wp >= '0' && wp <= '9')
|
|
|
|
|
wp = hex[wp - '0'];
|
|
|
|
|
else if (wp >= 'A' && wp <= 'F')
|
|
|
|
|
wp = hex[wp - 'A' + 10];
|
|
|
|
|
else if (wp >= 'a' && wp <= 'f')
|
|
|
|
|
wp = hex[wp - 'a' + 10];
|
|
|
|
|
else if(wp >= ' ')
|
|
|
|
|
return 0;
|
|
|
|
|
break;
|
2022-12-09 08:56:15 +00:00
|
|
|
|
//case WM_COPY:
|
|
|
|
|
// return 0;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
case WM_PASTE:
|
|
|
|
|
{
|
|
|
|
|
size_t l = 0;
|
|
|
|
|
if (file_util::get_clipboard(NULL, &l, CF_UNICODETEXT) == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
|
{
|
|
|
|
|
buf.resize(l + 4);
|
|
|
|
|
l++;
|
|
|
|
|
if (file_util::get_clipboard(&buf[0], &l, CF_UNICODETEXT))
|
|
|
|
|
l = 0;
|
|
|
|
|
}
|
|
|
|
|
if (l == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
lp = (LPARAM)&buf[0];
|
|
|
|
|
msg = WM_SETTEXT;
|
|
|
|
|
}
|
|
|
|
|
case WM_SETTEXT:
|
|
|
|
|
for (int i = 0; len < max_len + 1 && i < lstrlenW((wchar_t*)lp); ++i)
|
|
|
|
|
{
|
|
|
|
|
wchar_t ch = ((wchar_t*)lp)[i];
|
|
|
|
|
if (ch >= '0' && ch <= '9')
|
|
|
|
|
now[len++] = hex[ch - '0'];
|
|
|
|
|
else if (ch >= 'A' && ch <= 'F')
|
|
|
|
|
{
|
|
|
|
|
now[len++] = hex[ch - 'A' + 10];
|
|
|
|
|
all_digit = false;
|
|
|
|
|
}
|
|
|
|
|
else if (ch >= 'a' && ch <= 'f')
|
|
|
|
|
{
|
|
|
|
|
now[len++] = hex[ch - 'a' + 10];
|
|
|
|
|
all_digit = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(len == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
if (/*len == max_len + 1 &&*/ all_digit)
|
|
|
|
|
{
|
|
|
|
|
sel = _wtoi(now);
|
|
|
|
|
//if (sel <= 0x0ffff)
|
|
|
|
|
{
|
|
|
|
|
now[max_len] = 0;
|
|
|
|
|
for (int l = max_len - 1; l >= 0; --l, sel >>= 4)
|
|
|
|
|
now[l] = hex[sel % 16];
|
|
|
|
|
}
|
|
|
|
|
//else
|
|
|
|
|
// now[max_len] = 0;
|
|
|
|
|
}
|
|
|
|
|
lp = (LPARAM)now;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return wndproc(hwnd, msg, wp, lp);
|
|
|
|
|
}
|
|
|
|
|
static void set_vid_pid_proc(HWND hwnd)
|
|
|
|
|
{
|
|
|
|
|
SetPropW(hwnd, vid_pid_edit_org_proc.c_str(), (HANDLE)(FARPROC)GetWindowLong(hwnd, GWL_WNDPROC));
|
|
|
|
|
SetWindowLong(hwnd, GWL_WNDPROC, (LONG)(FARPROC)vid_pid_edit_proc);
|
|
|
|
|
}
|
|
|
|
|
static WORD vid_pid_edit_value(HWND hwnd)
|
|
|
|
|
{
|
|
|
|
|
wchar_t text[40] = { 0 };
|
|
|
|
|
int off = 10;
|
|
|
|
|
WORD vpid = 0;
|
|
|
|
|
|
|
|
|
|
GetWindowTextW(hwnd, text + off, _countof(text) - off - 1);
|
|
|
|
|
for (int i = 0; text[off + i]; ++i)
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* ptr = NULL;
|
|
|
|
|
|
|
|
|
|
text[0] = text[off + i];
|
|
|
|
|
ptr = wcsstr(hex, text);
|
|
|
|
|
if (!ptr)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
vpid <<= 4;
|
|
|
|
|
vpid += ptr - hex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vpid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::DoDataExchange(CDataExchange* pDX)
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::DoDataExchange(pDX);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST1, list_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_ITEM, combo_);
|
|
|
|
|
DDX_Control(pDX, IDC_IPADDRESS1, ip_);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
DDX_Control(pDX, IDC_LIST_PARAM, lst_write_down_);
|
|
|
|
|
DDX_Control(pDX, IDC_LIST_PARAM_TEST, lst_param_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_PARAM, combo_param_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_PARAM_VAL, combo_param_val_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_PARAM2, combo_param2_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_PARAM3, combo_param_val2_);
|
|
|
|
|
DDX_Control(pDX, IDC_COMBO_DEVICE, combo_device_);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDlgMgr, CDialogEx)
|
|
|
|
|
ON_BN_CLICKED(IDC_CHECK2, &CDlgMgr::OnBnClickedCheckReport)
|
|
|
|
|
ON_MESSAGE(WM_USER + 1, &CDlgMgr::OnDisableIPCtrl)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_MAINTAIN, &CDlgMgr::OnBnClickedButtonMaintain)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgMgr::OnBnClickedButtonAdd)
|
|
|
|
|
ON_CBN_SELCHANGE(IDC_COMBO_ITEM, &CDlgMgr::OnCbnSelchangeComboItem)
|
|
|
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgMgr::OnNMDblclkList1)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_ALL, &CDlgMgr::OnBnClickedButtonAddAll)
|
|
|
|
|
ON_WM_DROPFILES()
|
2022-12-09 08:56:15 +00:00
|
|
|
|
// ON_WM_GETDLGCODE()
|
|
|
|
|
ON_COMMAND(ID_LIST_PASTE_CLIPBOARD, &CDlgMgr::OnListPasteClipboard)
|
|
|
|
|
ON_NOTIFY(NM_RCLICK, IDC_LIST1, &CDlgMgr::OnNMRClickList1)
|
2022-12-09 09:43:55 +00:00
|
|
|
|
ON_COMMAND(ID_LIST_CLEAR, &CDlgMgr::OnListClear)
|
2023-01-04 10:23:36 +00:00
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM, &CDlgMgr::OnBnClickedButtonAddParam)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_CLEAR_ALL, &CDlgMgr::OnBnClickedButtonClearAll)
|
|
|
|
|
ON_CBN_SELCHANGE(IDC_COMBO_PARAM, &CDlgMgr::OnCbnSelchangeComboParam)
|
|
|
|
|
ON_NOTIFY(NM_CLICK, IDC_LIST_PARAM, &CDlgMgr::OnLvnItemchangedListParam)
|
|
|
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST_PARAM, &CDlgMgr::OnNMDblclkListParam)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM2, &CDlgMgr::OnBnClickedButtonAddParam2)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_PARAM3, &CDlgMgr::OnBnClickedButtonAddParam3)
|
|
|
|
|
ON_CBN_SELCHANGE(IDC_COMBO_PARAM2, &CDlgMgr::OnCbnSelchangeComboParam2)
|
|
|
|
|
ON_NOTIFY(NM_CLICK, IDC_LIST_PARAM_TEST, &CDlgMgr::OnNMClickListParamTest)
|
|
|
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST_PARAM_TEST, &CDlgMgr::OnNMDblclkListParamTest)
|
|
|
|
|
ON_NOTIFY(NM_CLICK, IDC_LIST1, &CDlgMgr::OnNMClickList1)
|
|
|
|
|
ON_BN_CLICKED(IDC_BUTTON_REFRESH, &CDlgMgr::OnBnClickedButtonRefresh)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
static DWORD WINAPI disable_ip_ctrl(LPVOID lp)
|
|
|
|
|
{
|
|
|
|
|
Sleep(500);
|
|
|
|
|
PostMessage((HWND)lp, WM_USER + 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
LRESULT CDlgMgr::OnDisableIPCtrl(WPARAM, LPARAM)
|
|
|
|
|
{
|
|
|
|
|
OnBnClickedCheckReport();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
// CDlgMgr 消息处理程序
|
|
|
|
|
BOOL CDlgMgr::OnInitDialog()
|
|
|
|
|
{
|
|
|
|
|
CDialogEx::OnInitDialog();
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
std::vector<LSTCOL> cols;
|
|
|
|
|
LSTCOL col;
|
|
|
|
|
|
|
|
|
|
col.align = 0;
|
|
|
|
|
col.title = L"\u5E8F\u53F7";
|
|
|
|
|
col.width = 40;
|
|
|
|
|
cols.push_back(col);
|
|
|
|
|
col.title = L"\u6D4B\u8BD5\u9879\u76EE";
|
|
|
|
|
col.width = 160;
|
|
|
|
|
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);
|
|
|
|
|
init_list_ctrl(&list_, cols);
|
|
|
|
|
|
|
|
|
|
cols.clear();
|
|
|
|
|
col.title = L"\u53C2\u6570\u540D\u79F0";
|
|
|
|
|
col.width = 120;
|
|
|
|
|
cols.push_back(col);
|
|
|
|
|
col.title = L"\u53C2\u6570\u503C";
|
|
|
|
|
col.width = 160;
|
|
|
|
|
cols.push_back(col);
|
|
|
|
|
init_list_ctrl(&lst_write_down_, cols);
|
|
|
|
|
init_list_ctrl(&lst_param_, cols);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
set_vid_pid_proc(GetDlgItem(IDC_EDIT_VID_SRC)->m_hWnd);
|
|
|
|
|
set_vid_pid_proc(GetDlgItem(IDC_EDIT_PID_SRC)->m_hWnd);
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_VID_SRC, 0x3072);
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PID_SRC, 0x200);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
|
|
|
|
|
std::wstring jsn(L"");
|
|
|
|
|
get_sane_config(jsn);
|
|
|
|
|
sane_cfg_ = known_file_util::create_jsonW();
|
|
|
|
|
load_sane_config(jsn);
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_EDIT_PARAM_VAL)->ShowWindow(SW_HIDE);
|
|
|
|
|
combo_device_.SetCurSel(1);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedCheckReport()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
bool enable = is_checked(this, IDC_CHECK2);
|
|
|
|
|
|
|
|
|
|
GetDlgItem(IDC_IPADDRESS1)->EnableWindow(enable);
|
|
|
|
|
GetDlgItem(IDC_IPADDRESS1)->ShowWindow(SW_SHOW);
|
|
|
|
|
GetDlgItem(IDC_EDIT_IP)->ShowWindow(SW_HIDE);
|
|
|
|
|
GetDlgItem(IDC_EDIT_PORT)->EnableWindow(enable);
|
|
|
|
|
GetDlgItem(IDC_EDIT_DB)->EnableWindow(enable);
|
|
|
|
|
if (enable)
|
|
|
|
|
GotoDlgCtrl(GetDlgItem(IDC_IPADDRESS1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonMaintain()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
::PostMessage(GetParent()->m_hWnd, WM_TO_ITEM_MGR_TAB, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
void CDlgMgr::OnBnClickedButtonRefresh()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
if (::MessageBoxW(m_hWnd, L"刷新测试项,需要清空列表,要继续刷新吗?", L"Warning", MB_YESNO | MB_ICONQUESTION) != IDYES)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
OnBnClickedButtonClearAll();
|
|
|
|
|
::PostMessage(GetParent()->m_hWnd, WM_REFRESH_TEST_ITEM, 0, 0);
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonAdd()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
wchar_t text[128] = { 0 };
|
2023-01-04 10:23:36 +00:00
|
|
|
|
int ind = -1, sel = combo_.GetCurSel();
|
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)combo_.GetItemData(sel);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
if (::GetWindowTextW(GetDlgItem(IDC_COMBO_ITEM)->m_hWnd, text, _countof(text) - 1) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
// sn title station priv online fatal
|
|
|
|
|
ind = find_list_item(&list_, text, 1);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
if (ind == -1)
|
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
int col = 1, nv = 0;
|
|
|
|
|
bool man = false;
|
|
|
|
|
|
|
|
|
|
ind = list_.InsertItem(list_.GetItemCount(), std::to_wstring(list_.GetItemCount() + 1).c_str());
|
|
|
|
|
if (json->get_value(L"title", &val))
|
|
|
|
|
list_.SetItemText(ind, col++, val);
|
|
|
|
|
else
|
|
|
|
|
col++;
|
|
|
|
|
if(json->get_value(L"station", &val))
|
|
|
|
|
list_.SetItemText(ind, col++, val);
|
|
|
|
|
else
|
|
|
|
|
col++;
|
|
|
|
|
if(json->get_value(L"authority", nv))
|
|
|
|
|
list_.SetItemText(ind, col++, std::to_wstring(nv).c_str());
|
|
|
|
|
else
|
|
|
|
|
col++;
|
|
|
|
|
json->get_value(L"man", man);
|
|
|
|
|
list_.SetItemText(ind, col++, man ? L"false" : L"true");
|
|
|
|
|
json->get_value(L"err-level", &val);
|
|
|
|
|
list_.SetItemText(ind, col++, wcscmp(val, L"fatal") ? L"false" : L"true");
|
|
|
|
|
|
|
|
|
|
list_.SetItemData(ind, (DWORD_PTR)json);
|
|
|
|
|
json->add_ref();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
select_list_item(&list_, ind);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnCbnSelchangeComboItem()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
2023-01-04 10:23:36 +00:00
|
|
|
|
wchar_t text[128];
|
|
|
|
|
int ind = -1;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
::GetWindowTextW(GetDlgItem(IDC_COMBO_ITEM)->m_hWnd, text, _countof(text) - 1);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
ind = find_list_item(&list_, text, 1);
|
|
|
|
|
if(ind != -1)
|
|
|
|
|
select_list_item(&list_, ind);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::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)
|
|
|
|
|
{
|
|
|
|
|
std::vector<int> width;
|
2022-12-14 09:59:02 +00:00
|
|
|
|
int ind = r.left, hpos = list_.GetScrollPos(SB_HORZ);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(ind);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list_.GetHeaderCtrl()->GetItemCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
RECT r = { 0 };
|
|
|
|
|
list_.GetHeaderCtrl()->GetItemRect(i, &r);
|
|
|
|
|
width.push_back(r.right - r.left);
|
|
|
|
|
}
|
2022-12-14 09:59:02 +00:00
|
|
|
|
pos.x += hpos;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
for (int i = 0; i < width.size(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (pos.x <= width[i])
|
|
|
|
|
{
|
|
|
|
|
wchar_t text[128] = { 0 };
|
|
|
|
|
if (i < 2)
|
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
DWORD_PTR data = NULL;
|
|
|
|
|
if (remove_prompt(&list_, ind, 1, L"\u5220\u9664\u6D4B\u8BD5\u9879\u76EE\uFF1F", &data))
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)data;
|
|
|
|
|
if(json)
|
|
|
|
|
json->release();
|
|
|
|
|
|
2022-12-09 07:31:09 +00:00
|
|
|
|
for (; ind < list_.GetItemCount(); ++ind)
|
|
|
|
|
{
|
|
|
|
|
swprintf_s(text, _countof(text) - 1, L"%u", ind + 1);
|
|
|
|
|
list_.SetItemText(ind, 0, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
else if (i < 4)
|
|
|
|
|
{
|
|
|
|
|
CDlgInput dlg;
|
|
|
|
|
|
|
|
|
|
dlg.val_ = get_list_item_text(&list_, ind, i);
|
|
|
|
|
dlg.title_ = get_list_column_title(&list_, i);
|
|
|
|
|
if (dlg.DoModal() == IDOK)
|
|
|
|
|
{
|
|
|
|
|
list_.SetItemText(ind, i, dlg.val_.c_str());
|
|
|
|
|
if (i == 2)
|
|
|
|
|
json->set_value(L"station", dlg.val_.c_str());
|
|
|
|
|
else
|
|
|
|
|
json->set_value(L"authority", _wtoi(dlg.val_.c_str()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
list_.GetItemText(ind, i, text, _countof(text) - 1);
|
|
|
|
|
if (wcscmp(text, L"true"))
|
2023-01-04 10:23:36 +00:00
|
|
|
|
{
|
2022-12-09 07:31:09 +00:00
|
|
|
|
list_.SetItemText(ind, i, L"true");
|
2023-01-04 10:23:36 +00:00
|
|
|
|
if (i == 4)
|
|
|
|
|
json->set_value(L"man", false);
|
|
|
|
|
else
|
|
|
|
|
json->set_value(L"err-level", L"fatal");
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
else
|
2023-01-04 10:23:36 +00:00
|
|
|
|
{
|
2022-12-09 07:31:09 +00:00
|
|
|
|
list_.SetItemText(ind, i, L"false");
|
2023-01-04 10:23:36 +00:00
|
|
|
|
if (i == 4)
|
|
|
|
|
json->set_value(L"man", true);
|
|
|
|
|
else
|
|
|
|
|
json->set_value(L"err-level", L"ignore");
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos.x -= width[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonAddAll()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
for (int i = 0; i < combo_.GetCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
combo_.SetCurSel(i);
|
|
|
|
|
OnCbnSelchangeComboItem();
|
|
|
|
|
OnBnClickedButtonAdd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
void CDlgMgr::init_test_items(known_file_util::IJsonW* json)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
int ind = 1;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < combo_.GetCount(); ++i)
|
|
|
|
|
((known_file_util::IJsonW*)combo_.GetItemData(i))->release();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
combo_.ResetContent();
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* item = json->first_child();
|
|
|
|
|
while (item)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* data = NULL;
|
|
|
|
|
|
|
|
|
|
std::wstring text(L"");
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
int cb_ind = 0;
|
|
|
|
|
|
|
|
|
|
item->to_string(got_wstr, &text);
|
|
|
|
|
item->release();
|
|
|
|
|
data = known_file_util::create_jsonW(text.c_str());
|
|
|
|
|
if (data)
|
|
|
|
|
{
|
|
|
|
|
data->get_value(L"title", &val);
|
|
|
|
|
if (val)
|
|
|
|
|
{
|
|
|
|
|
cb_ind = combo_.AddString(val);
|
|
|
|
|
combo_.SetItemData(cb_ind, (DWORD_PTR)data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
data->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
item = json->next_child();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
INTER_MODULE_CALLBACK(got_wstr)
|
|
|
|
|
{
|
|
|
|
|
*((std::wstring*)param) += std::wstring((const wchar_t*)data, len / 2);
|
|
|
|
|
|
|
|
|
|
return inter_module_data::SET_RESULT_CONTINUE;
|
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
void init_list_ctrl(CListCtrl* lst, const std::vector<LSTCOL>& cols)
|
|
|
|
|
{
|
|
|
|
|
while (lst->DeleteColumn(0));
|
|
|
|
|
|
|
|
|
|
for (const auto& v : cols)
|
|
|
|
|
{
|
|
|
|
|
lst->InsertColumn(lst->GetHeaderCtrl()->GetItemCount(), v.title.c_str(), v.align, v.width);
|
|
|
|
|
}
|
|
|
|
|
lst->SetExtendedStyle((lst->GetExStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES) & (~LVS_EX_CHECKBOXES));
|
|
|
|
|
lst->ModifyStyle(0, LVS_SINGLESEL);
|
|
|
|
|
}
|
|
|
|
|
std::wstring get_list_item_text(CListCtrl* lst, int item, int col)
|
|
|
|
|
{
|
|
|
|
|
int len = 10, size = len;
|
|
|
|
|
wchar_t* buf = new wchar_t[len];
|
|
|
|
|
|
|
|
|
|
while (lst->GetItemText(item, col, buf, len - 1) == len - 2)
|
|
|
|
|
{
|
|
|
|
|
len *= 2;
|
|
|
|
|
delete[] buf;
|
|
|
|
|
buf = new wchar_t[len];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::wstring ret(buf);
|
|
|
|
|
|
|
|
|
|
delete[] buf;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
std::wstring get_list_column_title(CListCtrl* lst, int col)
|
|
|
|
|
{
|
|
|
|
|
HDITEMW item = { 0 };
|
|
|
|
|
wchar_t buf[256] = { 0 };
|
|
|
|
|
|
|
|
|
|
item.cchTextMax = _countof(buf) - 1;
|
|
|
|
|
item.pszText = buf;
|
|
|
|
|
item.mask = LVIF_TEXT;
|
|
|
|
|
lst->GetHeaderCtrl()->GetItem(col, &item);
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
int find_list_item(CListCtrl* lst, const wchar_t* find, int col)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < lst->GetItemCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (get_list_item_text(lst, i, col) == find)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
int get_list_selected_item(CListCtrl* lst)
|
|
|
|
|
{
|
|
|
|
|
POSITION pos = lst->GetFirstSelectedItemPosition();
|
|
|
|
|
|
|
|
|
|
return lst->GetNextSelectedItem(pos);
|
|
|
|
|
}
|
|
|
|
|
void select_list_item(CListCtrl* lst, int item)
|
|
|
|
|
{
|
|
|
|
|
lst->SetItemState(item, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
|
|
|
|
|
lst->EnsureVisible(item, FALSE);
|
|
|
|
|
}
|
|
|
|
|
WORD vid_pid_from_hex(const wchar_t* hex, bool* ok)
|
|
|
|
|
{
|
|
|
|
|
WORD id = 0;
|
|
|
|
|
bool good = true;
|
|
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
|
ok = &good;
|
|
|
|
|
*ok = true;
|
|
|
|
|
while (*hex == L' ' || *hex == L'\t')
|
|
|
|
|
hex++;
|
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (*hex >= L'0' && *hex <= L'9')
|
|
|
|
|
{
|
|
|
|
|
id <<= 4;
|
|
|
|
|
id += *hex - L'0';
|
|
|
|
|
}
|
|
|
|
|
else if (*hex >= L'a' && *hex <= L'f')
|
|
|
|
|
{
|
|
|
|
|
id <<= 4;
|
|
|
|
|
id += *hex - L'a' + 10;
|
|
|
|
|
}
|
|
|
|
|
else if (*hex >= L'A' && *hex <= L'F')
|
|
|
|
|
{
|
|
|
|
|
id <<= 4;
|
|
|
|
|
id += *hex - L'A' + 10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
hex++;
|
|
|
|
|
}
|
|
|
|
|
if (*ok)
|
|
|
|
|
{
|
|
|
|
|
while (*hex == L' ' || *hex == L'\t')
|
|
|
|
|
hex++;
|
|
|
|
|
*ok = *hex == 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
void set_sane_config(known_file_util::IJsonW* sane, known_file_util::IJsonW* cfg, std::wstring& val)
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* type = NULL;
|
|
|
|
|
|
|
|
|
|
if (sane->get_value(L"type", &type) && type)
|
|
|
|
|
{
|
|
|
|
|
if (wcscmp(type, L"bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
cfg->set_value(sane->key(), val == L"true");
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(type, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
cfg->set_value(sane->key(), _wtoi(val.c_str()));
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(type, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
cfg->set_value(sane->key(), _wtof(val.c_str()));
|
|
|
|
|
}
|
|
|
|
|
else // string
|
|
|
|
|
{
|
|
|
|
|
cfg->set_value(sane->key(), val.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void get_sane_config(std::wstring& cfg)
|
|
|
|
|
{
|
|
|
|
|
coding_util::utf8_2_unicode((jsontext1 + jsontext2).c_str(), got_wstr, &cfg);
|
|
|
|
|
}
|
|
|
|
|
void on_combo_param_changed(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id, bool lst_trigger)
|
|
|
|
|
{
|
|
|
|
|
int ind = param_ctrl->GetCurSel(), item = -1;
|
|
|
|
|
DWORD_PTR data = param_ctrl->GetItemData(ind);
|
|
|
|
|
|
|
|
|
|
ShowWindow(GetDlgItem(dlg, edit_id), SW_HIDE);
|
|
|
|
|
val_ctrl->ShowWindow(SW_HIDE);
|
|
|
|
|
// if(!lst_param_trigger_sel_chg_)
|
|
|
|
|
{
|
|
|
|
|
wchar_t text[128] = { 0 };
|
|
|
|
|
::GetWindowTextW(param_ctrl->m_hWnd, text, _countof(text) - 1);
|
|
|
|
|
|
|
|
|
|
item = find_list_item(lst, text);
|
|
|
|
|
if (item != -1 && !lst_trigger)
|
|
|
|
|
select_list_item(lst, item);
|
|
|
|
|
}
|
|
|
|
|
if (data == PARAM_VID || data == PARAM_PID || data == PARAM_SPEED)
|
|
|
|
|
{
|
|
|
|
|
ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW);
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str());
|
|
|
|
|
}
|
|
|
|
|
SetFocus(GetDlgItem(dlg, edit_id));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data, * range = NULL;
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
|
|
|
|
|
jsn->get_value(L"range", &range);
|
|
|
|
|
if (range)
|
|
|
|
|
{
|
|
|
|
|
int l = 0;
|
|
|
|
|
double lf = .0f;
|
|
|
|
|
|
|
|
|
|
if (range->get_value(L"min", l) || range->get_value(L"min", lf))
|
|
|
|
|
{
|
|
|
|
|
ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW);
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str());
|
|
|
|
|
}
|
|
|
|
|
SetFocus(GetDlgItem(dlg, edit_id));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
val_ctrl->ShowWindow(SW_SHOW);
|
|
|
|
|
val_ctrl->ResetContent();
|
|
|
|
|
jsn->get_value(L"type", &val);
|
|
|
|
|
if (val)
|
|
|
|
|
{
|
|
|
|
|
if (wcscmp(val, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (range->members())
|
|
|
|
|
{
|
|
|
|
|
known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_INT);
|
|
|
|
|
val_ctrl->AddString(std::to_wstring(m.int_val).c_str());
|
|
|
|
|
for (int i = 1; i < range->members(); ++i)
|
|
|
|
|
{
|
|
|
|
|
m = range->next_member();
|
|
|
|
|
val_ctrl->AddString(std::to_wstring(m.int_val).c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(val, L"float") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (range->members())
|
|
|
|
|
{
|
|
|
|
|
known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_FLOAT);
|
|
|
|
|
val_ctrl->AddString(std::to_wstring(m.double_val).c_str());
|
|
|
|
|
for (int i = 1; i < range->members(); ++i)
|
|
|
|
|
{
|
|
|
|
|
m = range->next_member();
|
|
|
|
|
val_ctrl->AddString(std::to_wstring(m.double_val).c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // string
|
|
|
|
|
{
|
|
|
|
|
if (range->members())
|
|
|
|
|
{
|
|
|
|
|
known_file_util::JSONMEMW m = range->first_member(known_file_util::JV_STRING);
|
|
|
|
|
val_ctrl->AddString(m.str_val);
|
|
|
|
|
for (int i = 1; i < range->members(); ++i)
|
|
|
|
|
{
|
|
|
|
|
m = range->next_member();
|
|
|
|
|
val_ctrl->AddString(m.str_val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
std::wstring str(get_list_item_text(lst, item, 1));
|
|
|
|
|
item = val_ctrl->FindStringExact(-1, str.c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
item = 0;
|
|
|
|
|
val_ctrl->SetCurSel(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
range->release();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
jsn->get_value(L"type", &val);
|
|
|
|
|
if (val && wcscmp(val, L"bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
val_ctrl->ShowWindow(SW_SHOW);
|
|
|
|
|
val_ctrl->ResetContent();
|
|
|
|
|
val_ctrl->AddString(TEXT("true"));
|
|
|
|
|
val_ctrl->AddString(TEXT("false"));
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
std::wstring str(get_list_item_text(lst, item, 1));
|
|
|
|
|
item = val_ctrl->FindStringExact(-1, str.c_str());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
item = 0;
|
|
|
|
|
val_ctrl->SetCurSel(item);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowWindow(GetDlgItem(dlg, edit_id), SW_SHOW);
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
::SetDlgItemTextW(dlg, edit_id, get_list_item_text(lst, item, 1).c_str());
|
|
|
|
|
}
|
|
|
|
|
SetFocus(GetDlgItem(dlg, edit_id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int add_param(HWND dlg, CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id)
|
|
|
|
|
{
|
|
|
|
|
wchar_t val[128] = { 0 };
|
|
|
|
|
int ind = -1;
|
|
|
|
|
DWORD_PTR data = param_ctrl->GetItemData(param_ctrl->GetCurSel());
|
|
|
|
|
bool added = false;
|
|
|
|
|
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data, * child = NULL;
|
|
|
|
|
const wchar_t* type = NULL;
|
|
|
|
|
|
|
|
|
|
::GetWindowTextW(param_ctrl->m_hWnd, val, _countof(val) - 1);
|
|
|
|
|
ind = find_list_item(lst, val);
|
|
|
|
|
if (ind == -1)
|
|
|
|
|
{
|
|
|
|
|
ind = lst->InsertItem(lst->GetItemCount(), val);
|
|
|
|
|
added = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (val_ctrl->IsWindowVisible())
|
|
|
|
|
{
|
|
|
|
|
::GetWindowTextW(val_ctrl->m_hWnd, val, _countof(val) - 1);
|
|
|
|
|
jsn->get_value(L"type", &type);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
::GetDlgItemTextW(dlg, edit_id, val, _countof(val) - 1);
|
|
|
|
|
if (data == PARAM_VID || data == PARAM_PID)
|
|
|
|
|
{
|
|
|
|
|
bool ok = false;
|
|
|
|
|
wchar_t* ptr = val;
|
|
|
|
|
int id = vid_pid_from_hex(ptr, &ok);
|
|
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
|
|
|
|
::MessageBoxW(dlg, L"\uFF36\uFF29\uFF24\u2014\uFF30\uFF29\uFF24\u5FC5\u987B\u4E3A\uFF14\u4F4D\uFF11\uFF16\u8FDB\u5236\u6570\u636E\uFF01", L"Error", MB_OK | MB_ICONSTOP);
|
|
|
|
|
if (added)
|
|
|
|
|
lst->DeleteItem(ind);
|
|
|
|
|
SetFocus(GetDlgItem(dlg, edit_id));
|
|
|
|
|
return - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (data == PARAM_SPEED)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else// if (data != PARAM_VID && data != PARAM_PID && data != PARAM_SPEED)
|
|
|
|
|
{
|
|
|
|
|
jsn->get_value(L"type", &type);
|
|
|
|
|
if (jsn->get_value(L"range", &child))
|
|
|
|
|
{
|
|
|
|
|
double l = .0f, u = .0f;
|
|
|
|
|
|
|
|
|
|
if (wcscmp(type, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
int nl = 0, nu = 0;
|
|
|
|
|
child->get_value(L"min", nl);
|
|
|
|
|
child->get_value(L"max", nu);
|
|
|
|
|
l = nl;
|
|
|
|
|
u = nu;
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(type, L"float") == 0)
|
|
|
|
|
{
|
|
|
|
|
child->get_value(L"min", l);
|
|
|
|
|
child->get_value(L"max", u);
|
|
|
|
|
}
|
|
|
|
|
if (_wtof(val) < l || _wtof(val) > u)
|
|
|
|
|
{
|
|
|
|
|
if (wcscmp(type, L"int") == 0)
|
|
|
|
|
swprintf_s(val, _countof(val) - 1, L"\u6570\u503C\u5FC5\u987B\u5728\uFF3B%d, %d\uFF3D\u4E4B\u95F4\uFF01", (int)l, (int)u);
|
|
|
|
|
else
|
|
|
|
|
swprintf_s(val, _countof(val) - 1, L"\u6570\u503C\u5FC5\u987B\u5728\uFF3B%f, %f\uFF3D\u4E4B\u95F4\uFF01", l, u);
|
|
|
|
|
::MessageBoxW(dlg, val, L"Error", MB_OK | MB_ICONWARNING);
|
|
|
|
|
SetFocus(GetDlgItem(dlg, edit_id));
|
|
|
|
|
if (added)
|
|
|
|
|
lst->DeleteItem(ind);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (wcscmp(type, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
swprintf_s(val, _countof(val) - 1, L"%d", (int)(_wtof(val) + .5f));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
lst->SetItemText(ind, 1, val);
|
|
|
|
|
lst->SetItemData(ind, data);
|
|
|
|
|
|
|
|
|
|
return ind;
|
|
|
|
|
}
|
|
|
|
|
static int find_template(CComboBox* cb, const wchar_t* name, known_file_util::IJsonW** json = NULL)
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cb->GetCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)cb->GetItemData(i);
|
|
|
|
|
jsn->get_value(L"name", &val);
|
|
|
|
|
if (wcscmp(name, val) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (json)
|
|
|
|
|
*json = jsn;
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 07:31:09 +00:00
|
|
|
|
std::wstring CDlgMgr::export_config(bool *ok, bool used_in_code, int code_ver)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW * jsn = known_file_util::create_jsonW(),
|
2023-01-04 10:23:36 +00:00
|
|
|
|
* child = NULL;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
wchar_t text[256] = { 0 };
|
2022-12-09 07:37:18 +00:00
|
|
|
|
bool result = false;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
2022-12-09 07:37:18 +00:00
|
|
|
|
if (!ok)
|
|
|
|
|
ok = &result;
|
|
|
|
|
|
|
|
|
|
*ok = false;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
if (!used_in_code)
|
|
|
|
|
{
|
|
|
|
|
WORD vid_f = vid_pid_edit_value(GetDlgItem(IDC_EDIT_VID_SRC)->m_hWnd),
|
|
|
|
|
pid_f = vid_pid_edit_value(GetDlgItem(IDC_EDIT_PID_SRC)->m_hWnd),
|
2023-01-04 10:23:36 +00:00
|
|
|
|
vid_t = 0,
|
|
|
|
|
pid_t = 0,
|
|
|
|
|
sleep = 0, // GetDlgItemInt(IDC_EDIT_SLEEP),
|
|
|
|
|
speed = 0, // GetDlgItemInt(IDC_EDIT_SPEED),
|
2022-12-09 07:31:09 +00:00
|
|
|
|
port = 0;
|
2023-01-04 10:23:36 +00:00
|
|
|
|
bool report = is_checked(GetDlgItem(IDC_CHECK2)), has_vid = false, has_pid = false, has_speed = false;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
BYTE ip1 = 0, ip2 = 0, ip3 = 0, ip4 = 0;
|
|
|
|
|
|
|
|
|
|
if (!vid_f)
|
|
|
|
|
{
|
|
|
|
|
GotoDlgCtrl(GetDlgItem(IDC_EDIT_VID_SRC));
|
2022-12-09 07:37:18 +00:00
|
|
|
|
jsn->release();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
2022-12-09 08:56:15 +00:00
|
|
|
|
return L"\u8BF7\u91CD\u65B0\u8F93\u5165 \u6E90\uFF36\uFF29\uFF24\uFF01";
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
if (!pid_f)
|
|
|
|
|
{
|
|
|
|
|
GotoDlgCtrl(GetDlgItem(IDC_EDIT_PID_SRC));
|
2022-12-09 07:37:18 +00:00
|
|
|
|
jsn->release();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
2022-12-09 08:56:15 +00:00
|
|
|
|
return L"\u8BF7\u91CD\u65B0\u8F93\u5165 \u6E90\uFF30\uFF29\uFF24\uFF01";
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
child = known_file_util::create_jsonW();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
if (report)
|
|
|
|
|
{
|
|
|
|
|
ip_.GetAddress(ip1, ip2, ip3, ip4);
|
|
|
|
|
port = GetDlgItemInt(IDC_EDIT_PORT);
|
|
|
|
|
::GetDlgItemTextW(m_hWnd, IDC_EDIT_DB, text, _countof(text) - 1);
|
|
|
|
|
std::wstring url(text);
|
|
|
|
|
|
|
|
|
|
swprintf_s(text, _countof(text) - 1, L"%u:", port);
|
|
|
|
|
url.insert(0, text);
|
|
|
|
|
swprintf_s(text, _countof(text) - 1, L"%u.%u.%u.%u:", ip1, ip2, ip3, ip4);
|
|
|
|
|
url.insert(0, text);
|
|
|
|
|
child->set_value(L"report-url", url.c_str());
|
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
|
|
|
|
|
child->set_value(L"vid-org", vid_f);
|
|
|
|
|
child->set_value(L"pid-org", pid_f);
|
|
|
|
|
::GetDlgItemTextW(m_hWnd, IDC_COMBO_DEVICE, text, _countof(text) - 1);
|
|
|
|
|
child->set_value(L"type", text);
|
|
|
|
|
|
|
|
|
|
known_file_util::IJsonW* write = known_file_util::create_jsonW();
|
|
|
|
|
for(int i = 0; i< lst_write_down_.GetItemCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
DWORD_PTR data = lst_write_down_.GetItemData(i);
|
|
|
|
|
std::wstring text(get_list_item_text(&lst_write_down_, i, 1));
|
|
|
|
|
bool hex = true;
|
|
|
|
|
|
|
|
|
|
if (data == PARAM_VID)
|
|
|
|
|
{
|
|
|
|
|
has_vid = true;
|
|
|
|
|
vid_t = vid_pid_from_hex(text.c_str(), &hex);
|
|
|
|
|
if (!hex)
|
|
|
|
|
{
|
|
|
|
|
select_list_item(&lst_write_down_, i);
|
|
|
|
|
::MessageBoxW(m_hWnd, L"目标VID输入非法,请更正!", L"Error", MB_OK | MB_ICONSTOP);
|
|
|
|
|
vid_t = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
write->set_value(L"vid-to", vid_t);
|
|
|
|
|
}
|
|
|
|
|
else if (data == PARAM_PID)
|
|
|
|
|
{
|
|
|
|
|
has_pid = true;
|
|
|
|
|
pid_t = vid_pid_from_hex(text.c_str(), &hex);
|
|
|
|
|
if (!hex)
|
|
|
|
|
{
|
|
|
|
|
select_list_item(&lst_write_down_, i);
|
|
|
|
|
::MessageBoxW(m_hWnd, L"目标PID输入非法,请更正!", L"Error", MB_OK | MB_ICONSTOP);
|
|
|
|
|
pid_t = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
write->set_value(L"pid-to", pid_t);
|
|
|
|
|
}
|
|
|
|
|
else if (data == PARAM_SPEED)
|
|
|
|
|
{
|
|
|
|
|
has_speed = true;
|
|
|
|
|
speed = _wtoi(text.c_str());
|
|
|
|
|
write->set_value(L"speed-mode", speed);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
set_sane_config((known_file_util::IJsonW*)data, write, text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
child->set_value(L"write-down", write);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
jsn->set_value(L"global", child);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
write->release();
|
|
|
|
|
child->release();
|
|
|
|
|
if (!has_vid)
|
|
|
|
|
{
|
|
|
|
|
int ind = 0;
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_VID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
}
|
|
|
|
|
jsn->release();
|
|
|
|
|
return L"没有输入目标VID!";
|
|
|
|
|
}
|
|
|
|
|
if (!has_pid)
|
|
|
|
|
{
|
|
|
|
|
int ind = 0;
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_PID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
}
|
|
|
|
|
jsn->release();
|
|
|
|
|
return L"没有输入目标PID!";
|
|
|
|
|
}
|
|
|
|
|
if (!has_speed)
|
|
|
|
|
{
|
|
|
|
|
if (::MessageBoxW(m_hWnd, L"没有写入速度模式参数,是否返回设置?", L"缺少速度模式", MB_YESNO | MB_ICONQUESTION) == IDYES)
|
|
|
|
|
{
|
|
|
|
|
int ind = 0;
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
jsn->release();
|
|
|
|
|
return L"没有写入速度模式参数";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (vid_t == 0 || pid_t == 0)
|
|
|
|
|
{
|
|
|
|
|
jsn->release();
|
|
|
|
|
return L"";
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
2022-12-09 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
if (list_.GetItemCount() == 0)
|
|
|
|
|
{
|
|
|
|
|
jsn->release();
|
2022-12-09 08:56:15 +00:00
|
|
|
|
return L"\u6CA1\u6709\u8F93\u5165\u6709\u6548\u7684\u6D4B\u8BD5\u9879\u76EE\uFF01";
|
2022-12-09 07:37:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 07:31:09 +00:00
|
|
|
|
for (size_t i = 0; i < list_.GetItemCount(); ++i)
|
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* item = (known_file_util::IJsonW*)list_.GetItemData(i);
|
|
|
|
|
if (used_in_code)
|
2022-12-09 09:27:16 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* c = known_file_util::create_jsonW();
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
|
|
|
|
|
item->get_value(L"name", &val);
|
|
|
|
|
c->set_value(L"name", val);
|
|
|
|
|
c->set_value(L"ver", code_ver);
|
|
|
|
|
jsn->set_value(std::to_wstring(i + 1).c_str(), c);
|
|
|
|
|
c->release();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
jsn->set_value(std::to_wstring(i + 1).c_str(), item);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::wstring ret(L"");
|
|
|
|
|
|
|
|
|
|
jsn->to_string(got_wstr, &ret);
|
|
|
|
|
jsn->release();
|
|
|
|
|
if (used_in_code)
|
|
|
|
|
{
|
|
|
|
|
size_t pos = ret.find(L"\"");
|
|
|
|
|
|
|
|
|
|
while (pos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
ret.insert(pos, L"\\");
|
|
|
|
|
pos = ret.find(L"\"", pos + 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos = ret.find(L"\\u");
|
|
|
|
|
while (pos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
ret.insert(pos, L"\\");
|
|
|
|
|
pos = ret.find(L"\\u", pos + 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// divide into multi-lines with 16KB per line ...
|
|
|
|
|
int lines = 1;
|
|
|
|
|
wchar_t var[80] = { 0 };
|
|
|
|
|
|
|
|
|
|
pos = ret.length();
|
|
|
|
|
while (pos > 16 * 1024)
|
|
|
|
|
{
|
|
|
|
|
pos -= 12 * 1024;
|
|
|
|
|
while (ret[pos - 1] == L'\\')
|
|
|
|
|
pos++;
|
|
|
|
|
lines++;
|
2022-12-09 08:56:15 +00:00
|
|
|
|
swprintf_s(var, _countof(var) - 1, L"\");\r\nstatic std::wstring jsontext%d(L\"", lines);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
ret.insert(pos, var);
|
|
|
|
|
}
|
|
|
|
|
ret.insert(0, L"static std::string jsontext1(\"");
|
|
|
|
|
ret += L"\");\r\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*ok = true;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-09 08:56:15 +00:00
|
|
|
|
static void trans_code_json(std::wstring& json)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-05 01:52:48 +00:00
|
|
|
|
size_t pos = json.find(L"(\"");
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
2022-12-09 08:56:15 +00:00
|
|
|
|
if (pos == std::wstring::npos)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-01-05 01:52:48 +00:00
|
|
|
|
json.erase(0, pos + 2);
|
2022-12-09 08:56:15 +00:00
|
|
|
|
pos = json.rfind(L'\"');
|
|
|
|
|
if (pos != std::wstring::npos)
|
|
|
|
|
json.erase(pos);
|
|
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
|
while ((pos = json.find(L"\\\""), pos) != std::wstring::npos)
|
|
|
|
|
{
|
|
|
|
|
json.erase(pos++, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
|
while ((pos = json.find(L"\\"), pos) != std::wstring::npos)
|
|
|
|
|
{
|
|
|
|
|
json.erase(pos++, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
void CDlgMgr::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))
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* type = NULL, * val = NULL;
|
|
|
|
|
int ind = 0;
|
|
|
|
|
|
|
|
|
|
sane->get_value(L"type", &type);
|
|
|
|
|
FIND_DATA(*param_ctrl, GetCount, sane, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
param_ctrl->SetCurSel(ind);
|
|
|
|
|
(this->*cb_change)();
|
|
|
|
|
if (wcscmp(type, L"bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
bool bv = false;
|
|
|
|
|
cfg->get_value(key, bv);
|
|
|
|
|
ind = val_ctrl->FindStringExact(-1, bv ? L"true" : L"false");
|
|
|
|
|
val_ctrl->SetCurSel(ind);
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(type, L"int") == 0)
|
|
|
|
|
{
|
|
|
|
|
cfg->get_value(key, ind);
|
|
|
|
|
SetDlgItemInt(edit_id, ind);
|
|
|
|
|
ind = val_ctrl->FindStringExact(-1, std::to_wstring(ind).c_str());
|
|
|
|
|
val_ctrl->SetCurSel(ind);
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(type, L"float") == 0)
|
|
|
|
|
{
|
|
|
|
|
double dv = .0f;
|
|
|
|
|
cfg->get_value(key, dv);
|
|
|
|
|
SetDlgItemTextW(edit_id, std::to_wstring(dv).c_str());
|
|
|
|
|
ind = val_ctrl->FindStringExact(-1, std::to_wstring(dv).c_str());
|
|
|
|
|
val_ctrl->SetCurSel(ind);
|
|
|
|
|
}
|
|
|
|
|
else // string
|
|
|
|
|
{
|
|
|
|
|
cfg->get_value(key, &val);
|
|
|
|
|
SetDlgItemTextW(edit_id, val);
|
|
|
|
|
ind = val_ctrl->FindStringExact(-1, val);
|
|
|
|
|
val_ctrl->SetCurSel(ind);
|
|
|
|
|
}
|
|
|
|
|
(this->*add_func)();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 08:56:15 +00:00
|
|
|
|
void CDlgMgr::reload(std::wstring& cont)
|
|
|
|
|
{
|
2023-01-05 01:52:48 +00:00
|
|
|
|
bool code_jsn = false;
|
|
|
|
|
|
|
|
|
|
if (cont.find(L"static std::string") == 0)
|
|
|
|
|
{
|
2022-12-09 08:56:15 +00:00
|
|
|
|
trans_code_json(cont);
|
2023-01-05 01:52:48 +00:00
|
|
|
|
code_jsn = true;
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
known_file_util::IJsonW* jsn = known_file_util::create_jsonW();
|
|
|
|
|
if (jsn->attach(cont.c_str()))
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* child = NULL;
|
|
|
|
|
const wchar_t* val = NULL;
|
2023-01-04 10:23:36 +00:00
|
|
|
|
int ind = 0, id = 0;
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
jsn->get_value(L"global", &child);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
lst_write_down_.DeleteAllItems();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
if (child)
|
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
if (child->get_value(L"type", &val) && val)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
ind = combo_.FindStringExact(-1, val);
|
|
|
|
|
if (ind == -1)
|
|
|
|
|
ind = combo_.AddString(val);
|
|
|
|
|
combo_.SetCurSel(ind);
|
|
|
|
|
}
|
|
|
|
|
if (child->get_value(L"vid-org", ind))
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_VID_SRC, ind);
|
|
|
|
|
if (child->get_value(L"pid-org", ind))
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PID_SRC, ind);
|
|
|
|
|
|
|
|
|
|
known_file_util::IJsonW* write = NULL;
|
|
|
|
|
child->get_value(L"write-down", &write);
|
|
|
|
|
if (write)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* wc = write->first_child();
|
|
|
|
|
while (wc)
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
if (wcscmp(wc->key(), L"vid-to") == 0)
|
|
|
|
|
{
|
|
|
|
|
write->get_value(wc->key(), id);
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_VID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PARAM_VAL, id);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(wc->key(), L"pid-to") == 0)
|
|
|
|
|
{
|
|
|
|
|
write->get_value(wc->key(), id);
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_PID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PARAM_VAL, id);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(wc->key(), L"speed-mode") == 0)
|
|
|
|
|
{
|
|
|
|
|
write->get_value(wc->key(), id);
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PARAM_VAL, id);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* sane = NULL;
|
|
|
|
|
sane_cfg_->get_value(wc->key(), &sane);
|
|
|
|
|
if (sane)
|
|
|
|
|
{
|
|
|
|
|
add_param_from_config(&combo_param_, &combo_param_val_, IDC_EDIT_PARAM_VAL, sane, write, wc->key(), &CDlgMgr::OnCbnSelchangeComboParam, &CDlgMgr::OnBnClickedButtonAddParam);
|
|
|
|
|
sane->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
write->release();
|
2022-12-09 07:31:09 +00:00
|
|
|
|
}
|
2023-01-05 01:52:48 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int nv = 0;
|
|
|
|
|
if (child->get_value(L"vid-to", nv))
|
|
|
|
|
{
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_VID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
wchar_t hex[40] = { 0 };
|
|
|
|
|
|
|
|
|
|
swprintf_s(hex, _countof(hex) - 1, L"%04x", nv);
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (child->get_value(L"pid-to", nv))
|
|
|
|
|
{
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_PID, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
wchar_t hex[40] = { 0 };
|
|
|
|
|
|
|
|
|
|
swprintf_s(hex, _countof(hex) - 1, L"%04x", nv);
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
::SetDlgItemTextW(m_hWnd, IDC_EDIT_PARAM_VAL, hex);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (child->get_value(L"speed-mode", nv))
|
|
|
|
|
{
|
|
|
|
|
FIND_DATA(combo_param_, GetCount, PARAM_SPEED, ind);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
SetDlgItemInt(IDC_EDIT_PARAM_VAL, nv);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (child->get_value(L"sleep-time", nv))
|
|
|
|
|
{
|
|
|
|
|
ind = -1;
|
|
|
|
|
for (int i = 0; i < combo_param_.GetCount(); ++i)
|
|
|
|
|
{
|
|
|
|
|
DWORD_PTR data = combo_param_.GetItemData(i);
|
|
|
|
|
if (data != PARAM_VID && data != PARAM_PID && data != PARAM_SPEED)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* jsn = (known_file_util::IJsonW*)data;
|
|
|
|
|
if (wcscmp(jsn->key(), L"time-to-sleep") == 0)
|
|
|
|
|
{
|
|
|
|
|
ind = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
combo_param_.SetCurSel(ind);
|
|
|
|
|
OnCbnSelchangeComboParam();
|
|
|
|
|
ind = combo_param_val_.FindStringExact(-1, L"\u4E94\u5206\u949F");
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
combo_param_val_.SetCurSel(ind);
|
|
|
|
|
OnBnClickedButtonAddParam();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
child->release();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-04 10:23:36 +00:00
|
|
|
|
OnListClear();
|
|
|
|
|
ind = 1;
|
|
|
|
|
while (jsn->get_value(std::to_wstring(ind++).c_str(), &child))
|
2022-12-09 07:31:09 +00:00
|
|
|
|
{
|
2023-01-04 10:23:36 +00:00
|
|
|
|
known_file_util::IJsonW* tpl = NULL;
|
|
|
|
|
child->get_value(L"name", &val);
|
2023-01-05 01:52:48 +00:00
|
|
|
|
if (child->get_value(L"ver", id))
|
|
|
|
|
::PostMessage(GetParent()->m_hWnd, WM_SET_CODE_VER, 0, (LPARAM)id);
|
|
|
|
|
id = find_template(&combo_, val, &tpl);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
if (tpl)
|
2022-12-09 08:56:15 +00:00
|
|
|
|
{
|
2023-01-05 01:52:48 +00:00
|
|
|
|
combo_.SetCurSel(id);
|
2023-01-04 10:23:36 +00:00
|
|
|
|
OnBnClickedButtonAdd();
|
|
|
|
|
FIND_DATA(list_, GetItemCount, tpl, id);
|
|
|
|
|
if (id != -1)
|
|
|
|
|
{
|
|
|
|
|
bool bv = false;
|
|
|
|
|
int nv = 0;
|
|
|
|
|
if (child->get_value(L"station", &val))
|
|
|
|
|
list_.SetItemText(id, 2, val);
|
|
|
|
|
if (child->get_value(L"authority", nv))
|
|
|
|
|
list_.SetItemText(id, 3, std::to_wstring(nv).c_str());
|
|
|
|
|
if (child->get_value(L"man", bv))
|
|
|
|
|
list_.SetItemText(id, 4, bv ? L"false" : L"true");
|
|
|
|
|
if (child->get_value(L"err-level", &val))
|
|
|
|
|
list_.SetItemText(id, 5, wcscmp(val, L"fatal") ? L"false" : L"true");
|
|
|
|
|
|
|
|
|
|
known_file_util::IJsonW* param = NULL;
|
|
|
|
|
child->get_value(L"param", ¶m);
|
|
|
|
|
if (param)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* c = param->first_child();
|
|
|
|
|
OnBnClickedButtonAddParam3();
|
|
|
|
|
while (c)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* s = NULL;
|
|
|
|
|
sane_cfg_->get_value(c->key(), &s);
|
|
|
|
|
if (s)
|
|
|
|
|
{
|
|
|
|
|
add_param_from_config(&combo_param2_, &combo_param_val2_, IDC_EDIT_PARAM_VAL2, s, param, c->key(), &CDlgMgr::OnCbnSelchangeComboParam2, &CDlgMgr::OnBnClickedButtonAddParam2);
|
|
|
|
|
s->release();
|
|
|
|
|
}
|
|
|
|
|
c->release();
|
|
|
|
|
c = param->next_child();
|
|
|
|
|
}
|
|
|
|
|
param->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 08:56:15 +00:00
|
|
|
|
}
|
2022-12-09 07:31:09 +00:00
|
|
|
|
child->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jsn->release();
|
2022-12-09 08:56:15 +00:00
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
bool CDlgMgr::load_sane_config(std::wstring& jsn_txt)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(jsn_txt.c_str());
|
|
|
|
|
|
|
|
|
|
if (jsn)
|
|
|
|
|
{
|
|
|
|
|
int ind = 0;
|
|
|
|
|
|
|
|
|
|
sane_cfg_->release();
|
|
|
|
|
sane_cfg_ = jsn;
|
|
|
|
|
combo_param_.ResetContent();
|
|
|
|
|
ind = combo_param_.AddString(L"\u76EE\u6807\uFF36\uFF29\uFF24");
|
|
|
|
|
combo_param_.SetItemData(ind, PARAM_VID);
|
|
|
|
|
ind = combo_param_.AddString(L"\u76EE\u6807\uFF30\uFF29\uFF24");
|
|
|
|
|
combo_param_.SetItemData(ind, PARAM_PID);
|
|
|
|
|
ind = combo_param_.AddString(L"\u901F\u5EA6\u6A21\u5F0F");
|
|
|
|
|
combo_param_.SetItemData(ind, PARAM_SPEED);
|
|
|
|
|
|
|
|
|
|
combo_param2_.ResetContent();
|
|
|
|
|
|
|
|
|
|
jsn = sane_cfg_->first_child();
|
|
|
|
|
if (jsn)
|
|
|
|
|
{
|
|
|
|
|
jsn->release();
|
|
|
|
|
while ((jsn = sane_cfg_->next_child()))
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
if (jsn->get_value(L"type", &val))
|
|
|
|
|
{
|
|
|
|
|
if (wcscmp(val, L"button") && wcscmp(val, L"group"))
|
|
|
|
|
{
|
|
|
|
|
if (jsn->get_value(L"title", &val))
|
|
|
|
|
{
|
|
|
|
|
while (*val == L' ')
|
|
|
|
|
val++;
|
|
|
|
|
if (wcscmp(jsn->key(), L"time-to-sleep") == 0)
|
|
|
|
|
{
|
|
|
|
|
ind = combo_param_.AddString(val);
|
|
|
|
|
combo_param_.SetItemData(ind, (DWORD_PTR)jsn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ind = combo_param2_.AddString(val);
|
|
|
|
|
combo_param2_.SetItemData(ind, (DWORD_PTR)jsn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jsn->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-09 08:56:15 +00:00
|
|
|
|
void CDlgMgr::OnDropFiles(HDROP hDropInfo)
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
|
|
wchar_t path[MAX_PATH] = { 0 };
|
|
|
|
|
std::wstring cont(L"");
|
|
|
|
|
std::string bom("");
|
|
|
|
|
|
|
|
|
|
DragQueryFileW(hDropInfo, 0, path, _countof(path) - 1);
|
|
|
|
|
file_util::load_file(path, got_str, &bom);
|
|
|
|
|
coding_util::bom::to_unicode(bom.c_str(), bom.length(), got_wstr, &cont);
|
|
|
|
|
|
|
|
|
|
reload(cont);
|
2022-12-09 07:31:09 +00:00
|
|
|
|
|
|
|
|
|
__super::OnDropFiles(hDropInfo);
|
|
|
|
|
}
|
2022-12-09 08:56:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//UINT CDlgMgr::OnGetDlgCode()
|
|
|
|
|
//{
|
|
|
|
|
// // TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
|
|
|
//
|
|
|
|
|
// return __super::OnGetDlgCode();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnListPasteClipboard()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加命令处理程序代码
|
|
|
|
|
wchar_t* buf = NULL;
|
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
|
|
if (file_util::get_clipboard(buf, &len, CF_UNICODETEXT) == ERROR_INSUFFICIENT_BUFFER)
|
|
|
|
|
{
|
|
|
|
|
buf = new wchar_t[len + 8];
|
|
|
|
|
memset(buf, 0, (len + 8) * 2);
|
|
|
|
|
len++;
|
|
|
|
|
if (file_util::get_clipboard(buf, &len, CF_UNICODETEXT) == ERROR_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
std::wstring cont(buf);
|
|
|
|
|
reload(cont);
|
|
|
|
|
}
|
|
|
|
|
delete[] buf;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnNMRClickList1(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
POINT pt = { 0 };
|
|
|
|
|
CMenu menu;
|
|
|
|
|
|
|
|
|
|
menu.LoadMenuW(MAKEINTRESOURCE(IDR_MENU1));
|
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
|
menu.GetSubMenu(0)->TrackPopupMenu(0, pt.x, pt.y, this);
|
|
|
|
|
}
|
2022-12-09 09:43:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnListClear()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加命令处理程序代码
|
2023-01-04 10:23:36 +00:00
|
|
|
|
for (int i = 0; i < list_.GetItemCount(); ++i)
|
|
|
|
|
((known_file_util::IJsonW*)list_.GetItemData(i))->release();
|
2022-12-09 09:43:55 +00:00
|
|
|
|
list_.DeleteAllItems();
|
|
|
|
|
}
|
2023-01-04 10:23:36 +00:00
|
|
|
|
|
|
|
|
|
void CDlgMgr::add_param(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id)
|
|
|
|
|
{
|
|
|
|
|
int item = ::add_param(m_hWnd, param_ctrl, val_ctrl, lst, edit_id);
|
|
|
|
|
|
|
|
|
|
if (param_ctrl == &combo_param2_)
|
|
|
|
|
{
|
|
|
|
|
int ind = get_list_selected_item(&list_);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* cfg = (known_file_util::IJsonW*)list_.GetItemData(ind), * param = NULL,
|
|
|
|
|
* sane = (known_file_util::IJsonW*)lst_param_.GetItemData(item);
|
|
|
|
|
std::wstring str(get_list_item_text(&lst_param_, item, 1));
|
|
|
|
|
const wchar_t* sv = NULL;
|
|
|
|
|
|
|
|
|
|
if (!cfg->get_value(L"param", ¶m))
|
|
|
|
|
{
|
|
|
|
|
param = known_file_util::create_jsonW();
|
|
|
|
|
cfg->set_value(L"param", param);
|
|
|
|
|
}
|
|
|
|
|
sane->get_value(L"type", &sv);
|
|
|
|
|
if (wcscmp(sv, L"bool") == 0)
|
|
|
|
|
{
|
|
|
|
|
param->set_value(sane->key(), str == L"true");
|
|
|
|
|
}
|
|
|
|
|
else if (wcscmp(sv, L"int") == 0)
|
|
|
|
|
param->set_value(sane->key(), _wtoi(str.c_str()));
|
|
|
|
|
else if (wcscmp(sv, L"float") == 0)
|
|
|
|
|
param->set_value(sane->key(), _wtof(str.c_str()));
|
|
|
|
|
else
|
|
|
|
|
param->set_value(sane->key(), str.c_str());
|
|
|
|
|
param->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonAddParam()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
add_param(&combo_param_, &combo_param_val_, &lst_write_down_, IDC_EDIT_PARAM_VAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonClearAll()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
OnListClear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::on_combo_param_changed(CComboBox* param_ctrl, CComboBox* val_ctrl, CListCtrl* lst, UINT edit_id)
|
|
|
|
|
{
|
|
|
|
|
::on_combo_param_changed(m_hWnd, param_ctrl, val_ctrl, lst, edit_id, lst_param_trigger_sel_chg_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnCbnSelchangeComboParam()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
on_combo_param_changed(&combo_param_, &combo_param_val_, &lst_write_down_, IDC_EDIT_PARAM_VAL);
|
|
|
|
|
}
|
|
|
|
|
void on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(*cb_change_notify)(void*), void* param)
|
|
|
|
|
{
|
|
|
|
|
if (item != -1)
|
|
|
|
|
{
|
|
|
|
|
std::wstring str(get_list_item_text(lst, item, 0));
|
|
|
|
|
int ind = param_ctrl->FindStringExact(-1, str.c_str());
|
|
|
|
|
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
param_ctrl->SetCurSel(ind);
|
|
|
|
|
cb_change_notify(param);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::wstring get_window_text(HWND wnd)
|
|
|
|
|
{
|
|
|
|
|
int l = GetWindowTextLength(wnd);
|
|
|
|
|
wchar_t* buf = new wchar_t[l + 8];
|
|
|
|
|
|
|
|
|
|
l = GetWindowTextW(wnd, buf, l + 4);
|
|
|
|
|
buf[l] = 0;
|
|
|
|
|
|
|
|
|
|
std::wstring ret(buf);
|
|
|
|
|
|
|
|
|
|
delete[] buf;
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
void replace(std::wstring& str, const wchar_t* now, const wchar_t* to_be)
|
|
|
|
|
{
|
|
|
|
|
size_t pos = str.find(now);
|
|
|
|
|
int l0 = lstrlenW(now), l1 = lstrlenW(to_be);
|
|
|
|
|
|
|
|
|
|
while (pos != std::wstring::npos)
|
|
|
|
|
{
|
|
|
|
|
str.replace(pos, l0, to_be);
|
|
|
|
|
pos += l1;
|
|
|
|
|
pos = str.find(now, pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void CDlgMgr::notify_combo_param_changed(void* param)
|
|
|
|
|
{
|
|
|
|
|
struct _cb_chg
|
|
|
|
|
{
|
|
|
|
|
CDlgMgr* dlg;
|
|
|
|
|
void(CDlgMgr::* cb_sel_change)(void);
|
|
|
|
|
};
|
|
|
|
|
struct _cb_chg* chg = (struct _cb_chg*)param;
|
|
|
|
|
|
|
|
|
|
chg->dlg->lst_param_trigger_sel_chg_ = true;
|
|
|
|
|
(chg->dlg->*chg->cb_sel_change)();
|
|
|
|
|
chg->dlg->lst_param_trigger_sel_chg_ = false;
|
|
|
|
|
}
|
|
|
|
|
void CDlgMgr::on_list_param_sel_changed(CComboBox* param_ctrl, CListCtrl* lst, int item, void(CDlgMgr::* cb_sel_change)(void))
|
|
|
|
|
{
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
CDlgMgr* dlg;
|
|
|
|
|
void(CDlgMgr::* cb_sel_change)(void);
|
|
|
|
|
}param = { this, cb_sel_change };
|
|
|
|
|
::on_list_param_sel_changed(param_ctrl, lst, item, &CDlgMgr::notify_combo_param_changed, ¶m);
|
|
|
|
|
}
|
|
|
|
|
void CDlgMgr::OnLvnItemchangedListParam(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
|
|
|
|
|
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
on_list_param_sel_changed(&combo_param_, &lst_write_down_, pNMLV->iItem, &CDlgMgr::OnCbnSelchangeComboParam);
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
bool CDlgMgr::remove_prompt(CListCtrl* lst, int item, int sub, const wchar_t* title, DWORD_PTR* data)
|
|
|
|
|
{
|
|
|
|
|
std::wstring text(get_list_item_text(lst, item, sub));
|
|
|
|
|
|
|
|
|
|
if (::MessageBoxW(m_hWnd, text.c_str(), L"\u5220\u9664\u521D\u59CB\u5316\u53C2\u6570\uFF1F", MB_YESNO | MB_ICONQUESTION) == IDYES)
|
|
|
|
|
{
|
|
|
|
|
if (data)
|
|
|
|
|
*data = lst->GetItemData(item);
|
|
|
|
|
lst->DeleteItem(item);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
void CDlgMgr::OnNMDblclkListParam(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
if (pNMItemActivate->iItem != -1)
|
|
|
|
|
{
|
|
|
|
|
remove_prompt(&lst_write_down_, pNMItemActivate->iItem, 0, L"\u5220\u9664\u521D\u59CB\u5316\u53C2\u6570\uFF1F");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonAddParam2()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
add_param(&combo_param2_, &combo_param_val2_, &lst_param_, IDC_EDIT_PARAM_VAL2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnBnClickedButtonAddParam3()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
int ind = get_list_selected_item(&list_);
|
|
|
|
|
|
|
|
|
|
lst_param_.DeleteAllItems();
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(ind), * param = NULL;
|
|
|
|
|
if (json)
|
|
|
|
|
{
|
|
|
|
|
json->get_value(L"param", ¶m);
|
|
|
|
|
if (param)
|
|
|
|
|
{
|
|
|
|
|
param->clear();
|
|
|
|
|
param->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnCbnSelchangeComboParam2()
|
|
|
|
|
{
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
on_combo_param_changed(&combo_param2_, &combo_param_val2_, &lst_param_, IDC_EDIT_PARAM_VAL2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnNMClickListParamTest(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
on_list_param_sel_changed(&combo_param2_, &lst_param_, pNMItemActivate->iItem, &CDlgMgr::OnCbnSelchangeComboParam2);
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnNMDblclkListParamTest(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
if (pNMItemActivate->iItem != -1)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)lst_param_.GetItemData(pNMItemActivate->iItem);
|
|
|
|
|
if (remove_prompt(&lst_param_, pNMItemActivate->iItem, 0, L"\u5220\u9664\u6D4B\u8BD5\u53C2\u6570\uFF1F"))
|
|
|
|
|
{
|
|
|
|
|
int ind = get_list_selected_item(&list_);
|
|
|
|
|
if (ind != -1)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* cfg = (known_file_util::IJsonW*)list_.GetItemData(ind), * child = NULL;
|
|
|
|
|
if (cfg)
|
|
|
|
|
{
|
|
|
|
|
cfg->get_value(L"param", &child);
|
|
|
|
|
if (child)
|
|
|
|
|
{
|
|
|
|
|
child->remove_value(json->key());
|
|
|
|
|
child->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CDlgMgr::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
|
|
|
|
|
{
|
|
|
|
|
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
|
|
|
// TODO: 在此添加控件通知处理程序代码
|
|
|
|
|
if (pNMItemActivate->iItem != -1)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::IJsonW* json = (known_file_util::IJsonW*)list_.GetItemData(pNMItemActivate->iItem), * param = NULL, * child = NULL,
|
|
|
|
|
*sane = NULL;
|
|
|
|
|
int ind = -1;
|
|
|
|
|
|
|
|
|
|
lst_param_.DeleteAllItems();
|
|
|
|
|
json->get_value(L"param", ¶m);
|
|
|
|
|
if (param)
|
|
|
|
|
{
|
|
|
|
|
known_file_util::JSONMEMW jm = param->first_member();
|
|
|
|
|
while (jm.type != known_file_util::JV_UNKNOWN)
|
|
|
|
|
{
|
|
|
|
|
sane_cfg_->get_value(jm.key, &sane);
|
|
|
|
|
if (sane)
|
|
|
|
|
{
|
|
|
|
|
const wchar_t* val = NULL;
|
|
|
|
|
sane->get_value(L"title", &val);
|
|
|
|
|
sane->release();
|
|
|
|
|
ind = lst_param_.InsertItem(lst_param_.GetItemCount(), val);
|
|
|
|
|
if (jm.type == known_file_util::JV_BOOL)
|
|
|
|
|
lst_param_.SetItemText(ind, 1, jm.bool_val ? L"true" : L"false");
|
|
|
|
|
else if (jm.type == known_file_util::JV_INT)
|
|
|
|
|
lst_param_.SetItemText(ind, 1, std::to_wstring(jm.int_val).c_str());
|
|
|
|
|
else if (jm.type == known_file_util::JV_FLOAT)
|
|
|
|
|
lst_param_.SetItemText(ind, 1, std::to_wstring(jm.double_val).c_str());
|
|
|
|
|
else // string
|
|
|
|
|
lst_param_.SetItemText(ind, 1, jm.str_val);
|
|
|
|
|
}
|
|
|
|
|
jm = param->next_member();
|
|
|
|
|
}
|
|
|
|
|
param->release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GetDlgItem(IDC_BUTTON_ADD_PARAM2)->EnableWindow(pNMItemActivate->iItem != -1);
|
|
|
|
|
GetDlgItem(IDC_BUTTON_ADD_PARAM3)->EnableWindow(pNMItemActivate->iItem != -1);
|
|
|
|
|
lst_param_.EnableWindow(pNMItemActivate->iItem != -1);
|
|
|
|
|
|
|
|
|
|
*pResult = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|