-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrmRemoteHostInfo.cpp
105 lines (97 loc) · 3.34 KB
/
FrmRemoteHostInfo.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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "FrmRemoteHostInfo.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFormRemoteHostInfo *FormRemoteHostInfo;
//---------------------------------------------------------------------------
__fastcall TFormRemoteHostInfo::TFormRemoteHostInfo(TComponent* Owner)
: TForm(Owner)
{
MyHost = NULL;
MyAccounts = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::BtnApplyClick(TObject *Sender)
{
if (MyHost != NULL) {
MyHost->Port = StrToInt(EditPort->Text);
MyHost->Service = EditService->Text;
}
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::BtnCancelClick(TObject *Sender)
{
ModalResult = mrCancel;
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::BtnEditClick(TObject *Sender)
{
if (MyAccounts != NULL) {
MyAccounts->ShowDialog();
UpdateAccounts();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::SetMyHost(TRemoteHostInfo *host)
{
MyHost = host;
if (MyHost != NULL) {
LabelHost->Caption = host->HostName;
EditPort->Text = host->Port;
EditService->Text = host->Service;
MyAccounts = MyHost->GetAccounts();
if (MyAccounts != NULL)
UpdateAccounts();
}
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::UpdateAccounts()
{
if (MyAccounts != NULL) {
LabelCount->Caption = "(" + Trim(IntToStr(MyAccounts->UserCount)) + ")";
CheckListBox->Clear();
for (int j = 0; j < MyAccounts->UserID->Count; j++)
CheckListBox->Items->Add(MyAccounts->ExtractUserID(MyAccounts->UserID->Strings[j]));
if (MyAccounts->PreferredAccount != "") {
int i = CheckListBox->Items->IndexOf(MyAccounts->PreferredAccount);
for (int j = 0; j < CheckListBox->Items->Count; j++)
if (j == i)
CheckListBox->Checked[j] = true;
else
CheckListBox->Checked[j] = false;
}
} else
LabelCount->Caption = "(0)";
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::FormShow(TObject *Sender)
{
UpdateAccounts();
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::CheckListBoxMouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if (Button == mbLeft)
LastClick = CheckListBox->ItemAtPos(TPoint(X, Y), true);
}
//---------------------------------------------------------------------------
void __fastcall TFormRemoteHostInfo::CheckListBoxClickCheck(
TObject *Sender)
{
if (LastClick != -1) {
for (int i = 0; i < CheckListBox->Items->Count; i++) {
CheckListBox->Checked[i] = false;
if (LastClick == i) {
CheckListBox->Checked[i] = true;
if (MyAccounts != NULL)
MyAccounts->PreferredAccount = CheckListBox->Items->Strings[i];
}
}
}
}
//---------------------------------------------------------------------------