forked from HemulGM/IMJabber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IM.Tool.Console.pas
122 lines (104 loc) · 3.11 KB
/
IM.Tool.Console.pas
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
unit IM.Tool.Console;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, HGM.Controls.SpinEdit, HGM.Button,
Vcl.ComCtrls, Vcl.Grids, HGM.Controls.VirtualTable;
type
TFormConsole = class(TForm)
RichEditConsole: TRichEdit;
PanelControl: TPanel;
Label1: TLabel;
sLabel1: TLabel;
MemoXML: TMemo;
SpinEditMaxLines: TlkSpinEdit;
ButtonFlatSend: TButtonFlat;
ButtonFlatClear: TButtonFlat;
PageControl: TPageControl;
TabSheetLog: TTabSheet;
TabSheetXMPP: TTabSheet;
TableExXMPPItems: TTableEx;
RichEditXMPP: TRichEdit;
PanelNav: TPanel;
ButtonFlatXMPP: TButtonFlat;
ButtonFlatLog: TButtonFlat;
procedure ButtonFlatSendClick(Sender: TObject);
procedure ButtonFlatClearClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TableExXMPPItemsGetData(FCol, FRow: Integer; var Value: string);
procedure TableExXMPPItemsItemClick(Sender: TObject; MouseButton: TMouseButton; const Index: Integer);
procedure ButtonFlatXMPPClick(Sender: TObject);
procedure ButtonFlatLogClick(Sender: TObject);
procedure FormShow(Sender: TObject);
public
procedure AddLog(AText: string; AColor: TColor = clWhite);
end;
var
FormConsole: TFormConsole;
implementation
uses
IM.Main;
{$R *.dfm}
procedure TFormConsole.AddLog(AText: string; AColor: TColor);
begin
with RichEditConsole do
begin
if Lines.Count > SpinEditMaxLines.Value then
ButtonFlatClear.Click;
SelStart := Length(Text);
SelAttributes.Color := AColor;
SelAttributes.Size := 9;
SelAttributes.Name := 'Courier New';
Lines.Add(TimeToStr(Now) + ': ' + AText);
Perform(WM_VScroll, SB_BOTTOM, 0);
end;
end;
procedure TFormConsole.ButtonFlatSendClick(Sender: TObject);
begin
if FormMain.JabberClient.Connected then
begin
FormMain.JabberClient.SendData(MemoXML.Text);
MemoXML.Clear;
end;
end;
procedure TFormConsole.ButtonFlatXMPPClick(Sender: TObject);
begin
PageControl.ActivePage := TabSheetXMPP;
end;
procedure TFormConsole.FormCreate(Sender: TObject);
begin
FormMain.JabberClient.XMPPItems.AddTable(TableExXMPPItems);
end;
procedure TFormConsole.FormShow(Sender: TObject);
begin
BringToFront;
end;
procedure TFormConsole.TableExXMPPItemsGetData(FCol, FRow: Integer; var Value: string);
begin
Value := '';
if FCol = 0 then
Value := 'Ïóñòî';
if not FormMain.JabberClient.XMPPItems.IndexIn(FRow) then
Exit;
case FCol of
0:
Value := TimeToStr(FormMain.JabberClient.XMPPItems[FRow].Date);
1:
Value := FormMain.JabberClient.XMPPItems[FRow].Data;
end;
end;
procedure TFormConsole.TableExXMPPItemsItemClick(Sender: TObject; MouseButton: TMouseButton; const Index: Integer);
begin
if not FormMain.JabberClient.XMPPItems.IndexIn(Index) then
Exit;
RichEditXMPP.Text := FormMain.JabberClient.XMPPItems[Index].Data;
end;
procedure TFormConsole.ButtonFlatClearClick(Sender: TObject);
begin
RichEditConsole.Clear;
end;
procedure TFormConsole.ButtonFlatLogClick(Sender: TObject);
begin
PageControl.ActivePage := TabSheetLog;
end;
end.