-
Notifications
You must be signed in to change notification settings - Fork 26
/
BigTV.SmartGuide.pas
143 lines (125 loc) · 3.61 KB
/
BigTV.SmartGuide.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
unit BigTV.SmartGuide;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.ExtCtrls, Vcl.Grids, HGM.Controls.VirtualTable, Vcl.StdCtrls,
System.Generics.Collections;
type
TSmartGuideItem = record
Channel: string;
ChannelID: string;
When: string;
What: string;
After: string;
end;
TSmartGuide = TTableData<TSmartGuideItem>;
TFormGuide = class(TForm)
TableExTvGuide: TTableEx;
TimerUpdate: TTimer;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TableExTvGuideGetData(FCol, FRow: Integer; var Value: string);
procedure FormShow(Sender: TObject);
procedure TableExTvGuideDblClick(Sender: TObject);
procedure TimerUpdateTimer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
FSmartGuide: TSmartGuide;
end;
var
FormGuide: TFormGuide;
implementation
uses
BigTV.Main, DateUtils;
{$R *.dfm}
procedure TFormGuide.Button1Click(Sender: TObject);
var
i, j, delta: Integer;
Item: TSmartGuideItem;
begin
FSmartGuide.BeginUpdate;
FSmartGuide.Clear;
for i := 0 to FormMain.Channels.Count - 1 do
begin
Item.Channel := IntToStr(i+1) + ' '+ FormMain.Channels[i].Name;
Item.ChannelID := FormMain.Channels[i].TVGName;
Item.When := '';
Item.What := '';
Item.After := '';
j := FormMain.Channels[i].NowWatchId;
if IndexInList(j, FormMain.Channels[i].Guide.Count) then
begin
delta := GetMins(TimeOf(Now)) - GetMins(TimeOf(FormMain.Channels[i].Guide[j].Date));
{ if delta > 20 then
begin
if IndexInList(j + 1, FormMain.Channels[i].Guide.Count) then
begin
Item.What := FormMain.Channels[i].Guide[j + 1].Text;
delta := GetMins(TimeOf(FormMain.Channels[i].Guide[j + 1].Date)) - GetMins(TimeOf(Now));
Item.When := '÷åðåç ' + IntToStr(delta) + ' ìèí.';
end;
Item.After := 'ñåé÷àñ èä¸ò ' + FormMain.Channels[i].Guide[j].Text;
end
else
begin }
Item.What := FormMain.Channels[i].Guide[j].Text;
if delta = 0 then
Item.When := 'ïðÿìî ñåé÷àñ'
else
Item.When := 'èäåò óæå ' + IntToStr(delta) + ' ìèí.';
if IndexInList(j + 1, FormMain.Channels[i].Guide.Count) then
Item.After := 'äàëåå ' + FormMain.Channels[i].Guide[j + 1].Text;
{ end; }
end;
FSmartGuide.Add(Item);
end;
FSmartGuide.EndUpdate;
end;
procedure TFormGuide.FormCreate(Sender: TObject);
begin
FSmartGuide := TSmartGuide.Create(TableExTvGuide);
end;
procedure TFormGuide.FormDestroy(Sender: TObject);
begin
FSmartGuide.Free;
end;
procedure TFormGuide.FormShow(Sender: TObject);
begin
Button1Click(nil);
end;
procedure TFormGuide.TableExTvGuideDblClick(Sender: TObject);
var
I: Integer;
begin
if not IndexInList(TableExTvGuide.ItemIndex, FSmartGuide.Count) then
Exit;
I := FormMain.Channels.GetIdByTVGName(FSmartGuide[TableExTvGuide.ItemIndex].ChannelID);
if not IndexInList(I, FormMain.Channels.Count) then
Exit;
FormMain.Play(I);
end;
procedure TFormGuide.TableExTvGuideGetData(FCol, FRow: Integer; var Value: string);
begin
if not IndexInList(FRow, FSmartGuide.Count) then
Exit;
case FCol of
0:
Value := FSmartGuide[FRow].Channel;
1:
Value := FSmartGuide[FRow].What;
2:
Value := FSmartGuide[FRow].When;
3:
Value := FSmartGuide[FRow].After;
end;
end;
procedure TFormGuide.TimerUpdateTimer(Sender: TObject);
begin
if not Visible then
Exit;
Button1Click(nil);
end;
end.