forked from Frieve-A/Frieve-Editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoselectcard.cpp
More file actions
130 lines (117 loc) · 3.86 KB
/
Copy pathfoselectcard.cpp
File metadata and controls
130 lines (117 loc) · 3.86 KB
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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "foselectcard.h"
#include "setting.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFo_Select *Fo_Select;
//---------------------------------------------------------------------------
void TFo_Select::ApplyLanguageSetting()
{
if (!FileExists(LanguageFileName())){
return;
}
TFastIni *Ini = new TFastIni(LanguageFileName());
Bu_OK->Caption = Ini->ReadString("Dialog", "Bu_OK", Bu_OK->Caption);
Bu_Cancel->Caption = Ini->ReadString("Dialog", "Bu_Cancel", Bu_Cancel->Caption);
delete Ini;
}
//---------------------------------------------------------------------------
__fastcall TFo_Select::TFo_Select(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::FormShow(TObject *Sender)
{
ApplyLanguageSetting();
LB_Items->MultiSelect = m_bMultiSelect;
LB_Items->Items->BeginUpdate();
switch (m_nType){
case 0:
for (int i = 0 ; i < m_Document->m_Cards->Count ; i++){
TCard *Card = m_Document->GetCardByIndex(i);
LB_Items->Items->Add(DecodeES(Card->m_Title, " "));
}
break;
case 1:
case 2:
for (int i = 0 ; i < m_Document->m_Labels[m_nType - 1]->Count ; i++){
TCardLabel *Label = m_Document->GetLabelByIndex(m_nType - 1, i);
LB_Items->Items->Add(DecodeES(Label->m_Name, " "));
}
break;
}
LB_Items->Items->EndUpdate();
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::Bu_OKClick(TObject *Sender)
{
m_nID = -1;
switch (m_nType){
case 0://Card
if (!LB_Items->MultiSelect){
TCard *Card = m_Document->GetCardByIndex(LB_Items->ItemIndex);
if (Card){
m_nID = Card->m_nID;
m_IDs->Add((void*)m_nID);
}
}else{
for (int i = 0 ; i < m_Document->m_Cards->Count && i < LB_Items->Count ; i++){
if (LB_Items->Selected[i]){
TCard *Card = m_Document->GetCardByIndex(LB_Items->ItemIndex);
if (Card){
m_IDs->Add((void*)Card->m_nID);
}
}
}
}
break;
case 1://Label
case 2://Link Label
if (!LB_Items->MultiSelect){
m_nID = LB_Items->ItemIndex + 1;
m_IDs->Add((void*)m_nID);
}else{
for (int i = 0 ; i < m_Document->m_Labels[m_nType - 1]->Count && i < LB_Items->Count ; i++){
if (LB_Items->Selected[i]){
m_IDs->Add((void*)(i + 1));
}
}
}
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::LB_ItemsClick(TObject *Sender)
{
if (!LB_Items->MultiSelect){
Bu_OK->Enabled = true;
}else{
Bu_OK->Enabled = LB_Items->SelCount > 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::LB_ItemsDblClick(TObject *Sender)
{
if (LB_Items->MultiSelect && LB_Items->SelCount == 0){
return;
}
ModalResult = mrOk;
Bu_OKClick(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::FormCreate(TObject *Sender)
{
m_nType = 0;//ƒJ[ƒhB1=ƒ‰ƒxƒ‹
m_bMultiSelect = false;
m_IDs = new TList();
}
//---------------------------------------------------------------------------
void __fastcall TFo_Select::FormDestroy(TObject *Sender)
{
delete m_IDs;
}
//---------------------------------------------------------------------------