-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui_config.cpp
352 lines (322 loc) · 12.6 KB
/
ui_config.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
#include "ui_config.h"
#include "ui_accounts.h"
#include "ui_categories.h"
#include "ui_about.h"
#include "ui_imexport.h"
#include "ui_password.h"
#include "ui_backup.h"
#include "m8cash.h"
#include <cMzCommon.h>
using namespace cMzCommon;
MZ_IMPLEMENT_DYNAMIC(Ui_ConfigWnd)
#define MZ_IDC_TOOLBAR_CONFIG 101
#define MZ_IDC_CONFIG_SCROLLWIN 104
#define MZ_IDC_BUTTON_CFG_RESET 105
#define MZ_IDC_BUTTON_CFG_IMPORT 106
#define MZ_IDC_BUTTON_CFG_EXPORT 107
#define MZ_IDC_BUTTON_SET_PASSWORD 108
#define MZ_IDC_BUTTON_CFG_BACKUP 109
#define MZ_IDC_BUTTON_CFG_OPTIMIZE 110
#define MZ_IDC_BUTTON_CFG_CATLEVEL 111
#define MZ_IDC_BTN_AUTOLOCK 112
#define IDC_PPM_CANCEL 100
BOOL Ui_ConfigWnd::OnInitDialog() {
// Must all the Init of parent class first!
if (!CMzWndEx::OnInitDialog()) {
return FALSE;
}
// Then init the controls & other things in the window
int y = 0;
m_ScrollWin.SetPos(0, 0, GetWidth(), GetHeight() - MZM_HEIGHT_TEXT_TOOLBAR);
m_ScrollWin.SetID(MZ_IDC_CONFIG_SCROLLWIN);
m_ScrollWin.EnableScrollBarV(true);
AddUiWin(&m_ScrollWin);
//set the right image of the extended button m_BtnSetting1
m_BtnExport.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnExport.SetText(LOADSTRING(IDS_STR_IMPORT).C_Str());
m_BtnExport.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnExport.SetID(MZ_IDC_BUTTON_CFG_IMPORT);
m_ScrollWin.AddChild(&m_BtnExport);
m_BtnExport.SetImage2(imgArrow);
m_BtnExport.SetImageWidth2(imgArrow->GetImageWidth());
m_BtnExport.SetShowImage2(true);
m_BtnExport.SetImage1(pimg[IDB_PNG_EXPORT - IDB_PNG_CALC]);
m_BtnExport.SetImageWidth1(pimg[IDB_PNG_EXPORT - IDB_PNG_CALC]->GetImageWidth());
m_BtnExport.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
m_BtnImport.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnImport.SetText(LOADSTRING(IDS_STR_EXPORT).C_Str());
m_BtnImport.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnImport.SetID(MZ_IDC_BUTTON_CFG_EXPORT);
m_ScrollWin.AddChild(&m_BtnImport);
m_BtnImport.SetImage2(imgArrow);
m_BtnImport.SetImageWidth2(imgArrow->GetImageWidth());
m_BtnImport.SetShowImage2(true);
m_BtnImport.SetImage1(pimg[IDB_PNG_IMPORT - IDB_PNG_CALC]);
m_BtnImport.SetImageWidth1(pimg[IDB_PNG_IMPORT - IDB_PNG_CALC]->GetImageWidth());
m_BtnImport.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
m_BtnBackup.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnBackup.SetText(LOADSTRING(IDS_STR_BACKUP_DB).C_Str());
m_BtnBackup.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnBackup.SetID(MZ_IDC_BUTTON_CFG_BACKUP);
m_BtnBackup.SetTextMaxLen(0);
m_ScrollWin.AddChild(&m_BtnBackup);
m_BtnBackup.SetImage2(imgArrow);
m_BtnBackup.SetImageWidth2(imgArrow->GetImageWidth());
m_BtnBackup.SetShowImage2(true);
m_BtnBackup.SetImage1(pimg[IDB_PNG_BACKUP - IDB_PNG_CALC]);
m_BtnBackup.SetImageWidth1(pimg[IDB_PNG_BACKUP - IDB_PNG_CALC]->GetImageWidth());
m_BtnBackup.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
m_BtnSetPassword.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnSetPassword.SetText(LOADSTRING(IDS_STR_SETUP_PWD).C_Str());
m_BtnSetPassword.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnSetPassword.SetID(MZ_IDC_BUTTON_SET_PASSWORD);
m_BtnSetPassword.SetImage2(imgArrow);
m_BtnSetPassword.SetImageWidth2(imgArrow->GetImageWidth());
m_BtnSetPassword.SetShowImage2(true);
m_BtnSetPassword.SetTextMaxLen(0);
m_ScrollWin.AddChild(&m_BtnSetPassword);
m_BtnSetPassword.SetImage1(pimg[IDB_PNG_ENCRYPT - IDB_PNG_CALC]);
m_BtnSetPassword.SetImageWidth1(pimg[IDB_PNG_ENCRYPT - IDB_PNG_CALC]->GetImageWidth());
m_BtnSetPassword.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
c_expend_level = appconfig.IniCategoryExpandLevel.Get();
m_BtnCategoryExpand.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnCategoryExpand.SetText(LOADSTRING(IDS_STR_CONFIG_CATEGORY_EXPAND).C_Str());
m_BtnCategoryExpand.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnCategoryExpand.SetID(MZ_IDC_BUTTON_CFG_CATLEVEL);
m_BtnCategoryExpand.SetImage2(imgArrow);
m_BtnCategoryExpand.SetImageWidth2(imgArrow->GetImageWidth());
m_BtnCategoryExpand.SetShowImage2(true);
m_BtnCategoryExpand.SetTextMaxLen(0);
wchar_t strlevel[2] = {c_expend_level + 0x30, 0};
m_BtnCategoryExpand.SetText2(strlevel);
m_ScrollWin.AddChild(&m_BtnCategoryExpand);
m_BtnCategoryExpand.SetImage1(pimg[IDB_PNG_CATEGORY - IDB_PNG_CALC]);
m_BtnCategoryExpand.SetImageWidth1(pimg[IDB_PNG_CATEGORY - IDB_PNG_CALC]->GetImageWidth());
m_BtnCategoryExpand.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
m_BtnResetAll.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnResetAll.SetTextMaxLen(0);
m_BtnResetAll.SetText(LOADSTRING(IDS_STR_RECOVER_ALARM).C_Str());
m_BtnResetAll.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnResetAll.SetID(MZ_IDC_BUTTON_CFG_RESET);
m_ScrollWin.AddChild(&m_BtnResetAll);
m_BtnResetAll.SetImage1(pimg[IDB_PNG_RELOADALERT - IDB_PNG_CALC]);
m_BtnResetAll.SetImageWidth1(pimg[IDB_PNG_RELOADALERT - IDB_PNG_CALC]->GetImageWidth());
m_BtnResetAll.SetShowImage1(true);
y += MZM_HEIGHT_BUTTONEX;
m_BtnOptimize.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
m_BtnOptimize.SetTextMaxLen(0);
m_BtnOptimize.SetText(LOADSTRING(IDS_STR_OPTDB).C_Str());
m_BtnOptimize.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
m_BtnOptimize.SetID(MZ_IDC_BUTTON_CFG_OPTIMIZE);
m_ScrollWin.AddChild(&m_BtnOptimize);
m_BtnOptimize.SetImage1(pimg[IDB_PNG_OPTIMIZE - IDB_PNG_BEGIN]);
m_BtnOptimize.SetImageWidth1(pimg[IDB_PNG_OPTIMIZE - IDB_PNG_BEGIN]->GetImageWidth());
m_BtnOptimize.SetShowImage1(true);
y+=MZM_HEIGHT_BUTTONEX;
m_BtnAutoLock.SetPos(0,y,GetWidth(),MZM_HEIGHT_BUTTONEX);
m_BtnAutoLock.SetText(LOADSTRING(IDS_STR_CONFIG_AUTOLOCK).C_Str());
m_BtnAutoLock.SetImage1(pimg[IDB_PNG_LOGIN - IDB_PNG_CALC]);
m_BtnAutoLock.SetImageWidth1(pimg[IDB_PNG_LOGIN - IDB_PNG_CALC]->GetImageWidth());
m_BtnAutoLock.SetID(MZ_IDC_BTN_AUTOLOCK);
m_BtnAutoLock.SetShowImage1(true);
m_ScrollWin.AddChild(&m_BtnAutoLock);
m_Toolbar.SetPos(0, GetHeight() - MZM_HEIGHT_TEXT_TOOLBAR, GetWidth(), MZM_HEIGHT_TEXT_TOOLBAR);
m_Toolbar.SetButton(0, true, true, LOADSTRING(IDS_STR_RETURN).C_Str());
m_Toolbar.EnableLeftArrow(true);
m_Toolbar.SetButton(2, true, true, LOADSTRING(IDS_STR_ABOUT).C_Str());
m_Toolbar.SetID(MZ_IDC_TOOLBAR_CONFIG);
AddUiWin(&m_Toolbar);
updateAutolock();
return TRUE;
}
void Ui_ConfigWnd::updateAutolock(){
if(g_bencypt){
m_BtnAutoLock.SetVisible(true);
DWORD lock = appconfig.IniAutolock.Get();
WORD locktype = LOWORD(lock);
if(locktype != 0){
m_BtnAutoLock.SetSwitchStatus(TRUE);
WORD locktimeout = HIWORD(lock);
if(locktimeout > 1){
wchar_t s[16];
if(locktimeout < 60){
wsprintf(s,L"%d %s",locktimeout,LOADSTRING(IDS_STR_SECONDS).C_Str());
}else{
wsprintf(s,L"%d %s",locktimeout/60,LOADSTRING(IDS_STR_MIN).C_Str());
}
m_BtnAutoLock.SetText2(s);
}else{
m_BtnAutoLock.SetText2(LOADSTRING(IDS_STR_AUTOLOCK_IMM).C_Str());
}
}else{
m_BtnAutoLock.SetSwitchStatus(FALSE);
m_BtnAutoLock.SetText2(LOADSTRING(IDS_STR_DISABLED).C_Str());
}
}else{
m_BtnAutoLock.SetVisible(false);
}
m_BtnAutoLock.Invalidate();
}
void Ui_ConfigWnd::OnMzCommand(WPARAM wParam, LPARAM lParam) {
int nRet;
RECT rcWork;
Ui_AccountsWnd accountdlg;
Ui_CategoriesWnd catdlg;
UINT_PTR id = LOWORD(wParam);
switch (id) {
case MZ_IDC_BUTTON_CFG_EXPORT:
{
Ui_ImExportWnd dlg;
rcWork = MzGetWorkArea();
dlg.setMode(false);
dlg.Create(rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork),
m_hWnd, 0, WS_POPUP);
// set the animation of the window
dlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_RIGHT_TO_LEFT_2);
dlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_LEFT_TO_RIGHT_1);
nRet = dlg.DoModal();
if (nRet == ID_OK) {
//...
}
break;
}
case MZ_IDC_BUTTON_CFG_IMPORT:
{
Ui_ImExportWnd dlg;
rcWork = MzGetWorkArea();
dlg.setMode(true);
dlg.Create(rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork),
m_hWnd, 0, WS_POPUP);
// set the animation of the window
dlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_RIGHT_TO_LEFT_2);
dlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_LEFT_TO_RIGHT_1);
nRet = dlg.DoModal();
if (nRet == ID_OK) {
//...
}
break;
}
case MZ_IDC_BUTTON_CFG_BACKUP:
{
Ui_BackupWnd dlg;
rcWork = MzGetWorkArea();
dlg.Create(rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork),
m_hWnd, 0, WS_POPUP);
// set the animation of the window
dlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_RIGHT_TO_LEFT_2);
dlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_LEFT_TO_RIGHT_1);
nRet = dlg.DoModal();
if (nRet == ID_OK) {
//...
}
break;
}
case MZ_IDC_TOOLBAR_CONFIG:
{
int nIndex = lParam;
if (nIndex == 0) {
// exit the modal dialog
EndModal(ID_CANCEL);
return;
}
if (nIndex == 2) {//about
//about
UI_AboutWnd dlg;
rcWork = MzGetWorkArea();
dlg.Create(rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork),
m_hWnd, 0, WS_POPUP);
// set the animation of the window
dlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_RIGHT_TO_LEFT_2);
dlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_LEFT_TO_RIGHT_1);
nRet = dlg.DoModal();
return;
}
}
case MZ_IDC_BUTTON_SET_PASSWORD:
{
Ui_PasswordWnd dlg;
rcWork = MzGetWorkArea();
dlg.setMode(1);
dlg.Create(rcWork.left, rcWork.top, RECT_WIDTH(rcWork), RECT_HEIGHT(rcWork),
m_hWnd, 0, WS_POPUP);
// set the animation of the window
dlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_RIGHT_TO_LEFT_2);
dlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_LEFT_TO_RIGHT_1);
nRet = dlg.DoModal();
if (nRet == ID_OK) {
//
updateAutolock();
}
break;
}
case MZ_IDC_BUTTON_CFG_RESET:
{
if(MzMessageBoxEx(m_hWnd,
LOADSTRING(IDS_STR_WARN_ALARM_RESTORE).C_Str(),
LOADSTRING(IDS_STR_CONFIRM).C_Str(),MZ_YESNO,false) == 1){
cash_reminder.clearReminder();
cash_reminder.loadReminderList();
cash_reminder.recoverReminder();
cash_reminder.saveReminderList();
MzMessageAutoBoxV2(m_hWnd,LOADSTRING(IDS_STR_ALARM_RESTORE_S).C_Str());
}
break;
}
case MZ_IDC_BUTTON_CFG_OPTIMIZE:
{
MzBeginWaitDlg(m_hWnd,NULL,TRUE);
cash_db.reorgDatebase();
MzMessageAutoBoxV2(m_hWnd,LOADSTRING(IDS_STR_DB_OPT_S).C_Str());
MzEndWaitDlg();
break;
}
case MZ_IDC_BUTTON_CFG_CATLEVEL:
{
c_expend_level++;
if(c_expend_level > 2) c_expend_level = 0;
wchar_t strlevel[2] = {c_expend_level + 0x30, 0};
m_BtnCategoryExpand.SetText2(strlevel);
m_BtnCategoryExpand.Invalidate();
appconfig.IniCategoryExpandLevel.Set(c_expend_level);
break;
}
case MZ_IDC_BTN_AUTOLOCK + 0x100:
if(appconfig.IniAutolock.Get()){
appconfig.IniAutolock.Set(0);
updateAutolock();
break;
}
case MZ_IDC_BTN_AUTOLOCK:
{
UINT AutoLockTimeOut[] = {1,15,30,60,300};
wchar_t sTimeout[32];
//创建新弹出菜单对象
MzPopupMenu PopupMenu;
//设置弹出菜单的标题
PopupMenu.SetMenuTitle(LOADSTRING(IDS_STR_AUTOLOCK_TIP).C_Str());
for(int i = 0; i < sizeof(AutoLockTimeOut)/sizeof(AutoLockTimeOut[0]); i++){
if(AutoLockTimeOut[i] <= 1){
wsprintf(sTimeout,L"%s",LOADSTRING(IDS_STR_AUTOLOCK_IMM).C_Str());
}else{
if(AutoLockTimeOut[i] < 60){
wsprintf(sTimeout,L"%d %s",AutoLockTimeOut[i],LOADSTRING(IDS_STR_SECONDS).C_Str());
}else{
wsprintf(sTimeout,L"%d %s",AutoLockTimeOut[i]/60,LOADSTRING(IDS_STR_MIN).C_Str());
}
}
PopupMenu.AppendMenuItem(MZV2_MID_MIN + i + 1,sTimeout);
}
int result = PopupMenu.MzTrackPopupMenu(m_hWnd, TRUE);
if(result > MZV2_MID_MIN){
appconfig.IniAutolock.Set(MAKELONG(1,AutoLockTimeOut[result - MZV2_MID_MIN - 1]));
updateAutolock();
}
break;
}
}
}