3205 lines
114 KiB
C++
3205 lines
114 KiB
C++
// DlgInput.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "hgjson.h"
|
||
#include "DlgOptJson.h"
|
||
#include "afxdialogex.h"
|
||
#include "DlgRange.h"
|
||
#include "DlgCondition.h"
|
||
#include "opt_ui/DlgPage.h" // for local_trans
|
||
|
||
#include <algorithm>
|
||
|
||
#include "../../../../sdk/include/lang/app_language.h"
|
||
#include "../../../../code_device/hgdriver/hgdev/scanner_setting.h"
|
||
|
||
static std::string device_opt_json[] = {
|
||
"{\"restore\":{\"cat\":\"base\",\"group\":\"\",\"title\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"desc\":\"\\u6062\\u590d\\u9ed8\\u8ba4\\u8bbe\\u7f6e\",\"ver\":0,\"pos\":0,\"fix-id\":0,\"type\":\"button\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4},\"help\":{\"cat\":\"base\",\"group\":\"\",\"title\":\"\\u5e2e\\u52a9\",\"desc\":\"\\u663e\\u793a\\u8f6f\\u4ef6\\u5e2e\\u52a9\\u6587\\u6863\",\"ver\":0,\"pos\":0,\"fix-id\":34897,\"type\":\"button\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4},\"is-multiout\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\",\"desc\":\"\\u540c\\u65f6\\u8f93\\u51fa\\u591a\\u79cd\\u989c\\u8272\\u6a21\\u5f0f\\u7684\\u56fe\\u50cf\",\"ver\":0,\"pos\":0,\"fix-id\":34817,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"multiout-type\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u591a\\u6d41\\u8f93\\u51fa\\u7c7b\\u578b\",\"desc\":\"\\u9009\\u62e9\\u591a\\u6d41\\u8f93\\u51fa\\u7684\\u7c7b\\u578b\",\"ver\":0,\"pos\":0,\"fix-id\":34818,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":66,\"cur\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"default\":\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"range\":[\"\\u5f69\\u8272+\\u7070\\u5ea6+\\u9ed1\\u767d\",\"\\u5f69\\u8272+\\u7070\\u5ea6\",\"\\u5f69\\u8272+\\u9ed1\\u767d\",\"\\u7070\\u5ea6+\\u9ed1\\u767d\"],\"depend\":\"is-multiout==true\"},\"mode\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u989c\\u8272\\u6a21\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u8272\\u5f69\\u6a21\\u5f0f\",\"ver\":0,\"pos\":0,\"fix-id\":34819,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":54,\"cur\":\"24\\u4f4d\\u5f69\\u8272\",\"default\":\"24\\u4f4d\\u5f69\\u8272\",\"range\":[\"24\\u4f4d\\u5f69\\u8272\",\"256\\u7ea7\\u7070\\u5ea6\",\"\\u9ed1\\u767d\",\"\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"],\"depend\":\"is-multiout!=true\"},\"binary-threshold\":{\"cat\":\"base\",\"group\":\"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\",\"ver\":0,\"pos\":0,\"fix-id\":34870,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":127,\"default\":127,\"range\":{\"min\":0,\"max\":255,\"step\":1},\"depend\":\"multiout-type!=\\u5f69\\u8272+\\u7070\\u5ea6||mode==\\u9ed1\\u767d\"},\"reverse-bw\":{\"cat\":\"base\",\"group\":\"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\",\"ver\":0,\"pos\":0,\"fix-id\":34878,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"multiout-type!=\\u5f69\\u8272+\\u7070\\u5ea6||mode==\\u9ed1\\u767d\"},\"filter\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u7070\\u5ea6\\u6216\\u9ed1\\u767d\\u56fe\\u50cf - \\u9664\\u8272\\u4e0e\\u589e\\u5f3a\",\"desc\":\"\\u6d88\\u9664\\u6216\\u589e\\u5f3a\\u6307\\u5b9a\\u8272\\u5f69\",\"ver\":0,\"pos\":0,\"fix-id\":34820,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u4e0d\\u9664\\u8272\",\"default\":\"\\u4e0d\\u9664\\u8272\",\"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\":\"is-multiout!=true&&mode!=24\\u4f4d\\u5f69\\u8272&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-rid-multiout-red\":{\"cat\":\"base\",\"group\":\"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\",\"ver\":0,\"pos\":0,\"fix-id\":34821,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"is-multiout!=true&&mode!=256\\u7ea7\\u7070\\u5ea6&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-rid-answer-sheet-red\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"24\\u4f4d\\u5f69\\u8272\\u56fe\\u50cf - \\u7b54\\u9898\\u5361\\u9664\\u7ea2\",\"desc\":\"\\u8f93\\u51fa\\u9664\\u7ea2\\u5f69\\u8272\\u56fe\\u50cf\",\"ver\":0,\"pos\":0,\"fix-id\":34822,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"is-multiout!=true&&mode!=256\\u7ea7\\u7070\\u5ea6&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-erase-bkg\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u80cc\\u666f\\u79fb\\u9664\",\"desc\":\"\\u79fb\\u9664\\u6587\\u7a3f\\u80cc\\u666f\\u5e95\\u8272\",\"ver\":0,\"pos\":0,\"fix-id\":34823,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"is-multiout!=true&&mode!=256\\u7ea7\\u7070\\u5ea6&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"bkg-color-range\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\" \\u80cc\\u666f\\u8272\\u5f69\\u6d6e\\u52a8\\u8303\\u56f4\",\"desc\":\"\\u4e0e\\u80cc\\u666f\\u5e95\\u8272\\u504f\\u5dee\\u5728\\u8be5\\u503c\\u8303\\u56f4\\u5185\\u7684\\u989c\\u8272\\uff0c\\u90fd\\u5c06\\u88ab\\u79fb\\u9664\",\"ver\":0,\"pos\":0,\"fix-id\":34824,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":20,\"default\":20,\"range\":{\"min\":1,\"max\":128,\"step\":1},\"depend\":\"is-erase-bkg==true\"},\"sharpen\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u9510\\u5316\\u4e0e\\u6a21\\u7cca\",\"desc\":\"\\u9009\\u62e9\\u9510\\u5316\\u6548\\u679c\\u6216\\u6a21\\u7cca\\u6548\\u679c\",\"ver\":0,\"pos\":0,\"fix-id\":34825,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":48,\"cur\":\"\\u65e0\",\"default\":\"\\u65e0\",\"range\":[\"\\u65e0\",\"\\u9510\\u5316\",\"\\u8fdb\\u4e00\\u6b65\\u9510\\u5316\",\"\\u6a21\\u7cca\",\"\\u8fdb\\u4e00\\u6b65\\u6a21\\u7cca\"],\"depend\":\"is-multiout!=true&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-rid-morr\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u53bb\\u9664\\u6469\\u5c14\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u6469\\u5c14\\u7eb9\",\"ver\":0,\"pos\":0,\"fix-id\":34826,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"resolution<500&&is-multiout!=true&&paper!=\\u4e09\\u8054\\u8bd5\\u5377&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-rid-grid\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u9664\\u7f51\\u7eb9\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u7f51\\u7eb9\",\"ver\":0,\"pos\":0,\"fix-id\":34827,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"resolution<500&&is-multiout!=true&&paper!=\\u4e09\\u8054\\u8bd5\\u5377&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207&&mode!=\\u9ed1\\u767d&&mode!=\\u989c\\u8272\\u81ea\\u52a8\\u8bc6\\u522b\"},\"is-err-extension\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u9519\\u8bef\\u6269\\u6563\",\"desc\":\"\\u4ee5\\u70b9\\u9635\\u5f62\\u5f0f\\u6784\\u5efa\\u56fe\\u50cf\",\"ver\":0,\"pos\":0,\"fix-id\":34828,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"mode==\\u9ed1\\u767d\"},\"is-noise-optimize\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u9ed1\\u767d\\u56fe\\u50cf\\u566a\\u70b9\\u4f18\\u5316\",\"desc\":\"\\u53bb\\u9664\\u56fe\\u50cf\\u4e2d\\u7684\\u5b64\\u7acb\\u9ed1\\u70b9\",\"ver\":0,\"pos\":0,\"fix-id\":34829,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"mode==\\u9ed1\\u767d\"},\"noise-size\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\" \\u566a\\u70b9\\u4f18\\u5316\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u9700\\u8981\\u53bb\\u9664\\u7684\\u9ed1\\u8272\\u5b64\\u7acb\\u70b9\\u7684\\u8fde\\u901a\\u4e2a\\u6570\",\"ver\":0,\"pos\":0,\"fix-id\":34830,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":10,\"default\":10,\"range\":{\"min\":1,\"max\":50,\"step\":1},\"depend\":\"is-noise-optimize==true\"},\"paper\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u7eb8\\u5f20\\u5c3a\\u5bf8\",\"desc\":\"\\u8bbe\\u7f6e\\u51fa\\u56fe\\u5927\\u5c0f\",\"ver\":0,\"pos\":0,\"fix-id\":34831,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":96,\"cur\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"default\":\"\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8\",\"range\":[\"A3\",\"8\\u5f00\",\"A4\",\"A4\\u6a2a\\u5411\",\"16\\u5f00\",\"16\\u5f00\\u6a2a\\u5411\",\"A5\",\"A5\\u6a2a\\u5411\",\"A6\",\"A6\\u6a2a\\u5411\",\"B4\",\"B5\",\"B5\\u6a2a\\u5411\",\"B6\",\"B6\\u6a2a\\u5411\",\"Letter\",\"Letter\\u6a2a\\u5411\",\"Double Letter\",\"LEGAL\",\"\\u5339\\u914d\\u539f",
|
||
"\\u59cb\\u5c3a\\u5bf8\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\",\"\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\",\"\\u4e09\\u8054\\u8bd5\\u5377\"]},\"is-custom-area\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\",\"ver\":0,\"pos\":0,\"fix-id\":34832,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8&&paper!=\\u4e09\\u8054\\u8bd5\\u5377&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207\"},\"tl-x\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4e0a\\u89d2x\\u5750\\u6807\",\"ver\":0,\"pos\":0,\"fix-id\":34833,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.000000,\"default\":0.000000,\"range\":{\"min\":0.000000,\"max\":210.000000,\"step\":21.000000},\"depend\":\"is-custom-area==true\"},\"br-x\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4e0b\\u89d2x\\u5750\\u6807\",\"ver\":0,\"pos\":0,\"fix-id\":34834,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":210.000000,\"default\":210.000000,\"range\":{\"min\":0.000000,\"max\":210.000000,\"step\":21.000000},\"depend\":\"is-custom-area==true\"},\"tl-y\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u4e0a\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u5de6\\u4e0a\\u89d2y\\u5750\\u6807\",\"ver\":0,\"pos\":0,\"fix-id\":34835,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.000000,\"default\":0.000000,\"range\":{\"min\":0.000000,\"max\":297.000000,\"step\":29.700000},\"depend\":\"is-custom-area==true\"},\"br-y\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u626b\\u63cf\\u533a\\u57df\\u4e0b\\u4fa7\\uff08mm\\uff09\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u626b\\u63cf\\u533a\\u57df\\u53f3\\u4e0b\\u89d2y\\u5750\\u6807\",\"ver\":0,\"pos\":0,\"fix-id\":34836,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":297.000000,\"default\":297.000000,\"range\":{\"min\":0.000000,\"max\":297.000000,\"step\":29.700000},\"depend\":\"is-custom-area==true\"},\"is-size-check\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u5c3a\\u5bf8\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u7eb8\\u5f20\\u5b9e\\u9645\\u5c3a\\u5bf8\\u4e0e\\u8bbe\\u7f6e\\u662f\\u5426\\u5339\\u914d\",\"ver\":0,\"pos\":0,\"fix-id\":34837,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"paper==A3||paper==A4||paper==A4\\u6a2a\\u5411||paper==A5||paper==A5\\u6a2a\\u5411||paper==A6||paper==A6\\u6a2a\\u5411||paper==B4||paper==B5||paper==B5\\u6a2a\\u5411||paper==B6||paper==B6\\u6a2a\\u5411||paper==Double Letter||paper==LEGAL||paper==Letter||paper==Letter\\u6a2a\\u5411\"},\"page\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u626b\\u63cf\\u9875\\u9762\",\"desc\":\"\\u8bbe\\u7f6e\\u9875\\u9762\\u626b\\u63cf\\u65b9\\u5f0f\",\"ver\":0,\"pos\":0,\"fix-id\":34838,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":78,\"cur\":\"\\u53cc\\u9762\",\"default\":\"\\u53cc\\u9762\",\"range\":[\"\\u5355\\u9762\",\"\\u53cc\\u9762\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\",\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09\",\"\\u5bf9\\u6298\"]},\"discardblank\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\",\"desc\":\"\",\"ver\":0,\"pos\":0,\"fix-id\":34919,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"blank-sensitivity\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\" \\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\u7075\\u654f\\u5ea6\",\"desc\":\"\\u6570\\u503c\\u8d8a\\u5927\\uff0c\\u5219\\u8d8a\\u5bb9\\u6613\\u8df3\\u8fc7\",\"ver\":0,\"pos\":0,\"fix-id\":34839,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":30,\"default\":30,\"range\":{\"min\":1,\"max\":100,\"step\":1},\"depend\":\"page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09||page==\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09||discardblank==true\"},\"fold-type\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u5bf9\\u6298\\u6a21\\u5f0f\",\"desc\":\"\",\"ver\":0,\"pos\":0,\"fix-id\":34887,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"default\":\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"range\":[\"\\u5de6\\u53f3\\u5bf9\\u6298\",\"\\u4e0a\\u4e0b\\u5bf9\\u6298\",\"\\u81ea\\u52a8\\u5bf9\\u6298\"],\"depend\":\"page==\\u5bf9\\u6298\"},\"resolution\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u5206\\u8fa8\\u7387\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u56fe\\u50cf\\u7684\\u5206\\u8fa8\\u7387\",\"ver\":0,\"pos\":0,\"fix-id\":34840,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":200,\"default\":200,\"range\":{\"min\":100,\"max\":600,\"step\":1}},\"image-quality\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u753b\\u8d28\",\"desc\":\"\\u9009\\u62e9\\u626b\\u63cf\\u4eea\\u7684\\u753b\\u8d28\\u6a21\\u5f0f\",\"ver\":0,\"pos\":0,\"fix-id\":34841,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u753b\\u8d28\\u4f18\\u5148\",\"default\":\"\\u753b\\u8d28\\u4f18\\u5148\",\"range\":[\"\\u901f\\u5ea6\\u4f18\\u5148\",\"\\u753b\\u8d28\\u4f18\\u5148\"],\"depend\":\"resolution>=300\"},\"is-exchange\":{\"cat\":\"base\",\"group\":\"base\",\"title\":\"\\u4ea4\\u6362\\u6b63\\u53cd\\u9762\",\"desc\":\"\\u4ea4\\u6362\\u6bcf\\u5f20\\u6587\\u7a3f\\u7684\\u6b63\\u53cd\\u9762\\u51fa\\u56fe\\u987a\\u5e8f\",\"ver\":0,\"pos\":0,\"fix-id\":34842,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"page!=\\u5355\\u9762\"},\"is-custom-gamma\":{\"cat\":\"base\",\"group\":\"bright\",\"title\":\"\\u542f\\u7528\\u8272\\u8c03\\u66f2\\u7ebf\",\"desc\":\"\\u81ea\\u5b9a\\u4e49\\u56fe\\u50cf\\u8272\\u8c03\\u6548\\u679c\",\"ver\":0,\"pos\":0,\"fix-id\":34845,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"brightness\":{\"cat\":\"base\",\"group\":\"bright\",\"title\":\"\\u4eae\\u5ea6\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4eae\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34846,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":128,\"default\":128,\"range\":{\"min\":1,\"max\":255,\"step\":1},\"depend\":\"is-custom-gamma==false\"},\"contrast\":{\"cat\":\"base\",\"group\":\"bright\",\"title\":\"\\u5bf9\\u6bd4\\u5ea6\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u5bf9\\u6bd4\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34847,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":4,\"default\":4,\"range\":{\"min\":1,\"max\":7,\"step\":1},\"depend\":\"is-custom-gamma==false\"},\"gamma\":{\"cat\":\"base\",\"group\":\"bright\",\"title\":\"\\u4f3d\\u9a6c\\u503c\",\"desc\":\"\\u8c03\\u6574\\u56fe\\u50cf\\u4f3d\\u739b\\u503c\",\"ver\":0,\"pos\":0,\"fix-id\":34848,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":1.000000,\"default\":1.000000,\"range\":{\"min\":0.010000,\"max\":5.000000,\"step\":0.499000},\"depend\":\"is-custom-gamma==false\"},\"color-correction\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u8272\\u504f\\u6821\\u6b63\",\"desc\":\"\\u8272\\u5f69\\u8fd8\\u539f\\u5ea6\\u77eb\\u6b63\\u529f\\u80fd\",\"ver\":0,\"pos\":0,\"fix-id\":34888,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"is-anti-skew\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u81ea\\u52a8\\u7ea0\\u504f\",\"desc\":\"\\u81ea\\u52a8\\u7ea0\\u6b63\\u6b6a\\u659c\\u9001\\u5165\\u7684\\u6587\\u7a3f\\u56fe\\u50cf\",\"ver\":0,\"pos\":0,\"fix-id\":34844,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true,\"depend\":\"page!=\\u5bf9\\u6298\"},\"is-split\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u56fe\\u50cf\\u62c6\\u5206\",\"desc\":\"\\u81ea\\u52a8\\u62c6\\u5206\\u56fe\\u50cf\",\"ver\":0,\"pos\":0,\"fix-id\":34843,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"page!=\\u5bf9\\u6298&&page!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u53d1\\u7968\\u7eb8\\uff09&&page!=\\u8df3\\u8fc7\\u7a7a\\u767d\\u9875\\uff08\\u901a\\u7528\\uff09\"},\"is-erase-black-frame\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u6d88\\u9664\\u9ed1\\u6846\",\"desc\":\"\\u6d88\\u9664\\u6587\\u7a3f\\u8303\\u56f4\\u5916\\u7684\\u9ed1\\u8272\\u80cc\\u666f\",\"ver\":0,\"pos\":0,\"fix-id\":34849,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"bkg-fill-mode\":{\"cat\":\"base\",\"group\":\"i",
|
||
"mgp\",\"title\":\"\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"desc\":\"\\u9009\\u62e9\\u80cc\\u666f\\u586b\\u5145\\u65b9\\u5f0f\",\"ver\":0,\"pos\":0,\"fix-id\":34854,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"default\":\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"range\":[\"\\u51f8\\u591a\\u8fb9\\u5f62\",\"\\u51f9\\u591a\\u8fb9\\u5f62\"],\"depend\":\"is-erase-black-frame==true\"},\"is-fill-color\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u8272\\u5f69\\u586b\\u5145\",\"desc\":\"\\u542f\\u7528\\u540e\\u9ed1\\u6846\\u90e8\\u5206\\u5c06\\u586b\\u5145\\u4e3a\\u6587\\u7a3f\\u5e95\\u8272\",\"ver\":0,\"pos\":0,\"fix-id\":34859,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"is-erase-black-frame==true\"},\"threshold\":{\"cat\":\"base\",\"group\":\"imgp\",\"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\",\"ver\":0,\"pos\":0,\"fix-id\":34851,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":40,\"default\":40,\"range\":{\"min\":30,\"max\":50,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"anti-noise-level\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u80cc\\u666f\\u6297\\u566a\\u7b49\\u7ea7\",\"desc\":\"\\u80fd\\u591f\\u5bb9\\u5fcd\\u7684\\u80cc\\u666f\\u6742\\u8272\\u6761\\u7eb9\\u7684\\u5bbd\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34852,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":8,\"default\":8,\"range\":{\"min\":2,\"max\":20,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"margin\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u8fb9\\u7f18\\u7f29\\u8fdb\",\"desc\":\"\\u5bfb\\u627e\\u6587\\u7a3f\\u8fb9\\u7f18\\u65f6\\u5bf9\\u8fb9\\u7f18\\u7684\\u4fb5\\u5165\\u7a0b\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34853,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":5,\"default\":5,\"range\":{\"min\":2,\"max\":30,\"step\":1},\"depend\":\"is-erase-black-frame==true||paper==\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8||paper==\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207||is-anti-skew==true\"},\"is-dark-sample\":{\"cat\":\"base\",\"group\":\"imgp\",\"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\",\"ver\":0,\"pos\":0,\"fix-id\":34850,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"page!=\\u5bf9\\u6298&&is-erase-black-frame!=true&&paper!=\\u5339\\u914d\\u539f\\u59cb\\u5c3a\\u5bf8&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8&&paper!=\\u6700\\u5927\\u626b\\u63cf\\u5c3a\\u5bf8\\u81ea\\u52a8\\u88c1\\u5207&&is-anti-skew!=true\"},\"is-anti-permeate\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u9632\\u6b62\\u6e17\\u900f\",\"desc\":\"\\u9632\\u6b62\\u80cc\\u9762\\u56fe\\u6848\\u6e17\\u900f\",\"ver\":0,\"pos\":0,\"fix-id\":34855,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"permeate-level\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\" \\u9632\\u6b62\\u6e17\\u900f\\u7b49\\u7ea7\",\"desc\":\"\\u9009\\u62e9\\u9632\\u6b62\\u6e17\\u900f\\u7684\\u7b49\\u7ea7\",\"ver\":0,\"pos\":0,\"fix-id\":34856,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":30,\"cur\":\"\\u8f83\\u5f31\",\"default\":\"\\u8f83\\u5f31\",\"range\":[\"\\u5f31\",\"\\u8f83\\u5f31\",\"\\u4e00\\u822c\",\"\\u8f83\\u5f3a\",\"\\u5f3a\"],\"depend\":\"is-anti-permeate==true\"},\"is-rid-hole-l\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u5de6\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u5de6\\u4fa7\",\"ver\":0,\"pos\":0,\"fix-id\":34879,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-l\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\" \\u5de6\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":0,\"pos\":0,\"fix-id\":34880,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend\":\"is-rid-hole-l==true\"},\"is-rid-hole-r\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u53f3\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u4e0a\\u7684\\u53f3\\u4fa7\",\"ver\":0,\"pos\":0,\"fix-id\":34881,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-r\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\" \\u53f3\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":0,\"pos\":0,\"fix-id\":34882,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend\":\"is-rid-hole-r==true\"},\"is-rid-hole-t\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0a\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0a\\u90e8\",\"ver\":0,\"pos\":0,\"fix-id\":34883,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-t\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\" \\u4e0a\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":0,\"pos\":0,\"fix-id\":34884,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend\":\"is-rid-hole-t==true\"},\"is-rid-hole-b\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\"\\u7a7f\\u5b54\\u79fb\\u9664\\u2014\\u4e0b\\u4fa7\",\"desc\":\"\\u7a7f\\u5b54\\u5728\\u7eb8\\u5f20\\u7684\\u4e0b\\u90e8\",\"ver\":0,\"pos\":0,\"fix-id\":34885,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"search-hole-range-b\":{\"cat\":\"base\",\"group\":\"imgp\",\"title\":\" \\u4e0b\\u4fa7\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"desc\":\"\\u7a7f\\u5b54\\u641c\\u7d22\\u8303\\u56f4\\u5360\\u5e45\\u9762\\u6bd4\\u4f8b\",\"ver\":0,\"pos\":0,\"fix-id\":34886,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.000000,\"max\":0.500000,\"step\":0.050000},\"depend\":\"is-rid-hole-b==true\"},\"is-wait-scan\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u5f85\\u7eb8\\u626b\\u63cf\",\"desc\":\"\\u542f\\u7528\\u540e\\uff0c\\u6587\\u7a3f\\u653e\\u5165\\u626b\\u63cf\\u4eea\\u65f6\\u5c06\\u81ea\\u52a8\\u542f\\u52a8\\u626b\\u63cf\",\"ver\":0,\"pos\":0,\"fix-id\":34873,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"wait-scan-exit\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u5f85\\u7eb8\\u626b\\u63cf\\u9000\\u51fa\\u65f6\\u95f4\",\"desc\":\"\\u8bbe\\u7f6e\\u7ed3\\u675f\\u5f85\\u7eb8\\u626b\\u63cf\\u7684\\u65f6\\u95f4\",\"ver\":0,\"pos\":0,\"fix-id\":0,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":42,\"cur\":\"60s\",\"default\":\"60s\",\"range\":[\"15s\",\"30s\",\"60s\",\"2min\",\"4min\",\"8min\"],\"depend\":\"is-wait-scan==true\"},\"scan-mode\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u626b\\u63cf\\u5f20\\u6570\",\"desc\":\"\\u9009\\u62e9\\u6307\\u5b9a\\u6570\\u91cf\\u626b\\u63cf\\u6216\\u8fde\\u7eed\\u626b\\u63cf\",\"ver\":0,\"pos\":0,\"fix-id\":34862,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":54,\"cur\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"default\":\"\\u8fde\\u7eed\\u626b\\u63cf\",\"range\":[\"\\u8fde\\u7eed\\u626b\\u63cf\",\"\\u626b\\u63cf\\u6307\\u5b9a\\u5f20\\u6570\"],\"depend\":\"is-wait-scan==false\"},\"scan-count\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\" \\u626b\\u63cf\\u6570\\u91cf\",\"desc\":\"\\u626b\\u63cf\\u6307\\u5b9a\\u6570\\u91cf\",\"ver\":0,\"pos\":0,\"fix-id\":34863,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":-1,\"default\":-1,\"depend\":\"scan-mode==\\u626b\\u63cf\\u6307\\u5b9",
|
||
"a\\u5f20\\u6570\"},\"direction\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u6587\\u7a3f\\u65b9\\u5411\",\"desc\":\"\\u8bbe\\u7f6e\\u56fe\\u50cf\\u7684\\u65b9\\u5411\",\"ver\":0,\"pos\":0,\"fix-id\":34864,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":72,\"cur\":\"0\\u00b0\",\"default\":\"0\\u00b0\",\"range\":[\"0\\u00b0\",\"90\\u00b0\",\"180\\u00b0\",\"-90\\u00b0\",\"\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"]},\"is-rotate-bkg-180\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u80cc\\u9762\\u65cb\\u8f6c180\\u00b0\",\"desc\":\"\\u80cc\\u9762\\u626b\\u63cf\\u7684\\u56fe\\u50cf\\u65cb\\u8f6c180\\u00b0\",\"ver\":0,\"pos\":0,\"fix-id\":34865,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false,\"depend\":\"page!=\\u5355\\u9762&&page!=\\u5bf9\\u6298&&direction!=\\u81ea\\u52a8\\u6587\\u672c\\u65b9\\u5411\\u8bc6\\u522b\\u00b0\"},\"is-ultrosonic\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u8d85\\u58f0\\u6ce2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u53cc\\u5f20\\u9001\\u5165\",\"ver\":0,\"pos\":0,\"fix-id\":34860,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"double-feed\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u53cc\\u5f20\\u56fe\\u7247\\u5904\\u7406\",\"desc\":\"\\u68c0\\u6d4b\\u5230\\u53cc\\u5f20\\u8fdb\\u7eb8\\u540e\\u7684\\u5904\\u7406\\u65b9\\u5f0f\",\"ver\":0,\"pos\":0,\"fix-id\":34872,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":72,\"cur\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"default\":\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"range\":[\"\\u4e22\\u5f03\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\",\"\\u4e0a\\u4f20\\u56fe\\u50cf\\u5e76\\u505c\\u6b62\\u626b\\u63cf\"],\"depend\":\"is-ultrosonic==true\"},\"is-staple\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u88c5\\u8ba2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u7c98\\u8fde\\u9001\\u5165\",\"ver\":0,\"pos\":0,\"fix-id\":34861,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"is-check-askew\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u6b6a\\u659c\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u662f\\u5426\\u51fa\\u73b0\\u6b6a\\u659c\\u9001\\u5165\",\"ver\":0,\"pos\":0,\"fix-id\":34868,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":true,\"default\":true},\"askew-range\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u6b6a\\u659c\\u5bb9\\u5fcd\\u5ea6\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\uff0c\\u80fd\\u5bb9\\u5fcd\\u5f97\\u9001\\u5165\\u6587\\u7a3f\\u6b6a\\u659c\\u89d2\\u5ea6\\u8d8a\\u5c0f\",\"ver\":0,\"pos\":0,\"fix-id\":34869,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":3,\"default\":3,\"range\":{\"min\":1,\"max\":5,\"step\":1},\"depend\":\"is-check-askew==true\"},\"is-check-dog-ear\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u6298\\u89d2\\u68c0\\u6d4b\",\"desc\":\"\\u68c0\\u6d4b\\u6587\\u7a3f\\u662f\\u5426\\u5b58\\u5728\\u6298\\u89d2\",\"ver\":0,\"pos\":0,\"fix-id\":34866,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"dog-ear-size\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\" \\u6298\\u89d2\\u5927\\u5c0f\",\"desc\":\"\\u503c\\u8d8a\\u5c0f\\uff0c\\u80fd\\u68c0\\u6d4b\\u5230\\u7684\\u6298\\u89d2\\u8d8a\\u5c0f\",\"ver\":0,\"pos\":0,\"fix-id\":34867,\"type\":\"int\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":70,\"default\":70,\"range\":{\"min\":10,\"max\":300,\"step\":1},\"depend\":\"is-check-dog-ear==true\"},\"is-auto-strength\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u81ea\\u52a8\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u626b\\u63cf\\u4eea\\u81ea\\u52a8\\u4fee\\u6b63\\u5206\\u7eb8\\u529b\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34876,\"type\":\"bool\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":4,\"cur\":false,\"default\":false},\"feed-strength-value\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\" \\u8fdb\\u7eb8\\u5931\\u8d25\\u7387\",\"desc\":\"\\u9ad8\\u4e8e\\u8be5\\u503c\\u65f6\\u626b\\u63cf\\u4eea\\u5c06\\u8c03\\u6574\\u5206\\u7eb8\\u529b\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34877,\"type\":\"float\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":8,\"cur\":0.100000,\"default\":0.100000,\"range\":{\"min\":0.100000,\"max\":0.900000,\"step\":0.080000},\"depend\":\"is-auto-strength==true\"},\"feed-strength\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u5206\\u7eb8\\u5f3a\\u5ea6\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u5206\\u7eb8\\u529b\\u5ea6\",\"ver\":0,\"pos\":0,\"fix-id\":34874,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":30,\"cur\":\"\\u4e00\\u822c\",\"default\":\"\\u4e00\\u822c\",\"range\":[\"\\u5f31\",\"\\u4e00\\u822c\",\"\\u5f3a\"],\"depend\":\"is-auto-strength!=true\"},\"time-to-sleep\":{\"cat\":\"base\",\"group\":\"feeder\",\"title\":\"\\u4f11\\u7720\\u65f6\\u95f4\",\"desc\":\"\\u8bbe\\u7f6e\\u626b\\u63cf\\u4eea\\u7684\\u4f11\\u7720\\u65f6\\u95f4\",\"ver\":0,\"pos\":0,\"fix-id\":34875,\"type\":\"string\",\"unit\":\"none\",\"affect\":0,\"readonly\":false,\"visible\":true,\"enabled\":true,\"size\":36,\"cur\":\"\\u4e0d\\u4f11\\u7720\",\"default\":\"\\u4e0d\\u4f11\\u7720\",\"range\":[\"\\u4e0d\\u4f11\\u7720\",\"\\u4e94\\u5206\\u949f\",\"\\u5341\\u5206\\u949f\",\"\\u534a\\u5c0f\\u65f6\",\"\\u4e00\\u5c0f\\u65f6\",\"\\u4e24\\u5c0f\\u65f6\",\"\\u56db\\u5c0f\\u65f6\"]}}"
|
||
};
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
// known name ...
|
||
#include "opt_ui/DlgSetting.h"
|
||
#include "../../../../code_device/hgsane/sane_opt/sane_opts.h"
|
||
#include "../../../../code_device/hgdriver/hgdev/user-opt/device_opt.h"
|
||
#include "../../../../code_device/sdk/hginclude/huagaoxxx_warraper_ex.h"
|
||
|
||
namespace known_name
|
||
{
|
||
struct
|
||
{
|
||
std::wstring name;
|
||
std::wstring title;
|
||
}
|
||
g_cats[] = { {L"imgp", L"\u56FE\u50CF\u5904\u7406"}};
|
||
|
||
static std::wstring group_name(const wchar_t* grp_title)
|
||
{
|
||
std::string utf8(local_trans::u2a(grp_title, CP_UTF8));
|
||
|
||
return local_trans::a2u(device_option::trans_group(utf8.c_str(), false).c_str(), CP_UTF8);
|
||
}
|
||
static std::wstring group_title(const wchar_t* grp_name)
|
||
{
|
||
std::string utf8(local_trans::u2a(grp_name, CP_UTF8));
|
||
|
||
return local_trans::a2u(device_option::trans_group(utf8.c_str(), true).c_str(), CP_UTF8);
|
||
}
|
||
|
||
static std::wstring category_name(const wchar_t* cat_title)
|
||
{
|
||
for (auto& v : g_cats)
|
||
{
|
||
if (v.title == cat_title)
|
||
return v.name;
|
||
}
|
||
|
||
return cat_title;
|
||
}
|
||
static std::wstring category_title(const wchar_t* cat_name)
|
||
{
|
||
if (wcscmp(cat_name, L"imgproc") == 0)
|
||
cat_name = L"imgp";
|
||
|
||
for (auto& v : g_cats)
|
||
{
|
||
if (v.name == cat_name)
|
||
return v.title;
|
||
}
|
||
|
||
return cat_name;
|
||
}
|
||
|
||
#define NAME_WITH_FIX_ID(id) { SANE_STD_OPT_NAME_##id, SANE_OPT_ID_##id }
|
||
struct
|
||
{
|
||
std::string name;
|
||
int fix_id;
|
||
}g_fix_ids[] = {
|
||
NAME_WITH_FIX_ID(IS_MULTI_OUT),
|
||
NAME_WITH_FIX_ID(MULTI_OUT_TYPE),
|
||
NAME_WITH_FIX_ID(COLOR_MODE),
|
||
NAME_WITH_FIX_ID(FILTER),
|
||
NAME_WITH_FIX_ID(RID_MULTIOUT_RED),
|
||
NAME_WITH_FIX_ID(RID_ANSWER_SHEET_RED),
|
||
NAME_WITH_FIX_ID(ERASE_BACKGROUND),
|
||
NAME_WITH_FIX_ID(BKG_COLOR_RANGE),
|
||
NAME_WITH_FIX_ID(SHARPEN),
|
||
NAME_WITH_FIX_ID(RID_MORR),
|
||
NAME_WITH_FIX_ID(RID_GRID),
|
||
NAME_WITH_FIX_ID(ERROR_EXTENSION),
|
||
NAME_WITH_FIX_ID(NOISE_OPTIMIZE),
|
||
NAME_WITH_FIX_ID(NOISE_SIZE),
|
||
NAME_WITH_FIX_ID(PAPER),
|
||
NAME_WITH_FIX_ID(CUSTOM_AREA),
|
||
NAME_WITH_FIX_ID(CUSTOM_AREA_LEFT),
|
||
NAME_WITH_FIX_ID(CUSTOM_AREA_RIGHT),
|
||
NAME_WITH_FIX_ID(CUSTOM_AREA_TOP),
|
||
NAME_WITH_FIX_ID(CUSTOM_AREA_BOTTOM),
|
||
NAME_WITH_FIX_ID(SIZE_CHECK),
|
||
NAME_WITH_FIX_ID(PAGE),
|
||
NAME_WITH_FIX_ID(DISCARD_BLANK_SENS),
|
||
NAME_WITH_FIX_ID(RESOLUTION),
|
||
NAME_WITH_FIX_ID(IMAGE_QUALITY),
|
||
NAME_WITH_FIX_ID(EXCHANGE),
|
||
NAME_WITH_FIX_ID(SPLIT),
|
||
NAME_WITH_FIX_ID(ANTI_SKEW),
|
||
NAME_WITH_FIX_ID(IS_CUSTOM_GAMMA),
|
||
NAME_WITH_FIX_ID(BRIGHTNESS),
|
||
NAME_WITH_FIX_ID(CONTRAST),
|
||
NAME_WITH_FIX_ID(GAMMA),
|
||
NAME_WITH_FIX_ID(ERASE_BLACK_FRAME),
|
||
NAME_WITH_FIX_ID(DARK_SAMPLE),
|
||
NAME_WITH_FIX_ID(THRESHOLD),
|
||
NAME_WITH_FIX_ID(ANTI_NOISE_LEVEL),
|
||
NAME_WITH_FIX_ID(MARGIN),
|
||
NAME_WITH_FIX_ID(FILL_BKG_MODE),
|
||
NAME_WITH_FIX_ID(IS_ANTI_PERMEATE),
|
||
NAME_WITH_FIX_ID(ANTI_PERMEATE_LEVEL),
|
||
NAME_WITH_FIX_ID(RID_HOLE),
|
||
NAME_WITH_FIX_ID(SEARCH_HOLE_RANGE),
|
||
NAME_WITH_FIX_ID(IS_FILL_COLOR),
|
||
NAME_WITH_FIX_ID(IS_ULTROSONIC_CHECK),
|
||
NAME_WITH_FIX_ID(IS_CHECK_STAPLE),
|
||
NAME_WITH_FIX_ID(SCAN_MODE),
|
||
NAME_WITH_FIX_ID(SCAN_COUNT),
|
||
NAME_WITH_FIX_ID(TEXT_DIRECTION),
|
||
NAME_WITH_FIX_ID(IS_ROTATE_BKG_180),
|
||
NAME_WITH_FIX_ID(IS_CHECK_DOG_EAR),
|
||
NAME_WITH_FIX_ID(DOG_EAR_SIZE),
|
||
NAME_WITH_FIX_ID(IS_CHECK_ASKEW),
|
||
NAME_WITH_FIX_ID(ASKEW_RANGE),
|
||
NAME_WITH_FIX_ID(BINARY_THRESHOLD),
|
||
NAME_WITH_FIX_ID(IS_PHOTO_MODE),
|
||
NAME_WITH_FIX_ID(DOUBLE_FEED_HANDLE),
|
||
NAME_WITH_FIX_ID(WAIT_TO_SCAN),
|
||
NAME_WITH_FIX_ID(FEED_STRENGTH),
|
||
NAME_WITH_FIX_ID(TIME_TO_SLEEP),
|
||
NAME_WITH_FIX_ID(IS_AUTO_FEED_STRENGTH),
|
||
NAME_WITH_FIX_ID(FEED_STRENGTH_VALUE),
|
||
NAME_WITH_FIX_ID(REVERSE_01),
|
||
NAME_WITH_FIX_ID(RID_HOLE_L),
|
||
NAME_WITH_FIX_ID(SEARCH_HOLE_RANGE_L),
|
||
NAME_WITH_FIX_ID(RID_HOLE_R),
|
||
NAME_WITH_FIX_ID(SEARCH_HOLE_RANGE_R),
|
||
NAME_WITH_FIX_ID(RID_HOLE_T),
|
||
NAME_WITH_FIX_ID(SEARCH_HOLE_RANGE_T),
|
||
NAME_WITH_FIX_ID(RID_HOLE_B),
|
||
NAME_WITH_FIX_ID(SEARCH_HOLE_RANGE_B),
|
||
NAME_WITH_FIX_ID(FOLD_TYPE),
|
||
NAME_WITH_FIX_ID(COLOR_CORRECTION),
|
||
NAME_WITH_FIX_ID(HISTORY_COUNT),
|
||
NAME_WITH_FIX_ID(DRIVER_VERSION),
|
||
NAME_WITH_FIX_ID(MANUFACTURER),
|
||
NAME_WITH_FIX_ID(COPYRIGHT),
|
||
NAME_WITH_FIX_ID(CO_URL),
|
||
NAME_WITH_FIX_ID(CO_TEL),
|
||
NAME_WITH_FIX_ID(CO_ADDR),
|
||
NAME_WITH_FIX_ID(CO_GPS),
|
||
NAME_WITH_FIX_ID(HELP),
|
||
NAME_WITH_FIX_ID(VID),
|
||
NAME_WITH_FIX_ID(PID),
|
||
NAME_WITH_FIX_ID(DEV_NAME),
|
||
NAME_WITH_FIX_ID(DEV_FAMILY),
|
||
NAME_WITH_FIX_ID(DEVICE_SERIAL_NO),
|
||
NAME_WITH_FIX_ID(FIRMWARE_VERSION),
|
||
NAME_WITH_FIX_ID(DEVICE_IP_ADDR),
|
||
NAME_WITH_FIX_ID(DEVICE_MAC_ADDR),
|
||
NAME_WITH_FIX_ID(CUSTOM_GAMMA),
|
||
NAME_WITH_FIX_ID(ROLLER_LIFE),
|
||
NAME_WITH_FIX_ID(LANGUAGE),
|
||
NAME_WITH_FIX_ID(MOTOR_VER),
|
||
NAME_WITH_FIX_ID(TRANSFORM_IMAGE_FORMAT),
|
||
NAME_WITH_FIX_ID(FREE_BUFFER),
|
||
NAME_WITH_FIX_ID(PAPER_ON),
|
||
|
||
NAME_WITH_FIX_ID(GRAY_GAMMA),
|
||
NAME_WITH_FIX_ID(COLOR_GAMMA),
|
||
NAME_WITH_FIX_ID(RED_GAMMA),
|
||
NAME_WITH_FIX_ID(GREEN_GAMMA),
|
||
NAME_WITH_FIX_ID(BLUE_GAMMA),
|
||
NAME_WITH_FIX_ID(INITIAL_BOOT_TIME),
|
||
NAME_WITH_FIX_ID(DISCARDBLANK),
|
||
|
||
NAME_WITH_FIX_ID(LOGIN),
|
||
NAME_WITH_FIX_ID(LOGOUT),
|
||
NAME_WITH_FIX_ID(ROLLER_COUNT),
|
||
NAME_WITH_FIX_ID(DRIVER_LOG),
|
||
NAME_WITH_FIX_ID(DEVICE_LOG)
|
||
};
|
||
static int name_to_fix_id(const wchar_t* name)
|
||
{
|
||
std::string asc("");
|
||
|
||
coding_util::unicode_2_ansi(name, coding::get_string, &asc);
|
||
|
||
for (auto& v : g_fix_ids)
|
||
if (v.name == asc)
|
||
return v.fix_id;
|
||
|
||
return 0;
|
||
}
|
||
static std::string name_from_fix_id(int id)
|
||
{
|
||
for (auto& v : g_fix_ids)
|
||
{
|
||
if (v.fix_id == id)
|
||
return v.name;
|
||
}
|
||
|
||
return "";
|
||
}
|
||
|
||
static void erase_trans_letter(std::wstring& str)
|
||
{
|
||
size_t splash = str.find(L"\\\\");
|
||
|
||
while (splash != std::wstring::npos)
|
||
{
|
||
str.erase(splash++, 1);
|
||
splash = str.find(L"\\\\", splash);
|
||
}
|
||
|
||
splash = str.find(L"\\\"");
|
||
while (splash != std::wstring::npos)
|
||
{
|
||
str.erase(splash++, 1);
|
||
splash = str.find(L"\\\"", splash);
|
||
}
|
||
}
|
||
};
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||
// CDlgOptJson dialog
|
||
|
||
IMPLEMENT_DYNAMIC(CDlgOptJson, CDialogEx)
|
||
|
||
CDlgOptJson::CDlgOptJson(CWnd* pParent /*=NULL*/)
|
||
: CDialogEx(CDlgOptJson::IDD, pParent), tooltips_(NULL)
|
||
{
|
||
//_CrtSetBreakAlloc(350252);
|
||
}
|
||
|
||
CDlgOptJson::~CDlgOptJson()
|
||
{
|
||
delete_from_tree();
|
||
lang_initialize((void*)0xde1e);
|
||
delete tooltips_;
|
||
}
|
||
|
||
known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void)
|
||
{
|
||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(), *dep = NULL;
|
||
int nv = 0;
|
||
|
||
jsn->set_key(name.c_str());
|
||
jsn->set_value(L"cat", known_name::category_name(category.c_str()).c_str());
|
||
jsn->set_value(L"group", known_name::group_name(group.c_str()).c_str());
|
||
jsn->set_value(L"title", title.c_str());
|
||
jsn->set_value(L"desc", desc.c_str());
|
||
jsn->set_value(L"ver", ver);
|
||
jsn->set_value(L"pos", pos);
|
||
jsn->set_value(L"fix-id", fix_id);
|
||
jsn->set_value(L"type", type.c_str());
|
||
jsn->set_value(L"unit", unit.c_str());
|
||
SANEOPT::affect_str(nv, affect, false);
|
||
jsn->set_value(L"affect", nv);
|
||
if(readonly)
|
||
jsn->set_value(L"readonly", readonly);
|
||
if(open != OPT_VISIBLE_ALL)
|
||
jsn->set_value(L"visible", open);
|
||
if(!enable)
|
||
jsn->set_value(L"enabled", enable);
|
||
jsn->set_value(L"size", size);
|
||
if (!auto_restore_default)
|
||
jsn->set_value(L"auto", auto_restore_default);
|
||
|
||
if (type == L"bool")
|
||
{
|
||
if (def_val.size() == 1)
|
||
{
|
||
jsn->set_value(L"cur", *(bool*)def_val[0].val.c_str());
|
||
jsn->set_value(L"default", *(bool*)def_val[0].val.c_str());
|
||
}
|
||
else if (def_val.size() > 1)
|
||
{
|
||
known_file_util::IJsonW* def = known_file_util::create_jsonW();
|
||
for (auto& v : def_val)
|
||
{
|
||
if (v.cond.empty())
|
||
{
|
||
def->set_value(L"default", *(bool*)v.val.c_str());
|
||
jsn->set_value(L"cur", *(bool*)v.val.c_str());
|
||
}
|
||
else
|
||
def->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(bool*)v.val.c_str());
|
||
}
|
||
jsn->set_value(L"default", def);
|
||
def->release();
|
||
}
|
||
}
|
||
else if (type == L"int")
|
||
{
|
||
known_file_util::IJsonW* rng = NULL;
|
||
|
||
if (def_val.size() == 1)
|
||
{
|
||
jsn->set_value(L"cur", *(int*)def_val[0].val.c_str());
|
||
jsn->set_value(L"default", *(int*)def_val[0].val.c_str());
|
||
}
|
||
else if (def_val.size() > 1)
|
||
{
|
||
known_file_util::IJsonW* def = known_file_util::create_jsonW();
|
||
for (auto& v : def_val)
|
||
{
|
||
if (v.cond.empty())
|
||
{
|
||
def->set_value(L"default", *(int*)v.val.c_str());
|
||
jsn->set_value(L"cur", *(int*)v.val.c_str());
|
||
}
|
||
else
|
||
def->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(int*)v.val.c_str());
|
||
}
|
||
jsn->set_value(L"default", def);
|
||
def->release();
|
||
}
|
||
|
||
if (range_type == L"list")
|
||
{
|
||
rng = known_file_util::create_jsonW();
|
||
rng->set_as_array(true);
|
||
for (auto& v : range)
|
||
{
|
||
if(v.cond.empty())
|
||
*rng += *(int*)v.val.c_str();
|
||
else
|
||
{
|
||
known_file_util::IJsonW* condv = known_file_util::create_jsonW();
|
||
condv->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(int*)v.val.c_str());
|
||
*rng += condv;
|
||
condv->release();
|
||
}
|
||
}
|
||
}
|
||
else if (range_type == L"range" && range.size() >= 3)
|
||
{
|
||
std::vector<CONDVAL> l, u, s, * n, * na[] = {&l, &u, &s};
|
||
std::wstring key[] = { L"min", L"max", L"step" };
|
||
|
||
for (auto& v : range)
|
||
{
|
||
CONDVAL val(v);
|
||
size_t pos = val.cond.find("min:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 4);
|
||
l.push_back(val);
|
||
}
|
||
else
|
||
{
|
||
pos = val.cond.find("max:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 4);
|
||
u.push_back(val);
|
||
}
|
||
else
|
||
{
|
||
pos = val.cond.find("step:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 5);
|
||
s.push_back(val);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
rng = known_file_util::create_jsonW();
|
||
for (int i = 0; i < _countof(na); ++i)
|
||
{
|
||
n = na[i];
|
||
if (n->size() == 1)
|
||
{
|
||
rng->set_value(key[i].c_str(), *(int*)&(*n)[0].val[0]);
|
||
}
|
||
else if (n->size() > 1)
|
||
{
|
||
known_file_util::IJsonW* lower = known_file_util::create_jsonW();
|
||
for (auto& v : *n)
|
||
{
|
||
if (v.cond.empty())
|
||
lower->set_value(L"default", *(int*)&v.val[0]);
|
||
else
|
||
lower->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(int*)&v.val[0]);
|
||
}
|
||
rng->set_value(key[i].c_str(), lower);
|
||
lower->release();
|
||
}
|
||
}
|
||
}
|
||
if (rng)
|
||
{
|
||
jsn->set_value(L"range", rng);
|
||
rng->release();
|
||
}
|
||
}
|
||
else if (type == L"float")
|
||
{
|
||
known_file_util::IJsonW* rng = NULL;
|
||
|
||
//jsn->set_value(L"size", (int)sizeof(double));
|
||
if (def_val.size() == 1)
|
||
{
|
||
jsn->set_value(L"cur", *(double*)def_val[0].val.c_str());
|
||
jsn->set_value(L"default", *(double*)def_val[0].val.c_str());
|
||
}
|
||
else if (def_val.size() > 1)
|
||
{
|
||
known_file_util::IJsonW* def = known_file_util::create_jsonW();
|
||
for (auto& v : def_val)
|
||
{
|
||
if (v.cond.empty())
|
||
{
|
||
def->set_value(L"default", *(double*)v.val.c_str());
|
||
jsn->set_value(L"cur", *(double*)v.val.c_str());
|
||
}
|
||
else
|
||
def->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(double*)v.val.c_str());
|
||
}
|
||
jsn->set_value(L"default", def);
|
||
def->release();
|
||
}
|
||
|
||
if (range_type == L"list")
|
||
{
|
||
rng = known_file_util::create_jsonW();
|
||
rng->set_as_array(true);
|
||
for (auto& v : range)
|
||
{
|
||
if(v.cond.empty())
|
||
*rng += *(double*)v.val.c_str();
|
||
else
|
||
{
|
||
known_file_util::IJsonW* condv = known_file_util::create_jsonW();
|
||
condv->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(double*)v.val.c_str());
|
||
*rng += condv;
|
||
condv->release();
|
||
}
|
||
}
|
||
}
|
||
else if (range_type == L"range" && range.size() >= 3)
|
||
{
|
||
std::vector<CONDVAL> l, u, s, * n, * na[] = { &l, &u, &s };
|
||
std::wstring key[] = { L"min", L"max", L"step" };
|
||
|
||
for (auto& v : range)
|
||
{
|
||
CONDVAL val(v);
|
||
size_t pos = val.cond.find("min:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 4);
|
||
l.push_back(val);
|
||
}
|
||
else
|
||
{
|
||
pos = val.cond.find("max:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 4);
|
||
u.push_back(val);
|
||
}
|
||
else
|
||
{
|
||
pos = val.cond.find("step:");
|
||
if (pos != std::string::npos)
|
||
{
|
||
val.cond.erase(0, 5);
|
||
s.push_back(val);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
rng = known_file_util::create_jsonW();
|
||
for (int i = 0; i < _countof(na); ++i)
|
||
{
|
||
n = na[i];
|
||
if (n->size() == 1)
|
||
{
|
||
rng->set_value(key[i].c_str(), *(double*)&(*n)[0].val[0]);
|
||
}
|
||
else if (n->size() > 1)
|
||
{
|
||
known_file_util::IJsonW* lower = known_file_util::create_jsonW();
|
||
for (auto& v : *n)
|
||
{
|
||
if (v.cond.empty())
|
||
lower->set_value(L"default", *(double*)&v.val[0]);
|
||
else
|
||
lower->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), *(double*)&v.val[0]);
|
||
}
|
||
rng->set_value(key[i].c_str(), lower);
|
||
lower->release();
|
||
}
|
||
}
|
||
}
|
||
|
||
if (rng)
|
||
{
|
||
jsn->set_value(L"range", rng);
|
||
rng->release();
|
||
}
|
||
}
|
||
else if (type == L"string")
|
||
{
|
||
int len = 0;
|
||
if (def_val.size() == 1)
|
||
{
|
||
jsn->set_value(L"cur", (const wchar_t*)def_val[0].val.c_str());
|
||
jsn->set_value(L"default", (const wchar_t*)def_val[0].val.c_str());
|
||
if (len < def_val[0].val.length())
|
||
len = def_val[0].val.length();
|
||
}
|
||
else if (def_val.size() > 1)
|
||
{
|
||
known_file_util::IJsonW* def = known_file_util::create_jsonW();
|
||
for (auto& v : def_val)
|
||
{
|
||
if (v.cond.empty())
|
||
{
|
||
def->set_value(L"default", (const wchar_t*)v.val.c_str());
|
||
jsn->set_value(L"cur", (const wchar_t*)v.val.c_str());
|
||
}
|
||
else
|
||
def->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), (const wchar_t*)v.val.c_str());
|
||
if (len < v.val.length())
|
||
len = v.val.length();
|
||
}
|
||
jsn->set_value(L"default", def);
|
||
def->release();
|
||
}
|
||
|
||
if (range.size())
|
||
{
|
||
known_file_util::IJsonW* rng = known_file_util::create_jsonW();
|
||
rng->set_as_array(true);
|
||
for (auto& v : range)
|
||
{
|
||
if(v.cond.empty())
|
||
*rng += (const wchar_t*)v.val.c_str();
|
||
else
|
||
{
|
||
known_file_util::IJsonW* condv = known_file_util::create_jsonW();
|
||
condv->set_value(local_trans::a2u(v.cond.c_str(), CP_UTF8).c_str(), (const wchar_t*)v.val.c_str());
|
||
*rng += condv;
|
||
condv->release();
|
||
}
|
||
if (len < v.val.length())
|
||
len = v.val.length();
|
||
}
|
||
jsn->set_value(L"range", rng);
|
||
rng->release();
|
||
}
|
||
len += 4;
|
||
len *= 3;
|
||
//jsn->set_value(L"size", len);
|
||
}
|
||
|
||
if (!depend.empty())
|
||
{
|
||
std::wstring trans(L"");
|
||
//for (auto& v : depend)
|
||
//{
|
||
// wchar_t buf[20] = { 0 };
|
||
// if ((WORD)v > 0x7f)
|
||
// swprintf_s(buf, _countof(buf) - 1, L"\\u%04X", (WORD)v);
|
||
// else
|
||
// buf[0] = v;
|
||
// trans += buf;
|
||
//}
|
||
jsn->set_value(L"depend", depend.c_str());
|
||
}
|
||
|
||
return jsn;
|
||
}
|
||
bool CDlgOptJson::SANEOPT::from_json(known_file_util::IJsonW* jsn)
|
||
{
|
||
bool ret = true;
|
||
const wchar_t* strv = NULL;
|
||
known_file_util::IJsonW* child = NULL;
|
||
|
||
SANEOPT::init(this);
|
||
name = jsn->key() ? jsn->key() : L"";
|
||
if (jsn->get_value(L"title", &strv) && strv)
|
||
title = strv;
|
||
|
||
if (jsn->get_value(L"desc", &strv) && strv)
|
||
desc = strv;
|
||
|
||
if (jsn->get_value(L"group", &strv) && strv)
|
||
{
|
||
std::wstring str(strv);
|
||
|
||
group = known_name::group_title(str.c_str());
|
||
}
|
||
|
||
if (jsn->get_value(L"cat", &strv) && strv)
|
||
category = known_name::category_title(strv);
|
||
else if(jsn->get_value(L"field", &strv) && strv)
|
||
category = known_name::category_title(strv);
|
||
|
||
if (jsn->get_value(L"unit", &strv) && strv)
|
||
unit = strv;
|
||
std::transform(unit.begin(), unit.end(), unit.begin(), tolower);
|
||
|
||
if (jsn->get_value(L"type", &strv) && strv)
|
||
type = strv;
|
||
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
||
|
||
jsn->get_value(L"size", size);
|
||
|
||
if (type == L"bool")
|
||
{
|
||
bool v = false;
|
||
known_file_util::IJsonW* child = NULL;
|
||
CONDVAL cv;
|
||
|
||
if (jsn->get_value(L"default", &child) && child)
|
||
{
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (wcscmp(m.key, L"default") == 0)
|
||
cv.cond = "";
|
||
else
|
||
cv.cond = local_trans::u2a(m.key, CP_UTF8);
|
||
cv.val = std::string((char*)&m.bool_val, sizeof(m.bool_val));
|
||
m = child->next_member();
|
||
}
|
||
child->release();
|
||
}
|
||
else
|
||
{
|
||
if (!jsn->get_value(L"default", v))
|
||
jsn->get_value(L"cur", v);
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
cv.cond = "";
|
||
def_val.push_back(cv);
|
||
}
|
||
}
|
||
else if(type == L"int")
|
||
{
|
||
int v = 0;
|
||
known_file_util::IJsonW* child = NULL;
|
||
CONDVAL cv;
|
||
|
||
if (jsn->get_value(L"default", &child) && child)
|
||
{
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (wcscmp(m.key, L"default") == 0)
|
||
cv.cond = "";
|
||
else
|
||
cv.cond = local_trans::u2a(m.key, CP_UTF8);
|
||
if(m.type == known_file_util::JV_UINT64)
|
||
cv.val = std::string((char*)&m.uint64_val, sizeof(m.uint64_val));
|
||
else
|
||
cv.val = std::string((char*)&m.int_val, sizeof(m.int_val));
|
||
m = child->next_member();
|
||
}
|
||
child->release();
|
||
}
|
||
else if (!jsn->get_value(L"default", v))
|
||
{
|
||
// try uint64 ...
|
||
unsigned long long n64 = 0;
|
||
if(jsn->get_value(L"default", n64) || jsn->get_value(L"cur", n64))
|
||
{
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&n64, sizeof(n64));
|
||
def_val.push_back(cv);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
def_val.push_back(cv);
|
||
}
|
||
}
|
||
else if(type == L"float")
|
||
{
|
||
double v = false;
|
||
known_file_util::IJsonW* child = NULL;
|
||
CONDVAL cv;
|
||
|
||
if (jsn->get_value(L"default", &child) && child)
|
||
{
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (wcscmp(m.key, L"default") == 0)
|
||
cv.cond = "";
|
||
else
|
||
cv.cond = local_trans::u2a(m.key, CP_UTF8);
|
||
cv.val = std::string((char*)&m.double_val, sizeof(m.double_val));
|
||
m = child->next_member();
|
||
}
|
||
child->release();
|
||
}
|
||
else
|
||
{
|
||
if (!jsn->get_value(L"default", v))
|
||
jsn->get_value(L"cur", v);
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
cv.cond = "";
|
||
def_val.push_back(cv);
|
||
}
|
||
}
|
||
else if(type == L"string")
|
||
{
|
||
strv = NULL;
|
||
known_file_util::IJsonW* child = NULL;
|
||
CONDVAL cv;
|
||
|
||
if (jsn->get_value(L"default", &child) && child)
|
||
{
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (wcscmp(m.key, L"default") == 0)
|
||
cv.cond = "";
|
||
else
|
||
cv.cond = local_trans::u2a(m.key, CP_UTF8);
|
||
cv.val = std::string((const char*)m.str_val, lstrlenW(m.str_val) * 2 + 2);
|
||
m = child->next_member();
|
||
}
|
||
child->release();
|
||
}
|
||
else
|
||
{
|
||
if (!jsn->get_value(L"default", &strv))
|
||
jsn->get_value(L"cur", &strv);
|
||
cv.val = std::string((const char*)strv, lstrlenW(strv) * 2 + 2);
|
||
cv.cond = "";
|
||
def_val.push_back(cv);
|
||
}
|
||
}
|
||
|
||
jsn->get_value(L"affect", ver);
|
||
SANEOPT::affect_str(ver, affect, true);
|
||
jsn->get_value(L"ver", ver);
|
||
jsn->get_value(L"pos", pos);
|
||
if (!jsn->get_value(L"readonly", readonly))
|
||
readonly = false;
|
||
|
||
bool bv = false;
|
||
if (jsn->get_value(L"visible", bv))
|
||
open = bv ? OPT_VISIBLE_ALL : OPT_VISIBLE_HIDE;
|
||
else if (!jsn->get_value(L"visible", open))
|
||
open = OPT_VISIBLE_ALL;
|
||
if (!jsn->get_value(L"enabled", enable))
|
||
enable = true;
|
||
if (!jsn->get_value(L"fix-id", fix_id) && !name.empty())
|
||
{
|
||
fix_id = known_name::name_to_fix_id(name.c_str());
|
||
}
|
||
if (!jsn->get_value(L"auto", auto_restore_default))
|
||
auto_restore_default = true;
|
||
|
||
if (jsn->get_value(L"range", &child) && child)
|
||
{
|
||
if (type == L"int")
|
||
{
|
||
int nv = 0;
|
||
known_file_util::IJsonW* son = NULL;
|
||
if (child->get_value(L"min", nv) || child->get_value(L"min", &son))
|
||
{
|
||
range_type = L"range";
|
||
if (son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.cond.insert(0, "min:");
|
||
v.val = std::string((char*)&son1.int_val, sizeof(son1.int_val));
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
else
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "min:");
|
||
range.push_back(v);
|
||
}
|
||
|
||
if (child->get_value(L"max", nv))
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "max:");
|
||
range.push_back(v);
|
||
}
|
||
else if (child->get_value(L"max", &son) && son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.val = std::string((char*)&son1.int_val, sizeof(son1.int_val));
|
||
v.cond.insert(0, "max:");
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
|
||
if (child->get_value(L"step", nv))
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "step:");
|
||
range.push_back(v);
|
||
}
|
||
else if (child->get_value(L"step", &son) && son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.val = std::string((char*)&son1.int_val, sizeof(son1.int_val));
|
||
v.cond.insert(0, "step:");
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
range_type = L"list";
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (m.type == known_file_util::JV_OBJECT)
|
||
{
|
||
known_file_util::JSONMEMW s = m.child->first_member();
|
||
while (s.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = local_trans::u2a(s.key, CP_UTF8);
|
||
cv.val = std::string((char*)&s.int_val, sizeof(s.int_val));
|
||
range.push_back(cv);
|
||
s = m.child->next_member();
|
||
}
|
||
m.child->release();
|
||
}
|
||
else
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&m.int_val, sizeof(m.int_val));
|
||
range.push_back(cv);
|
||
}
|
||
m = child->next_member();
|
||
}
|
||
}
|
||
}
|
||
else if (type == L"float")
|
||
{
|
||
double nv = 0;
|
||
known_file_util::IJsonW* son = NULL;
|
||
if (child->get_value(L"min", nv) || child->get_value(L"min", &son))
|
||
{
|
||
range_type = L"range";
|
||
if (son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.val = std::string((char*)&son1.double_val, sizeof(son1.double_val));
|
||
v.cond.insert(0, "min:");
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
else
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "min:");
|
||
range.push_back(v);
|
||
}
|
||
|
||
if (child->get_value(L"max", nv))
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "max:");
|
||
range.push_back(v);
|
||
}
|
||
else if (child->get_value(L"max", &son) && son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.cond.insert(0, "max:");
|
||
v.val = std::string((char*)&son1.double_val, sizeof(son1.double_val));
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
|
||
if (child->get_value(L"step", nv))
|
||
{
|
||
CONDVAL v;
|
||
v.val = std::string((char*)&nv, sizeof(nv));
|
||
v.cond.insert(0, "step:");
|
||
range.push_back(v);
|
||
}
|
||
else if (child->get_value(L"step", &son) && son)
|
||
{
|
||
known_file_util::JSONMEMW son1 = son->first_member();
|
||
while (son1.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL v;
|
||
v.cond = local_trans::u2a(son1.key, CP_UTF8);
|
||
if (v.cond == "default")
|
||
v.cond = "";
|
||
v.val = std::string((char*)&son1.double_val, sizeof(son1.double_val));
|
||
v.cond.insert(0, "step:");
|
||
range.push_back(v);
|
||
|
||
son1 = son->next_member();
|
||
}
|
||
son->release();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
range_type = L"list";
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
if (m.type == known_file_util::JV_OBJECT)
|
||
{
|
||
known_file_util::JSONMEMW s = m.child->first_member();
|
||
while (s.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = local_trans::u2a(s.key, CP_UTF8);
|
||
cv.val = std::string((char*)&s.double_val, sizeof(s.double_val));
|
||
range.push_back(cv);
|
||
s = m.child->next_member();
|
||
}
|
||
m.child->release();
|
||
}
|
||
else
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&m.double_val, sizeof(m.double_val));
|
||
range.push_back(cv);
|
||
}
|
||
m = child->next_member();
|
||
}
|
||
}
|
||
}
|
||
else if (type == L"string")
|
||
{
|
||
range_type = L"list";
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
CONDVAL cv;
|
||
if (m.type == known_file_util::JV_OBJECT)
|
||
{
|
||
known_file_util::JSONMEMW s = m.child->first_member();
|
||
while (s.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
cv.cond = local_trans::u2a(s.key, CP_UTF8);
|
||
cv.val = std::string((const char*)s.str_val, lstrlenW(s.str_val) * 2 + 2);
|
||
range.push_back(cv);
|
||
s = m.child->next_member();
|
||
}
|
||
m.child->release();
|
||
}
|
||
else
|
||
{
|
||
cv.cond = "";
|
||
cv.val = std::string((const char*)m.str_val, lstrlenW(m.str_val) * 2 + 2);
|
||
range.push_back(cv);
|
||
}
|
||
m = child->next_member();
|
||
}
|
||
}
|
||
child->release();
|
||
}
|
||
|
||
std::wstring oper(L"");
|
||
if (jsn->get_value(L"depend_and", &child) && child)
|
||
oper = L"&&";
|
||
else if (jsn->get_value(L"depend_or", &child) && child)
|
||
oper = L"||";
|
||
else
|
||
{
|
||
const wchar_t* dpnd = NULL;
|
||
jsn->get_value(L"depend", &dpnd);
|
||
depend = dpnd ? dpnd : L"";
|
||
}
|
||
if (child)
|
||
{
|
||
known_file_util::JSONMEMW m = child->first_member();
|
||
std::wstring n(L"");
|
||
while (m.type != known_file_util::JV_UNKNOWN)
|
||
{
|
||
std::wstring exp(m.str_val), nm(coding::name_from_depend_exp(exp));
|
||
|
||
if (nm.empty())
|
||
exp.insert(0, n);
|
||
else
|
||
n = nm;
|
||
|
||
if (!depend.empty())
|
||
depend += oper;
|
||
depend += exp;
|
||
|
||
m = child->next_member();
|
||
}
|
||
child->release();
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
void CDlgOptJson::SANEOPT::init(struct _sane_opt_json* opt)
|
||
{
|
||
opt->name = opt->title = opt->desc = L"";
|
||
opt->group = L"\u57FA\u672C\u8BBE\u7F6E";
|
||
opt->category = opt->unit = opt->affect = opt->range_type = L"none";
|
||
opt->range.clear();
|
||
|
||
opt->def_val.clear();
|
||
opt->type = L"int";
|
||
opt->ver = 1;
|
||
opt->fix_id = 0;
|
||
opt->pos = -1;
|
||
opt->readonly = false;
|
||
opt->open = OPT_VISIBLE_ALL;
|
||
opt->enable = true;
|
||
opt->auto_restore_default = true;
|
||
}
|
||
|
||
std::wstring CDlgOptJson::get_item_text(UINT id)
|
||
{
|
||
int l = GetDlgItem(id)->GetWindowTextLengthW();
|
||
wchar_t* buf = new wchar_t[l + 4];
|
||
|
||
l = GetDlgItem(id)->GetWindowTextW(buf, l + 2);
|
||
buf[l] = 0;
|
||
|
||
std::wstring ret(buf);
|
||
|
||
delete[] buf;
|
||
|
||
return std::move(ret);
|
||
}
|
||
bool CDlgOptJson::is_button_check(UINT id)
|
||
{
|
||
return ((CButton*)GetDlgItem(id))->GetCheck() == BST_CHECKED;
|
||
}
|
||
void CDlgOptJson::set_button_check(UINT id, bool check)
|
||
{
|
||
((CButton*)GetDlgItem(id))->SetCheck(check ? BST_CHECKED : BST_UNCHECKED);
|
||
}
|
||
std::wstring CDlgOptJson::get_json_text(const wchar_t* tab)
|
||
{
|
||
known_file_util::IJsonW* root = known_file_util::create_jsonW(), * child = NULL;
|
||
std::wstring nofid(L"");
|
||
int nfidcnt = 0;
|
||
|
||
for (auto& v : opts_)
|
||
{
|
||
child = v.to_json();
|
||
if (v.fix_id <= 0)
|
||
nofid += L" " + std::to_wstring(++nfidcnt) + L"<EFBFBD><EFBFBD> " + v.title + L"\r\n";
|
||
if (child)
|
||
{
|
||
if(wcscmp(child->key(), L"global"))
|
||
root->set_value(v.name.c_str(), child);
|
||
child->release();
|
||
}
|
||
}
|
||
if (!nofid.empty())
|
||
{
|
||
nofid.insert(0, L" \u8BF7\u6CE8\u610F\uFF0C\u4EE5\u4E0B\u5C5E\u6027\u6CA1\u6709\u63D0\u4F9B\uFF26\uFF49\uFF58\uFF45\uFF44\uFF0D\uFF29\uFF24\u6570\u636E\uFF0C\u5C06\r\n\u65E0\u6CD5\u88AB\u6620\u5C04\u5230\uFF34\uFF37\uFF21\uFF29\uFF2E\u534F\u8BAE\u4E2D\uFF01\r\n\r\n");
|
||
MessageBox(nofid.c_str(), TEXT("Notice"), MB_OK | MB_ICONWARNING);
|
||
}
|
||
|
||
std::wstring cont(L"");
|
||
|
||
root->to_string(coding::get_wstring, &cont, tab);
|
||
root->release();
|
||
|
||
return std::move(cont);
|
||
}
|
||
|
||
void CDlgOptJson::from_ui(SANEOPT& sop)
|
||
{
|
||
std::wstring val(L"");
|
||
|
||
sop.name = get_item_text(IDC_EDIT_NAME);
|
||
sop.title = get_item_text(IDC_EDIT_TITLE);
|
||
sop.desc = get_item_text(IDC_EDIT_DESCRIPTION);
|
||
|
||
sop.group = get_item_text(IDC_COMBO_GROUP);
|
||
if (group_.FindStringExact(-1, sop.group.c_str()) == -1)
|
||
group_.AddString(sop.group.c_str());
|
||
|
||
sop.category = get_item_text(IDC_COMBO_CATEGORY);
|
||
if (cat_.FindStringExact(-1, sop.category.c_str()) == -1)
|
||
cat_.AddString(sop.group.c_str());
|
||
|
||
sop.affect = get_item_text(IDC_COMBO_AFFECT);
|
||
sop.unit = get_item_text(IDC_COMBO_UNIT);
|
||
sop.ver = GetDlgItemInt(IDC_EDIT_VER);
|
||
sop.type = get_item_text(IDC_COMBO_DATA_TYPE);
|
||
sop.pos = GetDlgItemInt(IDC_EDIT_POSITION);
|
||
//sop.fix_id = GetDlgItemInt(IDC_EDIT_FIXED_ID);
|
||
sop.fix_id = fix_id_edit_.value();
|
||
sop.readonly = is_button_check(IDC_CHECK_READONLY);
|
||
sop.open = visible_.GetCurSel(); // is_button_check(IDC_CHECK_PUBLIC);
|
||
sop.range_type = get_item_text(IDC_COMBO_RANGE);
|
||
|
||
if (GetDlgItem(IDC_EDIT_DEFAULT)->IsWindowVisible())
|
||
val = get_item_text(IDC_EDIT_DEFAULT);
|
||
else
|
||
val = get_item_text(IDC_COMBO_DEFAULT);
|
||
sop.size = GetDlgItemInt(IDC_EDIT_SIZE);
|
||
|
||
sop.def_val.clear(); // FIXED me to support multi-value!!!
|
||
if (sop.type == L"bool")
|
||
{
|
||
bool v = val == L"true";
|
||
CONDVAL cv;
|
||
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
sop.def_val.push_back(cv);
|
||
}
|
||
else if (sop.type == L"int")
|
||
{
|
||
int v = _wtoi(val.c_str());
|
||
CONDVAL cv;
|
||
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
sop.def_val.push_back(cv);
|
||
}
|
||
else if (sop.type == L"float")
|
||
{
|
||
double v = _wtof(val.c_str());
|
||
CONDVAL cv;
|
||
|
||
cv.cond = "";
|
||
cv.val = std::string((char*)&v, sizeof(v));
|
||
sop.def_val.push_back(cv);
|
||
}
|
||
else if (sop.type == L"string")
|
||
{
|
||
CONDVAL cv;
|
||
|
||
cv.cond = "";
|
||
cv.val = std::string((const char*)val.c_str(), val.length() * 2 + 2);
|
||
sop.def_val.push_back(cv);
|
||
}
|
||
|
||
sop.enable = is_button_check(IDC_CHECK_ENABLE);
|
||
sop.range_type = get_item_text(IDC_COMBO_RANGE);
|
||
sop.auto_restore_default = is_button_check(IDC_CHECK_AUTO_RESTORE);
|
||
sop.depend = get_item_text(IDC_EDIT_LOGIC);
|
||
|
||
simple_logic logic;
|
||
int pos = 0;
|
||
|
||
if (!logic.parse(local_trans::u2a(sop.depend.c_str(), CP_UTF8).c_str(), &pos))
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Invalid char at position %u('%c')!", pos, sop.depend[pos]);
|
||
MessageBox(info, L"Invalid Logic-Expression");
|
||
}
|
||
}
|
||
void CDlgOptJson::to_ui(const SANEOPT& sop)
|
||
{
|
||
int n = 0;
|
||
|
||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_NAME, sop.name.c_str());
|
||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_TITLE, sop.title.c_str());
|
||
::SetDlgItemTextW(m_hWnd, IDC_EDIT_DESCRIPTION, sop.desc.c_str());
|
||
SetDlgItemInt(IDC_EDIT_SIZE, sop.size);
|
||
|
||
n = group_.FindStringExact(-1, sop.group.c_str());
|
||
if (n == -1)
|
||
n = group_.AddString(sop.group.c_str());
|
||
group_.SetCurSel(n);
|
||
|
||
n = cat_.FindStringExact(-1, sop.category.c_str());
|
||
if (n == -1)
|
||
n = cat_.AddString(sop.category.c_str());
|
||
cat_.SetCurSel(n);
|
||
|
||
n = affect_.FindStringExact(-1, sop.affect.c_str());
|
||
affect_.SetCurSel(n);
|
||
|
||
n = unit_.FindStringExact(-1, sop.unit.c_str());
|
||
unit_.SetCurSel(n);
|
||
|
||
SetDlgItemInt(IDC_EDIT_VER, sop.ver);
|
||
|
||
n = type_.FindStringExact(-1, sop.type.c_str());
|
||
type_.SetCurSel(n);
|
||
|
||
SetDlgItemInt(IDC_EDIT_POSITION, sop.pos);
|
||
//SetDlgItemInt(IDC_EDIT_FIXED_ID, sop.fix_id);
|
||
fix_id_edit_.set_value(sop.fix_id);
|
||
|
||
set_button_check(IDC_CHECK_READONLY, sop.readonly);
|
||
//set_button_check(IDC_CHECK_PUBLIC, sop.open);
|
||
visible_.SetCurSel(sop.open);
|
||
set_button_check(IDC_CHECK_ENABLE, sop.enable);
|
||
set_button_check(IDC_CHECK_AUTO_RESTORE, sop.auto_restore_default);
|
||
|
||
n = range_.FindStringExact(-1, sop.range_type.c_str());
|
||
range_.SetCurSel(n);
|
||
|
||
// default value ...
|
||
|
||
// depend item ...
|
||
SetDlgItemText(IDC_EDIT_LOGIC, sop.depend.c_str());
|
||
n = true;
|
||
parent_.EnableWindow(n);
|
||
logic_.EnableWindow(n);
|
||
depends_.EnableWindow(n);
|
||
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(n);
|
||
//GetDlgItem(IDC_EDIT_LOW)->EnableWindow(n);
|
||
//GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_SHOW);
|
||
//GetDlgItem(IDC_COMBO_LOW)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_STATIC_AND)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_EDIT_BIG)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_COMBO_BIG)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_BUTTON_SET)->EnableWindow(sop.range_type != L"none");
|
||
|
||
parent_.ResetContent();
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == sop.name)
|
||
continue;
|
||
|
||
parent_.AddString(v.title.c_str());
|
||
}
|
||
|
||
OnCbnDataTypeSelchange();
|
||
OnCbnRangeSelchange();
|
||
OnCbnDependSelchange();
|
||
|
||
// default value ...
|
||
if (sop.type == L"bool")
|
||
{
|
||
bool bv = false;
|
||
for (auto& v : sop.def_val)
|
||
{
|
||
bv = *(bool*)v.val.c_str();
|
||
if (v.cond == "default")
|
||
break;
|
||
}
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
|
||
def_val_.ShowWindow(SW_SHOW);
|
||
def_val_.ResetContent();
|
||
def_val_.AddString(L"false");
|
||
def_val_.AddString(L"true");
|
||
def_val_.SetCurSel(def_val_.FindStringExact(-1, bv ? L"true" : L"false"));
|
||
}
|
||
else if (sop.type == L"int")
|
||
{
|
||
int nv = 0;
|
||
for (auto& v : sop.def_val)
|
||
{
|
||
nv = *(int*)v.val.c_str();
|
||
if (v.cond == "default")
|
||
break;
|
||
}
|
||
if (sop.range_type == L"list")
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
|
||
def_val_.ShowWindow(SW_SHOW);
|
||
def_val_.ResetContent();
|
||
for (auto& v : sop.range)
|
||
{
|
||
def_val_.AddString(std::to_wstring(*(int*)v.val.c_str()).c_str());
|
||
}
|
||
def_val_.SetCurSel(def_val_.FindStringExact(-1, std::to_wstring(nv).c_str()));
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_SHOW);
|
||
SetDlgItemInt(IDC_EDIT_DEFAULT, nv);
|
||
def_val_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
else if (sop.type == L"float")
|
||
{
|
||
double dbv = 0;
|
||
for (auto& v : sop.def_val)
|
||
{
|
||
dbv = *(double*)v.val.c_str();
|
||
if (v.cond == "default")
|
||
break;
|
||
}
|
||
if (sop.range_type == L"list")
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
|
||
def_val_.ShowWindow(SW_SHOW);
|
||
def_val_.ResetContent();
|
||
for (auto& v : sop.range)
|
||
{
|
||
def_val_.AddString(std::to_wstring(*(double*)v.val.c_str()).c_str());
|
||
}
|
||
def_val_.SetCurSel(def_val_.FindStringExact(-1, std::to_wstring(dbv).c_str()));
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_SHOW);
|
||
SetDlgItemInt(IDC_EDIT_DEFAULT, dbv);
|
||
def_val_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
else if (sop.type == L"string")
|
||
{
|
||
std::wstring strv(L"");
|
||
for (auto& v : sop.def_val)
|
||
{
|
||
strv = (const wchar_t*)v.val.c_str();
|
||
if (v.cond == "default")
|
||
break;
|
||
}
|
||
if (sop.range_type == L"list")
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
|
||
def_val_.ShowWindow(SW_SHOW);
|
||
def_val_.ResetContent();
|
||
for (auto& v : sop.range)
|
||
{
|
||
def_val_.AddString((const wchar_t*)v.val.c_str());
|
||
}
|
||
def_val_.SetCurSel(def_val_.FindStringExact(-1, strv.c_str()));
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_SHOW);
|
||
SetDlgItemText(IDC_EDIT_DEFAULT, strv.c_str());
|
||
def_val_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
}
|
||
HTREEITEM CDlgOptJson::insert_new_item(const SANEOPT& opt, bool sel)
|
||
{
|
||
if (opt.name == L"global")
|
||
return NULL;
|
||
|
||
int fid = known_name::name_to_fix_id(opt.name.c_str());
|
||
if (fid && fid != opt.fix_id)
|
||
{
|
||
std::wstring text(L"fix-id<69><64><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>IDֵ");
|
||
wchar_t buf[40] = { 0 };
|
||
|
||
swprintf_s(buf, _countof(buf) - 1, L" 0x%04X ", fid);
|
||
text += buf;
|
||
text += L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>";
|
||
::MessageBoxW(m_hWnd, text.c_str(), NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
|
||
return NULL;
|
||
}
|
||
|
||
if (opt.fix_id)
|
||
{
|
||
std::string n(known_name::name_from_fix_id(opt.fix_id));
|
||
if (!n.empty() && n != local_trans::u2a(opt.name.c_str(), CP_UTF8))
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Fix-ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", local_trans::a2u(n.c_str(), CP_UTF8).c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
return NULL;
|
||
}
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.fix_id == opt.fix_id)
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Fix-ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", v.title.c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
return NULL;
|
||
}
|
||
else if (v.category == opt.category && v.category == L"ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" && v.pos == opt.pos)
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Position <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", v.title.c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_POSITION));
|
||
return NULL;
|
||
}
|
||
}
|
||
}
|
||
|
||
HTREEITEM item = tree_.InsertItem(opt.title.c_str());
|
||
wchar_t* name = new wchar_t[opt.name.length() + 2];
|
||
|
||
wcscpy(name, opt.name.c_str());
|
||
if (!tree_.SetItemData(item, (DWORD_PTR)name))
|
||
delete[] name;
|
||
|
||
opts_.push_back(opt);
|
||
if (sel)
|
||
{
|
||
tree_.SelectItem(item);
|
||
tree_.EnsureVisible(item);
|
||
}
|
||
|
||
return item;
|
||
}
|
||
void CDlgOptJson::delete_from_tree(const wchar_t* name)
|
||
{
|
||
if (name)
|
||
{
|
||
HTREEITEM item = tree_.GetRootItem();
|
||
while (item)
|
||
{
|
||
wchar_t* buf = (wchar_t*)tree_.GetItemData(item);
|
||
if (buf && wcscmp(buf, name) == 0)
|
||
{
|
||
delete[] buf;
|
||
tree_.DeleteItem(item);
|
||
break;
|
||
}
|
||
|
||
item = tree_.GetNextSiblingItem(item);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
HTREEITEM item = tree_.GetRootItem();
|
||
while (item)
|
||
{
|
||
wchar_t* buf = (wchar_t*)tree_.GetItemData(item);
|
||
if (buf)
|
||
delete[] buf;
|
||
item = tree_.GetNextSiblingItem(item);
|
||
}
|
||
tree_.DeleteAllItems();
|
||
}
|
||
}
|
||
HTREEITEM CDlgOptJson::modify_tree_title(const wchar_t* name, const wchar_t* title)
|
||
{
|
||
HTREEITEM item = tree_.GetRootItem(), found = NULL;
|
||
|
||
while (item)
|
||
{
|
||
wchar_t* buf = (wchar_t*)tree_.GetItemData(item);
|
||
if (buf && wcscmp(buf, name) == 0)
|
||
{
|
||
tree_.SetItemText(item, title);
|
||
found = item;
|
||
break;
|
||
}
|
||
|
||
item = tree_.GetNextSiblingItem(item);
|
||
}
|
||
|
||
return found;
|
||
}
|
||
|
||
bool CDlgOptJson::load_from_file(const wchar_t* path_file)
|
||
{
|
||
std::string cont("");
|
||
std::wstring unic(L"");
|
||
bool ret = false;
|
||
|
||
file_util::load_file(path_file, coding::get_string, &cont);
|
||
coding_util::bom::to_unicode(cont.c_str(), cont.length(), coding::get_wstring, &unic);
|
||
if (unic.length())
|
||
{
|
||
if (!load_from_json_text(unic.c_str()))
|
||
{
|
||
unic = path_file;
|
||
unic.insert(0, L"Parse json file '");
|
||
unic += L"' failed";
|
||
::MessageBoxW(m_hWnd, unic.c_str(), L"Error", MB_OK);
|
||
}
|
||
else
|
||
ret = true;
|
||
}
|
||
|
||
return ret;
|
||
}
|
||
bool CDlgOptJson::load_from_json_text(const wchar_t* txt, std::wstring* err_msg)
|
||
{
|
||
int pos = 0;
|
||
known_file_util::IJsonW* jsn = known_file_util::create_jsonW(txt, &pos), * child = NULL;
|
||
|
||
while (!jsn)
|
||
{
|
||
// try code-text ...
|
||
{
|
||
std::wstring code(txt);
|
||
size_t splash = 0;
|
||
|
||
known_name::erase_trans_letter(code);
|
||
jsn = known_file_util::create_jsonW(&code[0], (int*)&splash);
|
||
if (jsn)
|
||
break;
|
||
}
|
||
|
||
// try device_opt_json
|
||
{
|
||
std::wstring code(txt), tag(L"static std::string device_opt_json[] = {");
|
||
size_t pos = code.find(tag);
|
||
|
||
if (pos == 0)
|
||
{
|
||
code.erase(0, tag.length());
|
||
tag = L"\r\n\t\"";
|
||
while ((pos = code.find(tag)) != std::wstring::npos)
|
||
{
|
||
if (pos > 2 && code[pos - 1] == L',' && code[pos - 2] == L'\"')
|
||
code.erase(pos - 2, tag.length() + 2);
|
||
else
|
||
code.erase(pos, tag.length());
|
||
}
|
||
tag = L"\"\r\n";
|
||
pos = code.find(tag);
|
||
if (pos != std::wstring::npos)
|
||
code.erase(pos);
|
||
known_name::erase_trans_letter(code);
|
||
pos = 0;
|
||
jsn = known_file_util::create_jsonW(&code[0], (int*)&pos);
|
||
}
|
||
if (jsn)
|
||
break;
|
||
}
|
||
|
||
int ep = 10, len = 10;
|
||
if (lstrlenW(txt + pos) < 10)
|
||
len = lstrlenW(txt + pos);
|
||
if (pos < 10)
|
||
{
|
||
ep = pos;
|
||
pos = 10;
|
||
}
|
||
pos -= 10;
|
||
|
||
std::wstring info(txt + pos, len + ep + 1);
|
||
wchar_t msg[80] = { 0 };
|
||
|
||
swprintf_s(msg, L"Error at position %d of char '%c'!\r\n\r\n", ep, info[ep]);
|
||
if (err_msg)
|
||
*err_msg = msg + info;
|
||
else
|
||
::MessageBoxW(m_hWnd, (msg + info).c_str(), L"Load Error", MB_OK);
|
||
|
||
return false;
|
||
}
|
||
|
||
std::wstring group(L"");
|
||
|
||
delete_from_tree();
|
||
opts_.clear();
|
||
child = jsn->first_child();
|
||
while (child)
|
||
{
|
||
SANEOPT opt;
|
||
|
||
if (opt.from_json(child))
|
||
{
|
||
if (opt.type == L"group")
|
||
{
|
||
group = opt.title;
|
||
}
|
||
else
|
||
{
|
||
if(opt.group.empty() && !group.empty())
|
||
opt.group = group;
|
||
insert_new_item(opt, false);
|
||
}
|
||
}
|
||
|
||
child->release();
|
||
child = jsn->next_child();
|
||
}
|
||
jsn->release();
|
||
return true;
|
||
}
|
||
|
||
void CDlgOptJson::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialogEx::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_COMBO_GROUP, group_);
|
||
DDX_Control(pDX, IDC_COMBO_CATEGORY, cat_);
|
||
DDX_Control(pDX, IDC_COMBO_AFFECT, affect_);
|
||
DDX_Control(pDX, IDC_COMBO_UNIT, unit_);
|
||
DDX_Control(pDX, IDC_COMBO_DATA_TYPE, type_);
|
||
DDX_Control(pDX, IDC_COMBO_RANGE, range_);
|
||
DDX_Control(pDX, IDC_COMBO_DEFAULT, def_val_);
|
||
DDX_Control(pDX, IDC_COMBO_DEPEND, depend_);
|
||
DDX_Control(pDX, IDC_COMBO_PARENT, parent_);
|
||
DDX_Control(pDX, IDC_COMBO_LOGIC, logic_);
|
||
DDX_Control(pDX, IDC_COMBO_LOW, lower_);
|
||
DDX_Control(pDX, IDC_COMBO_BIG, upper_);
|
||
DDX_Control(pDX, IDC_COMBO_EXPORT, export_type_);
|
||
DDX_Control(pDX, IDC_COMBO_VISIBLE, visible_);
|
||
DDX_Control(pDX, IDC_LIST_DEPEND, depends_);
|
||
DDX_Control(pDX, IDC_TREE2, tree_);
|
||
}
|
||
BOOL CDlgOptJson::OnInitDialog()
|
||
{
|
||
CDialogEx::OnInitDialog();
|
||
|
||
// Set the icon for this dialog. The framework does this automatically
|
||
// when the application's main window is not a dialog
|
||
group_.SetCurSel(0);
|
||
cat_.SetCurSel(0);
|
||
affect_.SetCurSel(0);
|
||
unit_.SetCurSel(0);
|
||
type_.SetCurSel(0);
|
||
range_.SetCurSel(0);
|
||
def_val_.SetCurSel(0);
|
||
depend_.SetCurSel(0);
|
||
set_button_check(IDC_CHECK_AUTO_RESTORE, true);
|
||
|
||
parent_.EnableWindow(FALSE);
|
||
logic_.EnableWindow(FALSE);
|
||
GetDlgItem(IDC_EDIT_LOW)->EnableWindow(FALSE);
|
||
depends_.EnableWindow(FALSE);
|
||
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(FALSE);
|
||
|
||
BITMAP bmi = { 0 };
|
||
GetObject(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)), sizeof(bmi), &bmi);
|
||
tree_img_.Create(IDB_BITMAP1, bmi.bmWidth / 2, bmi.bmWidth / 2, RGB(255, 255, 255));
|
||
tree_.SetImageList(&tree_img_, TVSIL_NORMAL);
|
||
|
||
tree_menu_.LoadMenu(IDR_MENU1);
|
||
fix_id_edit_.attach(GetDlgItem(IDC_EDIT_FIXED_ID)->m_hWnd);
|
||
|
||
export_type_.SetCurSel(1);
|
||
visible_.SetCurSel(0);
|
||
|
||
tooltips_ = new tooltip_wnd();
|
||
tooltips_->create(m_hWnd);
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_AUTO_RESTORE), L"\u662F\u5426\u652F\u6301\u6062\u590D\u5230\u9ED8\u8BA4\u503C\u7684\u64CD\u4F5C");
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_PUBLIC), L"\u662F\u5426\u5BF9\u666E\u901A\u7528\u6237\u5F00\u653E");
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_COMBO_CATEGORY), L"\u5C5E\u6027\u5206\u7C7B\u3002\u5982\u679C\u4E3A\u56FE\u50CF\u5206\u7C7B\uFF0C\u4F1A\u6309\u7167\u201Cposition\u201D\u503C\u6392\u5E8F\uFF0C\u4EE5\u786E\u5B9A\u6267\u884C\u7684\u5148\u540E\u987A\u5E8F");
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_EDIT_POSITION), L"\u8BE5\u5C5E\u6027\u5728\u6307\u5B9A\u5206\u7C7B\u4E2D\u7684\u6267\u884C\u987A\u5E8F");
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_EDIT_FIXED_ID), L"\u63D0\u4F9B\u8BE5\u503C\uFF0C\u8BE5\u5C5E\u6027\u5373\u53EF\u88ABTWAIN\u534F\u8BAE\u4FA6\u6D4B\u5230");
|
||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_COMBO_GROUP), L"\u8BE5\u5C5E\u6027\u5728\u754C\u9762\u4E0A\u663E\u793A\u65F6\uFF0C\u6240\u5F52\u5C5E\u7684\u5206\u7EC4\u540D\u79F0");
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnDestroy()
|
||
{
|
||
CDialogEx::OnDestroy();
|
||
|
||
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
delete_from_tree();
|
||
}
|
||
|
||
BEGIN_MESSAGE_MAP(CDlgOptJson, CDialogEx)
|
||
ON_WM_PASTE()
|
||
ON_CBN_SELCHANGE(IDC_COMBO_DATA_TYPE, &CDlgOptJson::OnCbnDataTypeSelchange)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_RANGE, &CDlgOptJson::OnCbnRangeSelchange)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_DEPEND, &CDlgOptJson::OnCbnDependSelchange)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_PARENT, &CDlgOptJson::OnCbnParentSelchange)
|
||
ON_CBN_SELCHANGE(IDC_COMBO_LOGIC, &CDlgOptJson::OnCbnLogicSelchange)
|
||
ON_BN_CLICKED(IDC_BUTTON_MODIFY, &CDlgOptJson::OnBnClickedButtonModify)
|
||
ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgOptJson::OnBnClickedButtonAdd)
|
||
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE2, &CDlgOptJson::OnTvnSelchangedTree2)
|
||
ON_NOTIFY(NM_RCLICK, IDC_TREE2, &CDlgOptJson::OnNMRClickTree2)
|
||
ON_NOTIFY(TVN_SELCHANGING, IDC_TREE2, &CDlgOptJson::OnTvnSelchangingTree2)
|
||
ON_COMMAND(ID_TREE_LOADFILE, &CDlgOptJson::OnTreeLoadfile)
|
||
ON_COMMAND(ID_TREE_LOADCLIPBOARD, &CDlgOptJson::OnTreeLoadclipboard)
|
||
ON_LBN_DBLCLK(IDC_LIST_DEPEND, &CDlgOptJson::OnLbnDblclkListDepend)
|
||
ON_BN_CLICKED(IDC_BUTTON_SET, &CDlgOptJson::OnBnClickedButtonSet)
|
||
ON_COMMAND(ID_TREE_DELITEM, &CDlgOptJson::OnTreeDelitem)
|
||
ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CDlgOptJson::OnBnClickedButtonExport)
|
||
ON_COMMAND(ID_TREE_MODIFYALLFIELD, &CDlgOptJson::OnTreeModifyallfield)
|
||
ON_COMMAND(ID_SORT_NAME, &CDlgOptJson::OnSortName)
|
||
ON_COMMAND(ID_SORT_TITLE, &CDlgOptJson::OnSortTitle)
|
||
ON_COMMAND(ID_SORT_GROUP, &CDlgOptJson::OnSortGroup)
|
||
ON_COMMAND(ID_SORT_POSITION, &CDlgOptJson::OnSortPosition)
|
||
ON_BN_CLICKED(IDC_BUTTON_SHOWUI, &CDlgOptJson::OnBnClickedButtonShowui)
|
||
ON_WM_DESTROY()
|
||
END_MESSAGE_MAP()
|
||
|
||
|
||
// CDlgOptJson message handlers
|
||
void CDlgOptJson::OnCbnSelchange()
|
||
{
|
||
|
||
}
|
||
void CDlgOptJson::OnCbnDataTypeSelchange()
|
||
{
|
||
std::wstring val(get_item_text(IDC_COMBO_DATA_TYPE));
|
||
|
||
range_.EnableWindow();
|
||
if (val == L"bool")
|
||
{
|
||
range_.SetCurSel(range_.FindStringExact(-1, L"none"));
|
||
OnCbnRangeSelchange();
|
||
range_.EnableWindow(FALSE);
|
||
}
|
||
|
||
if (val == L"bool" || val == L"int")
|
||
{
|
||
SetDlgItemInt(IDC_EDIT_SIZE, sizeof(int));
|
||
GetDlgItem(IDC_EDIT_SIZE)->EnableWindow(FALSE);
|
||
}
|
||
else if (val == L"float")
|
||
{
|
||
SetDlgItemInt(IDC_EDIT_SIZE, sizeof(double));
|
||
GetDlgItem(IDC_EDIT_SIZE)->EnableWindow(FALSE);
|
||
}
|
||
else // if (val == L"string")
|
||
{
|
||
int size = val == L"string" ? 16 : 4;
|
||
std::wstring n(get_item_text(IDC_EDIT_NAME));
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == n)
|
||
{
|
||
size = v.size;
|
||
break;
|
||
}
|
||
}
|
||
SetDlgItemInt(IDC_EDIT_SIZE, size);
|
||
GetDlgItem(IDC_EDIT_SIZE)->EnableWindow(TRUE);
|
||
}
|
||
}
|
||
void CDlgOptJson::OnCbnRangeSelchange()
|
||
{
|
||
std::wstring val(get_item_text(IDC_COMBO_RANGE)),
|
||
type(get_item_text(IDC_COMBO_DATA_TYPE));
|
||
|
||
GetDlgItem(IDC_BUTTON_SET)->EnableWindow(val != L"none");
|
||
if (val == L"list" || type == L"bool")
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_COMBO_DEFAULT)->ShowWindow(SW_SHOW);
|
||
def_val_.ResetContent();
|
||
if (type == L"bool")
|
||
{
|
||
def_val_.AddString(L"false");
|
||
def_val_.AddString(L"true");
|
||
def_val_.SetCurSel(0);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_DEFAULT)->ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_COMBO_DEFAULT)->ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
void CDlgOptJson::OnCbnDependSelchange()
|
||
{
|
||
std::wstring val(get_item_text(IDC_COMBO_DEPEND));
|
||
|
||
val = L"and";
|
||
parent_.EnableWindow(val != L"none");
|
||
logic_.EnableWindow(val != L"none");
|
||
depends_.EnableWindow(val != L"none");
|
||
lower_.EnableWindow(val != L"none");
|
||
upper_.EnableWindow(val != L"none");
|
||
|
||
GetDlgItem(IDC_BUTTON_ADD)->EnableWindow(val != L"none");
|
||
GetDlgItem(IDC_EDIT_LOW)->EnableWindow(val != L"none");
|
||
GetDlgItem(IDC_EDIT_BIG)->EnableWindow(val != L"none");
|
||
|
||
if (val != L"none")
|
||
{
|
||
val = get_item_text(IDC_EDIT_NAME);
|
||
parent_.ResetContent();
|
||
for (auto& v : opts_)
|
||
{
|
||
if (val == v.name)
|
||
continue;
|
||
parent_.AddString(v.title.c_str());
|
||
}
|
||
}
|
||
}
|
||
void CDlgOptJson::OnCbnParentSelchange()
|
||
{
|
||
std::wstring val(get_item_text(IDC_COMBO_PARENT));
|
||
SANEOPT opt;
|
||
|
||
for (auto& v : opts_)
|
||
{
|
||
if (val == v.title)
|
||
{
|
||
opt = v;
|
||
break;
|
||
}
|
||
}
|
||
|
||
logic_.ResetContent();
|
||
logic_.AddString(L"enabled");
|
||
logic_.AddString(L"!enabled");
|
||
if (opt.type == L"bool")
|
||
{
|
||
logic_.AddString(L"==");
|
||
logic_.SetCurSel(0);
|
||
OnCbnLogicSelchange();
|
||
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_HIDE);
|
||
lower_.ShowWindow(SW_SHOW);
|
||
lower_.ResetContent();
|
||
lower_.AddString(L"false");
|
||
lower_.AddString(L"true");
|
||
lower_.SetCurSel(0);
|
||
}
|
||
else if (opt.type == L"int" || opt.type == L"float")
|
||
{
|
||
logic_.AddString(L"==");
|
||
logic_.AddString(L"!=");
|
||
logic_.AddString(L"<");
|
||
logic_.AddString(L"<=");
|
||
logic_.AddString(L">");
|
||
logic_.AddString(L">=");
|
||
logic_.AddString(L"between");
|
||
logic_.AddString(L"out of");
|
||
logic_.SetCurSel(0);
|
||
OnCbnLogicSelchange();
|
||
|
||
if (opt.range_type == L"list")
|
||
{
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_HIDE);
|
||
lower_.ShowWindow(SW_SHOW);
|
||
lower_.ResetContent();
|
||
upper_.ResetContent();
|
||
|
||
if (opt.type == L"int")
|
||
{
|
||
for (auto& v : opt.range)
|
||
{
|
||
std::wstring val(std::to_wstring(*(int*)v.val.c_str()));
|
||
lower_.AddString(val.c_str());
|
||
upper_.AddString(val.c_str());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (auto& v : opt.range)
|
||
{
|
||
std::wstring val(std::to_wstring(*(double*)v.val.c_str()));
|
||
lower_.AddString(val.c_str());
|
||
upper_.AddString(val.c_str());
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_SHOW);
|
||
lower_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
else if (opt.type == L"string")
|
||
{
|
||
logic_.AddString(L"==");
|
||
logic_.AddString(L"!=");
|
||
logic_.SetCurSel(0);
|
||
OnCbnLogicSelchange();
|
||
|
||
if (opt.range_type == L"list")
|
||
{
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_HIDE);
|
||
lower_.ShowWindow(SW_SHOW);
|
||
lower_.ResetContent();
|
||
for (auto& v : opt.range)
|
||
{
|
||
std::wstring val((const wchar_t*)v.val.c_str());
|
||
lower_.AddString(val.c_str());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_SHOW);
|
||
lower_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
}
|
||
void CDlgOptJson::OnCbnLogicSelchange()
|
||
{
|
||
std::wstring val(get_item_text(IDC_COMBO_LOGIC));
|
||
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_SHOW);
|
||
lower_.ShowWindow(SW_SHOW);
|
||
|
||
if (val == L"enabled" || val == L"!enabled")
|
||
{
|
||
GetDlgItem(IDC_STATIC_AND)->ShowWindow(SW_HIDE);
|
||
|
||
GetDlgItem(IDC_EDIT_LOW)->ShowWindow(SW_HIDE);
|
||
lower_.ShowWindow(SW_HIDE);
|
||
|
||
GetDlgItem(IDC_EDIT_BIG)->ShowWindow(SW_HIDE);
|
||
upper_.ShowWindow(SW_HIDE);
|
||
}
|
||
else if (val == L"between" || val == L"out of")
|
||
{
|
||
GetDlgItem(IDC_STATIC_AND)->ShowWindow(SW_SHOW);
|
||
// upper_.ShowWindow(SW_SHOW);
|
||
|
||
val = get_item_text(IDC_COMBO_PARENT);
|
||
for (auto& v : opts_)
|
||
{
|
||
if (val == v.title)
|
||
{
|
||
val = v.range_type;
|
||
break;
|
||
}
|
||
}
|
||
if (val == L"list")
|
||
{
|
||
upper_.ShowWindow(SW_SHOW);
|
||
GetDlgItem(IDC_EDIT_BIG)->ShowWindow(SW_HIDE);
|
||
}
|
||
else
|
||
{
|
||
upper_.ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_EDIT_BIG)->ShowWindow(SW_SHOW);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDC_STATIC_AND)->ShowWindow(SW_HIDE);
|
||
GetDlgItem(IDC_EDIT_BIG)->ShowWindow(SW_HIDE);
|
||
upper_.ShowWindow(SW_HIDE);
|
||
}
|
||
}
|
||
|
||
void CDlgOptJson::OnPaste()
|
||
{
|
||
coding::CLPD clpb;
|
||
|
||
file_util::get_clipboard(coding::get_clipboard_content, &clpb);
|
||
if (clpb.cont.empty())
|
||
{
|
||
MessageBox(TEXT("clipboard is empty."));
|
||
return;
|
||
}
|
||
|
||
if (clpb.file)
|
||
{
|
||
size_t pos = clpb.cont.find(L"\r\n");
|
||
bool loaded = false;
|
||
|
||
while (!loaded && pos != std::wstring::npos)
|
||
{
|
||
loaded = load_from_file(clpb.cont.substr(0, pos).c_str());
|
||
clpb.cont.erase(0, pos + 2);
|
||
pos = clpb.cont.find(L"\r\n");
|
||
}
|
||
if (!loaded && file_util::is_file_existing(clpb.cont.c_str()))
|
||
load_from_file(clpb.cont.c_str());
|
||
}
|
||
else
|
||
{
|
||
std::wstring err(L"");
|
||
if (load_from_json_text(clpb.cont.c_str(), &err))
|
||
return;
|
||
|
||
// we assum the content from codes ...
|
||
std::wstring jsn(L"");
|
||
size_t pos = clpb.cont.find(L" std::string");
|
||
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
clpb.cont.erase(0, pos);
|
||
pos = clpb.cont.find(L"\"");
|
||
if (pos == std::wstring::npos)
|
||
break;
|
||
clpb.cont.erase(0, pos + 1);
|
||
pos = clpb.cont.find(L"\");");
|
||
if (pos == std::wstring::npos)
|
||
{
|
||
jsn += clpb.cont;
|
||
break;
|
||
}
|
||
else
|
||
jsn += clpb.cont.substr(0, pos);
|
||
clpb.cont.erase(0, pos);
|
||
pos = clpb.cont.find(L" std::string");
|
||
}
|
||
|
||
if (jsn.length())
|
||
{
|
||
pos = jsn.find(L"\\\\");
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
jsn.erase(pos++, 1);
|
||
pos = jsn.find(L"\\\\", pos);
|
||
}
|
||
pos = jsn.find(L"\\\"");
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
jsn.erase(pos++, 1);
|
||
pos = jsn.find(L"\\\"", pos);
|
||
}
|
||
|
||
load_from_json_text(jsn.c_str());
|
||
}
|
||
else
|
||
::MessageBoxW(m_hWnd, err.c_str(), L"Load Error", MB_OK);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
void CDlgOptJson::OnBnClickedButtonModify()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
SANEOPT sop;
|
||
|
||
from_ui(sop);
|
||
if (sop.fix_id > 0 && sop.fix_id < 0x8800)
|
||
{
|
||
::MessageBoxW(m_hWnd, L"Fix-ID <20><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>0x8800<30><30><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ֵ<EFBFBD><D6B5>", NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
return;
|
||
}
|
||
|
||
if (sop.name.empty() || sop.title.empty())
|
||
{
|
||
MessageBox(TEXT("Name and Title must input!"));
|
||
return;
|
||
}
|
||
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.title == sop.title && v.name != sop.name)
|
||
{
|
||
if (::MessageBoxW(m_hWnd, (L"\u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A\u201C" + v.title + L"\u201D\u7684\u914D\u7F6E\u9879\uFF01\uFF0C\u60F3\u4FEE\u6539Name\u5B57\u6BB5\u5417\uFF1F").c_str(), L"Error", MB_ICONSTOP | MB_YESNO) == IDYES)
|
||
{
|
||
sop.range = std::move(v.range);
|
||
v = std::move(sop);
|
||
}
|
||
return;
|
||
}
|
||
}
|
||
|
||
int fid = known_name::name_to_fix_id(sop.name.c_str());
|
||
if (fid && fid != sop.fix_id)
|
||
{
|
||
std::wstring text(L"fix-id<69><64><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>IDֵ");
|
||
wchar_t buf[40] = { 0 };
|
||
|
||
swprintf_s(buf, _countof(buf) - 1, L" 0x%04X ", fid);
|
||
text += buf;
|
||
text += L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>";
|
||
::MessageBoxW(m_hWnd, text.c_str(), NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
|
||
return;
|
||
}
|
||
|
||
if (sop.fix_id)
|
||
{
|
||
std::string n(known_name::name_from_fix_id(sop.fix_id));
|
||
if (!n.empty() && n != local_trans::u2a(sop.name.c_str(), CP_UTF8))
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Fix-ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", local_trans::a2u(n.c_str(), CP_UTF8).c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
return ;
|
||
}
|
||
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.fix_id == sop.fix_id)
|
||
{
|
||
if (v.name != sop.name)
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Fix-ID <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", v.title.c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_FIXED_ID));
|
||
return;
|
||
}
|
||
}
|
||
else if (v.category == sop.category && v.category == L"ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" && v.pos == sop.pos)
|
||
{
|
||
wchar_t info[128] = { 0 };
|
||
swprintf_s(info, _countof(info) - 1, L"Position <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԡ<EFBFBD>%s<><73><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>", v.title.c_str());
|
||
::MessageBoxW(m_hWnd, info, NULL, MB_OK);
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_POSITION));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == sop.name)
|
||
{
|
||
sop.range = std::move(v.range);
|
||
v = std::move(sop);
|
||
modify_tree_title(v.name.c_str(), v.title.c_str());
|
||
return;
|
||
}
|
||
}
|
||
|
||
insert_new_item(sop);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnBnClickedButtonAdd()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - add depend items
|
||
//std::wstring opt(get_item_text(IDC_COMBO_PARENT)),
|
||
// logic(get_item_text(IDC_COMBO_LOGIC)),
|
||
// l(L""), u(L"");
|
||
//int ind = 0;
|
||
//
|
||
//for (auto& v : opts_)
|
||
//{
|
||
// if (v.title == opt)
|
||
// {
|
||
// opt = v.name;
|
||
// break;
|
||
// }
|
||
//}
|
||
//
|
||
//if (lower_.IsWindowVisible())
|
||
// l = get_item_text(IDC_COMBO_LOW);
|
||
//else
|
||
// l = get_item_text(IDC_EDIT_LOW);
|
||
//
|
||
//if (upper_.IsWindowVisible())
|
||
// u = get_item_text(IDC_COMBO_BIG);
|
||
//else if (GetDlgItem(IDC_EDIT_BIG)->IsWindowVisible())
|
||
// u = get_item_text(IDC_EDIT_BIG);
|
||
//
|
||
//if (logic == L"enabled" || logic == L"!enabled")
|
||
//{
|
||
// opt += L"." + logic;
|
||
//}
|
||
//else if (logic == L"between")
|
||
//{
|
||
// opt += L"==[" + l + L"," + u + L"]";
|
||
//}
|
||
//else if (logic == L"out of")
|
||
//{
|
||
// opt += L"!=[" + l + L"," + u + L"]";
|
||
//}
|
||
//else
|
||
//{
|
||
// opt += logic + l;
|
||
//}
|
||
//
|
||
//u = get_item_text(IDC_EDIT_LOGIC);
|
||
//if (!u.empty())
|
||
// u += L" || ";
|
||
//u += opt;
|
||
//SetDlgItemText(IDC_EDIT_LOGIC, u.c_str());
|
||
//
|
||
//ind = depends_.FindStringExact(-1, opt.c_str());
|
||
//if (ind == -1)
|
||
//{
|
||
// ind = depends_.AddString(opt.c_str());
|
||
//}
|
||
//depends_.SetCurSel(ind);
|
||
|
||
std::wstring text(get_item_text(IDC_EDIT_LOGIC)), name(get_item_text(IDC_EDIT_NAME));
|
||
CDlgCondition dlg(name.c_str());
|
||
|
||
auto get_opts = [&](int ind, int* type, int* range, std::wstring * name) -> std::wstring
|
||
{
|
||
if(ind < 0 || ind >= opts_.size())
|
||
return L"";
|
||
|
||
if (type)
|
||
{
|
||
if (opts_[ind].type == L"bool")
|
||
*type = SANE_TYPE_BOOL;
|
||
else if (opts_[ind].type == L"int")
|
||
*type = SANE_TYPE_INT;
|
||
else if (opts_[ind].type == L"float")
|
||
*type = SANE_TYPE_FIXED;
|
||
else if (opts_[ind].type == L"string")
|
||
*type = SANE_TYPE_STRING;
|
||
else if (opts_[ind].type == L"group")
|
||
*type = SANE_TYPE_GROUP;
|
||
else if (opts_[ind].type == L"button")
|
||
*type = SANE_TYPE_BUTTON;
|
||
else
|
||
*type = SANE_TYPE_INT;
|
||
}
|
||
if (range)
|
||
{
|
||
if (opts_[ind].range_type == L"range")
|
||
*range = SANE_CONSTRAINT_RANGE;
|
||
else if (opts_[ind].range_type == L"list")
|
||
*range = SANE_CONSTRAINT_STRING_LIST;
|
||
else
|
||
*range = SANE_CONSTRAINT_NONE;
|
||
}
|
||
if (name)
|
||
*name = opts_[ind].name;
|
||
|
||
return opts_[ind].title;
|
||
};
|
||
auto get_range = [&](const wchar_t* name, int ind) -> std::wstring
|
||
{
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == name)
|
||
{
|
||
if (ind >= 0 && ind < v.range.size())
|
||
{
|
||
if (v.type == L"bool")
|
||
return *(bool*)&v.range[ind].val[0] ? L"true" : L"false";
|
||
else if (v.type == L"int")
|
||
return std::to_wstring(*(int*)&v.range[ind].val[0]);
|
||
else if (v.type == L"float")
|
||
return std::to_wstring(*(double*)&v.range[ind].val[0]);
|
||
else if (v.type == L"string")
|
||
return (const wchar_t*)v.range[ind].val.c_str();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
return L"";
|
||
};
|
||
|
||
dlg.init_data(get_opts, get_range, text.c_str());
|
||
if (dlg.DoModal() == IDOK)
|
||
SetDlgItemText(IDC_EDIT_LOGIC, dlg.get_condition().c_str());
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTvnSelchangedTree2(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM item = tree_.GetSelectedItem();
|
||
|
||
if (item)
|
||
{
|
||
TVITEM tvi;
|
||
|
||
tvi.mask = TVIF_SELECTEDIMAGE;
|
||
tvi.iSelectedImage = 1;
|
||
tvi.hItem = item;
|
||
tree_.SetItem(&tvi);
|
||
|
||
wchar_t* name = (wchar_t*)tree_.GetItemData(item);
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == name)
|
||
{
|
||
to_ui(v);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnNMRClickTree2(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*pResult = 0;
|
||
|
||
POINT pt = { 0 };
|
||
HTREEITEM hsel = tree_.GetSelectedItem();
|
||
|
||
tree_menu_.EnableMenuItem(ID_TREE_ADDGROUP, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_ADDITEM, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_ADDPRODUCT, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_DELITEM, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_RENAME, MF_DISABLED);
|
||
|
||
tree_menu_.EnableMenuItem(ID_TREE_TOOLTIPS, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_EXPORTCHAR, MF_DISABLED);
|
||
tree_menu_.EnableMenuItem(ID_TREE_UNIFYSEQUENCE, MF_DISABLED);
|
||
|
||
if (hsel)
|
||
{
|
||
tree_menu_.EnableMenuItem(ID_TREE_DELITEM, MF_ENABLED);
|
||
}
|
||
|
||
GetCursorPos(&pt);
|
||
tree_menu_.GetSubMenu(0)->TrackPopupMenu(0, pt.x, pt.y, this);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTvnSelchangingTree2(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM hsel = tree_.GetSelectedItem();
|
||
|
||
if (hsel)
|
||
{
|
||
|
||
}
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTreeLoadfile()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
file_util::PATHFILE path = { 0 };
|
||
|
||
if (file_util::browser_file(m_hWnd, &path))
|
||
{
|
||
load_from_file(path.path);
|
||
}
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTreeLoadclipboard()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
OnPaste();
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnLbnDblclkListDepend()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
int sel = depends_.GetCurSel();
|
||
|
||
if (sel >= 0 && sel < depends_.GetCount())
|
||
depends_.DeleteString(sel);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnBnClickedButtonSet()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
std::wstring val(get_item_text(IDC_COMBO_RANGE)), name(get_item_text(IDC_EDIT_NAME));
|
||
CDlgRange dlg(name.c_str(), val == L"list", this);
|
||
SANEOPT opt;
|
||
|
||
val = get_item_text(IDC_EDIT_NAME);
|
||
if (val.empty())
|
||
{
|
||
MessageBox(TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ψһ<EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>Name<EFBFBD>ֶ<EFBFBD>ֵ<EFBFBD><EFBFBD>"));
|
||
GotoDlgCtrl(GetDlgItem(IDC_EDIT_NAME));
|
||
return;
|
||
}
|
||
opt.name = val;
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == val)
|
||
{
|
||
opt = v;
|
||
break;
|
||
}
|
||
}
|
||
val = get_item_text(IDC_COMBO_DATA_TYPE);
|
||
if (!opt.name.empty())
|
||
{
|
||
if (val == L"int")
|
||
{
|
||
for (auto& v : opt.def_val)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = std::to_wstring(*(int*)v.val.c_str());
|
||
dlg.init_.push_back(cv);
|
||
}
|
||
|
||
for (auto& v : opt.range)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = std::to_wstring(*(int*)v.val.c_str());
|
||
dlg.vals_.push_back(cv);
|
||
}
|
||
}
|
||
else if (val == L"float")
|
||
{
|
||
for (auto& v : opt.def_val)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = std::to_wstring(*(double*)v.val.c_str());
|
||
dlg.init_.push_back(cv);
|
||
}
|
||
|
||
for (auto& v : opt.range)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = std::to_wstring(*(double*)v.val.c_str());
|
||
dlg.vals_.push_back(cv);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
int len = 0;
|
||
for (auto& v : opt.def_val)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = (const wchar_t*)v.val.c_str();
|
||
if (len < cv.val.length())
|
||
len = cv.val.length();
|
||
dlg.init_.push_back(cv);
|
||
}
|
||
|
||
for (auto& v : opt.range)
|
||
{
|
||
CDlgRange::CONDVAL cv;
|
||
cv.cond = local_trans::a2u(v.cond.c_str(), CP_UTF8);
|
||
cv.val = (const wchar_t*)v.val.c_str();
|
||
if (len < cv.val.length())
|
||
len = cv.val.length();
|
||
dlg.vals_.push_back(cv);
|
||
}
|
||
|
||
len += 4;
|
||
len *= 3;
|
||
SetDlgItemInt(IDC_EDIT_SIZE, len);
|
||
}
|
||
}
|
||
|
||
auto get_opts = [&](int ind, int* type, int* range, std::wstring* name) -> std::wstring
|
||
{
|
||
if (ind < 0 || ind >= opts_.size())
|
||
return L"";
|
||
|
||
if (type)
|
||
{
|
||
if (opts_[ind].type == L"bool")
|
||
*type = SANE_TYPE_BOOL;
|
||
else if (opts_[ind].type == L"int")
|
||
*type = SANE_TYPE_INT;
|
||
else if (opts_[ind].type == L"float")
|
||
*type = SANE_TYPE_FIXED;
|
||
else if (opts_[ind].type == L"string")
|
||
*type = SANE_TYPE_STRING;
|
||
else if (opts_[ind].type == L"group")
|
||
*type = SANE_TYPE_GROUP;
|
||
else if (opts_[ind].type == L"button")
|
||
*type = SANE_TYPE_BUTTON;
|
||
else
|
||
*type = SANE_TYPE_INT;
|
||
}
|
||
if (range)
|
||
{
|
||
if (opts_[ind].range_type == L"range")
|
||
*range = SANE_CONSTRAINT_RANGE;
|
||
else if (opts_[ind].range_type == L"list")
|
||
*range = SANE_CONSTRAINT_STRING_LIST;
|
||
else
|
||
*range = SANE_CONSTRAINT_NONE;
|
||
}
|
||
if (name)
|
||
*name = opts_[ind].name;
|
||
|
||
return opts_[ind].title;
|
||
};
|
||
auto get_range = [&](const wchar_t* name, int ind) -> std::wstring
|
||
{
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == name)
|
||
{
|
||
if (ind >= 0 && ind < v.range.size())
|
||
{
|
||
if (v.type == L"bool")
|
||
return *(bool*)&v.range[ind].val[0] ? L"true" : L"false";
|
||
else if (v.type == L"int")
|
||
return std::to_wstring(*(int*)&v.range[ind].val[0]);
|
||
else if (v.type == L"float")
|
||
return std::to_wstring(*(double*)&v.range[ind].val[0]);
|
||
else if (v.type == L"string")
|
||
return (const wchar_t*)v.range[ind].val.c_str();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
return L"";
|
||
};
|
||
|
||
|
||
dlg.set_init_val_api(INIT_VAL_API_PROTO(), get_opts, get_range);
|
||
|
||
if (dlg.DoModal() == IDOK)
|
||
{
|
||
opt.def_val.clear();
|
||
|
||
if (val == L"int")
|
||
{
|
||
for (auto& v : dlg.init_)
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
|
||
int n = _wtoi(v.val.c_str());
|
||
cv.val = std::string((char*)&n, sizeof(n));
|
||
opt.def_val.push_back(cv);
|
||
}
|
||
|
||
opt.range.clear();
|
||
for (auto& v : dlg.vals_)
|
||
{
|
||
CONDVAL cv;
|
||
|
||
int n = _wtoi(v.val.c_str());
|
||
cv.val = std::string((char*)&n, sizeof(n));
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
opt.range.push_back(cv);
|
||
}
|
||
}
|
||
else if (val == L"float")
|
||
{
|
||
for (auto& v : dlg.init_)
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
|
||
double n = _wtof(v.val.c_str());
|
||
cv.val = std::string((char*)&n, sizeof(n));
|
||
opt.def_val.push_back(cv);
|
||
}
|
||
|
||
opt.range.clear();
|
||
for (auto& v : dlg.vals_)
|
||
{
|
||
CONDVAL cv;
|
||
|
||
double n = _wtof(v.val.c_str());
|
||
cv.val = std::string((char*)&n, sizeof(n));
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
opt.range.push_back(cv);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
for (auto& v : dlg.init_)
|
||
{
|
||
CONDVAL cv;
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
cv.val = std::string((const char*)v.val.c_str(), v.val.length() * 2 + 2);
|
||
opt.def_val.push_back(cv);
|
||
}
|
||
|
||
opt.range.clear();
|
||
for (auto& v : dlg.vals_)
|
||
{
|
||
CONDVAL cv;
|
||
|
||
cv.val = std::string((const char*)v.val.c_str(), v.val.length() * 2 + 2);
|
||
cv.cond = local_trans::u2a(v.cond.c_str(), CP_UTF8);
|
||
opt.range.push_back(cv);
|
||
}
|
||
}
|
||
|
||
// add or insert ...
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == opt.name)
|
||
{
|
||
from_ui(v);
|
||
v.range = opt.range;
|
||
v.def_val = opt.def_val;
|
||
to_ui(v);
|
||
return;
|
||
}
|
||
}
|
||
|
||
SANEOPT so;
|
||
|
||
from_ui(so);
|
||
so.range = opt.range;
|
||
so.def_val = opt.def_val;
|
||
insert_new_item(so);
|
||
to_ui(so);
|
||
}
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTreeDelitem()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM item = tree_.GetSelectedItem();
|
||
|
||
if (item)
|
||
{
|
||
CString text(tree_.GetItemText(item));
|
||
|
||
if (MessageBox(TEXT("ȷ<EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"), text.GetBuffer(), MB_YESNO) == IDYES)
|
||
{
|
||
wchar_t* buf = (wchar_t*)tree_.GetItemData(item);
|
||
tree_.DeleteItem(item);
|
||
if (buf)
|
||
{
|
||
for (int i = 0; i < opts_.size(); ++i)
|
||
{
|
||
if (opts_[i].name == buf)
|
||
{
|
||
opts_.erase(opts_.begin() + i);
|
||
break;
|
||
}
|
||
}
|
||
delete[] buf;
|
||
}
|
||
}
|
||
text.ReleaseBuffer();
|
||
}
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnBnClickedButtonExport()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
std::wstring type(get_item_text(IDC_COMBO_EXPORT)),
|
||
cont(get_json_text(type == L"\u683C\u5F0F\u6587\u672C" ? L"\t" : NULL));
|
||
|
||
if (cont.empty())
|
||
{
|
||
MessageBox(TEXT("No content has been serialized! change exporting type and try again."), NULL, MB_OK | MB_ICONERROR);
|
||
return;
|
||
}
|
||
|
||
if (type == L"\u4EE3\u7801\u6587\u672C")
|
||
{
|
||
size_t pos = cont.find(L"\\");
|
||
|
||
while (pos++ != std::wstring::npos)
|
||
{
|
||
cont.insert(pos++, L"\\");
|
||
pos = cont.find(L"\\", pos);
|
||
}
|
||
|
||
pos = cont.find(L"\"");
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
cont.insert(pos, L"\\");
|
||
pos = cont.find(L"\"", pos + 2);
|
||
}
|
||
|
||
// segmention up to 10 * 1024
|
||
int line_len = 10 * 1024,
|
||
ind = 0;
|
||
std::wstring pre(L"static std::string device_opt_json[] = {\r\n\t\"");
|
||
|
||
cont.insert(0, pre);
|
||
pos = pre.length();
|
||
while (cont.length() - pos > line_len)
|
||
{
|
||
if (cont[pos + line_len - 1] == L'\\')
|
||
{
|
||
pos--;
|
||
while (cont[pos + line_len] == L'\\')
|
||
pos--;
|
||
}
|
||
|
||
pos += line_len;
|
||
cont.insert(pos, L"\",\r\n\t\"");
|
||
pos += 5; // ");\r\n
|
||
}
|
||
cont += L"\"\r\n};\r\n";
|
||
}
|
||
else if (type == L"\u5916\u90E8\u914D\u7F6E.hsc")
|
||
{
|
||
std::wstring name(L"\u8BF7\u75284\u4F4DPID\u66FF\u6362.hsc");
|
||
std::string txt(local_trans::u2a(cont.c_str(), CP_UTF8)), ansi("");
|
||
wchar_t path[MAX_PATH] = { 0 };
|
||
|
||
GetModuleFileNameW(NULL, path, _countof(path) - 1);
|
||
wcsrchr(path, L'\\')[1] = 0;
|
||
name.insert(0, path);
|
||
ansi = local_trans::u2a(name.c_str(), CP_ACP);
|
||
if (save_scanner_setting(ansi.c_str(), txt) == 0)
|
||
file_util::display_file_in_explorer(name.c_str());
|
||
|
||
return;
|
||
}
|
||
|
||
int n = file_util::set_clipboard(cont.c_str(), cont.length() * 2, CF_UNICODETEXT);
|
||
MessageBox(TEXT("JSON text has set to clipboard already"), std::to_wstring(cont.length()).c_str());
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnTreeModifyallfield()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// Group;Category;Affect;Version;Position;Readonly;Public;Enabled;Depends;
|
||
std::wstring name(get_item_text(IDC_EDIT_NAME));
|
||
CDlgRange dlg(name.c_str(), CDlgRange::TYPE_FIELDS, this);
|
||
|
||
auto init_val = [&](const wchar_t* field, CComboBox* box) -> void
|
||
{
|
||
std::wstring n(field);
|
||
wchar_t text[256] = { 0 };
|
||
int l = 0;
|
||
|
||
box->ResetContent();
|
||
box->EnableWindow(); // 0x50010302
|
||
// ::SetWindowLong(box->m_hWnd, GWL_STYLE, (LONG)0x50010302);
|
||
if (n == L"Group")
|
||
{
|
||
for (int i = 0; i < group_.GetCount(); ++i)
|
||
{
|
||
l = group_.GetLBText(i, text);
|
||
text[l] = 0;
|
||
box->AddString(text);
|
||
}
|
||
}
|
||
else if (n == L"Category")
|
||
{
|
||
for (int i = 0; i < cat_.GetCount(); ++i)
|
||
{
|
||
l = cat_.GetLBText(i, text);
|
||
text[l] = 0;
|
||
box->AddString(text);
|
||
}
|
||
}
|
||
else if (n == L"Depends")
|
||
{
|
||
box->AddString(L"none");
|
||
box->SetCurSel(0);
|
||
box->EnableWindow(FALSE);
|
||
}
|
||
else if (n == L"Affect")
|
||
{
|
||
for (int i = 0; i < affect_.GetCount(); ++i)
|
||
{
|
||
l = affect_.GetLBText(i, text);
|
||
text[l] = 0;
|
||
box->AddString(text);
|
||
}
|
||
}
|
||
else if (n == L"Version")
|
||
{
|
||
box->AddString(L"1");
|
||
box->SetCurSel(0);
|
||
}
|
||
else if (n == L"Position")
|
||
{
|
||
box->AddString(L"-1");
|
||
box->SetCurSel(0);
|
||
}
|
||
else if (n == L"Readonly")
|
||
{
|
||
box->AddString(L"false");
|
||
box->AddString(L"true");
|
||
//::SetWindowLong(box->m_hWnd, GWL_STYLE, (LONG)0x50010203);
|
||
}
|
||
else if (n == L"Public")
|
||
{
|
||
box->AddString(L"false");
|
||
box->AddString(L"true");
|
||
//::SetWindowLong(box->m_hWnd, GWL_STYLE, (LONG)0x50010203);
|
||
}
|
||
else if (n == L"Enabled")
|
||
{
|
||
box->AddString(L"false");
|
||
box->AddString(L"true");
|
||
//::SetWindowLong(box->m_hWnd, GWL_STYLE, (LONG)0x50010203);
|
||
}
|
||
};
|
||
auto get_opts = [&](int ind, int* type, int* range, std::wstring* name) -> std::wstring
|
||
{
|
||
if (ind < 0 || ind >= opts_.size())
|
||
return L"";
|
||
|
||
if (type)
|
||
{
|
||
if (opts_[ind].type == L"bool")
|
||
*type = SANE_TYPE_BOOL;
|
||
else if (opts_[ind].type == L"int")
|
||
*type = SANE_TYPE_INT;
|
||
else if (opts_[ind].type == L"float")
|
||
*type = SANE_TYPE_FIXED;
|
||
else if (opts_[ind].type == L"string")
|
||
*type = SANE_TYPE_STRING;
|
||
else if (opts_[ind].type == L"group")
|
||
*type = SANE_TYPE_GROUP;
|
||
else if (opts_[ind].type == L"button")
|
||
*type = SANE_TYPE_BUTTON;
|
||
else
|
||
*type = SANE_TYPE_INT;
|
||
}
|
||
if (range)
|
||
{
|
||
if (opts_[ind].range_type == L"range")
|
||
*range = SANE_CONSTRAINT_RANGE;
|
||
else if (opts_[ind].range_type == L"list")
|
||
*range = SANE_CONSTRAINT_STRING_LIST;
|
||
else
|
||
*range = SANE_CONSTRAINT_NONE;
|
||
}
|
||
if (name)
|
||
*name = opts_[ind].name;
|
||
|
||
return opts_[ind].title;
|
||
};
|
||
auto get_range = [&](const wchar_t* name, int ind) -> std::wstring
|
||
{
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == name)
|
||
{
|
||
if (ind >= 0 && ind < v.range.size())
|
||
{
|
||
if (v.type == L"bool")
|
||
return *(bool*)&v.range[ind].val[0] ? L"true" : L"false";
|
||
else if (v.type == L"int")
|
||
return std::to_wstring(*(int*)&v.range[ind].val[0]);
|
||
else if (v.type == L"float")
|
||
return std::to_wstring(*(double*)&v.range[ind].val[0]);
|
||
else if (v.type == L"string")
|
||
return (const wchar_t*)v.range[ind].val.c_str();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
return L"";
|
||
};
|
||
|
||
|
||
dlg.set_init_val_api(init_val, get_opts, get_range);
|
||
if (dlg.DoModal() == IDOK)
|
||
{
|
||
std::wstring n(dlg.vals_[0].val),
|
||
val(dlg.init_[0].val);
|
||
|
||
if (n == L"Group")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.group = val;
|
||
}
|
||
else if (n == L"Category")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.category = val;
|
||
}
|
||
else if (n == L"Depends")
|
||
{
|
||
//for (auto& v : opts_)
|
||
// v.depend_oper = val;
|
||
}
|
||
else if (n == L"Affect")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.affect = val;
|
||
}
|
||
else if (n == L"Version")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.ver = _wtoi(val.c_str());
|
||
}
|
||
else if (n == L"Position")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.pos = _wtoi(val.c_str());
|
||
}
|
||
else if (n == L"Readonly")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.readonly = val == L"true";
|
||
}
|
||
else if (n == L"Public")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.open = val == L"true";
|
||
}
|
||
else if (n == L"Enabled")
|
||
{
|
||
for (auto& v : opts_)
|
||
v.enable = val == L"true";
|
||
}
|
||
|
||
HTREEITEM sel = tree_.GetSelectedItem();
|
||
if (sel)
|
||
{
|
||
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||
for (auto& v : opts_)
|
||
{
|
||
if (v.name == n)
|
||
{
|
||
to_ui(v);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnSortName()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM sel = tree_.GetSelectedItem();
|
||
std::wstring name(L"");
|
||
std::vector<SANEOPT> all(std::move(opts_));
|
||
|
||
std::sort(all.begin(), all.end(), SANEOPT::compare_name);
|
||
if (sel)
|
||
{
|
||
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||
if (n)
|
||
name = n;
|
||
}
|
||
|
||
delete_from_tree();
|
||
for (auto& v : all)
|
||
insert_new_item(v, v.name == name);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnSortTitle()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM sel = tree_.GetSelectedItem();
|
||
std::wstring name(L"");
|
||
std::vector<SANEOPT> all(std::move(opts_));
|
||
|
||
std::sort(all.begin(), all.end(), SANEOPT::compare_title);
|
||
if (sel)
|
||
{
|
||
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||
if (n)
|
||
name = n;
|
||
}
|
||
|
||
delete_from_tree();
|
||
for (auto& v : all)
|
||
insert_new_item(v, v.name == name);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnSortGroup()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM sel = tree_.GetSelectedItem();
|
||
std::wstring name(L"");
|
||
std::vector<SANEOPT> all(std::move(opts_));
|
||
|
||
std::sort(all.begin(), all.end(), SANEOPT::compare_group);
|
||
if (sel)
|
||
{
|
||
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||
if (n)
|
||
name = n;
|
||
}
|
||
|
||
delete_from_tree();
|
||
for (auto& v : all)
|
||
insert_new_item(v, v.name == name);
|
||
}
|
||
|
||
|
||
void CDlgOptJson::OnSortPosition()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EEB4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
HTREEITEM sel = tree_.GetSelectedItem();
|
||
std::wstring name(L"");
|
||
std::vector<SANEOPT> all(std::move(opts_));
|
||
|
||
std::sort(all.begin(), all.end(), SANEOPT::compare_position);
|
||
if (sel)
|
||
{
|
||
wchar_t* n = (wchar_t*)tree_.GetItemData(sel);
|
||
if (n)
|
||
name = n;
|
||
}
|
||
|
||
delete_from_tree();
|
||
for (auto& v : all)
|
||
insert_new_item(v, v.name == name);
|
||
}
|
||
|
||
|
||
|
||
|
||
namespace test_sane_ui
|
||
{
|
||
typedef struct _sane_objects
|
||
{
|
||
device_option dev_opt;
|
||
device_opts sane_opt;
|
||
}SANEOBJ, *LPSANEOBJ;
|
||
static void print_err(const char* msg)
|
||
{
|
||
std::string err("Error: ");
|
||
|
||
err += msg;
|
||
err += "\r\n";
|
||
OutputDebugStringA(err.c_str());
|
||
}
|
||
|
||
|
||
SANE_Status sane_get_devices_api(const SANE_Device*** device_list, SANE_Bool local_only)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_open_api(SANE_String_Const devicename, SANE_Handle* handle)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
void sane_close_api(SANE_Handle handle)
|
||
{}
|
||
const SANE_Option_Descriptor* sane_get_option_descriptor_api(SANE_Handle handle, SANE_Int option)
|
||
{
|
||
LPSANEOBJ sane = (LPSANEOBJ)handle;
|
||
|
||
return sane->sane_opt.get_opt_descriptor((void*)option);
|
||
}
|
||
SANE_Status sane_control_option_api(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info)
|
||
{
|
||
LPSANEOBJ sane = (LPSANEOBJ)handle;
|
||
SANE_Option_Descriptor* desc = sane->sane_opt.get_opt_descriptor((void*)option);
|
||
|
||
if (action == SANE_ACTION_SET_VALUE)
|
||
{
|
||
bool modify = sane->dev_opt.refine_data(desc->name, value);
|
||
int err = sane->dev_opt.update_data(desc->name, value);
|
||
|
||
if (err == SCANNER_ERR_RELOAD_OPT_PARAM)
|
||
{
|
||
std::string text(sane->dev_opt.get_option_value(nullptr, OPT_VAL_JSON));
|
||
sane->sane_opt.init_from(text.c_str(), print_err);
|
||
err = 0;
|
||
if (info)
|
||
*info = SANE_INFO_RELOAD_OPTIONS;
|
||
}
|
||
}
|
||
else if (action == SANE_ACTION_GET_VALUE)
|
||
{
|
||
std::string val(sane->dev_opt.get_option_value(desc->name, OPT_VAL_CURRENT));
|
||
if (desc->type == SANE_TYPE_FIXED)
|
||
{
|
||
SANE_Fixed sf = SANE_FIX(*(double*)&val[0]);
|
||
val = std::string((char*)&sf, sizeof(sf));
|
||
}
|
||
memcpy(value, val.c_str(), val.length());
|
||
}
|
||
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_get_parameters_api(SANE_Handle handle, SANE_Parameters* params)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_start_api(SANE_Handle handle)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_read_api(SANE_Handle handle, SANE_Byte* data, SANE_Int max_length, SANE_Int* length)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
void sane_cancel_api(SANE_Handle handle)
|
||
{
|
||
}
|
||
SANE_Status sane_set_io_mode_api(SANE_Handle handle, SANE_Bool non_blocking)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_get_select_fd_api(SANE_Handle handle, SANE_Int* fd)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_String_Const sane_strstatus_api(SANE_Status status)
|
||
{
|
||
return "";
|
||
}
|
||
SANE_Status sane_io_control_api(SANE_Handle h, unsigned long code, void* data, unsigned* len)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
SANE_Status sane_init_api(SANE_Int* version_code, SANE_Auth_Callback authorize)
|
||
{
|
||
return SANE_STATUS_GOOD;
|
||
}
|
||
void sane_exit_api(void)
|
||
{}
|
||
|
||
void init_api(LPSANEAPI api)
|
||
{
|
||
#define SET_API(to) api->##to = to;
|
||
|
||
SET_API(sane_cancel_api);
|
||
SET_API(sane_close_api);
|
||
SET_API(sane_control_option_api);
|
||
SET_API(sane_exit_api);
|
||
SET_API(sane_get_devices_api);
|
||
SET_API(sane_get_option_descriptor_api);
|
||
SET_API(sane_get_parameters_api);
|
||
SET_API(sane_get_select_fd_api);
|
||
SET_API(sane_init_api);
|
||
SET_API(sane_io_control_api);
|
||
SET_API(sane_open_api);
|
||
SET_API(sane_read_api);
|
||
SET_API(sane_set_io_mode_api);
|
||
SET_API(sane_start_api);
|
||
SET_API(sane_strstatus_api);
|
||
}
|
||
}
|
||
void CDlgOptJson::OnBnClickedButtonShowui()
|
||
{
|
||
// TODO: <20>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD>ӿؼ<D3BF>֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
std::wstring text(get_json_text());
|
||
std::string utf8(local_trans::u2a(text.c_str(), CP_UTF8));
|
||
test_sane_ui::SANEOBJ sane;
|
||
|
||
{
|
||
gb_json* jsn = new gb_json();
|
||
|
||
if (jsn->attach_text(&utf8[0]))
|
||
{
|
||
std::string tmp(jsn->to_string()), cp("");
|
||
int cmp = strcmp(utf8.c_str(), tmp.c_str());
|
||
|
||
for (int i = 0; i < 10; ++i)
|
||
{
|
||
if (jsn->attach_text(&tmp[0]))
|
||
{
|
||
cp = jsn->to_string();
|
||
cmp = strcmp(cp.c_str(), tmp.c_str());
|
||
}
|
||
}
|
||
}
|
||
jsn->release();
|
||
}
|
||
|
||
int n = file_util::set_clipboard(text.c_str(), text.length() * 2, CF_UNICODETEXT);
|
||
text.clear();
|
||
if (sane.dev_opt.init(utf8.c_str()))
|
||
{
|
||
utf8 = sane.dev_opt.get_option_value(nullptr, OPT_VAL_JSON);
|
||
if (sane.sane_opt.init_from(utf8.c_str(), test_sane_ui::print_err))
|
||
{
|
||
SANEAPI api = { 0 };
|
||
|
||
test_sane_ui::init_api(&api);
|
||
{
|
||
dlg_setting dlg(::GetParent(m_hWnd), &api, (SANE_Handle)&sane, false, L"Test");
|
||
|
||
dlg.do_modal(::GetParent(m_hWnd));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|