|
| |
23 |
23 |
#include "RuleEditAlreadyExistsDlg.h" |
|
|
| |
24 |
24 |
#include "RuleEditErrorDlg.h" |
|
|
| |
25 |
25 |
#include "RuleEditNotEnoughSpaceDlg.h" |
|
| |
|
26 |
#include <type_traits> |
|
|
| |
|
27 |
#include <functional> |
|
|
| |
26 |
28 |
|
|
|
| |
27 |
29 |
#ifdef _DEBUG |
|
|
| |
28 |
30 |
#define new DEBUG_NEW |
| |
|
|
| |
33 |
35 |
using namespace string; |
|
|
| |
34 |
36 |
using namespace chengine; |
|
|
| |
35 |
37 |
|
|
| |
|
38 |
namespace |
|
|
| |
|
39 |
{ |
|
|
| |
|
40 |
template<class RuleList> |
|
|
| |
|
41 |
void OnUpButton(RuleEditDlg* pDlg, CListCtrl& ctlList, RuleList& ruleList, std::function<void(RuleEditDlg*)> reloadList) |
|
|
| |
|
42 |
{ |
|
|
| |
|
43 |
POSITION pos = ctlList.GetFirstSelectedItemPosition(); |
|
|
| |
|
44 |
if(pos == nullptr) |
|
|
| |
|
45 |
return; |
|
|
| |
|
46 |
|
|
|
| |
|
47 |
int iItem = ctlList.GetNextSelectedItem(pos); |
|
|
| |
|
48 |
if(iItem < 1) |
|
|
| |
|
49 |
return; |
|
|
| |
|
50 |
|
|
|
| |
|
51 |
|
|
|
| |
|
52 |
auto rRule = ruleList.GetAt(iItem); |
|
|
| |
|
53 |
|
|
|
| |
|
54 |
|
|
|
| |
|
55 |
ctlList.DeleteItem(iItem); |
|
|
| |
|
56 |
ruleList.RemoveAt(iItem); |
|
|
| |
|
57 |
|
|
|
| |
|
58 |
|
|
|
| |
|
59 |
ruleList.InsertAt(iItem - 1, rRule); |
|
|
| |
|
60 |
reloadList(pDlg); |
|
|
| |
|
61 |
|
|
|
| |
|
62 |
ctlList.SetItemState(iItem - 1, LVIS_SELECTED, LVIS_SELECTED); |
|
|
| |
|
63 |
} |
|
|
| |
|
64 |
|
|
|
| |
|
65 |
template<class RuleList> |
|
|
| |
|
66 |
void OnDownButton(RuleEditDlg* pDlg, CListCtrl& ctlList, RuleList& ruleList, std::function<void(RuleEditDlg*)> reloadList) |
|
|
| |
|
67 |
{ |
|
|
| |
|
68 |
POSITION pos = ctlList.GetFirstSelectedItemPosition(); |
|
|
| |
|
69 |
if(pos == nullptr) |
|
|
| |
|
70 |
return; |
|
|
| |
|
71 |
|
|
|
| |
|
72 |
int iItem = ctlList.GetNextSelectedItem(pos); |
|
|
| |
|
73 |
if(iItem < 0 || iItem + 1 >= ctlList.GetItemCount()) |
|
|
| |
|
74 |
return; |
|
|
| |
|
75 |
|
|
|
| |
|
76 |
|
|
|
| |
|
77 |
auto rRule = ruleList.GetAt(iItem); |
|
|
| |
|
78 |
|
|
|
| |
|
79 |
|
|
|
| |
|
80 |
ctlList.DeleteItem(iItem); |
|
|
| |
|
81 |
ruleList.RemoveAt(iItem); |
|
|
| |
|
82 |
|
|
|
| |
|
83 |
|
|
|
| |
|
84 |
ruleList.InsertAt(iItem + 1, rRule); |
|
|
| |
|
85 |
reloadList(pDlg); |
|
|
| |
|
86 |
|
|
|
| |
|
87 |
ctlList.SetItemState(iItem + 1, LVIS_SELECTED, LVIS_SELECTED); |
|
|
| |
|
88 |
} |
|
|
| |
|
89 |
|
|
|
| |
|
90 |
template<class RuleList> |
|
|
| |
|
91 |
void OnRemoveButton(CListCtrl& ctlList, RuleList& ruleList) |
|
|
| |
|
92 |
{ |
|
|
| |
|
93 |
POSITION pos = ctlList.GetFirstSelectedItemPosition(); |
|
|
| |
|
94 |
if(pos == nullptr) |
|
|
| |
|
95 |
return; |
|
|
| |
|
96 |
|
|
|
| |
|
97 |
int iItem = ctlList.GetNextSelectedItem(pos); |
|
|
| |
|
98 |
if(iItem < 0) |
|
|
| |
|
99 |
return; |
|
|
| |
|
100 |
|
|
|
| |
|
101 |
ctlList.DeleteItem(iItem); |
|
|
| |
|
102 |
ruleList.RemoveAt(iItem); |
|
|
| |
|
103 |
} |
|
|
| |
|
104 |
} |
|
|
| |
|
105 |
|
|
|
| |
36 |
106 |
RuleEditDlg::RuleEditDlg(const FeedbackRules& rRules) : |
|
|
| |
37 |
107 |
ictranslate::CLanguageDialog(IDD_RULE_EDIT_ALL_DIALOG), |
|
|
| |
38 |
108 |
m_rules(rRules) |
| |
|
|
| |
53 |
123 |
ON_BN_CLICKED(IDC_ALREADY_EXISTS_CHANGE_BUTTON, OnAlreadyExistsChangeButton) |
|
|
| |
54 |
124 |
ON_BN_CLICKED(IDC_ALREADY_EXISTS_ADD_BUTTON, OnAlreadyExistsAddButton) |
|
|
| |
55 |
125 |
ON_BN_CLICKED(IDC_ALREADY_EXISTS_REMOVE_BUTTON, OnAlreadyExistsRemoveButton) |
|
| |
|
126 |
ON_BN_CLICKED(IDC_ALREADY_EXISTS_UP_BUTTON, OnAlreadyExistsUpButton) |
|
|
| |
|
127 |
ON_BN_CLICKED(IDC_ALREADY_EXISTS_DOWN_BUTTON, OnAlreadyExistsDownButton) |
|
|
| |
56 |
128 |
|
|
|
| |
57 |
129 |
ON_BN_CLICKED(IDC_FILE_ERROR_CHANGE_BUTTON, OnErrorChangeButton) |
|
|
| |
58 |
130 |
ON_BN_CLICKED(IDC_FILE_ERROR_ADD_BUTTON, OnErrorAddButton) |
|
|
| |
59 |
131 |
ON_BN_CLICKED(IDC_FILE_ERROR_REMOVE_BUTTON, OnErrorRemoveButton) |
|
| |
|
132 |
ON_BN_CLICKED(IDC_FILE_ERROR_UP_BUTTON, OnErrorUpButton) |
|
|
| |
|
133 |
ON_BN_CLICKED(IDC_FILE_ERROR_DOWN_BUTTON, OnErrorDownButton) |
|
|
| |
60 |
134 |
|
|
|
| |
61 |
135 |
ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_CHANGE_BUTTON, OnNotEnoughSpaceChangeButton) |
|
|
| |
62 |
136 |
ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_ADD_BUTTON, OnNotEnoughSpaceAddButton) |
|
|
| |
63 |
137 |
ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON, OnNotEnoughSpaceRemoveButton) |
|
| |
|
138 |
ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_UP_BUTTON, OnNotEnoughSpaceUpButton) |
|
|
| |
|
139 |
ON_BN_CLICKED(IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON, OnNotEnoughSpaceDownButton) |
|
|
| |
64 |
140 |
|
|
|
| |
65 |
141 |
ON_NOTIFY(NM_DBLCLK, IDC_FILE_ALREADY_EXISTS_RULES_LIST, OnDblclkAlreadyExistsList) |
|
|
| |
66 |
142 |
ON_NOTIFY(NM_DBLCLK, IDC_FILE_ERROR_RULES_LIST, OnDblclkErrorList) |
| |
|
|
| |
82 |
158 |
AddResizableControl(IDC_ALREADY_EXISTS_CHANGE_BUTTON, 1.0, 0.34, 0.0, 0.0); |
|
|
| |
83 |
159 |
AddResizableControl(IDC_ALREADY_EXISTS_ADD_BUTTON, 1.0, 0.34, 0.0, 0.0); |
|
|
| |
84 |
160 |
AddResizableControl(IDC_ALREADY_EXISTS_REMOVE_BUTTON, 1.0, 0.34, 0.0, 0.0); |
|
| |
|
161 |
AddResizableControl(IDC_ALREADY_EXISTS_UP_BUTTON, 0.0, 0.34, 0.0, 0.0); |
|
|
| |
|
162 |
AddResizableControl(IDC_ALREADY_EXISTS_DOWN_BUTTON, 0.0, 0.34, 0.0, 0.0); |
|
|
| |
85 |
163 |
|
|
|
| |
86 |
164 |
AddResizableControl(IDC_FILE_ERROR_RULES_STATIC, 0.0, 0.34, 1.0, 0.0); |
|
|
| |
87 |
165 |
AddResizableControl(IDC_FILE_ERROR_RULES_LIST, 0.0, 0.34, 1.0, 0.33); |
|
|
| |
88 |
166 |
AddResizableControl(IDC_FILE_ERROR_CHANGE_BUTTON, 1.0, 0.67, 0.0, 0.0); |
|
|
| |
89 |
167 |
AddResizableControl(IDC_FILE_ERROR_ADD_BUTTON, 1.0, 0.67, 0.0, 0.0); |
|
|
| |
90 |
168 |
AddResizableControl(IDC_FILE_ERROR_REMOVE_BUTTON, 1.0, 0.67, 0.0, 0.0); |
|
| |
|
169 |
AddResizableControl(IDC_FILE_ERROR_UP_BUTTON, 0.0, 0.67, 0.0, 0.0); |
|
|
| |
|
170 |
AddResizableControl(IDC_FILE_ERROR_DOWN_BUTTON, 0.0, 0.67, 0.0, 0.0); |
|
|
| |
91 |
171 |
|
|
|
| |
92 |
172 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_STATIC, 0.0, 0.67, 1.0, 0.0); |
|
|
| |
93 |
173 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_RULES_LIST, 0.0, 0.67, 1.0, 0.33); |
|
|
| |
94 |
174 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_CHANGE_BUTTON, 1.0, 1.0, 0.0, 0.0); |
|
|
| |
95 |
175 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_ADD_BUTTON, 1.0, 1.0, 0.0, 0.0); |
|
|
| |
96 |
176 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_REMOVE_BUTTON, 1.0, 1.0, 0.0, 0.0); |
|
| |
|
177 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_UP_BUTTON, 0.0, 1.0, 0.0, 0.0); |
|
|
| |
|
178 |
AddResizableControl(IDC_NOT_ENOUGH_SPACE_DOWN_BUTTON, 0.0, 1.0, 0.0, 0.0); |
|
|
| |
97 |
179 |
|
|
|
| |
98 |
180 |
AddResizableControl(IDOK, 1.0, 1.0, 0.0, 0.0); |
|
|
| |
99 |
181 |
AddResizableControl(IDCANCEL, 1.0, 1.0, 0.0, 0.0); |
| |
|
|
| |
112 |
194 |
InitErrorColumns(); |
|
|
| |
113 |
195 |
InitNotEnoughSpaceColumns(); |
|
|
| |
114 |
196 |
|
|
| |
|
197 |
FillAlreadyExistsList(); |
|
|
| |
|
198 |
FillErrorList(); |
|
|
| |
|
199 |
FillNotEnoughSpaceList(); |
|
|
| |
|
200 |
|
|
|
| |
115 |
201 |
UpdateData(FALSE); |
|
|
| |
116 |
202 |
|
|
|
| |
117 |
203 |
return TRUE; |
| |
|
|
| |
564 |
650 |
|
|
|
| |
565 |
651 |
void RuleEditDlg::OnAlreadyExistsRemoveButton() |
|
|
| |
566 |
652 |
{ |
|
| |
567 |
|
FeedbackAlreadyExistsRuleList& rRules = m_rules.GetAlreadyExistsRules(); |
|
|
| |
|
653 |
OnRemoveButton(m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules()); |
|
|
| |
|
654 |
} |
|
|
| |
568 |
655 |
|
|
| |
569 |
|
while(true) |
|
|
| |
570 |
|
{ |
|
|
| |
571 |
|
POSITION pos = m_ctlAlreadyExistsRulesList.GetFirstSelectedItemPosition(); |
|
|
| |
572 |
|
if(pos == nullptr) |
|
|
| |
573 |
|
break; |
|
|
| |
|
656 |
void RuleEditDlg::OnAlreadyExistsUpButton() |
|
|
| |
|
657 |
{ |
|
|
| |
|
658 |
OnUpButton(this, m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules(), &RuleEditDlg::FillAlreadyExistsList); |
|
|
| |
|
659 |
} |
|
|
| |
574 |
660 |
|
|
| |
575 |
|
int iItem = m_ctlAlreadyExistsRulesList.GetNextSelectedItem(pos); |
|
|
| |
576 |
|
if(iItem < 0) |
|
|
| |
577 |
|
return; |
|
|
| |
578 |
|
|
|
|
| |
579 |
|
m_ctlAlreadyExistsRulesList.DeleteItem(iItem); |
|
|
| |
580 |
|
rRules.RemoveAt(iItem); |
|
|
| |
581 |
|
} |
|
|
| |
|
661 |
void RuleEditDlg::OnAlreadyExistsDownButton() |
|
|
| |
|
662 |
{ |
|
|
| |
|
663 |
OnDownButton(this, m_ctlAlreadyExistsRulesList, m_rules.GetAlreadyExistsRules(), &RuleEditDlg::FillAlreadyExistsList); |
|
|
| |
582 |
664 |
} |
|
|
| |
583 |
665 |
|
|
|
| |
584 |
666 |
void RuleEditDlg::OnDblclkErrorList(NMHDR* , LRESULT* pResult) |
| |
|
|
| |
627 |
709 |
|
|
|
| |
628 |
710 |
void RuleEditDlg::OnErrorRemoveButton() |
|
|
| |
629 |
711 |
{ |
|
| |
630 |
|
FeedbackErrorRuleList& rRules = m_rules.GetErrorRules(); |
|
|
| |
|
712 |
OnRemoveButton(m_ctlErrorRulesList, m_rules.GetErrorRules()); |
|
|
| |
|
713 |
} |
|
|
| |
631 |
714 |
|
|
| |
632 |
|
while(true) |
|
|
| |
633 |
|
{ |
|
|
| |
634 |
|
POSITION pos = m_ctlErrorRulesList.GetFirstSelectedItemPosition(); |
|
|
| |
635 |
|
if(pos == nullptr) |
|
|
| |
636 |
|
break; |
|
|
| |
|
715 |
void RuleEditDlg::OnErrorUpButton() |
|
|
| |
|
716 |
{ |
|
|
| |
|
717 |
OnUpButton(this, m_ctlErrorRulesList, m_rules.GetErrorRules(), &RuleEditDlg::FillErrorList); |
|
|
| |
|
718 |
} |
|
|
| |
637 |
719 |
|
|
| |
638 |
|
int iItem = m_ctlErrorRulesList.GetNextSelectedItem(pos); |
|
|
| |
639 |
|
if(iItem < 0) |
|
|
| |
640 |
|
return; |
|
|
| |
641 |
|
|
|
|
| |
642 |
|
m_ctlErrorRulesList.DeleteItem(iItem); |
|
|
| |
643 |
|
rRules.RemoveAt(iItem); |
|
|
| |
644 |
|
} |
|
|
| |
|
720 |
void RuleEditDlg::OnErrorDownButton() |
|
|
| |
|
721 |
{ |
|
|
| |
|
722 |
OnDownButton(this, m_ctlErrorRulesList, m_rules.GetErrorRules(), &RuleEditDlg::FillErrorList); |
|
|
| |
645 |
723 |
} |
|
|
| |
646 |
724 |
|
|
|
| |
647 |
725 |
void RuleEditDlg::OnDblclkNotEnoughSpaceList(NMHDR* , LRESULT* pResult) |
| |
|
|
| |
690 |
768 |
|
|
|
| |
691 |
769 |
void RuleEditDlg::OnNotEnoughSpaceRemoveButton() |
|
|
| |
692 |
770 |
{ |
|
| |
693 |
|
FeedbackNotEnoughSpaceRuleList& rRules = m_rules.GetNotEnoughSpaceRules(); |
|
|
| |
|
771 |
OnRemoveButton(m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules()); |
|
|
| |
|
772 |
} |
|
|
| |
694 |
773 |
|
|
| |
695 |
|
while(true) |
|
|
| |
696 |
|
{ |
|
|
| |
697 |
|
POSITION pos = m_ctlNotEnoughSpaceRulesList.GetFirstSelectedItemPosition(); |
|
|
| |
698 |
|
if(pos == nullptr) |
|
|
| |
699 |
|
break; |
|
|
| |
|
774 |
void RuleEditDlg::OnNotEnoughSpaceUpButton() |
|
|
| |
|
775 |
{ |
|
|
| |
|
776 |
OnUpButton(this, m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules(), &RuleEditDlg::FillNotEnoughSpaceList); |
|
|
| |
|
777 |
} |
|
|
| |
700 |
778 |
|
|
| |
701 |
|
int iItem = m_ctlNotEnoughSpaceRulesList.GetNextSelectedItem(pos); |
|
|
| |
702 |
|
if(iItem < 0) |
|
|
| |
703 |
|
return; |
|
|
| |
704 |
|
|
|
|
| |
705 |
|
m_ctlNotEnoughSpaceRulesList.DeleteItem(iItem); |
|
|
| |
706 |
|
rRules.RemoveAt(iItem); |
|
|
| |
707 |
|
} |
|
|
| |
|
779 |
void RuleEditDlg::OnNotEnoughSpaceDownButton() |
|
|
| |
|
780 |
{ |
|
|
| |
|
781 |
OnDownButton(this, m_ctlNotEnoughSpaceRulesList, m_rules.GetNotEnoughSpaceRules(), &RuleEditDlg::FillNotEnoughSpaceList); |
|
| |
708 |
782 |
} |