-
Notifications
You must be signed in to change notification settings - Fork 0
/
uUtilitarios.pas
76 lines (64 loc) · 1.82 KB
/
uUtilitarios.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
unit uUtilitarios;
interface
uses
System.SysUtils,
System.Classes,
System.NetEncoding,
System.Hash,
Vcl.Imaging.pngimage,
Vcl.Graphics,
Vcl.Forms,
dxMessageDialog,
Vcl.Dialogs,
Windows;
type
TUtilitarios = class
class function ColorToHex(color: TColor): String;
class function HexToColor(hexStr: String) : TColor;
class function EhDataValida(const Dt: TDateTime): Boolean;
class procedure MensagemErroRapido(const Texto: String);
class procedure MensagemAlertaRapido(const Texto: String);
class procedure MensagemInformativaRapida(const Texto: String);
end;
implementation
class function TUtilitarios.EhDataValida(const Dt: TDateTime): Boolean;
begin
Result := (Dt <= MaxDateTime) and (Dt >= MinDateTime);
end;
class function TUtilitarios.HexToColor(hexStr: string): TColor;
var
R, G, B: Byte;
begin
if hexStr[1] = '#' then
begin
Delete(hexStr, 1, 1);
end;
R := StrToInt('$' + Copy(hexStr, 1, 2));
G := StrToInt('$' + Copy(hexStr, 3, 2));
B := StrToInt('$' + Copy(hexStr, 5, 2));
Result := RGB(R, G, B);
end;
class function TUtilitarios.ColorToHex(color: TColor): String;
var
RGBValue: Longint;
Red, Green, Blue: Byte;
begin
RGBValue := ColorToRGB(color);
Red := GetRValue(RGBValue);
Green := GetGValue(RGBValue);
Blue := GetBValue(RGBValue);
Result := Format('#%.2x%.2x%.2x', [Red, Green, Blue]);
end;
class procedure TUtilitarios.MensagemAlertaRapido(const Texto: String);
begin
dxMessageDlg(Texto, TMsgDlgType.mtWarning, [TMsgDlgBtn.mbOK], 0);
end;
class procedure TUtilitarios.MensagemErroRapido(const Texto: String);
begin
dxMessageDlg(Texto, TMsgDlgType.mtError, [TMsgDlgBtn.mbOK], 0);
end;
class procedure TUtilitarios.MensagemInformativaRapida(const Texto: String);
begin
dxMessageDlg(Texto, TMsgDlgType.mtInformation, [TMsgDlgBtn.mbOK], 0);
end;
end.