增加属性计数显示
This commit is contained in:
parent
412f741b2e
commit
78bd8ba4c5
|
@ -1461,6 +1461,7 @@ HTREEITEM CDlgOptJson::insert_new_item(const SANEOPT& opt, bool sel)
|
|||
tree_.SelectItem(item);
|
||||
tree_.EnsureVisible(item);
|
||||
}
|
||||
update_opt_count();
|
||||
|
||||
return item;
|
||||
}
|
||||
|
@ -1474,8 +1475,16 @@ void CDlgOptJson::delete_from_tree(const wchar_t* name)
|
|||
wchar_t* buf = (wchar_t*)tree_.GetItemData(item);
|
||||
if (buf && wcscmp(buf, name) == 0)
|
||||
{
|
||||
delete[] buf;
|
||||
tree_.DeleteItem(item);
|
||||
for (int i = 0; i < opts_.size(); ++i)
|
||||
{
|
||||
if (opts_[i].name == buf)
|
||||
{
|
||||
opts_.erase(opts_.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete[] buf;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1493,7 +1502,10 @@ void CDlgOptJson::delete_from_tree(const wchar_t* name)
|
|||
item = tree_.GetNextSiblingItem(item);
|
||||
}
|
||||
tree_.DeleteAllItems();
|
||||
opts_.clear();
|
||||
}
|
||||
|
||||
update_opt_count();
|
||||
}
|
||||
HTREEITEM CDlgOptJson::modify_tree_title(const wchar_t* name, const wchar_t* title)
|
||||
{
|
||||
|
@ -1514,6 +1526,18 @@ HTREEITEM CDlgOptJson::modify_tree_title(const wchar_t* name, const wchar_t* tit
|
|||
|
||||
return found;
|
||||
}
|
||||
void CDlgOptJson::update_opt_count(void)
|
||||
{
|
||||
wchar_t hz_num[] = { L"0123456789" }, text[10] = { 0 }, *cur = text + _countof(text) - 2;
|
||||
int cnt = opts_.size();
|
||||
|
||||
do
|
||||
{
|
||||
*cur-- = hz_num[cnt % 10];
|
||||
cnt /= 10;
|
||||
} while (cnt > 0);
|
||||
SetDlgItemText(IDC_STATIC_CNT, cur + 1);
|
||||
}
|
||||
|
||||
bool CDlgOptJson::load_from_file(const wchar_t* path_file)
|
||||
{
|
||||
|
@ -1735,6 +1759,8 @@ BEGIN_MESSAGE_MAP(CDlgOptJson, CDialogEx)
|
|||
ON_COMMAND(ID_SORT_POSITION, &CDlgOptJson::OnSortPosition)
|
||||
ON_BN_CLICKED(IDC_BUTTON_SHOWUI, &CDlgOptJson::OnBnClickedButtonShowui)
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_CTLCOLOR()
|
||||
ON_MESSAGE(WM_CTLCOLORSTATIC, &CDlgOptJson::OnStaticColor)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
@ -2642,26 +2668,12 @@ void CDlgOptJson::OnTreeDelitem()
|
|||
|
||||
if (item)
|
||||
{
|
||||
CString text(tree_.GetItemText(item));
|
||||
wchar_t* name = (wchar_t*)tree_.GetItemData(item);
|
||||
|
||||
if (MessageBox(TEXT("确定要删除该项配置吗?"), text.GetBuffer(), MB_YESNO) == IDYES)
|
||||
if (MessageBox(TEXT("确定要删除该项配置吗?"), name, 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;
|
||||
}
|
||||
delete_from_tree(name);
|
||||
}
|
||||
text.ReleaseBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2946,6 +2958,26 @@ void CDlgOptJson::OnTreeModifyallfield()
|
|||
}
|
||||
|
||||
|
||||
HBRUSH CDlgOptJson::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||||
{
|
||||
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
|
||||
|
||||
// TODO: 在此更改 DC 的任何特性
|
||||
|
||||
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
|
||||
return hbr;
|
||||
}
|
||||
|
||||
|
||||
LRESULT CDlgOptJson::OnStaticColor(WPARAM wp, LPARAM lp)
|
||||
{
|
||||
::SetBkMode((HDC)wp, TRANSPARENT);
|
||||
if (GetDlgItem(IDC_STATIC_CNT)->m_hWnd == (HWND)lp)
|
||||
::SetTextColor((HDC)wp, RGB(192, 64, 240));
|
||||
|
||||
return (LRESULT)GetSysColorBrush(COLOR_3DFACE);
|
||||
}
|
||||
|
||||
void CDlgOptJson::OnSortName()
|
||||
{
|
||||
// TODO: 在此添加命令处理程序代码
|
||||
|
|
|
@ -165,6 +165,7 @@ protected:
|
|||
HTREEITEM insert_new_item(const SANEOPT& opt, bool sel = true);
|
||||
void delete_from_tree(const wchar_t* name = NULL);
|
||||
HTREEITEM modify_tree_title(const wchar_t* name, const wchar_t* title);
|
||||
void update_opt_count(void);
|
||||
|
||||
bool load_from_file(const wchar_t* path_file);
|
||||
bool load_from_json_text(const wchar_t* txt, std::wstring* err_msg = NULL);
|
||||
|
@ -196,4 +197,6 @@ public:
|
|||
afx_msg void OnSortPosition();
|
||||
afx_msg void OnBnClickedButtonShowui();
|
||||
afx_msg void OnDestroy();
|
||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
||||
afx_msg LRESULT OnStaticColor(WPARAM wp, LPARAM lp);
|
||||
};
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue