Skip to content

Commit f62aa5e

Browse files
author
César Cardoso
committed
commit/init
1 parent 6aafaa2 commit f62aa5e

14 files changed

+2324
-0
lines changed

C4DLogFile.dpk

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package C4DLogFile;
2+
3+
{$R *.res}
4+
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
5+
{$ALIGN 8}
6+
{$ASSERTIONS ON}
7+
{$BOOLEVAL OFF}
8+
{$DEBUGINFO OFF}
9+
{$EXTENDEDSYNTAX ON}
10+
{$IMPORTEDDATA ON}
11+
{$IOCHECKS ON}
12+
{$LOCALSYMBOLS ON}
13+
{$LONGSTRINGS ON}
14+
{$OPENSTRINGS ON}
15+
{$OPTIMIZATION OFF}
16+
{$OVERFLOWCHECKS OFF}
17+
{$RANGECHECKS OFF}
18+
{$REFERENCEINFO ON}
19+
{$SAFEDIVIDE OFF}
20+
{$STACKFRAMES ON}
21+
{$TYPEDADDRESS OFF}
22+
{$VARSTRINGCHECKS ON}
23+
{$WRITEABLECONST OFF}
24+
{$MINENUMSIZE 1}
25+
{$IMAGEBASE $400000}
26+
{$DEFINE DEBUG}
27+
{$ENDIF IMPLICITBUILDING}
28+
{$RUNONLY}
29+
{$IMPLICITBUILD ON}
30+
31+
requires
32+
rtl;
33+
34+
contains
35+
C4D.LogFile in 'Src\C4D.LogFile.pas',
36+
C4D.LogFile.Utils in 'Src\C4D.LogFile.Utils.pas';
37+
38+
end.

C4DLogFile.dproj

Lines changed: 914 additions & 0 deletions
Large diffs are not rendered by default.

C4DLogFile.res

652 Bytes
Binary file not shown.

C4DLogFileGroup.groupproj

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<PropertyGroup>
3+
<ProjectGuid>{F6FE2D82-B4D6-4E2E-B7B4-A4120D9698ED}</ProjectGuid>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Projects Include="C4DLogFile.dproj">
7+
<Dependencies/>
8+
</Projects>
9+
<Projects Include="Samples\Demo01\C4DLogFileDemo01.dproj">
10+
<Dependencies/>
11+
</Projects>
12+
</ItemGroup>
13+
<ProjectExtensions>
14+
<Borland.Personality>Default.Personality.12</Borland.Personality>
15+
<Borland.ProjectType/>
16+
<BorlandProject>
17+
<Default.Personality/>
18+
</BorlandProject>
19+
</ProjectExtensions>
20+
<Target Name="C4DLogFile">
21+
<MSBuild Projects="C4DLogFile.dproj"/>
22+
</Target>
23+
<Target Name="C4DLogFile:Clean">
24+
<MSBuild Projects="C4DLogFile.dproj" Targets="Clean"/>
25+
</Target>
26+
<Target Name="C4DLogFile:Make">
27+
<MSBuild Projects="C4DLogFile.dproj" Targets="Make"/>
28+
</Target>
29+
<Target Name="C4DLogFileDemo01">
30+
<MSBuild Projects="Samples\Demo01\C4DLogFileDemo01.dproj"/>
31+
</Target>
32+
<Target Name="C4DLogFileDemo01:Clean">
33+
<MSBuild Projects="Samples\Demo01\C4DLogFileDemo01.dproj" Targets="Clean"/>
34+
</Target>
35+
<Target Name="C4DLogFileDemo01:Make">
36+
<MSBuild Projects="Samples\Demo01\C4DLogFileDemo01.dproj" Targets="Make"/>
37+
</Target>
38+
<Target Name="Build">
39+
<CallTarget Targets="C4DLogFile;C4DLogFileDemo01"/>
40+
</Target>
41+
<Target Name="Clean">
42+
<CallTarget Targets="C4DLogFile:Clean;C4DLogFileDemo01:Clean"/>
43+
</Target>
44+
<Target Name="Make">
45+
<CallTarget Targets="C4DLogFile:Make;C4DLogFileDemo01:Make"/>
46+
</Target>
47+
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
48+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
program C4DLogFileDemo01;
2+
3+
uses
4+
Vcl.Forms,
5+
C4D.LogFileDemo01.View.Main in 'Src\View\C4D.LogFileDemo01.View.Main.pas' {C4DLogFileDemo01ViewMain};
6+
7+
{$R *.res}
8+
9+
begin
10+
Application.Initialize;
11+
Application.MainFormOnTaskbar := True;
12+
Application.CreateForm(TC4DLogFileDemo01ViewMain, C4DLogFileDemo01ViewMain);
13+
Application.Run;
14+
end.

Samples/Demo01/C4DLogFileDemo01.dproj

Lines changed: 977 additions & 0 deletions
Large diffs are not rendered by default.
58.2 KB
Binary file not shown.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
object C4DLogFileDemo01ViewMain: TC4DLogFileDemo01ViewMain
2+
Left = 0
3+
Top = 0
4+
Caption = 'Code4Delphi - LogFile - Demo'
5+
ClientHeight = 155
6+
ClientWidth = 610
7+
Color = clBtnFace
8+
Font.Charset = DEFAULT_CHARSET
9+
Font.Color = clWindowText
10+
Font.Height = -11
11+
Font.Name = 'Tahoma'
12+
Font.Style = []
13+
OldCreateOrder = False
14+
Position = poScreenCenter
15+
OnCreate = FormCreate
16+
OnShow = FormShow
17+
PixelsPerInch = 96
18+
TextHeight = 13
19+
object Label3: TLabel
20+
Left = 24
21+
Top = 17
22+
Width = 44
23+
Height = 13
24+
Caption = 'Pasta log'
25+
end
26+
object btnAdd: TButton
27+
Left = 24
28+
Top = 114
29+
Width = 113
30+
Height = 25
31+
Cursor = crHandPoint
32+
Caption = 'Add log'
33+
TabOrder = 0
34+
OnClick = btnAddClick
35+
end
36+
object edtTexto: TEdit
37+
Left = 24
38+
Top = 91
39+
Width = 534
40+
Height = 21
41+
TabOrder = 1
42+
Text = 'edtTexto'
43+
end
44+
object edtPastaLog: TEdit
45+
Left = 24
46+
Top = 32
47+
Width = 534
48+
Height = 21
49+
TabOrder = 2
50+
Text = 'C:\Temp\Logs'
51+
end
52+
object btnPastaImg: TPngBitBtn
53+
Left = 560
54+
Top = 31
55+
Width = 24
56+
Height = 23
57+
Cursor = crHandPoint
58+
Caption = '...'
59+
TabOrder = 3
60+
OnClick = btnPastaImgClick
61+
end
62+
object btnAbrirPasta: TButton
63+
Left = 24
64+
Top = 57
65+
Width = 113
66+
Height = 25
67+
Cursor = crHandPoint
68+
Caption = 'Abrir pasta'
69+
TabOrder = 4
70+
OnClick = btnAbrirPastaClick
71+
end
72+
end
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
unit C4D.LogFileDemo01.View.Main;
2+
3+
interface
4+
5+
uses
6+
Winapi.Windows,
7+
Winapi.Messages,
8+
System.SysUtils,
9+
System.Variants,
10+
System.Classes,
11+
Vcl.Graphics,
12+
Vcl.Controls,
13+
Vcl.Forms,
14+
Vcl.Dialogs,
15+
Vcl.StdCtrls,
16+
Vcl.Buttons,
17+
PngBitBtn,
18+
C4D.LogFile,
19+
ShellAPI;
20+
21+
type
22+
TC4DLogFileDemo01ViewMain = class(TForm)
23+
btnAdd: TButton;
24+
edtTexto: TEdit;
25+
Label3: TLabel;
26+
edtPastaLog: TEdit;
27+
btnPastaImg: TPngBitBtn;
28+
btnAbrirPasta: TButton;
29+
procedure FormShow(Sender: TObject);
30+
procedure btnAddClick(Sender: TObject);
31+
procedure btnPastaImgClick(Sender: TObject);
32+
procedure FormCreate(Sender: TObject);
33+
procedure btnAbrirPastaClick(Sender: TObject);
34+
private
35+
procedure AddTextoTesteNoEdt;
36+
function SelecionaDiretorio(ADefaultFolder: String): String;
37+
public
38+
39+
end;
40+
41+
var
42+
C4DLogFileDemo01ViewMain: TC4DLogFileDemo01ViewMain;
43+
44+
implementation
45+
46+
{$R *.dfm}
47+
48+
function TC4DLogFileDemo01ViewMain.SelecionaDiretorio(ADefaultFolder: String): String;
49+
var
50+
LFileOpenDialog: TFileOpenDialog;
51+
begin
52+
LFileOpenDialog := TFileOpenDialog.Create(nil);
53+
try
54+
LFileOpenDialog.Title := 'Code4Delphi - Selecione uma pasta';;
55+
LFileOpenDialog.Options := [fdoPickFolders];
56+
57+
if(not ADefaultFolder.Trim.IsEmpty)and(System.SysUtils.DirectoryExists(ADefaultFolder))then
58+
LFileOpenDialog.DefaultFolder := ADefaultFolder;
59+
60+
if(not LFileOpenDialog.Execute)then
61+
Exit(ADefaultFolder);
62+
63+
Result := IncludeTrailingPathDelimiter(LFileOpenDialog.FileName).Trim;
64+
finally
65+
LFileOpenDialog.Free;
66+
end;
67+
end;
68+
69+
procedure TC4DLogFileDemo01ViewMain.btnPastaImgClick(Sender: TObject);
70+
begin
71+
edtPastaLog.Text := Self.SelecionaDiretorio(edtPastaLog.Text);
72+
end;
73+
74+
procedure TC4DLogFileDemo01ViewMain.FormCreate(Sender: TObject);
75+
begin
76+
ReportMemoryLeaksOnShutdown := True;
77+
end;
78+
79+
procedure TC4DLogFileDemo01ViewMain.FormShow(Sender: TObject);
80+
begin
81+
Self.AddTextoTesteNoEdt;
82+
end;
83+
84+
procedure TC4DLogFileDemo01ViewMain.AddTextoTesteNoEdt;
85+
begin
86+
edtTexto.Text := 'Texto teste com acentos éêãçàí: ' + DateTimeToStr(Now);
87+
end;
88+
89+
procedure TC4DLogFileDemo01ViewMain.btnAbrirPastaClick(Sender: TObject);
90+
begin
91+
if(not DirectoryExists(edtPastaLog.Text))then
92+
raise Exception.Create('Pasta informada não pode ser encontrada');
93+
94+
ShellExecute(Application.Handle, nil, PWideChar(edtPastaLog.Text), '', nil, SW_ShowNormal);
95+
end;
96+
97+
procedure TC4DLogFileDemo01ViewMain.btnAddClick(Sender: TObject);
98+
begin
99+
if(DirectoryExists(edtPastaLog.Text))then
100+
begin
101+
//A PASTA PODE SER SETADA APENAS UMA VEZ (NO CREATE DO PROJETO POR EXEMPLO)
102+
C4DLogFile.SetDir(edtPastaLog.Text);
103+
end;
104+
105+
C4DLogFile.AddLog('Linha 01: ' + edtTexto.Text);
106+
C4DLogFile.AddLog('Linha 02: ' + edtTexto.Text);
107+
Self.AddTextoTesteNoEdt;
108+
end;
109+
110+
end.

Src/C4D.LogFile.Utils.pas

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
unit C4D.LogFile.Utils;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils;
7+
8+
type
9+
TC4DLogFileUtils = class
10+
public
11+
class function RemoveAcento(AStr: String): String;
12+
class function RemoveAcentoTrocaSimbolos(AStr: String): String;
13+
class function TrocaSimbolos(AStr: String): String;
14+
end;
15+
16+
implementation
17+
18+
class function TC4DLogFileUtils.RemoveAcentoTrocaSimbolos(AStr: String): String;
19+
begin
20+
Result := TrocaSimbolos(RemoveAcento(AStr));
21+
end;
22+
23+
class function TC4DLogFileUtils.RemoveAcento(AStr: String): String;
24+
const
25+
C_COM_ACENTOS = 'àâêôûãõáéíóúçüÀÂÊÔÛÃÕÁÉÍÓÚÇÜ';
26+
C_SEM_ACENTOS = 'aaeouaoaeioucuAAEOUAOAEIOUCU';
27+
var
28+
i: Integer;
29+
begin
30+
for i := 1 to Length(AStr) do
31+
if(Pos(AStr[i], C_COM_ACENTOS) <> 0)then
32+
AStr[i] := C_SEM_ACENTOS[Pos(AStr[i], C_COM_ACENTOS)];
33+
34+
Result := AStr;
35+
end;
36+
37+
class function TC4DLogFileUtils.TrocaSimbolos(AStr: String): String;
38+
const
39+
C_SIMBOLOS_OLD = 'ºª&®½¼ßµþýÝ¨æÆø£Øƒª¿|~^´`';
40+
C_SIMBOLOS_NEW = 'oae BupyY o 0faw ';
41+
var
42+
i: Integer;
43+
begin
44+
for i := 1 to Length(AStr)do
45+
if(Pos(AStr[i], C_SIMBOLOS_OLD) <> 0)then
46+
AStr[i] := C_SIMBOLOS_NEW[Pos(AStr[i], C_SIMBOLOS_OLD)];
47+
48+
Result := AStr;
49+
end;
50+
51+
end.

0 commit comments

Comments
 (0)