-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathYOTM.Form.OverlayTime.pas
102 lines (84 loc) · 2.47 KB
/
YOTM.Form.OverlayTime.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
unit YOTM.Form.OverlayTime;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, YOTM.Form,
HGM.Button, Vcl.StdCtrls, Vcl.ExtCtrls, HGM.Controls.PanelExt;
type
TChangeActive = procedure(Sender: TObject; State: Boolean) of object;
TFormTimeOverlay = class(TFormCustom)
LabelTime: TLabel;
ButtonFlatSwitch: TButtonFlat;
procedure FormCreate(Sender: TObject);
procedure ButtonFlatSwitchClick(Sender: TObject);
procedure LabelCaptionMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
FActiveWork: Boolean;
FTime: string;
FCallback: TChangeActive;
procedure SetActiveWork(const Value: Boolean);
procedure SetTime(const Value: string);
procedure SetCallback(const Value: TChangeActive);
{ Private declarations }
public
property Time: string read FTime write SetTime;
property ActiveWork: Boolean read FActiveWork write SetActiveWork;
procedure SetActivateLow(Value: Boolean);
procedure Stop;
procedure Resume;
property Callback: TChangeActive read FCallback write SetCallback;
end;
var
FormTimeOverlay: TFormTimeOverlay;
implementation
{$R *.dfm}
procedure TFormTimeOverlay.ButtonFlatSwitchClick(Sender: TObject);
begin
ActiveWork := not ActiveWork;
end;
procedure TFormTimeOverlay.FormCreate(Sender: TObject);
begin
inherited;
Top := Screen.WorkAreaRect.Bottom - ClientHeight - 5;
Left := Screen.WorkAreaRect.Right - ClientWidth - 5;
end;
procedure TFormTimeOverlay.LabelCaptionMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
DragBarTop.DoDrag;
end;
procedure TFormTimeOverlay.Stop;
begin
ActiveWork := False;
end;
procedure TFormTimeOverlay.Resume;
begin
ActiveWork := True;
end;
procedure TFormTimeOverlay.SetActivateLow(Value: Boolean);
begin
FActiveWork := Value;
case Value of
True:
ButtonFlatSwitch.ImageIndex := 28;
False:
ButtonFlatSwitch.ImageIndex := 27;
end;
end;
procedure TFormTimeOverlay.SetActiveWork(const Value: Boolean);
begin
if FActiveWork = Value then
Exit;
SetActivateLow(Value);
if Assigned(FCallback) then
FCallback(Self, FActiveWork);
end;
procedure TFormTimeOverlay.SetCallback(const Value: TChangeActive);
begin
FCallback := Value;
end;
procedure TFormTimeOverlay.SetTime(const Value: string);
begin
FTime := Value;
LabelTime.Caption := FTime;
end;
end.