├── Chapter01
├── Instagram.dpr
├── Instagram.dproj
├── Instagram.dproj.local
├── Instagram.identcache
├── Instagram.res
├── Instagram.skincfg
├── Instagram.stat
├── uFrmInstagram.LgXhdpiPh.fmx
├── uFrmInstagram.NmXhdpiPh.fmx
├── uFrmInstagram.fmx
└── uFrmInstagram.pas
├── Chapter02
├── LoginFacebook.dpr
├── LoginFacebook.dproj
├── LoginFacebook.dproj.local
├── LoginFacebook.identcache
├── LoginFacebook.res
├── Unit1.fmx
├── Unit1.pas
├── iconfinder_love-book_2903245.png
├── uFrmLogin.fmx
└── uFrmLogin.pas
├── Chapter03
├── Android Services
│ ├── AndroidManifest.template.xml
│ ├── BootReceiverRemote
│ │ └── src
│ │ │ └── com
│ │ │ └── embarcadero
│ │ │ └── boot
│ │ │ └── BootPacktAndroidService.java
│ ├── JavaClasses
│ │ └── PacktAndroidService
│ │ │ └── com
│ │ │ └── embarcadero
│ │ │ └── services
│ │ │ ├── PacktAndroidService$LocalBinder.class
│ │ │ ├── PacktAndroidService.class
│ │ │ └── PacktAndroidServiceProxyInterface.class
│ ├── PacktAndroidService.dpr
│ ├── PacktAndroidService.dproj
│ ├── PacktAndroidService.dproj.local
│ ├── PacktAndroidService.identcache
│ ├── PacktAndroidService.res
│ ├── PacktAndroidService.skincfg
│ ├── PacktAndroidService.stat
│ ├── PacktAndroidService.template.java
│ ├── PacktAndroidServiceProxyInterface.template.java
│ ├── PacktGroupAndroidServices.groupproj
│ ├── PacktGroupAndroidServices.groupproj.local
│ ├── PacktHostApp.dpr
│ ├── PacktHostApp.dproj
│ ├── PacktHostApp.dproj.local
│ ├── PacktHostApp.res
│ ├── PacktHostApp.skincfg
│ ├── PacktHostApp.stat
│ ├── uFrmHostSerivce.fmx
│ ├── uFrmHostSerivce.pas
│ ├── uPacktAndroidServiceDM.dfm
│ └── uPacktAndroidServiceDM.pas
└── Windows Services
│ ├── pService.dpr
│ ├── pService.dproj
│ ├── pService.dproj.local
│ ├── pService.identcache
│ ├── pService.res
│ ├── pService.skincfg
│ ├── pService.stat
│ ├── uService.dfm
│ └── uService.pas
├── Chapter04
├── MultiDatabase.dpr
├── MultiDatabase.dproj
├── MultiDatabase.dproj.local
├── MultiDatabase.identcache
├── MultiDatabase.res
├── MultiDatabase.skincfg
├── MultiDatabase.stat
├── uConfiguration.pas
├── uCustomers.pas
├── uDM_RepositoryPostgreSQL.dfm
├── uDM_RepositoryPostgreSQL.pas
├── uDM_RepositorySQLServer.dfm
├── uDM_RepositorySQLServer.pas
├── uFrmMain.dfm
├── uFrmMain.pas
├── uProducts.pas
├── uRepositorySystemPostgreSQL.dfm
├── uRepositorySystemPostgreSQL.pas
├── uRepositorySystemSQLServer.dfm
├── uRepositorySystemSQLServer.pas
├── uUsers.pas
├── uiConfig.pas
├── uiRepoSystem.pas
└── uiRepositories.pas
├── Chapter05
├── AndroidManifest.template.xml
├── Material.deployproj
├── Material.dpr
├── Material.dproj
├── Material.dproj.local
├── Material.identcache
├── Material.res
├── Material.stat
├── images
│ ├── mat_back.jpg
│ └── will.jpg
├── uFrmMenu.fmx
└── uFrmMenu.pas
├── Chapter06
├── __history
│ ├── uFrmCap6_Server.fmx.~10~
│ ├── uFrmCap6_Server.fmx.~11~
│ ├── uFrmCap6_Server.fmx.~12~
│ ├── uFrmCap6_Server.fmx.~13~
│ ├── uFrmCap6_Server.fmx.~14~
│ ├── uFrmCap6_Server.fmx.~5~
│ ├── uFrmCap6_Server.fmx.~6~
│ ├── uFrmCap6_Server.fmx.~7~
│ ├── uFrmCap6_Server.fmx.~8~
│ ├── uFrmCap6_Server.fmx.~9~
│ ├── uFrmCap6_Server.pas.~1~
│ ├── uFrmCap6_Server.pas.~2~
│ ├── uFrmCap6_Server.pas.~3~
│ ├── uFrmCap6_Server.pas.~4~
│ ├── uFrmCap6_Server.pas.~5~
│ ├── uFrmCap6_Server.pas.~6~
│ ├── uFrmCap6_Server.pas.~7~
│ └── uFrmCap6_Server.pas.~8~
├── appRemoteDesktop.dpr
├── appRemoteDesktop.dproj
├── appRemoteDesktop.dproj.local
├── appRemoteDesktop.identcache
├── appRemoteDesktop.res
├── appRemoteDesktop.skincfg
├── appRemoteDesktop.stat
├── mobile
│ ├── AndroidManifest.template.xml
│ ├── Chapter6_Mob.deployproj
│ ├── Chapter6_Mob.dpr
│ ├── Chapter6_Mob.dproj
│ ├── Chapter6_Mob.dproj.local
│ ├── Chapter6_Mob.identcache
│ ├── Chapter6_Mob.res
│ ├── Chapter6_Mob.skincfg
│ ├── Chapter6_Mob.stat
│ ├── Win32
│ │ └── Debug
│ │ │ └── uFrmMobile.dcu
│ ├── __history
│ │ ├── uFrmMobile.fmx.~10~
│ │ ├── uFrmMobile.fmx.~11~
│ │ ├── uFrmMobile.fmx.~12~
│ │ ├── uFrmMobile.fmx.~13~
│ │ ├── uFrmMobile.fmx.~4~
│ │ ├── uFrmMobile.fmx.~5~
│ │ ├── uFrmMobile.fmx.~6~
│ │ ├── uFrmMobile.fmx.~7~
│ │ ├── uFrmMobile.fmx.~8~
│ │ ├── uFrmMobile.fmx.~9~
│ │ ├── uFrmMobile.pas.~10~
│ │ ├── uFrmMobile.pas.~11~
│ │ ├── uFrmMobile.pas.~12~
│ │ ├── uFrmMobile.pas.~13~
│ │ ├── uFrmMobile.pas.~4~
│ │ ├── uFrmMobile.pas.~5~
│ │ ├── uFrmMobile.pas.~6~
│ │ ├── uFrmMobile.pas.~7~
│ │ ├── uFrmMobile.pas.~8~
│ │ └── uFrmMobile.pas.~9~
│ ├── uFrmMobile.fmx
│ └── uFrmMobile.pas
├── uFrmCap6_Server.fmx
└── uFrmCap6_Server.pas
├── Chapter07
├── Converter.pas
├── ConverterRS.dpk
├── ConverterRS.dproj
├── ConverterRS.dproj.local
├── ConverterRS.identcache
├── ConverterRS.res
├── ConverterRS.skincfg
├── ConverterRadS.skincfg
├── Link.txt
├── uConverterRADServer.dfm
└── uConverterRADServer.pas
├── LICENSE
└── README.md
/Chapter01/Instagram.dpr:
--------------------------------------------------------------------------------
1 | program Instagram;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | uFrmInstagram in 'uFrmInstagram.pas' {Form1};
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.CreateForm(TForm1, Form1);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/Chapter01/Instagram.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2016/09/15 14:31:27.000.266,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2017/03/20 19:34:45.000.065,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2017/06/23 00:14:20.000.496,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2018/01/25 21:27:09.000.193,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
8 | 2018/01/29 19:10:21.000.582,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
9 | 2018/05/10 18:28:07.000.409,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
10 | 2018/08/09 11:37:16.000.530,=C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas
11 | 2018/08/09 11:37:44.000.769,C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.pas=H:\99Coders\Posts\24 - Clone Instagram - 02 - Login\Fontes\Form_Inicial.pas
12 | 2018/08/09 11:37:44.000.769,C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Unit1.fmx=H:\99Coders\Posts\24 - Clone Instagram - 02 - Login\Fontes\Form_Inicial.fmx
13 | 2018/08/09 11:37:51.000.552,C:\Users\Heber\Documents\Embarcadero\Studio\Projects\Project1.dproj=H:\99Coders\Posts\24 - Clone Instagram - 02 - Login\Fontes\Instagram.dproj
14 | 2018/08/17 19:46:59.000.974,=H:\99Coders\Posts\28 - Clone Instagram - 03 - Nova Conta\Fontes\Unit2.pas
15 | 2018/08/17 19:47:17.000.280,H:\99Coders\Posts\28 - Clone Instagram - 03 - Nova Conta\Fontes\Form_Login.pas=H:\99Coders\Posts\28 - Clone Instagram - 03 - Nova Conta\Fontes\Unit2.pas
16 | 2018/08/17 19:47:17.000.280,H:\99Coders\Posts\28 - Clone Instagram - 03 - Nova Conta\Fontes\Form_Login.fmx=H:\99Coders\Posts\28 - Clone Instagram - 03 - Nova Conta\Fontes\Unit2.fmx
17 | 2018/10/26 01:30:31.000.076,=C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\Unit1.pas
18 | 2018/10/26 04:17:34.000.885,C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\uFrmInstagram.pas
19 | 2018/10/26 04:17:34.000.885,C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\Unit1.fmx=C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\uFrmInstagram.fmx
20 | 2018/12/04 03:50:16.000.950,C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\Form_Login.pas=
21 | 2018/12/04 03:50:17.000.188,C:\Projetos\Livro Delphi Packt\examples\01 - Instagram Clone\Form_Inicial.pas=
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/Chapter01/Instagram.identcache:
--------------------------------------------------------------------------------
1 | jC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\01 - Instagram Clone\uFrmInstagram.pas fC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\01 - Instagram Clone\Instagram.dpr
--------------------------------------------------------------------------------
/Chapter01/Instagram.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter01/Instagram.res
--------------------------------------------------------------------------------
/Chapter01/Instagram.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter01/Instagram.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=1
3 | DesignerSecs=342
4 | InspectorSecs=385
5 | CompileSecs=168591
6 | OtherSecs=9
7 | StartTime=17/08/2018 19:28:13
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=162
11 |
--------------------------------------------------------------------------------
/Chapter01/uFrmInstagram.LgXhdpiPh.fmx:
--------------------------------------------------------------------------------
1 | inherited Form1_LgXhdpiPh: TForm1_LgXhdpiPh
2 | ClientHeight = 695
3 | ClientWidth = 450
4 | DesignerMasterStyle = 0
5 | inherited ToolBar1: TToolBar
6 | Size.Width = 450.000000000000000000
7 | inherited Button3: TButton
8 | Position.X = 397.000000000000000000
9 | end
10 | end
11 | inherited ToolBar2: TToolBar
12 | Position.Y = 647.000000000000000000
13 | Size.Width = 450.000000000000000000
14 | inherited Button1: TButton
15 | Position.X = 397.000000000000000000
16 | end
17 | end
18 | inherited Layout1: TLayout
19 | Size.Width = 450.000000000000000000
20 | Size.Height = 599.000000000000000000
21 | inherited ImgInsta: TImage
22 | Size.Width = 450.000000000000000000
23 | Size.Height = 599.000000000000000000
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/Chapter01/uFrmInstagram.NmXhdpiPh.fmx:
--------------------------------------------------------------------------------
1 | inherited Form1_NmXhdpiPh: TForm1_NmXhdpiPh
2 | ClientHeight = 615
3 | ClientWidth = 400
4 | DesignerMasterStyle = 0
5 | inherited ToolBar1: TToolBar
6 | Size.Width = 400.000000000000000000
7 | inherited Button3: TButton
8 | Position.X = 347.000000000000000000
9 | end
10 | end
11 | inherited ToolBar2: TToolBar
12 | Position.Y = 567.000000000000000000
13 | Size.Width = 400.000000000000000000
14 | inherited Button1: TButton
15 | Position.X = 347.000000000000000000
16 | end
17 | end
18 | inherited Layout1: TLayout
19 | Size.Width = 400.000000000000000000
20 | Size.Height = 519.000000000000000000
21 | inherited ImgInsta: TImage
22 | Size.Width = 400.000000000000000000
23 | Size.Height = 519.000000000000000000
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/Chapter01/uFrmInstagram.fmx:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | OnCreate = FormCreate
11 | DesignerMasterStyle = 3
12 | object ToolBar1: TToolBar
13 | Size.Width = 640.000000000000000000
14 | Size.Height = 48.000000000000000000
15 | Size.PlatformDefault = False
16 | TabOrder = 0
17 | object btnPhoto: TButton
18 | Action = TakePhotoFromCameraAction1
19 | Align = Left
20 | Enabled = True
21 | ImageIndex = -1
22 | Margins.Left = 5.000000000000000000
23 | Margins.Top = 5.000000000000000000
24 | Margins.Right = 5.000000000000000000
25 | Margins.Bottom = 5.000000000000000000
26 | Position.X = 5.000000000000000000
27 | Position.Y = 5.000000000000000000
28 | Size.Width = 48.000000000000000000
29 | Size.Height = 48.000000000000000000
30 | Size.PlatformDefault = False
31 | StyleLookup = 'cameratoolbutton'
32 | TabOrder = 0
33 | end
34 | object Button2: TButton
35 | Action = TakePhotoFromLibraryAction1
36 | Align = Left
37 | Enabled = True
38 | ImageIndex = -1
39 | Margins.Left = 5.000000000000000000
40 | Margins.Top = 5.000000000000000000
41 | Margins.Right = 5.000000000000000000
42 | Margins.Bottom = 5.000000000000000000
43 | Position.X = 63.000000000000000000
44 | Position.Y = 5.000000000000000000
45 | Size.Width = 48.000000000000000000
46 | Size.Height = 48.000000000000000000
47 | Size.PlatformDefault = False
48 | StyleLookup = 'searchtoolbutton'
49 | TabOrder = 1
50 | end
51 | object Rectangle1: TRectangle
52 | Align = Center
53 | ClipChildren = True
54 | Fill.Color = claNull
55 | Size.Width = 171.000000000000000000
56 | Size.Height = 48.000000000000000000
57 | Size.PlatformDefault = False
58 | Stroke.Kind = None
59 | XRadius = 5.000000000000000000
60 | YRadius = 5.000000000000000000
61 | object SpeedButton1: TSpeedButton
62 | Align = Client
63 | Size.Width = 171.000000000000000000
64 | Size.Height = 48.000000000000000000
65 | Size.PlatformDefault = False
66 | StyleLookup = 'SpeedButton1Style1'
67 | Text = 'Share'
68 | object Path1: TPath
69 | Align = Left
70 | Data.Path = {
71 | 4A000000000000009A99F94000000040010000009A9981410000004002000000
72 | 33339B4100000040020000000000B04133339340020000000000B0419A99F940
73 | 010000000000B0419A998141020000000000B041DC399B4102000000DD399B41
74 | 0000B041020000009B9981410000B041010000009A99F9400000B04102000000
75 | 333393400000B041020000000000004033339B4102000000000000409A998141
76 | 01000000000000409A99F94002000000020000408E1893400200000092189340
77 | FCFFFF3F020000009C99F94000000040000000003333F3400000804002000000
78 | AA93B340010080400200000001008040AA93B34002000000020080403433F340
79 | 0100000002008040333383410200000000008040B81E9341020000001F85B340
80 | 0000A041020000003333F3400000A04101000000333383410000A04102000000
81 | 161B93410100A041020000000100A041161B9341020000000100A04134338341
82 | 010000000100A0413333F340020000000000A0411F85B34002000000B81E9341
83 | 00008040020000003333834100008040010000003333F3400000804000000000
84 | 00008A410000B04002000000D9858F410000B04002000000000094419BE8C140
85 | 02000000000094410000D84002000000000094416517EE4002000000D9858F41
86 | 000000410200000000008A410000004102000000277A84410000004102000000
87 | 000080416517EE4002000000000080410000D84002000000000080419AE8C140
88 | 02000000277A84410000B0400200000000008A410000B0400000000000004041
89 | 0000E04002000000CB2E6C410000E040020000000000884135D1134102000000
90 | 00008841000040410200000000008841CB2E6C4102000000CB2E6C4100008841
91 | 0200000000004041000088410200000035D1134100008841020000000000E040
92 | CB2E6C41020000000000E04000004041020000000100E04034D1134102000000
93 | 36D11341FFFFDF4002000000010040410000E040000000000000404100001041
94 | 02000000867D2541000010410200000000001041867D25410200000000001041
95 | 0000404102000000000010417A825A4102000000867D25410000704102000000
96 | 0000404100007041020000007A825A410000704102000000000070417A825A41
97 | 0200000000007041000040410200000000007041867D2541020000007A825A41
98 | 00001041020000000000404100001041030000000000404100001041}
99 | Fill.Color = xFFD317FA
100 | Margins.Left = 1.000000000000000000
101 | Margins.Top = 5.000000000000000000
102 | Margins.Right = 1.000000000000000000
103 | Margins.Bottom = 5.000000000000000000
104 | Position.X = 1.000000000000000000
105 | Position.Y = 5.000000000000000000
106 | Size.Width = 43.000000000000000000
107 | Size.Height = 38.000000000000000000
108 | Size.PlatformDefault = False
109 | Stroke.Kind = None
110 | end
111 | end
112 | end
113 | object Button3: TButton
114 | Align = Right
115 | Margins.Left = 5.000000000000000000
116 | Margins.Top = 5.000000000000000000
117 | Margins.Right = 5.000000000000000000
118 | Margins.Bottom = 5.000000000000000000
119 | Position.X = 587.000000000000000000
120 | Position.Y = 5.000000000000000000
121 | Size.Width = 48.000000000000000000
122 | Size.Height = 48.000000000000000000
123 | Size.PlatformDefault = False
124 | StyleLookup = 'cameratoolbutton'
125 | TabOrder = 3
126 | Text = 'Button3'
127 | OnClick = Button3Click
128 | end
129 | end
130 | object ToolBar2: TToolBar
131 | Align = Bottom
132 | Position.Y = 432.000000000000000000
133 | Size.Width = 640.000000000000000000
134 | Size.Height = 48.000000000000000000
135 | Size.PlatformDefault = False
136 | TabOrder = 1
137 | object Button1: TButton
138 | Align = Right
139 | Margins.Left = 5.000000000000000000
140 | Margins.Top = 5.000000000000000000
141 | Margins.Right = 5.000000000000000000
142 | Margins.Bottom = 5.000000000000000000
143 | Position.X = 587.000000000000000000
144 | Position.Y = 5.000000000000000000
145 | Size.Width = 48.000000000000000000
146 | Size.Height = 48.000000000000000000
147 | Size.PlatformDefault = False
148 | StyleLookup = 'escapetoolbutton'
149 | TabOrder = 0
150 | Text = 'Button1'
151 | end
152 | end
153 | object Layout1: TLayout
154 | Align = Client
155 | Size.Width = 640.000000000000000000
156 | Size.Height = 384.000000000000000000
157 | Size.PlatformDefault = False
158 | TabOrder = 2
159 | object ImgInsta: TImage
160 | MultiResBitmap = <
161 | item
162 | end>
163 | Align = Client
164 | Size.Width = 640.000000000000000000
165 | Size.Height = 384.000000000000000000
166 | Size.PlatformDefault = False
167 | end
168 | end
169 | object ActionList1: TActionList
170 | Left = 488
171 | Top = 392
172 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
173 | Category = 'Media Library'
174 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
175 | end
176 | object TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction
177 | Category = 'Media Library'
178 | OnDidFinishTaking = TakePhotoFromLibraryAction1DidFinishTaking
179 | end
180 | object ShowShareSheetAction1: TShowShareSheetAction
181 | Category = 'Media Library'
182 | OnBeforeExecute = ShowShareSheetAction1BeforeExecute
183 | end
184 | end
185 | end
186 |
--------------------------------------------------------------------------------
/Chapter01/uFrmInstagram.pas:
--------------------------------------------------------------------------------
1 | unit uFrmInstagram;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
8 | FMX.StdCtrls, FMX.Layouts, FMX.Controls.Presentation, System.Actions,
9 | FMX.ActnList, FMX.StdActns, FMX.MediaLibrary.Actions,
10 | FMX.MediaLibrary, FMX.Platform, System.Messaging;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | ToolBar1: TToolBar;
15 | btnPhoto: TButton;
16 | Button2: TButton;
17 | ToolBar2: TToolBar;
18 | Button1: TButton;
19 | Layout1: TLayout;
20 | Rectangle1: TRectangle;
21 | SpeedButton1: TSpeedButton;
22 | Path1: TPath;
23 | ImgInsta: TImage;
24 | ActionList1: TActionList;
25 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
26 | TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction;
27 | Button3: TButton;
28 | ShowShareSheetAction1: TShowShareSheetAction;
29 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
30 | procedure TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
31 | procedure Button3Click(Sender: TObject);
32 | procedure ShowShareSheetAction1BeforeExecute(Sender: TObject);
33 | procedure FormCreate(Sender: TObject);
34 | private
35 | { Private declarations }
36 | public
37 | { Public declarations }
38 | procedure DoDidFinish(Image: TBitmap);
39 | procedure DoMessageListener(const Sender: TObject; const M: TMessage);
40 | end;
41 |
42 | var
43 | Form1: TForm1;
44 |
45 | implementation
46 |
47 | {$R *.fmx}
48 | {$R *.LgXhdpiPh.fmx ANDROID}
49 | {$R *.NmXhdpiPh.fmx ANDROID}
50 | {$R *.SmXhdpiPh.fmx ANDROID}
51 |
52 | { TForm1 }
53 |
54 | procedure TForm1.Button3Click(Sender: TObject);
55 | var
56 | Service: IFMXCameraService;
57 | Params: TParamsPhotoQuery;
58 | begin
59 | if TPlatformServices.Current.SupportsPlatformService(IFMXCameraService,
60 | Service) then
61 | begin
62 | Params.Editable := True;
63 | // Specifies whether to save a picture to device Photo Library
64 | Params.NeedSaveToAlbum := True;
65 | Params.RequiredResolution := TSize.Create(640, 640);
66 | Params.OnDidFinishTaking := DoDidFinish;
67 | Service.TakePhoto(Button3, Params);
68 | end
69 | else
70 | ShowMessage('This device does not support the camera service');
71 | end;
72 |
73 | procedure TForm1.DoDidFinish(Image: TBitmap);
74 | begin
75 | ImgInsta.Bitmap.Assign(Image);
76 | end;
77 |
78 | procedure TForm1.DoMessageListener(const Sender: TObject; const M: TMessage);
79 | begin
80 | if M is TMessageDidFinishTakingImageFromLibrary then
81 | ImgInsta.Bitmap.Assign(TMessageDidFinishTakingImageFromLibrary(M).Value);
82 | end;
83 |
84 | procedure TForm1.FormCreate(Sender: TObject);
85 | begin
86 | TMessageManager.DefaultManager.SubscribeToMessage(
87 | TMessageDidFinishTakingImageFromLibrary, DoMessageListener);
88 | end;
89 |
90 | procedure TForm1.ShowShareSheetAction1BeforeExecute(Sender: TObject);
91 | begin
92 | ShowShareSheetAction1.Bitmap.Assign(ImgInsta.Bitmap);
93 | end;
94 |
95 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
96 | begin
97 | DoDidFinish(Image);
98 | end;
99 |
100 | procedure TForm1.TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
101 | begin
102 | DoDidFinish(Image);
103 | end;
104 |
105 | end.
106 |
--------------------------------------------------------------------------------
/Chapter02/LoginFacebook.dpr:
--------------------------------------------------------------------------------
1 | program LoginFacebook;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | Unit1 in 'Unit1.pas' {Form1},
7 | uFrmLogin in 'uFrmLogin.pas' {FrmLogin};
8 |
9 | {$R *.res}
10 |
11 | begin
12 | Application.Initialize;
13 | Application.CreateForm(TForm1, Form1);
14 | Application.CreateForm(TFrmLogin, FrmLogin);
15 | Application.Run;
16 | end.
17 |
--------------------------------------------------------------------------------
/Chapter02/LoginFacebook.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2017/01/27 01:51:54.000.434,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2017/01/27 01:56:03.000.741,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2017/01/28 02:15:30.000.300,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2017/01/28 15:34:59.000.164,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
8 | 2018/02/20 11:24:07.000.197,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
9 | 2018/12/02 23:26:01.660,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
10 | 2018/12/03 03:56:18.156,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit2.pas
11 | 2018/12/03 05:10:28.961,C:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\Unit1.fmx=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.fmx
12 | 2018/12/03 05:10:28.961,C:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\Unit1.pas=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
13 | 2018/12/03 05:10:42.477,C:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\uFrmLogin.pas=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit2.pas
14 | 2018/12/03 05:10:42.477,C:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\uFrmLogin.fmx=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit2.fmx
15 | 2018/12/03 05:10:50.241,C:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\LoginFacebook.dproj=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Chapter02/LoginFacebook.identcache:
--------------------------------------------------------------------------------
1 | EC:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\Unit1.pas MC:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\LoginFacebook.dpr IC:\Projetos\Livro Delphi Packt\examples\02 - Facebook Login\uFrmLogin.pas
--------------------------------------------------------------------------------
/Chapter02/LoginFacebook.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter02/LoginFacebook.res
--------------------------------------------------------------------------------
/Chapter02/Unit1.fmx:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object edtName: TEdit
12 | Touch.InteractiveGestures = [LongTap, DoubleTap]
13 | TabOrder = 4
14 | Position.X = 112.000000000000000000
15 | Position.Y = 80.000000000000000000
16 | Size.Width = 137.000000000000000000
17 | Size.Height = 22.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object edtEmail: TEdit
21 | Touch.InteractiveGestures = [LongTap, DoubleTap]
22 | TabOrder = 5
23 | Position.X = 112.000000000000000000
24 | Position.Y = 112.000000000000000000
25 | Size.Width = 137.000000000000000000
26 | Size.Height = 22.000000000000000000
27 | Size.PlatformDefault = False
28 | end
29 | object btnLogin: TButton
30 | Position.X = 152.000000000000000000
31 | Position.Y = 200.000000000000000000
32 | TabOrder = 6
33 | Text = 'btnLogin'
34 | OnClick = btnLoginClick
35 | end
36 | object circle_photo: TCircle
37 | Fill.Bitmap.WrapMode = Tile
38 | Fill.Kind = Bitmap
39 | Position.X = 272.000000000000000000
40 | Position.Y = 80.000000000000000000
41 | Size.Width = 150.000000000000000000
42 | Size.Height = 150.000000000000000000
43 | Size.PlatformDefault = False
44 | end
45 | object RESTClient1: TRESTClient
46 | Authenticator = OAuth2Authenticator1
47 | Accept = 'application/json, text/plain; q=0.9, text/html;q=0.8,'
48 | Params = <>
49 | HandleRedirects = True
50 | Left = 56
51 | Top = 88
52 | end
53 | object RESTResponse1: TRESTResponse
54 | ContentType = 'application/json'
55 | Left = 56
56 | Top = 32
57 | end
58 | object RESTRequest1: TRESTRequest
59 | Client = RESTClient1
60 | Params = <>
61 | Response = RESTResponse1
62 | OnAfterExecute = RESTRequest1AfterExecute
63 | SynchronizedEvents = False
64 | Left = 56
65 | Top = 144
66 | end
67 | object OAuth2Authenticator1: TOAuth2Authenticator
68 | AuthorizationEndpoint = 'https://www.facebook.com/dialog/oauth'
69 | ResponseType = rtTOKEN
70 | Scope = 'user_about_me,user_birthday'
71 | Left = 56
72 | Top = 200
73 | end
74 | end
75 |
--------------------------------------------------------------------------------
/Chapter02/Unit1.pas:
--------------------------------------------------------------------------------
1 | unit Unit1;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Edit, REST.Client,
9 | REST.Authenticator.OAuth, Data.Bind.Components, Data.Bind.ObjectScope;
10 |
11 | type
12 | TForm1 = class(TForm)
13 | RESTClient1: TRESTClient;
14 | RESTResponse1: TRESTResponse;
15 | RESTRequest1: TRESTRequest;
16 | OAuth2Authenticator1: TOAuth2Authenticator;
17 | edtName: TEdit;
18 | edtEmail: TEdit;
19 | btnLogin: TButton;
20 | circle_photo: TCircle;
21 | procedure RESTRequest1AfterExecute(Sender: TCustomRESTRequest);
22 | procedure btnLoginClick(Sender: TObject);
23 | private
24 | { Private declarations }
25 |
26 | function LoadPhoto(url : string): TMemoryStream;
27 | public
28 | { Public declarations }
29 | FAccessToken : String;
30 | end;
31 |
32 | var
33 | Form1: TForm1;
34 |
35 | implementation
36 |
37 | {$R *.fmx}
38 |
39 | uses
40 | REST.Utils, System.JSON, Web.HTTPApp,System.Net.HttpClient,IdHTTP,
41 | uFrmLogin;
42 |
43 | procedure TForm1.btnLoginClick(Sender: TObject);
44 | var
45 | app_id, LURL : string;
46 | begin
47 | try
48 | FAccessToken := '';
49 | app_id := '1000017776848929'; // Your App ID here...
50 |
51 | LURL := 'https://www.facebook.com/dialog/oauth'
52 | + '?client_id=' + URIEncode(app_id)
53 | + '&response_type=token'
54 | + '&scope=' + URIEncode('public_profile,email')
55 | + '&redirect_uri=' + URIEncode('https://www.facebook.com/connect/login_success.html');
56 |
57 |
58 | // Abre tela de login do facebook...
59 | try
60 | FrmLogin := TFrmLogin.Create(nil);
61 | FrmLogin.WebBrowser1.Navigate(LURL);
62 | FrmLogin.ShowModal(
63 | procedure(ModalResult: TModalResult)
64 | begin
65 | if FAccessToken <> '' then
66 | begin
67 | RESTRequest1.ResetToDefaults;
68 | RESTClient1.ResetToDefaults;
69 | RESTResponse1.ResetToDefaults;
70 |
71 | RESTClient1.BaseURL := 'https://graph.facebook.com';
72 | RESTClient1.Authenticator := OAuth2Authenticator1;
73 | RESTRequest1.Resource := 'me?fields=first_name,last_name,email,picture.height(150)';
74 | OAuth2Authenticator1.AccessToken := FAccessToken;
75 |
76 | RESTRequest1.Execute;
77 | end;
78 | end);
79 | finally
80 |
81 | end;
82 |
83 |
84 | except on e:exception do
85 | showmessage(e.Message);
86 | end;
87 | end;
88 |
89 | function TForm1.LoadPhoto(url : string): TMemoryStream;
90 | var
91 | MS : TMemoryStream;
92 | photo: TBitmap;
93 | http : THTTPClient;
94 | begin
95 | MS := TMemoryStream.Create;
96 | http := THTTPClient.Create;
97 |
98 | photo := TBitmap.Create;
99 | try
100 | try
101 | http.Get(url, MS);
102 |
103 | except on e: EIdHTTPProtocolException do
104 | begin
105 | if e.ErrorCode = 404 then
106 | begin
107 | // url not found
108 | showmessage('Not found');
109 | end
110 | else
111 | begin
112 | // error.
113 | showmessage('Error...');
114 | end;
115 | end;
116 | end;
117 |
118 | MS.Position := 0;
119 | Result := MS;
120 | finally
121 | photo.Free;
122 | end;
123 | end;
124 |
125 | procedure TForm1.RESTRequest1AfterExecute(Sender: TCustomRESTRequest);
126 | var
127 | LJsonObj : TJSONObject;
128 | LElements: TJSONValue;
129 |
130 | msg, url_photo, name, email, user_id : string;
131 |
132 | MS: TMemoryStream;
133 | begin
134 | try
135 | msg := '';
136 | FAccessToken := '';
137 |
138 |
139 | // Valid JSON
140 | if Assigned(RESTResponse1.JSONValue) then
141 | msg := RESTResponse1.JSONValue.ToString;
142 |
143 |
144 | // Extract JSON fields
145 | LJsonObj := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(msg), 0) as TJSONObject;
146 |
147 | try
148 | user_id := HTMLDecode(StringReplace(TJSONObject(LJsonObj).Get('id').JsonValue.ToString, '"', '', [rfReplaceAll]));
149 | except
150 | end;
151 |
152 | try
153 | email := StringReplace(TJSONObject(LJsonObj).Get('email').JsonValue.ToString, '"', '', [rfReplaceAll]);
154 | except
155 | end;
156 |
157 | try
158 | // First Name
159 | name := StringReplace(TJSONObject(LJsonObj).Get('first_name').JsonValue.ToString, '"', '', [rfReplaceAll]);
160 | except
161 | end;
162 |
163 | try
164 | // Last Name
165 | name := name + ' ' + StringReplace(TJSONObject(LJsonObj).Get('last_name').JsonValue.ToString, '"', '', [rfReplaceAll]);
166 | except
167 | end;
168 |
169 | try
170 | LElements := TJSONObject(TJSONObject(LJsonObj).Get('picture').JsonValue).Get('data').JsonValue;
171 | url_photo := StringReplace(TJSONObject(LElements).Get('url').JsonValue.ToString, '"', '', [rfReplaceAll]);
172 | except
173 | end;
174 |
175 |
176 |
177 |
178 | // Download Photo
179 | try
180 | MS := TMemoryStream.Create;
181 | MS := LoadPhoto(url_photo);
182 |
183 | circle_photo.Fill.Bitmap.Bitmap.LoadFromStream(MS);
184 |
185 | except
186 | showmessage('Error');
187 | end;
188 |
189 | edtName.Text := name;
190 | edtEmail.Text := email;
191 |
192 | except
193 |
194 | end;
195 | end;
196 |
197 |
198 | end.
199 |
--------------------------------------------------------------------------------
/Chapter02/iconfinder_love-book_2903245.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter02/iconfinder_love-book_2903245.png
--------------------------------------------------------------------------------
/Chapter02/uFrmLogin.fmx:
--------------------------------------------------------------------------------
1 | object FrmLogin: TFrmLogin
2 | Left = 0
3 | Top = 0
4 | Caption = 'FrmLogin'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Rectangle1: TRectangle
12 | Align = Top
13 | Fill.Color = xFF0023AA
14 | Size.Width = 640.000000000000000000
15 | Size.Height = 50.000000000000000000
16 | Size.PlatformDefault = False
17 | Stroke.Kind = None
18 | object btnCancel: TButton
19 | Align = Left
20 | Size.Width = 80.000000000000000000
21 | Size.Height = 50.000000000000000000
22 | Size.PlatformDefault = False
23 | TabOrder = 0
24 | Text = 'Cancel'
25 | end
26 | end
27 | object WebBrowser1: TWebBrowser
28 | Align = Client
29 | Size.Width = 640.000000000000000000
30 | Size.Height = 430.000000000000000000
31 | Size.PlatformDefault = False
32 | OnDidFinishLoad = WebBrowser1DidFinishLoad
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/Chapter02/uFrmLogin.pas:
--------------------------------------------------------------------------------
1 | unit uFrmLogin;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.WebBrowser,
8 | FMX.Controls.Presentation, FMX.StdCtrls, FMX.Objects;
9 |
10 | type
11 | TWebFormRedirectEvent = procedure(const AURL : string; var DoCloseWebView: boolean) of object;
12 |
13 | type
14 | TFrmLogin = class(TForm)
15 | Rectangle1: TRectangle;
16 | btnCancel: TButton;
17 | WebBrowser1: TWebBrowser;
18 | procedure WebBrowser1DidFinishLoad(ASender: TObject);
19 | private
20 | FOnBeforeRedirect: TWebFormRedirectEvent;
21 | { Private declarations }
22 | public
23 | { Public declarations }
24 | property OnBeforeRedirect: TWebFormRedirectEvent read FOnBeforeRedirect write FOnBeforeRedirect;
25 | end;
26 |
27 | var
28 | FrmLogin: TFrmLogin;
29 |
30 | implementation
31 |
32 | {$R *.fmx}
33 |
34 | uses
35 | Unit1;
36 |
37 | procedure Facebook_AccessTokenRedirect(const AURL: string; var DoCloseWebView: boolean);
38 | var
39 | LATPos: integer;
40 | LToken: string;
41 | begin
42 | try
43 | LATPos := Pos('access_token=', AURL);
44 |
45 | if (LATPos > 0) then
46 | begin
47 | LToken := Copy(AURL, LATPos + 13, Length(AURL));
48 |
49 | if (Pos('&', LToken) > 0) then
50 | begin
51 | LToken := Copy(LToken, 1, Pos('&', LToken) - 1);
52 | end;
53 |
54 | Form1.FAccessToken := LToken;
55 |
56 | if (LToken <> '') then
57 | begin
58 | DoCloseWebView := True;
59 | end;
60 | end
61 | else
62 | begin
63 | LATPos := Pos('api_key=', AURL);
64 |
65 | if LATPos <= 0 then
66 | begin
67 | LATPos := Pos('access_denied', AURL);
68 |
69 | if (LATPos > 0) then
70 | begin
71 | // Denied, Not Allow
72 | Form1.FAccessToken := '';
73 | DoCloseWebView := True;
74 | end;
75 | end;
76 | end;
77 | except
78 | on E: Exception do
79 | ShowMessage(E.Message);
80 | END;
81 | end;
82 |
83 | procedure TFrmLogin.WebBrowser1DidFinishLoad(ASender: TObject);
84 | var
85 | CloseWebView : boolean;
86 | url : string;
87 | begin
88 | url := TWebBrowser(ASender).URL;
89 | CloseWebView := false;
90 |
91 | if url <> '' then
92 | Facebook_AccessTokenRedirect(url, CloseWebView);
93 |
94 | if CloseWebView then
95 | begin
96 | TWebBrowser(ASender).Stop;
97 | TWebBrowser(ASender).URL := '';
98 | FrmLogin.close;
99 | ModalResult := mrok;
100 | end;
101 | end;
102 |
103 | end.
104 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/AndroidManifest.template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 | <%uses-permission%>
12 |
13 |
21 |
22 | <%application-meta-data%>
23 | <%services%>
24 |
26 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 | <%activity%>
39 | <%receivers%>
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/BootReceiverRemote/src/com/embarcadero/boot/BootPacktAndroidService.java:
--------------------------------------------------------------------------------
1 | package com.embarcadero.boot;
2 |
3 | import android.app.Activity;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Intent;
6 | import android.content.Context;
7 |
8 | public class BootPacktAndroidService extends BroadcastReceiver
9 | {
10 |
11 | @Override
12 | public void onReceive(Context context, Intent intent)
13 | {
14 |
15 | Intent launchintent = new Intent();
16 | launchintent.setClassName(context, "com.embarcadero.services.PacktAndroidService");
17 |
18 | context.startService(launchintent);
19 |
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidService$LocalBinder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidService$LocalBinder.class
--------------------------------------------------------------------------------
/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidService.class
--------------------------------------------------------------------------------
/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidServiceProxyInterface.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Android Services/JavaClasses/PacktAndroidService/com/embarcadero/services/PacktAndroidServiceProxyInterface.class
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.dpr:
--------------------------------------------------------------------------------
1 | program PacktAndroidService;
2 |
3 | uses
4 | System.Android.ServiceApplication,
5 | uPacktAndroidServiceDM in 'uPacktAndroidServiceDM.pas' {DM: TAndroidService};
6 |
7 | {$R *.res}
8 |
9 | begin
10 | Application.Initialize;
11 | Application.CreateForm(TDM, DM);
12 | Application.Run;
13 | end.
14 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2017/01/27 01:51:54.000.434,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2017/01/27 01:56:03.000.741,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2017/01/28 02:15:30.000.300,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2017/01/28 15:34:59.000.164,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
8 | 2018/02/20 11:24:07.000.197,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
9 | 2019/01/20 19:19:57.000.787,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
10 | 2019/01/20 19:23:28.000.685,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
11 | 2019/01/20 19:25:03.000.238,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\PacktAndroidService.dproj
12 | 2019/01/20 19:29:00.000.011,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\Unit1.pas
13 | 2019/01/20 19:29:00.000.011,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Projetos\Livro Delphi Packt\Unit1.dfm
14 | 2019/01/20 19:30:03.000.114,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\PacktAndroidService.dproj=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\PacktAndroidService.dproj
15 | 2019/01/20 19:30:28.000.907,C:\Projetos\Livro Delphi Packt\Unit1.dfm=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uPacktAndroidServiceDM.dfm
16 | 2019/01/20 19:30:28.000.907,C:\Projetos\Livro Delphi Packt\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uPacktAndroidServiceDM.pas
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.identcache:
--------------------------------------------------------------------------------
1 | aC:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uPacktAndroidServiceDM.pas ^C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\PacktAndroidService.dpr
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Android Services/PacktAndroidService.res
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=214
3 | DesignerSecs=12
4 | InspectorSecs=2
5 | CompileSecs=36119
6 | OtherSecs=6
7 | StartTime=20/01/2019 19:49:48
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=1
11 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidService.template.java:
--------------------------------------------------------------------------------
1 | //*******************************************************
2 | //
3 | // CodeGear Delphi Runtime Library
4 | // Copyright(c) 2014-2017 Embarcadero Technologies, Inc.
5 | // All rights reserved
6 | //
7 | //*******************************************************
8 |
9 | package com.embarcadero.services;
10 |
11 | import android.app.Service;
12 | import android.content.Intent;
13 | import android.content.res.Configuration;
14 | import android.os.IBinder;
15 | import android.os.Binder;
16 | import com.embarcadero.rtl.ProxyService;
17 |
18 | public class <%ServiceName%> extends Service {
19 | private final String baseLibraryName = "<%ServiceName%>";
20 | private String libraryName;
21 |
22 | // Binder given to clients
23 | public final IBinder mBinder = new LocalBinder();
24 |
25 | /**
26 | * Class used for the client Binder. Because we know this service always
27 | * runs in the same process as its clients, we don't need to deal with IPC.
28 | */
29 | public class LocalBinder extends Binder {
30 | public long getService() {
31 | // Return the instance of the Delphi LocalService so clients can call public methods
32 | return ProxyService.getService(this, libraryName);
33 | }
34 | }
35 |
36 | @Override
37 | public void onCreate() {
38 | libraryName = getApplicationInfo().nativeLibraryDir + "/lib" + baseLibraryName + ".so";
39 | super.onCreate();
40 | ProxyService.onCreate(this, libraryName);
41 | }
42 |
43 | @Override
44 | public void onDestroy() {
45 | ProxyService.onDestroy(this, libraryName);
46 | super.onDestroy();
47 | }
48 |
49 | @Override
50 | public int onStartCommand(Intent intent, int flags, int startId) {
51 | return ProxyService.onStartCommand(this, libraryName, intent, flags, startId);
52 | }
53 |
54 | @Override
55 | public IBinder onBind(Intent intent) {
56 | return ProxyService.onBind(this, libraryName, intent);
57 | }
58 |
59 | @Override
60 | public void onRebind(Intent intent) {
61 | ProxyService.onRebind(this, libraryName, intent);
62 | }
63 |
64 | @Override
65 | public boolean onUnbind(Intent intent) {
66 | return ProxyService.onUnbind(this, libraryName, intent);
67 | }
68 |
69 | @Override
70 | public void onConfigurationChanged(Configuration newConfig) {
71 | ProxyService.onConfigurationChanged(this, libraryName, newConfig);
72 | }
73 |
74 | @Override
75 | public void onLowMemory() {
76 | ProxyService.onLowMemory(this, libraryName);
77 | }
78 |
79 | @Override
80 | public void onTrimMemory(int level) {
81 | ProxyService.onTrimMemory(this, libraryName, level);
82 | }
83 |
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktAndroidServiceProxyInterface.template.java:
--------------------------------------------------------------------------------
1 | //*******************************************************
2 | //
3 | // CodeGear Delphi Runtime Library
4 | // Copyright(c) 2014-2017 Embarcadero Technologies, Inc.
5 | // All rights reserved
6 | //
7 | //*******************************************************
8 |
9 | package com.embarcadero.services;
10 |
11 | import java.lang.reflect.InvocationHandler;
12 | import java.lang.reflect.Method;
13 | import java.lang.reflect.Proxy;
14 |
15 | public class <%ServiceName%>ProxyInterface implements InvocationHandler{
16 | long pointer;
17 |
18 | public Object CreateProxyClass(Class listenerClass, long pointer) throws ClassNotFoundException{
19 | this.pointer = pointer;
20 | return Proxy.newProxyInstance(listenerClass.getClassLoader(), new Class[]{listenerClass}, this);
21 | }
22 |
23 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
24 | Object Obj = dispatchToNative(method.getName(), args, pointer);
25 | cleanNative(pointer);
26 | return Obj;
27 | }
28 |
29 | public native Object dispatchToNative(String method, Object[] args, long pointer);
30 | public native void cleanNative(long pointer);
31 | }
32 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktGroupAndroidServices.groupproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {587209DC-3AE1-491A-92F2-16392E46EE45}
4 |
5 |
6 |
7 |
8 |
9 |
10 | PacktAndroidService.dproj
11 |
12 |
13 |
14 | Default.Personality.12
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 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktGroupAndroidServices.groupproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/01/20 19:53:45.515,C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\PacktGroupAndroidServices.groupproj=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\ProjectGroup1.groupproj
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktHostApp.dpr:
--------------------------------------------------------------------------------
1 | program PacktHostApp;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | uFrmHostSerivce in 'uFrmHostSerivce.pas' {Form1},
7 | uPacktAndroidServiceDM in 'uPacktAndroidServiceDM.pas' {DM: TAndroidService};
8 |
9 | {$R *.res}
10 |
11 | begin
12 | Application.Initialize;
13 | Application.CreateForm(TForm1, Form1);
14 | Application.Run;
15 | end.
16 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktHostApp.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/01/20 19:49:24.000.619,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/01/20 19:50:12.110,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2019/01/20 19:52:06.198,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\PacktHostApp.dproj=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj
7 | 2019/01/20 19:52:15.151,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\uFrmHostSerivce.fmx=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.fmx
8 | 2019/01/20 19:52:15.151,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\uFrmHostSerivce.pas=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
9 | 2019/01/20 19:52:36.673,C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uFrmHostSerivce.fmx=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\uFrmHostSerivce.fmx
10 | 2019/01/20 19:52:36.673,C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uFrmHostSerivce.pas=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\uFrmHostSerivce.pas
11 | 2019/01/20 19:52:39.343,C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\PacktHostApp.dproj=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\PacktHostApp.dproj
12 | 2019/01/20 22:15:21.104,=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\uPacktAndroidServiceDM.pas
13 | 2019/01/20 22:15:21.179,=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Android Services\Android\Debug\PacktAndroidService.jar
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktHostApp.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Android Services/PacktHostApp.res
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktHostApp.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/PacktHostApp.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=102
3 | DesignerSecs=20
4 | InspectorSecs=9
5 | CompileSecs=2276
6 | OtherSecs=13
7 | StartTime=20/01/2019 21:56:51
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=1
11 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/uFrmHostSerivce.fmx:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object Button1: TButton
12 | Position.X = 248.000000000000000000
13 | Position.Y = 200.000000000000000000
14 | Size.Width = 137.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 1
18 | Text = 'Start Service'
19 | OnClick = Button1Click
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/uFrmHostSerivce.pas:
--------------------------------------------------------------------------------
1 | unit uFrmHostSerivce;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
8 | System.Android.Service, FMX.Controls.Presentation, FMX.StdCtrls;
9 |
10 | type
11 | TForm1 = class(TForm)
12 | Button1: TButton;
13 | procedure Button1Click(Sender: TObject);
14 | private
15 | { Private declarations }
16 | ConnService : TLocalServiceConnection;
17 | public
18 | { Public declarations }
19 | end;
20 |
21 | var
22 | Form1: TForm1;
23 |
24 | implementation
25 |
26 | {$R *.fmx}
27 |
28 | procedure TForm1.Button1Click(Sender: TObject);
29 | begin
30 | ConnService := TLocalServiceConnection.Create;
31 | ConnService.StartService('PacktAndroidService');
32 | end;
33 |
34 | end.
35 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/uPacktAndroidServiceDM.dfm:
--------------------------------------------------------------------------------
1 | object DM: TDM
2 | OldCreateOrder = False
3 | OnStartCommand = AndroidServiceStartCommand
4 | Height = 238
5 | Width = 324
6 | object NotificationCenter1: TNotificationCenter
7 | Left = 136
8 | Top = 96
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/Chapter03/Android Services/uPacktAndroidServiceDM.pas:
--------------------------------------------------------------------------------
1 | unit uPacktAndroidServiceDM;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils,
7 | System.Classes,
8 | System.Android.Service,
9 | AndroidApi.JNI.GraphicsContentViewText,
10 | Androidapi.JNI.Os, System.Notification, System.Threading,
11 | System.DateUtils;
12 |
13 | type
14 | TDM = class(TAndroidService)
15 | NotificationCenter1: TNotificationCenter;
16 | function AndroidServiceStartCommand(const Sender: TObject;
17 | const Intent: JIntent; Flags, StartId: Integer): Integer;
18 | private
19 | { Private declarations }
20 | public
21 | { Public declarations }
22 | T : ITask;
23 | procedure LaunchNotification(Name, Title, Body : String);
24 | end;
25 |
26 | var
27 | DM: TDM;
28 |
29 | implementation
30 |
31 | uses Androidapi.JNI.App;
32 |
33 | {%CLASSGROUP 'FMX.Controls.TControl'}
34 |
35 | {$R *.dfm}
36 |
37 | function TDM.AndroidServiceStartCommand(const Sender: TObject;
38 | const Intent: JIntent; Flags, StartId: Integer): Integer;
39 | begin
40 | Result := TJService.JavaClass.START_STICKY;
41 | T := TTask.Run( procedure
42 | begin
43 | while True do
44 | sleep(10);
45 | LaunchNotification('Packt Delphi Book', 'Delphi Rocks',
46 | 'This is Chapter 3!');
47 | exit;
48 | end
49 | )
50 | end;
51 |
52 | procedure TDM.LaunchNotification(Name, Title, Body: String);
53 | var
54 | Notify : TNotification;
55 | begin
56 | Notify := NotificationCenter1.CreateNotification;
57 | Try
58 | Notify.Name := Name;
59 | Notify.Title := Title;
60 | Notify.AlertBody := Body;
61 | Notify.FireDate := IncSecond(Now,1);
62 | NotificationCenter1.ScheduleNotification(Notify);
63 | Finally
64 | Notify.Free;
65 | End;
66 | end;
67 |
68 | end.
69 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.dpr:
--------------------------------------------------------------------------------
1 | program pService;
2 |
3 | uses
4 | Vcl.SvcMgr,
5 | uService in 'uService.pas' {PacktBooks_Service: TService};
6 |
7 | {$R *.RES}
8 |
9 | begin
10 | // Windows 2003 Server requires StartServiceCtrlDispatcher to be
11 | // called before CoRegisterClassObject, which can be called indirectly
12 | // by Application.Initialize. TServiceApplication.DelayInitialize allows
13 | // Application.Initialize to be called from TService.Main (after
14 | // StartServiceCtrlDispatcher has been called).
15 | //
16 | // Delayed initialization of the Application object may affect
17 | // events which then occur prior to initialization, such as
18 | // TService.OnCreate. It is only recommended if the ServiceApplication
19 | // registers a class object with OLE and is intended for use with
20 | // Windows 2003 Server.
21 | //
22 | // Application.DelayInitialize := True;
23 | //
24 | if not Application.DelayInitialize or Application.Installing then
25 | Application.Initialize;
26 | Application.CreateForm(TPacktBooks_Service, PacktBooks_Service);
27 | Application.Run;
28 | end.
29 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2017/01/27 01:51:54.000.434,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2017/01/27 01:56:03.000.741,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2017/01/28 02:15:30.000.300,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2017/01/28 15:34:59.000.164,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
8 | 2018/02/20 11:24:07.000.197,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
9 | 2019/01/13 19:58:45.000.153,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
10 | 2019/01/15 00:47:56.000.191,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Windows Services\uService.pas
11 | 2019/01/15 00:47:56.000.191,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Windows Services\uService.dfm
12 | 2019/01/15 00:48:04.000.390,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Projetos\Livro Delphi Packt\examples\03 - Services\Windows Services\pService.dproj
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.identcache:
--------------------------------------------------------------------------------
1 | Sc:\program files (x86)\embarcadero\studio\19.0\source\rtl\common\System.Classes.pas SC:\Projetos\Livro Delphi Packt\examples\03 - Services\Windows Services\pService.dpr SC:\Projetos\Livro Delphi Packt\examples\03 - Services\Windows Services\uService.pas
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter03/Windows Services/pService.res
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/pService.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=99
3 | DesignerSecs=3
4 | InspectorSecs=27
5 | CompileSecs=17960
6 | OtherSecs=138
7 | StartTime=19/01/2019 22:44:31
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=147
11 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/uService.dfm:
--------------------------------------------------------------------------------
1 | object PacktBooks_Service: TPacktBooks_Service
2 | OldCreateOrder = False
3 | DisplayName = 'PacktBooks_Service'
4 | OnContinue = ServiceContinue
5 | OnExecute = ServiceExecute
6 | OnPause = ServicePause
7 | OnStart = ServiceStart
8 | OnStop = ServiceStop
9 | Height = 150
10 | Width = 215
11 | object Timer1: TTimer
12 | Enabled = False
13 | Interval = 10000
14 | OnTimer = Timer1Timer
15 | Left = 88
16 | Top = 56
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/Chapter03/Windows Services/uService.pas:
--------------------------------------------------------------------------------
1 | unit uService;
2 |
3 | interface
4 |
5 | uses
6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,
7 | Vcl.ExtCtrls;
8 |
9 | type
10 | TPacktBooks_Service = class(TService)
11 | Timer1: TTimer;
12 | procedure ServiceExecute(Sender: TService);
13 | procedure Timer1Timer(Sender: TObject);
14 | procedure ServiceStart(Sender: TService; var Started: Boolean);
15 | procedure ServiceContinue(Sender: TService; var Continued: Boolean);
16 | procedure ServicePause(Sender: TService; var Paused: Boolean);
17 | procedure ServiceStop(Sender: TService; var Stopped: Boolean);
18 | private
19 | { Private declarations }
20 | public
21 | function GetServiceController: TServiceController; override;
22 | { Public declarations }
23 | end;
24 |
25 | TNewServiceThread = class(TThread)
26 | public
27 | procedure Execute; override;
28 | end;
29 |
30 | var
31 | PacktBooks_Service: TPacktBooks_Service;
32 | NewServiceThread: TNewServiceThread;
33 |
34 | implementation
35 |
36 | {$R *.dfm}
37 |
38 | procedure ServiceController(CtrlCode: DWord); stdcall;
39 | begin
40 | PacktBooks_Service.Controller(CtrlCode);
41 | end;
42 |
43 | function TPacktBooks_Service.GetServiceController: TServiceController;
44 | begin
45 | Result := ServiceController;
46 | end;
47 |
48 | procedure TPacktBooks_Service.ServiceContinue(Sender: TService;
49 | var Continued: Boolean);
50 | begin
51 | NewServiceThread.Resume;
52 | Continued := True;
53 | end;
54 |
55 | procedure TPacktBooks_Service.ServiceExecute(Sender: TService);
56 | begin
57 | // Timer1.Enabled := True;
58 | while not Terminated do
59 | ServiceThread.ProcessRequests(True);
60 | // Timer1.Enabled := False;
61 | end;
62 |
63 | procedure TPacktBooks_Service.ServicePause(Sender: TService;
64 | var Paused: Boolean);
65 | begin
66 | NewServiceThread.Suspend;
67 | Paused := True;
68 | end;
69 |
70 | procedure TPacktBooks_Service.ServiceStart(Sender: TService;
71 | var Started: Boolean);
72 | begin
73 | NewServiceThread := TNewServiceThread.Create(False);
74 | Started := True;
75 | end;
76 |
77 | procedure TPacktBooks_Service.ServiceStop(Sender: TService;
78 | var Stopped: Boolean);
79 | begin
80 | NewServiceThread.Terminate;
81 | Stopped := True;
82 | end;
83 |
84 | procedure TPacktBooks_Service.Timer1Timer(Sender: TObject);
85 | Const
86 | FileName = 'c:\Chapter3_WindowsServices.txt';
87 | var
88 | F: TextFile;
89 | begin
90 | AssignFile(f,FileName);
91 |
92 | if FileExists(FileName) then
93 | Append(f)
94 | else
95 | Rewrite(f);
96 |
97 | writeln(f,DateTimeToStr(Now));
98 | CloseFile(f);
99 | end;
100 |
101 | { TServiceThread }
102 |
103 | procedure TNewServiceThread.Execute;
104 | const
105 | FileName = 'c:\Chapter3_WindowsServices_SafeThread.txt';
106 | var
107 | F: TextFile;
108 | begin
109 | while not Terminated do
110 | begin
111 | AssignFile(f,FileName);
112 |
113 | if FileExists(FileName) then
114 | Append(f)
115 | else
116 | Rewrite(f);
117 |
118 | writeln(f,DateTimeToStr(Now));
119 | CloseFile(f);
120 | Sleep(10000);
121 | end;
122 | end;
123 |
124 | end.
125 |
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.dpr:
--------------------------------------------------------------------------------
1 | program MultiDatabase;
2 |
3 | uses
4 | Vcl.Forms,
5 | uFrmMain in 'uFrmMain.pas' {Form1},
6 | uiRepositories in 'uiRepositories.pas',
7 | uiRepoSystem in 'uiRepoSystem.pas',
8 | uUsers in 'uUsers.pas',
9 | uProducts in 'uProducts.pas',
10 | uCustomers in 'uCustomers.pas',
11 | uDM_RepositorySQLServer in 'uDM_RepositorySQLServer.pas' {DM_RepositorySQLServer: TDataModule},
12 | uRepositorySystemSQLServer in 'uRepositorySystemSQLServer.pas' {DM_RepositorySystemSQLServer: TDataModule},
13 | uDM_RepositoryPostgreSQL in 'uDM_RepositoryPostgreSQL.pas' {DM_RepositoryPostgreSQL: TDataModule},
14 | uRepositorySystemPostgreSQL in 'uRepositorySystemPostgreSQL.pas' {DM_RepositorySystemPostgreSQL: TDataModule},
15 | uiConfig in 'uiConfig.pas',
16 | uConfiguration in 'uConfiguration.pas';
17 |
18 | {$R *.res}
19 |
20 | begin
21 | Application.Initialize;
22 | Application.MainFormOnTaskbar := True;
23 | Application.CreateForm(TForm1, Form1);
24 | Application.Run;
25 | end.
26 |
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/02/18 01:45:38.000.980,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/02/18 01:49:48.000.946,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit2.pas
6 | 2019/02/18 01:50:31.000.170,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit2.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiSystem.pas
7 | 2019/02/18 01:54:47.000.182,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.dfm=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uFrmMain.dfm
8 | 2019/02/18 01:54:47.000.182,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uFrmMain.pas
9 | 2019/02/18 01:55:06.000.508,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiSystem.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiRepositories.pas
10 | 2019/02/18 01:55:17.000.269,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\MultiDatabase.dproj
11 | 2019/02/18 02:01:26.000.502,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
12 | 2019/02/18 02:01:43.000.727,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiRepoSystem.pas
13 | 2019/02/18 02:11:55.000.533,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
14 | 2019/02/18 02:12:01.000.225,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uUsers.pas
15 | 2019/02/18 02:12:04.000.451,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
16 | 2019/02/18 02:12:11.000.297,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uProducts.pas
17 | 2019/02/18 02:12:14.000.447,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
18 | 2019/02/18 02:12:20.000.324,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uCustomers.pas
19 | 2019/02/22 00:13:43.000.778,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
20 | 2019/02/22 02:16:24.000.779,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.dfm=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositorySQLServer.dfm
21 | 2019/02/22 02:16:24.000.779,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositorySQLServer.pas
22 | 2019/02/23 23:57:49.000.543,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
23 | 2019/02/24 00:07:24.000.474,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
24 | 2019/02/24 00:12:47.000.038,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemSQLServer.pas
25 | 2019/02/24 00:12:47.000.038,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.dfm=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemSQLServer.dfm
26 | 2019/03/03 19:02:58.555,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
27 | 2019/03/03 19:27:48.207,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositoryPostgreSQL.dfm=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.dfm
28 | 2019/03/03 19:27:48.207,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositoryPostgreSQL.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
29 | 2019/03/04 03:06:12.594,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
30 | 2019/03/04 03:08:14.570,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemPostgreSQL.dfm=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.dfm
31 | 2019/03/04 03:08:14.570,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemPostgreSQL.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
32 | 2019/03/04 04:10:30.153,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
33 | 2019/03/05 01:16:52.351,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiConfig.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
34 | 2019/03/05 01:17:00.054,=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
35 | 2019/03/05 01:28:51.009,C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uConfiguration.pas=C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\Unit1.pas
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.identcache:
--------------------------------------------------------------------------------
1 | NC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiRepositories.pas HC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiConfig.pas XC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositoryPostgreSQL.pas Ic:\program files (x86)\embarcadero\studio\19.0\SOURCE\RTL\SYS\SysInit.pas Zc:\program files (x86)\embarcadero\studio\19.0\source\data\firedac\FireDAC.Comp.Client.pas ZC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemSQLServer.pas [C:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uRepositorySystemPostgreSQL.pas WC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uDM_RepositorySQLServer.pas FC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uUsers.pas MC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\MultiDatabase.dpr JC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uCustomers.pas Hc:\program files (x86)\embarcadero\studio\19.0\SOURCE\RTL\SYS\System.pas IC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uProducts.pas HC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uFrmMain.pas LC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uiRepoSystem.pas NC:\Projetos\Livro Delphi Packt\examples\04 - Multi Database\uConfiguration.pas
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter04/MultiDatabase.res
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter04/MultiDatabase.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=884
3 | DesignerSecs=24
4 | InspectorSecs=144
5 | CompileSecs=44568
6 | OtherSecs=146
7 | StartTime=03/03/2019 17:21:10
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=269
11 |
--------------------------------------------------------------------------------
/Chapter04/uConfiguration.pas:
--------------------------------------------------------------------------------
1 | unit uConfiguration;
2 |
3 | interface
4 |
5 | uses
6 | uiConfig;
7 |
8 | Type
9 | TConfig = class(TInterfacedObject, IConfig)
10 | private
11 | fTypeDataBase : Integer;
12 | public
13 | function getTypeDataBase: Integer;
14 | procedure setTypeDataBase(const Value: Integer);
15 | Constructor Create;
16 | end;
17 |
18 | function configuration : IConfig;
19 |
20 |
21 | implementation
22 |
23 | uses
24 | SysUtils, IniFiles;
25 |
26 | var
27 | mConfig : IConfig = Nil;
28 | Ini : TIniFile;
29 |
30 | function configuration : IConfig;
31 | begin
32 | if not Assigned( mConfig )
33 | then
34 | mConfig := TConfig.Create;
35 | Result := mConfig;
36 | end;
37 |
38 | { TConfig }
39 |
40 | constructor TConfig.Create;
41 | begin
42 | Ini := TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'Packt.ini');
43 | end;
44 |
45 | function TConfig.getTypeDataBase: Integer;
46 | begin
47 | Result := Ini.ReadInteger('PACKT','DATABASE',0);
48 | end;
49 |
50 | procedure TConfig.setTypeDataBase(const Value: Integer);
51 | begin
52 | Ini.WriteInteger('PACKT','DATABASE',Value);
53 | fTypeDataBase := Value;
54 | end;
55 |
56 | end.
57 |
--------------------------------------------------------------------------------
/Chapter04/uCustomers.pas:
--------------------------------------------------------------------------------
1 | unit uCustomers;
2 |
3 | interface
4 |
5 | Type
6 | TCustomer = class
7 | private
8 | Fname: string;
9 | Fid: integer;
10 | Fstatus: integer;
11 | procedure Setid(const Value: integer);
12 | procedure Setname(const Value: string);
13 | procedure Setstatus(const Value: integer);
14 | published
15 | property id : integer read Fid write Setid;
16 | property name : string read Fname write Setname;
17 | property status : integer read Fstatus write Setstatus;
18 | end;
19 |
20 | implementation
21 |
22 | { TCustomer }
23 |
24 | procedure TCustomer.Setid(const Value: integer);
25 | begin
26 | Fid := Value;
27 | end;
28 |
29 | procedure TCustomer.Setname(const Value: string);
30 | begin
31 | Fname := Value;
32 | end;
33 |
34 | procedure TCustomer.Setstatus(const Value: integer);
35 | begin
36 | Fstatus := Value;
37 | end;
38 |
39 | end.
40 |
--------------------------------------------------------------------------------
/Chapter04/uDM_RepositoryPostgreSQL.dfm:
--------------------------------------------------------------------------------
1 | object DM_RepositoryPostgreSQL: TDM_RepositoryPostgreSQL
2 | OldCreateOrder = False
3 | OnCreate = DataModuleCreate
4 | Height = 204
5 | Width = 215
6 | object FDConnPostgreSQL: TFDConnection
7 | Params.Strings = (
8 | 'User_Name=postgres'
9 | 'Password=postgres'
10 | 'Database=packt'
11 | 'Port=5433'
12 | 'DriverID=PG')
13 | LoginPrompt = False
14 | Left = 88
15 | Top = 56
16 | end
17 | object FDPhysPgDriverLink1: TFDPhysPgDriverLink
18 | Left = 88
19 | Top = 112
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/Chapter04/uDM_RepositoryPostgreSQL.pas:
--------------------------------------------------------------------------------
1 | unit uDM_RepositoryPostgreSQL;
2 |
3 | interface
4 |
5 | uses
6 | Forms, Dialogs, uiRepositories, uiRepoSystem,
7 | System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
8 | FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
9 | FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.PG,
10 | FireDAC.Phys.PGDef, FireDAC.VCLUI.Wait, Data.DB, FireDAC.Comp.Client;
11 |
12 | type
13 | TDM_RepositoryPostgreSQL = class(TDataModule, IRepositories)
14 | FDConnPostgreSQL: TFDConnection;
15 | FDPhysPgDriverLink1: TFDPhysPgDriverLink;
16 | procedure DataModuleCreate(Sender: TObject);
17 | private
18 | { Private declarations }
19 | public
20 | { Public declarations }
21 | function Repository: IRepoSystem;
22 | end;
23 |
24 | var
25 | DM_RepositoryPostgreSQL: TDM_RepositoryPostgreSQL;
26 |
27 | procedure initialize; //declaration
28 |
29 | implementation
30 |
31 | uses
32 | uRepositorySystemPostgreSQL;
33 |
34 | {%CLASSGROUP 'Vcl.Controls.TControl'}
35 |
36 | var
37 | mRepository : IRepoSystem;
38 |
39 | procedure initialize;
40 | begin
41 | If Assigned( DM_RepositoryPostgreSQL ) then
42 | exit;
43 | Application.CreateForm(TDM_RepositoryPostgreSQL, DM_RepositoryPostgreSQL);
44 | end;
45 |
46 |
47 | {$R *.dfm}
48 |
49 | procedure TDM_RepositoryPostgreSQL.DataModuleCreate(Sender: TObject);
50 | begin
51 | Try
52 | FDConnPostgreSQL.Connected := False;
53 | FDConnPostgreSQL.Connected := True;
54 | Except
55 | On E : Exception do
56 | ShowMessage('Error Connect PostgreSQL : ' + E.Message)
57 | End;
58 | end;
59 |
60 | function TDM_RepositoryPostgreSQL.Repository: IRepoSystem;
61 | begin
62 | if not assigned(mRepository) then
63 | mRepository := TDM_RepositorySystemPostgreSQL.Create(Self);
64 | Result := mRepository;
65 | end;
66 |
67 | end.
68 |
--------------------------------------------------------------------------------
/Chapter04/uDM_RepositorySQLServer.dfm:
--------------------------------------------------------------------------------
1 | object DM_RepositorySQLServer: TDM_RepositorySQLServer
2 | OldCreateOrder = False
3 | OnCreate = DataModuleCreate
4 | Height = 201
5 | Width = 289
6 | object FDConnSQLServer: TFDConnection
7 | Params.Strings = (
8 | 'Server=localhost'
9 | 'User_Name=sa'
10 | 'Password=nwsoftware'
11 | 'Database=PACKT'
12 | 'DriverID=MSSQL')
13 | LoginPrompt = False
14 | Left = 88
15 | Top = 56
16 | end
17 | object FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink
18 | Left = 88
19 | Top = 104
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/Chapter04/uDM_RepositorySQLServer.pas:
--------------------------------------------------------------------------------
1 | unit uDM_RepositorySQLServer;
2 |
3 | interface
4 |
5 | uses
6 | Forms, Dialogs, uiRepositories, uiRepoSystem,
7 | System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
8 | FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
9 | FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.MSSQL,
10 | FireDAC.Phys.MSSQLDef, FireDAC.VCLUI.Wait, FireDAC.Phys.ODBCBase, Data.DB,
11 | FireDAC.Comp.Client;
12 |
13 | type
14 | TDM_RepositorySQLServer = class(TDataModule, IRepositories)
15 | FDConnSQLServer: TFDConnection;
16 | FDPhysMSSQLDriverLink1: TFDPhysMSSQLDriverLink;
17 | procedure DataModuleCreate(Sender: TObject);
18 | private
19 | { Private declarations }
20 | public
21 | function Repository: IRepoSystem;
22 | { Public declarations }
23 | end;
24 |
25 | var
26 | DM_RepositorySQLServer: TDM_RepositorySQLServer;
27 |
28 | procedure initialize;
29 |
30 | implementation
31 |
32 | {%CLASSGROUP 'Vcl.Controls.TControl'}
33 |
34 | {$R *.dfm}
35 |
36 | uses
37 | uRepositorySystemSQLServer;
38 |
39 | var
40 | mRepository : IRepoSystem;
41 |
42 | procedure initialize;
43 | begin
44 | If Assigned( DM_RepositorySQLServer ) then
45 | exit;
46 | Application.CreateForm(TDM_RepositorySQLServer, DM_RepositorySQLServer);
47 | end;
48 |
49 | procedure TDM_RepositorySQLServer.DataModuleCreate(Sender: TObject);
50 | begin
51 | Try
52 | FDConnSQLServer.Connected := False;
53 | FDConnSQLServer.Connected := True;
54 | Except
55 | On E : Exception do
56 | ShowMessage('Error Connect SQL Server : ' + E.Message)
57 | End;
58 | end;
59 |
60 | function TDM_RepositorySQLServer.Repository: IRepoSystem;
61 | begin
62 | if not assigned(mRepository) then
63 | mRepository := TDM_RepositorySystemSQLServer.Create(Self);
64 | Result := mRepository;
65 | end;
66 |
67 | end.
68 |
--------------------------------------------------------------------------------
/Chapter04/uFrmMain.dfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 201
6 | ClientWidth = 447
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 | PixelsPerInch = 96
15 | TextHeight = 13
16 | object btnShowUser: TButton
17 | Left = 24
18 | Top = 32
19 | Width = 75
20 | Height = 25
21 | Caption = 'User'
22 | TabOrder = 0
23 | OnClick = btnShowUserClick
24 | end
25 | object btnShowCustomer: TButton
26 | Left = 24
27 | Top = 72
28 | Width = 75
29 | Height = 25
30 | Caption = 'Customer'
31 | TabOrder = 1
32 | OnClick = btnShowCustomerClick
33 | end
34 | object btnShowProduct: TButton
35 | Left = 24
36 | Top = 112
37 | Width = 75
38 | Height = 25
39 | Caption = 'Product'
40 | TabOrder = 2
41 | OnClick = btnShowProductClick
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/Chapter04/uFrmMain.pas:
--------------------------------------------------------------------------------
1 | unit uFrmMain;
2 |
3 | interface
4 |
5 | uses
6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
7 | Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
8 |
9 | type
10 | TForm1 = class(TForm)
11 | btnShowUser: TButton;
12 | btnShowCustomer: TButton;
13 | btnShowProduct: TButton;
14 | procedure btnShowUserClick(Sender: TObject);
15 | procedure btnShowCustomerClick(Sender: TObject);
16 | procedure btnShowProductClick(Sender: TObject);
17 | private
18 | { Private declarations }
19 | public
20 | { Public declarations }
21 | end;
22 |
23 | var
24 | Form1: TForm1;
25 |
26 | implementation
27 |
28 | uses
29 | uiRepositories, uUsers, uProducts, uCustomers;
30 |
31 | {$R *.dfm}
32 |
33 | procedure TForm1.btnShowProductClick(Sender: TObject);
34 | var
35 | pProduct : TProducts;
36 | begin
37 | pProduct := Repositories.Repository.ReturnProduct(1);
38 | ShowMessage(pProduct.descr);
39 | end;
40 |
41 | procedure TForm1.btnShowUserClick(Sender: TObject);
42 | var
43 | pUser : TUser;
44 | begin
45 | pUser := Repositories.Repository.ReturnUser(1);
46 | ShowMessage(pUser.login);
47 | end;
48 |
49 | procedure TForm1.btnShowCustomerClick(Sender: TObject);
50 | var
51 | pCustomer : TCustomer;
52 | begin
53 | pCustomer := Repositories.Repository.ReturnCustomer(1);
54 | ShowMessage(pCustomer.name);
55 | end;
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/Chapter04/uProducts.pas:
--------------------------------------------------------------------------------
1 | unit uProducts;
2 |
3 | interface
4 |
5 | Type
6 | TProducts = class
7 | private
8 | Fcode: string;
9 | Fid: integer;
10 | Fdescr: string;
11 | Fquantity: double;
12 | Ftax: double;
13 | Flist_price: double;
14 | procedure Setcode(const Value: string);
15 | procedure Setdescr(const Value: string);
16 | procedure Setid(const Value: integer);
17 | procedure Setlist_price(const Value: double);
18 | procedure Setquantity(const Value: double);
19 | procedure Settax(const Value: double);
20 | published
21 | property id : integer read Fid write Setid;
22 | property code : string read Fcode write Setcode;
23 | property descr : string read Fdescr write Setdescr;
24 | property list_price : double read Flist_price write Setlist_price;
25 | property tax : double read Ftax write Settax;
26 | property quantity : double read Fquantity write Setquantity;
27 | end;
28 |
29 | implementation
30 |
31 | { TProducts }
32 |
33 | procedure TProducts.Setcode(const Value: string);
34 | begin
35 | Fcode := Value;
36 | end;
37 |
38 | procedure TProducts.Setdescr(const Value: string);
39 | begin
40 | Fdescr := Value;
41 | end;
42 |
43 | procedure TProducts.Setid(const Value: integer);
44 | begin
45 | Fid := Value;
46 | end;
47 |
48 | procedure TProducts.Setlist_price(const Value: double);
49 | begin
50 | Flist_price := Value;
51 | end;
52 |
53 | procedure TProducts.Setquantity(const Value: double);
54 | begin
55 | Fquantity := Value;
56 | end;
57 |
58 | procedure TProducts.Settax(const Value: double);
59 | begin
60 | Ftax := Value;
61 | end;
62 |
63 | end.
64 |
--------------------------------------------------------------------------------
/Chapter04/uRepositorySystemPostgreSQL.dfm:
--------------------------------------------------------------------------------
1 | object DM_RepositorySystemPostgreSQL: TDM_RepositorySystemPostgreSQL
2 | OldCreateOrder = False
3 | Height = 190
4 | Width = 215
5 | object QryCustomerPostgreSQL: TFDQuery
6 | Connection = DM_RepositoryPostgreSQL.FDConnPostgreSQL
7 | SQL.Strings = (
8 |
9 | 'SELECT id_customer, customer_name, customer_status from customer' +
10 | 's'
11 | 'where id_customer =:id')
12 | Left = 80
13 | Top = 23
14 | ParamData = <
15 | item
16 | Name = 'ID'
17 | DataType = ftInteger
18 | ParamType = ptInput
19 | Value = Null
20 | end>
21 | end
22 | object QryUserPostgreSQL: TFDQuery
23 | Connection = DM_RepositoryPostgreSQL.FDConnPostgreSQL
24 | SQL.Strings = (
25 | 'select id_user, login, password from users'
26 | 'where id_user = :id')
27 | Left = 80
28 | Top = 71
29 | ParamData = <
30 | item
31 | Name = 'ID'
32 | ParamType = ptInput
33 | end>
34 | end
35 | object QryProductPostgreSQL: TFDQuery
36 | Connection = DM_RepositoryPostgreSQL.FDConnPostgreSQL
37 | SQL.Strings = (
38 | 'select id_product, code, descr, list_price,'
39 | ' tax, quantity from products'
40 | ' where id_product = :id')
41 | Left = 80
42 | Top = 127
43 | ParamData = <
44 | item
45 | Name = 'ID'
46 | DataType = ftInteger
47 | ParamType = ptInput
48 | Value = Null
49 | end>
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/Chapter04/uRepositorySystemPostgreSQL.pas:
--------------------------------------------------------------------------------
1 | unit uRepositorySystemPostgreSQL;
2 |
3 | interface
4 |
5 | uses
6 | Dialogs, uDM_RepositoryPostgreSQL, uiRepoSystem, uCustomers, uUsers, uProducts,
7 | System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
8 | FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
9 | FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, Data.DB,
10 | FireDAC.Comp.DataSet, FireDAC.Comp.Client;
11 |
12 | type
13 | TDM_RepositorySystemPostgreSQL = class(TDataModule, iRepoSystem)
14 | QryCustomerPostgreSQL: TFDQuery;
15 | QryUserPostgreSQL: TFDQuery;
16 | QryProductPostgreSQL: TFDQuery;
17 | private
18 | { Private declarations }
19 | public
20 | { Public declarations }
21 | function ReturnCustomer(id: Integer): TCustomer;
22 | function ReturnProduct(id: Integer): TProducts;
23 | function ReturnUser(id: Integer): TUser;
24 | end;
25 |
26 | var
27 | DM_RepositorySystemPostgreSQL: TDM_RepositorySystemPostgreSQL;
28 |
29 | implementation
30 |
31 | {%CLASSGROUP 'Vcl.Controls.TControl'}
32 |
33 | {$R *.dfm}
34 |
35 | { TDM_RepositorySystemPostgreSQL }
36 |
37 | function TDM_RepositorySystemPostgreSQL.ReturnCustomer(id: Integer): TCustomer;
38 | begin
39 | Try
40 | QryCustomerPostgreSQL.Close;
41 | QryCustomerPostgreSQL.ParamByName('id').Value := id;
42 | QryCustomerPostgreSQL.Open;
43 |
44 | if not QryCustomerPostgreSQL.IsEmpty then
45 | begin
46 | Result := TCustomer.Create;
47 | Result.id := QryCustomerPostgreSQL.FieldByName('id_customer').AsInteger;
48 | Result.name := QryCustomerPostgreSQL.FieldByName('customer_name').AsString;
49 | Result.status := QryCustomerPostgreSQL.FieldByName('customer_status').AsInteger;
50 | end
51 | else
52 | Result := nil;
53 | Except
54 | On E : Exception do
55 | ShowMessage(E.Message);
56 | End;
57 | end;
58 |
59 | function TDM_RepositorySystemPostgreSQL.ReturnProduct(id: Integer): TProducts;
60 | begin
61 | Try
62 | QryProductPostgreSQL.Close;
63 | QryProductPostgreSQL.ParamByName('id').Value := id;
64 | QryProductPostgreSQL.Open;
65 |
66 | if not QryProductPostgreSQL.IsEmpty then
67 | begin
68 | Result := TProducts.Create;
69 | Result.id := QryProductPostgreSQL.FieldByName('id_product').AsInteger;
70 | Result.code := QryProductPostgreSQL.FieldByName('code').AsString;
71 | Result.descr := QryProductPostgreSQL.FieldByName('descr').AsString;
72 | Result.list_price := QryProductPostgreSQL.FieldByName('list_price').AsFloat;
73 | Result.tax := QryProductPostgreSQL.FieldByName('tax').AsFloat;
74 | Result.quantity := QryProductPostgreSQL.FieldByName('quantity').AsFloat;
75 | end
76 | else
77 | Result := nil;
78 | Except
79 | On E : Exception do
80 | ShowMessage(E.Message);
81 | End;
82 | end;
83 |
84 | function TDM_RepositorySystemPostgreSQL.ReturnUser(id: Integer): TUser;
85 | begin
86 | Try
87 | QryUserPostgreSQL.Close;
88 | QryUserPostgreSQL.ParamByName('id').Value := id;
89 | QryUserPostgreSQL.Open;
90 |
91 | if not QryUserPostgreSQL.IsEmpty then
92 | begin
93 | Result := TUser.Create;
94 | Result.id := QryUserPostgreSQL.FieldByName('id_user').AsInteger;
95 | Result.login := QryUserPostgreSQL.FieldByName('login').AsString;
96 | Result.password := QryUserPostgreSQL.FieldByName('password').AsString;
97 | end
98 | else
99 | Result := nil;
100 | Except
101 | On E : Exception do
102 | ShowMessage(E.Message);
103 | End;
104 | end;
105 |
106 | end.
107 |
--------------------------------------------------------------------------------
/Chapter04/uRepositorySystemSQLServer.dfm:
--------------------------------------------------------------------------------
1 | object DM_RepositorySystemSQLServer: TDM_RepositorySystemSQLServer
2 | OldCreateOrder = False
3 | Height = 216
4 | Width = 215
5 | object QryCustomerSQLServer: TFDQuery
6 | Connection = DM_RepositorySQLServer.FDConnSQLServer
7 | SQL.Strings = (
8 |
9 | 'SELECT id_customer, customer_name, customer_status from customer' +
10 | 's'
11 | 'where id_customer =:id')
12 | Left = 80
13 | Top = 23
14 | ParamData = <
15 | item
16 | Name = 'ID'
17 | ParamType = ptInput
18 | end>
19 | end
20 | object QryUserSQLServer: TFDQuery
21 | Connection = DM_RepositorySQLServer.FDConnSQLServer
22 | SQL.Strings = (
23 | 'select id_user, login, password from users'
24 | 'where id_user = :id')
25 | Left = 80
26 | Top = 71
27 | ParamData = <
28 | item
29 | Name = 'ID'
30 | ParamType = ptInput
31 | end>
32 | end
33 | object QryProductSQLServer: TFDQuery
34 | Connection = DM_RepositorySQLServer.FDConnSQLServer
35 | SQL.Strings = (
36 | 'select id_product, code, descr, list_price,'
37 | ' tax, quantity from products'
38 | ' where id_product = :id')
39 | Left = 80
40 | Top = 127
41 | ParamData = <
42 | item
43 | Name = 'ID'
44 | DataType = ftInteger
45 | ParamType = ptInput
46 | Value = Null
47 | end>
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/Chapter04/uRepositorySystemSQLServer.pas:
--------------------------------------------------------------------------------
1 | unit uRepositorySystemSQLServer;
2 |
3 | interface
4 |
5 | uses
6 | Dialogs, uDM_RepositorySQLServer, uiRepoSystem, uCustomers, uUsers, uProducts,
7 | System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
8 | FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
9 | FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, Data.DB,
10 | FireDAC.Comp.DataSet, FireDAC.Comp.Client;
11 |
12 | type
13 | TDM_RepositorySystemSQLServer = class(TDataModule, IRepoSystem)
14 | QryCustomerSQLServer: TFDQuery;
15 | QryUserSQLServer: TFDQuery;
16 | QryProductSQLServer: TFDQuery;
17 | private
18 | { Private declarations }
19 | public
20 | { Public declarations }
21 | function ReturnCustomer(id: Integer): TCustomer;
22 | function ReturnProduct(id: Integer): TProducts;
23 | function ReturnUser(id: Integer): TUser;
24 |
25 | end;
26 |
27 | var
28 | DM_RepositorySystemSQLServer: TDM_RepositorySystemSQLServer;
29 |
30 | implementation
31 |
32 | {%CLASSGROUP 'Vcl.Controls.TControl'}
33 |
34 | {$R *.dfm}
35 |
36 | { TDM_RepositorySystemSQLServer }
37 |
38 | function TDM_RepositorySystemSQLServer.ReturnCustomer(id: Integer): TCustomer;
39 | begin
40 | Try
41 | QryCustomerSQLServer.Close;
42 | QryCustomerSQLServer.ParamByName('id').Value := id;
43 | QryCustomerSQLServer.Open;
44 |
45 | if not QryCustomerSQLServer.IsEmpty then
46 | begin
47 | Result := TCustomer.Create;
48 | Result.id := QryCustomerSQLServer.FieldByName('id_customer').AsInteger;
49 | Result.name := QryCustomerSQLServer.FieldByName('customer_name').AsString;
50 | Result.status := QryCustomerSQLServer.FieldByName('customer_status').AsInteger;
51 | end
52 | else
53 | Result := nil;
54 | Except
55 | On E : Exception do
56 | ShowMessage(E.Message);
57 | End;
58 | end;
59 |
60 | function TDM_RepositorySystemSQLServer.ReturnProduct(id: Integer): TProducts;
61 | begin
62 | Try
63 | QryProductSQLServer.Close;
64 | QryProductSQLServer.ParamByName('id').Value := id;
65 | QryProductSQLServer.Open;
66 |
67 | if not QryProductSQLServer.IsEmpty then
68 | begin
69 | Result := TProducts.Create;
70 | Result.id := QryProductSQLServer.FieldByName('id_product').AsInteger;
71 | Result.code := QryProductSQLServer.FieldByName('code').AsString;
72 | Result.descr := QryProductSQLServer.FieldByName('descr').AsString;
73 | Result.list_price := QryProductSQLServer.FieldByName('list_price').AsFloat;
74 | Result.tax := QryProductSQLServer.FieldByName('tax').AsFloat;
75 | Result.quantity := QryProductSQLServer.FieldByName('quantity').AsFloat;
76 | end
77 | else
78 | Result := nil;
79 | Except
80 | On E : Exception do
81 | ShowMessage(E.Message);
82 | End;
83 | end;
84 |
85 | function TDM_RepositorySystemSQLServer.ReturnUser(id: Integer): TUser;
86 | begin
87 | Try
88 | QryUserSQLServer.Close;
89 | QryUserSQLServer.ParamByName('id').Value := id;
90 | QryUserSQLServer.Open;
91 |
92 | if not QryUserSQLServer.IsEmpty then
93 | begin
94 | Result := TUser.Create;
95 | Result.id := QryUserSQLServer.FieldByName('id_user').AsInteger;
96 | Result.login := QryUserSQLServer.FieldByName('login').AsString;
97 | Result.password := QryUserSQLServer.FieldByName('password').AsString;
98 | end
99 | else
100 | Result := nil;
101 | Except
102 | On E : Exception do
103 | ShowMessage(E.Message);
104 | End;
105 | end;
106 |
107 | end.
108 |
--------------------------------------------------------------------------------
/Chapter04/uUsers.pas:
--------------------------------------------------------------------------------
1 | unit uUsers;
2 |
3 | interface
4 |
5 | Type
6 | TUser = class
7 | private
8 | Fid: integer;
9 | Fpassword: string;
10 | Flogin: string;
11 | procedure Setid(const Value: integer);
12 | procedure Setlogin(const Value: string);
13 | procedure Setpassword(const Value: string);
14 | published
15 | property id : integer read Fid write Setid;
16 | property login : string read Flogin write Setlogin;
17 | property password : string read Fpassword write Setpassword;
18 | end;
19 |
20 | implementation
21 |
22 | { TUser }
23 |
24 | procedure TUser.Setid(const Value: integer);
25 | begin
26 | Fid := Value;
27 | end;
28 |
29 | procedure TUser.Setlogin(const Value: string);
30 | begin
31 | Flogin := Value;
32 | end;
33 |
34 | procedure TUser.Setpassword(const Value: string);
35 | begin
36 | Fpassword := Value;
37 | end;
38 |
39 | end.
40 |
--------------------------------------------------------------------------------
/Chapter04/uiConfig.pas:
--------------------------------------------------------------------------------
1 | unit uiConfig;
2 |
3 | interface
4 |
5 | Type
6 | IConfig = interface
7 | procedure setTypeDataBase(const Value : Integer);
8 | function getTypeDataBase : Integer;
9 | property TypeDataBase : Integer read getTypeDataBase write setTypeDataBase;
10 | end;
11 |
12 |
13 | implementation
14 |
15 |
16 |
17 | end.
18 |
--------------------------------------------------------------------------------
/Chapter04/uiRepoSystem.pas:
--------------------------------------------------------------------------------
1 | unit uiRepoSystem;
2 |
3 | interface
4 |
5 | uses
6 | uUsers, uCustomers, uProducts;
7 |
8 | Type
9 | IRepoSystem = interface
10 | function ReturnUser ( id : integer ) : TUser;
11 | function ReturnCustomer( id : integer) : TCustomer;
12 | function ReturnProduct( id : integer) : TProducts;
13 | end;
14 |
15 | implementation
16 |
17 | end.
18 |
--------------------------------------------------------------------------------
/Chapter04/uiRepositories.pas:
--------------------------------------------------------------------------------
1 | unit uiRepositories;
2 |
3 | interface
4 |
5 | uses
6 | uiRepoSystem;
7 |
8 | Type
9 | TpTypeRepo = ( trADOSQLServer, trUniPostgreSQL );
10 |
11 | IRepositories = interface
12 | function Repository : IRepoSystem;
13 | end;
14 |
15 | function Repositories: IRepositories;
16 |
17 | implementation
18 |
19 | uses
20 | uConfiguration,
21 | uDM_RepositorySQLServer,
22 | uDM_RepositoryPostgreSQL;
23 |
24 | var
25 | mRepositories : IRepositories = nil;
26 |
27 | function Repositories : IRepositories;
28 | begin
29 | If assigned(result) then
30 | exit;
31 |
32 | case TpTypeRepo( configuration.TypeDataBase ) of
33 | trADOSQLServer :
34 | begin
35 | if not Assigned(mRepositories) then
36 | begin
37 | uDM_RepositorySQLServer.initialize;
38 | mRepositories := DM_RepositorySQLServer;
39 | end;
40 | Result := mRepositories;
41 |
42 | end;
43 |
44 | trUniPostgreSQL:
45 | begin
46 | if not Assigned(mRepositories) then
47 | begin
48 | uDM_RepositoryPostgreSQL.initialize;
49 | mRepositories := DM_RepositoryPostgreSQL;
50 | end;
51 | Result := mRepositories;
52 | end;
53 | end;
54 |
55 | end;
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/Chapter05/AndroidManifest.template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 | <%uses-permission%>
12 |
13 |
21 |
22 | <%application-meta-data%>
23 | <%services%>
24 |
26 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 | <%activity%>
39 | <%receivers%>
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Chapter05/Material.dpr:
--------------------------------------------------------------------------------
1 | program Material;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | uFrmMenu in 'uFrmMenu.pas' {Form1};
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.CreateForm(TForm1, Form1);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/Chapter05/Material.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/03/16 16:30:43.000.242,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/03/16 19:56:30.000.195,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2019/03/16 20:51:28.000.262,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\05 - Material Design\uFrmMenu.pas
7 | 2019/03/16 20:51:28.000.262,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.fmx=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\05 - Material Design\uFrmMenu.fmx
8 | 2019/03/16 20:51:36.000.225,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\05 - Material Design\Material.dproj
9 |
10 |
11 |
12 |
13 | Debug
14 |
15 |
--------------------------------------------------------------------------------
/Chapter05/Material.identcache:
--------------------------------------------------------------------------------
1 | eC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\05 - Material Design\uFrmMenu.pas eC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\05 - Material Design\Material.dpr
--------------------------------------------------------------------------------
/Chapter05/Material.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter05/Material.res
--------------------------------------------------------------------------------
/Chapter05/Material.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=120
3 | DesignerSecs=279
4 | InspectorSecs=671
5 | CompileSecs=156011
6 | OtherSecs=1052
7 | StartTime=17/03/2019 00:40:46
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=331
11 |
--------------------------------------------------------------------------------
/Chapter05/images/mat_back.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter05/images/mat_back.jpg
--------------------------------------------------------------------------------
/Chapter05/images/will.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter05/images/will.jpg
--------------------------------------------------------------------------------
/Chapter05/uFrmMenu.pas:
--------------------------------------------------------------------------------
1 | unit uFrmMenu;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
8 | FMX.Controls.Presentation, FMX.MultiView, FMX.Objects, FMX.Layouts,
9 | FMX.StdCtrls, FMX.Effects, FMX.Ani;
10 |
11 | type
12 | TForm1 = class(TForm)
13 | Layout1: TLayout;
14 | Rectangle1: TRectangle;
15 | MultiView1: TMultiView;
16 | SpeedButton1: TSpeedButton;
17 | rectMenuTop: TRectangle;
18 | GridPanelLayout1: TGridPanelLayout;
19 | Circle1: TCircle;
20 | Layout2: TLayout;
21 | Label1: TLabel;
22 | Label2: TLabel;
23 | rectMainMenu: TRectangle;
24 | rectMenuItem1: TRectangle;
25 | PathLabel1: TPathLabel;
26 | Label3: TLabel;
27 | rectMenuItem2: TRectangle;
28 | PathLabel2: TPathLabel;
29 | Label4: TLabel;
30 | VertScrollBox1: TVertScrollBox;
31 | rectMenuItem3: TRectangle;
32 | PathLabel3: TPathLabel;
33 | Label5: TLabel;
34 | lineItem: TLine;
35 | rectMenuItem4: TRectangle;
36 | PathLabel4: TPathLabel;
37 | Label6: TLabel;
38 | Rectangle2: TRectangle;
39 | Layout3: TLayout;
40 | rectAnimate: TRectangle;
41 | ShadowEffect1: TShadowEffect;
42 | Layout4: TLayout;
43 | Line1: TLine;
44 | lblCollapse: TLabel;
45 | Label8: TLabel;
46 | Circle2: TCircle;
47 | lblFloatButton: TLabel;
48 | layoutMenuFloat: TLayout;
49 | Circle3: TCircle;
50 | procedure MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
51 | procedure MouseLeave(Sender: TObject);
52 | procedure lblCollapseClick(Sender: TObject);
53 | procedure lblFloatButtonClick(Sender: TObject);
54 | private
55 | { Private declarations }
56 |
57 | public
58 | { Public declarations }
59 | end;
60 |
61 | var
62 | Form1: TForm1;
63 |
64 | implementation
65 |
66 | {$R *.fmx}
67 |
68 | procedure TForm1.MouseMove(Sender: TObject; Shift: TShiftState; X,
69 | Y: Single);
70 | begin
71 | TRectangle(Sender).Fill.Color := $FFE0B4B4;
72 | end;
73 |
74 | procedure TForm1.lblFloatButtonClick(Sender: TObject);
75 | begin
76 | if layoutMenuFloat.Visible = False then
77 | begin
78 | layoutMenuFloat.Visible := true;
79 | TAnimator.AnimateFloat(Circle3, 'Position.Y', Circle2.Position.Y - 55, 0.4,
80 | TAnimationType.&In, TInterpolationType.Circular);
81 | end
82 | else
83 | begin
84 | TAnimator.AnimateFloat(Circle3, 'Position.Y', Circle2.Position.Y, 0.4,
85 | TAnimationType.&In, TInterpolationType.Circular);
86 | layoutMenuFloat.Visible := False;
87 | end;
88 | end;
89 |
90 | procedure TForm1.lblCollapseClick(Sender: TObject);
91 | begin
92 | if rectAnimate.Height = 300 then
93 | begin
94 | TAnimator.AnimateFloat(rectAnimate,'Height',100,0.7,
95 | TAnimationType.&In, TInterpolationType.Linear);
96 | lblCollapse.Text := 'EXPAND';
97 | end
98 | else
99 | begin
100 | TAnimator.AnimateFloat(rectAnimate,'Height',300,0.7,
101 | TAnimationType.&In, TInterpolationType.Linear);
102 | lblCollapse.Text := 'COLLAPSE';
103 | end;
104 | end;
105 |
106 | procedure TForm1.MouseLeave(Sender: TObject);
107 | begin
108 | TRectangle(Sender).Fill.Color := $FFFFFF;
109 | end;
110 |
111 | end.
112 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~10~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <
34 | item
35 | Name = 'Photo'
36 | IsPublic = True
37 | Kind = Mirror
38 | ResType = Stream
39 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
40 | end>
41 | Left = 352
42 | Top = 248
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~11~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <
33 | item
34 | Name = 'Action1'
35 | IsPublic = True
36 | Action = Action1
37 | NotifyUpdates = False
38 | end>
39 | Resources = <
40 | item
41 | Name = 'Photo'
42 | IsPublic = True
43 | Kind = Mirror
44 | ResType = Stream
45 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
46 | end>
47 | Left = 352
48 | Top = 248
49 | end
50 | object ActionList1: TActionList
51 | Left = 240
52 | Top = 248
53 | object Action1: TAction
54 | Text = 'Action1'
55 | OnExecute = Action1Execute
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~12~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object Button1: TButton
21 | Position.X = 240.000000000000000000
22 | Position.Y = 144.000000000000000000
23 | TabOrder = 4
24 | Text = 'Button1'
25 | end
26 | object TetheringManager1: TTetheringManager
27 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
28 | Password = 'delphi'
29 | Text = 'TetheringManager1'
30 | AllowedAdapters = 'Network'
31 | Left = 352
32 | Top = 192
33 | end
34 | object TetheringAppProfile1: TTetheringAppProfile
35 | Manager = TetheringManager1
36 | Text = 'TetheringAppProfile'
37 | Group = 'Packt'
38 | Actions = <
39 | item
40 | Name = 'Action1'
41 | IsPublic = True
42 | Action = Action1
43 | NotifyUpdates = False
44 | end>
45 | Resources = <
46 | item
47 | Name = 'Photo'
48 | IsPublic = True
49 | Kind = Mirror
50 | ResType = Stream
51 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
52 | end>
53 | Left = 352
54 | Top = 248
55 | end
56 | object ActionList1: TActionList
57 | Left = 240
58 | Top = 248
59 | object Action1: TAction
60 | Text = 'Action1'
61 | OnExecute = Action1Execute
62 | end
63 | end
64 | end
65 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~13~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <
33 | item
34 | Name = 'Action1'
35 | IsPublic = True
36 | Action = Action1
37 | NotifyUpdates = False
38 | end>
39 | Resources = <
40 | item
41 | Name = 'Photo'
42 | IsPublic = True
43 | Kind = Mirror
44 | ResType = Stream
45 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
46 | end>
47 | Left = 352
48 | Top = 248
49 | end
50 | object ActionList1: TActionList
51 | Left = 240
52 | Top = 248
53 | object Action1: TAction
54 | Text = 'Action1'
55 | OnExecute = Action1Execute
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~14~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <
33 | item
34 | Name = 'Calc'
35 | IsPublic = True
36 | Action = Action1
37 | NotifyUpdates = False
38 | end>
39 | Resources = <
40 | item
41 | Name = 'Photo'
42 | IsPublic = True
43 | Kind = Mirror
44 | ResType = Stream
45 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
46 | end>
47 | Left = 352
48 | Top = 248
49 | end
50 | object ActionList1: TActionList
51 | Left = 240
52 | Top = 248
53 | object Action1: TAction
54 | Text = 'Action1'
55 | OnExecute = Action1Execute
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~5~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile1'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <>
34 | OnResourceReceived = TetheringAppProfile1ResourceReceived
35 | Left = 352
36 | Top = 248
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~6~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <>
34 | OnResourceReceived = TetheringAppProfile1ResourceReceived
35 | Left = 352
36 | Top = 248
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~7~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <
34 | item
35 | Name = 'Photo'
36 | IsPublic = True
37 | Kind = Mirror
38 | ResType = Stream
39 | end>
40 | OnResourceReceived = TetheringAppProfile1ResourceReceived
41 | Left = 352
42 | Top = 248
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~8~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network_V4'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <
34 | item
35 | Name = 'Photo'
36 | IsPublic = True
37 | Kind = Mirror
38 | ResType = Stream
39 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
40 | end>
41 | Left = 352
42 | Top = 248
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.fmx.~9~:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <>
33 | Resources = <
34 | item
35 | Name = 'Photo'
36 | IsPublic = True
37 | Kind = Mirror
38 | ResType = Stream
39 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
40 | end>
41 | Left = 352
42 | Top = 248
43 | end
44 | end
45 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~1~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | private
15 | { Private declarations }
16 | public
17 | { Public declarations }
18 | end;
19 |
20 | var
21 | FrmCap6: TFrmCap6;
22 |
23 | implementation
24 |
25 | {$R *.fmx}
26 |
27 | end.
28 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~2~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | private
15 | { Private declarations }
16 | public
17 | { Public declarations }
18 | end;
19 |
20 | var
21 | FrmCap6: TFrmCap6;
22 |
23 | implementation
24 |
25 | {$R *.fmx}
26 |
27 | uses
28 | System.Tether.NetworkAdapter;
29 |
30 | end.
31 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~3~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
15 | const ARemoteIdentifier: string; var Password: string);
16 | private
17 | { Private declarations }
18 | public
19 | { Public declarations }
20 | end;
21 |
22 | var
23 | FrmCap6: TFrmCap6;
24 |
25 | implementation
26 |
27 | {$R *.fmx}
28 |
29 | uses
30 | System.Tether.NetworkAdapter;
31 |
32 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
33 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
34 | begin
35 | Password := 'delphi';
36 | end;
37 |
38 | end.
39 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~4~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | Image1: TImage;
15 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
16 | const ARemoteIdentifier: string; var Password: string);
17 | private
18 | { Private declarations }
19 | public
20 | { Public declarations }
21 | end;
22 |
23 | var
24 | FrmCap6: TFrmCap6;
25 |
26 | implementation
27 |
28 | {$R *.fmx}
29 |
30 | uses
31 | System.Tether.NetworkAdapter;
32 |
33 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
34 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
35 | begin
36 | Password := 'delphi';
37 | end;
38 |
39 | end.
40 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~5~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | Image1: TImage;
15 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
16 | const ARemoteIdentifier: string; var Password: string);
17 | procedure TetheringAppProfile1ResourceReceived(const Sender: TObject;
18 | const AResource: TRemoteResource);
19 | private
20 | { Private declarations }
21 | public
22 | { Public declarations }
23 | end;
24 |
25 | var
26 | FrmCap6: TFrmCap6;
27 |
28 | implementation
29 |
30 | {$R *.fmx}
31 |
32 | uses
33 | System.Tether.NetworkAdapter;
34 |
35 | procedure TFrmCap6.TetheringAppProfile1ResourceReceived(const Sender: TObject;
36 | const AResource: TRemoteResource);
37 | begin
38 | TThread.Synchronize(nil, procedure
39 | var
40 | LSize : Int64;
41 | begin
42 | Try
43 | LSize := AResource.Value.AsStream.Size;
44 | AResource.Value.AsStream.Position := 0;
45 | Image1.Bitmap.LoadFromStream(AResource.Value.AsStream);
46 | image1.Repaint;
47 | Except
48 |
49 | End;
50 | end);
51 | end;
52 |
53 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
54 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
55 | begin
56 | Password := 'delphi';
57 | end;
58 |
59 | end.
60 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~6~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects;
9 |
10 | type
11 | TFrmCap6 = class(TForm)
12 | TetheringManager1: TTetheringManager;
13 | TetheringAppProfile1: TTetheringAppProfile;
14 | Image1: TImage;
15 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
16 | const ARemoteIdentifier: string; var Password: string);
17 | procedure TetheringAppProfile1Resources0ResourceReceived(
18 | const Sender: TObject; const AResource: TRemoteResource);
19 | private
20 | { Private declarations }
21 | public
22 | { Public declarations }
23 | end;
24 |
25 | var
26 | FrmCap6: TFrmCap6;
27 |
28 | implementation
29 |
30 | {$R *.fmx}
31 |
32 | uses
33 | System.Tether.NetworkAdapter;
34 |
35 | procedure TFrmCap6.TetheringAppProfile1Resources0ResourceReceived(
36 | const Sender: TObject; const AResource: TRemoteResource);
37 | begin
38 | TThread.Synchronize(nil, procedure
39 | var
40 | LSize : Int64;
41 | begin
42 | Try
43 | LSize := AResource.Value.AsStream.Size;
44 | AResource.Value.AsStream.Position := 0;
45 | Image1.Bitmap.LoadFromStream(AResource.Value.AsStream);
46 | image1.Repaint;
47 | Except
48 |
49 | End;
50 | end);
51 | end;
52 |
53 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
54 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
55 | begin
56 | Password := 'delphi';
57 | end;
58 |
59 | end.
60 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~7~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects,
9 | System.Actions, FMX.ActnList;
10 |
11 | type
12 | TFrmCap6 = class(TForm)
13 | TetheringManager1: TTetheringManager;
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | Image1: TImage;
16 | ActionList1: TActionList;
17 | Action1: TAction;
18 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
19 | const ARemoteIdentifier: string; var Password: string);
20 | procedure TetheringAppProfile1Resources0ResourceReceived(
21 | const Sender: TObject; const AResource: TRemoteResource);
22 | procedure Action1Execute(Sender: TObject);
23 | private
24 | { Private declarations }
25 | public
26 | { Public declarations }
27 | end;
28 |
29 | var
30 | FrmCap6: TFrmCap6;
31 |
32 | implementation
33 |
34 | {$R *.fmx}
35 |
36 | uses
37 | System.Tether.NetworkAdapter;
38 |
39 | procedure TFrmCap6.Action1Execute(Sender: TObject);
40 | begin
41 | ShowMessage('Hello, remote control');
42 | end;
43 |
44 | procedure TFrmCap6.TetheringAppProfile1Resources0ResourceReceived(
45 | const Sender: TObject; const AResource: TRemoteResource);
46 | begin
47 | TThread.Synchronize(nil, procedure
48 | var
49 | LSize : Int64;
50 | begin
51 | Try
52 | LSize := AResource.Value.AsStream.Size;
53 | AResource.Value.AsStream.Position := 0;
54 | Image1.Bitmap.LoadFromStream(AResource.Value.AsStream);
55 | image1.Repaint;
56 | Except
57 |
58 | End;
59 | end);
60 | end;
61 |
62 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
63 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
64 | begin
65 | Password := 'delphi';
66 | end;
67 |
68 | end.
69 |
--------------------------------------------------------------------------------
/Chapter06/__history/uFrmCap6_Server.pas.~8~:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects,
9 | System.Actions, FMX.ActnList, Winapi.ShellAPI, Winapi.Windows,
10 | FMX.Controls.Presentation, FMX.StdCtrls;
11 |
12 | type
13 | TFrmCap6 = class(TForm)
14 | TetheringManager1: TTetheringManager;
15 | TetheringAppProfile1: TTetheringAppProfile;
16 | Image1: TImage;
17 | ActionList1: TActionList;
18 | Action1: TAction;
19 | Button1: TButton;
20 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
21 | const ARemoteIdentifier: string; var Password: string);
22 | procedure TetheringAppProfile1Resources0ResourceReceived(
23 | const Sender: TObject; const AResource: TRemoteResource);
24 | procedure Action1Execute(Sender: TObject);
25 | private
26 | { Private declarations }
27 | public
28 | { Public declarations }
29 | end;
30 |
31 | var
32 | FrmCap6: TFrmCap6;
33 |
34 | implementation
35 |
36 | {$R *.fmx}
37 |
38 | uses
39 | System.Tether.NetworkAdapter;
40 |
41 | procedure TFrmCap6.Action1Execute(Sender: TObject);
42 | begin
43 | ShellExecute(0,'open', PChar('C:\Windows\System32\calc.exe'), '',
44 | nil, SW_ShowNormal)
45 | end;
46 |
47 | procedure TFrmCap6.TetheringAppProfile1Resources0ResourceReceived(
48 | const Sender: TObject; const AResource: TRemoteResource);
49 | begin
50 | TThread.Synchronize(nil, procedure
51 | var
52 | LSize : Int64;
53 | begin
54 | Try
55 | LSize := AResource.Value.AsStream.Size;
56 | AResource.Value.AsStream.Position := 0;
57 | Image1.Bitmap.LoadFromStream(AResource.Value.AsStream);
58 | image1.Repaint;
59 | Except
60 |
61 | End;
62 | end);
63 | end;
64 |
65 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
66 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
67 | begin
68 | Password := 'delphi';
69 | end;
70 |
71 | end.
72 |
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.dpr:
--------------------------------------------------------------------------------
1 | program appRemoteDesktop;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | uFrmCap6_Server in 'uFrmCap6_Server.pas' {FrmCap6};
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.CreateForm(TFrmCap6, FrmCap6);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/03/16 16:30:43.000.242,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/03/24 18:16:17.000.690,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2019/04/07 16:30:58.000.941,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\uFrmCap6_Server.pas
7 | 2019/04/07 16:30:58.000.957,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.fmx=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\uFrmCap6_Server.fmx
8 | 2019/04/07 16:31:13.000.995,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\appRemoteDesktop.dproj
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.identcache:
--------------------------------------------------------------------------------
1 | Nc:\program files (x86)\embarcadero\studio\19.0\source\Indy10\Core\IdThread.pas lC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\appRemoteDesktop.dpr kC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\uFrmCap6_Server.pas
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter06/appRemoteDesktop.res
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter06/appRemoteDesktop.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=5
3 | DesignerSecs=1610
4 | InspectorSecs=5
5 | CompileSecs=47530
6 | OtherSecs=35
7 | StartTime=08/04/2019 01:32:54
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=18479
11 |
--------------------------------------------------------------------------------
/Chapter06/mobile/AndroidManifest.template.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
11 | <%uses-permission%>
12 |
13 |
21 |
22 | <%application-meta-data%>
23 | <%services%>
24 |
26 |
30 |
31 |
33 |
34 |
35 |
36 |
37 |
38 | <%activity%>
39 | <%receivers%>
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.dpr:
--------------------------------------------------------------------------------
1 | program Chapter6_Mob;
2 |
3 | uses
4 | System.StartUpCopy,
5 | FMX.Forms,
6 | uFrmMobile in 'uFrmMobile.pas' {Form1};
7 |
8 | {$R *.res}
9 |
10 | begin
11 | Application.Initialize;
12 | Application.CreateForm(TForm1, Form1);
13 | Application.Run;
14 | end.
15 |
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/03/16 16:30:43.000.242,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/04/07 17:09:44.000.149,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2019/04/07 18:12:54.000.795,=C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2019/04/08 01:23:24.000.958,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.pas=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\mobile\uFrmMobile.pas
8 | 2019/04/08 01:23:24.000.958,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Unit1.fmx=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\mobile\uFrmMobile.fmx
9 | 2019/04/08 01:23:33.000.644,C:\Users\Dell\Documents\Embarcadero\Studio\Projects\Project1.dproj=C:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\mobile\Chapter6_Mob.dproj
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.identcache:
--------------------------------------------------------------------------------
1 | oC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\mobile\Chapter6_Mob.dpr mC:\Projetos\Livro Delphi Packt\examples\Delphi-Programming-Projects\06 - Remote Control\mobile\uFrmMobile.pas
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter06/mobile/Chapter6_Mob.res
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinBlack=1
6 | dxSkinBlue=1
7 | dxSkinBlueprint=1
8 | dxSkinCaramel=1
9 | dxSkinCoffee=1
10 | dxSkinDarkRoom=1
11 | dxSkinDarkSide=1
12 | dxSkinDevExpressDarkStyle=1
13 | dxSkinDevExpressStyle=1
14 | dxSkinFoggy=1
15 | dxSkinGlassOceans=1
16 | dxSkinHighContrast=1
17 | dxSkiniMaginary=1
18 | dxSkinLilian=1
19 | dxSkinLiquidSky=1
20 | dxSkinLondonLiquidSky=1
21 | dxSkinMcSkin=1
22 | dxSkinMetropolis=1
23 | dxSkinMetropolisDark=1
24 | dxSkinMoneyTwins=1
25 | dxSkinOffice2007Black=1
26 | dxSkinOffice2007Blue=1
27 | dxSkinOffice2007Green=1
28 | dxSkinOffice2007Pink=1
29 | dxSkinOffice2007Silver=1
30 | dxSkinOffice2010Black=1
31 | dxSkinOffice2010Blue=1
32 | dxSkinOffice2010Silver=1
33 | dxSkinOffice2013DarkGray=1
34 | dxSkinOffice2013LightGray=1
35 | dxSkinOffice2013White=1
36 | dxSkinOffice2016Colorful=1
37 | dxSkinOffice2016Dark=1
38 | dxSkinPumpkin=1
39 | dxSkinSeven=1
40 | dxSkinSevenClassic=1
41 | dxSkinSharp=1
42 | dxSkinSharpPlus=1
43 | dxSkinSilver=1
44 | dxSkinSpringTime=1
45 | dxSkinStardust=1
46 | dxSkinSummer2008=1
47 | dxSkinTheAsphaltWorld=1
48 | dxSkinsDefaultPainters=1
49 | dxSkinValentine=1
50 | dxSkinVisualStudio2013Blue=1
51 | dxSkinVisualStudio2013Dark=1
52 | dxSkinVisualStudio2013Light=1
53 | dxSkinVS2010=1
54 | dxSkinWhiteprint=1
55 | dxSkinXmas2008Blue=1
56 |
--------------------------------------------------------------------------------
/Chapter06/mobile/Chapter6_Mob.stat:
--------------------------------------------------------------------------------
1 | [Stats]
2 | EditorSecs=8
3 | DesignerSecs=7
4 | InspectorSecs=166
5 | CompileSecs=146387
6 | OtherSecs=20
7 | StartTime=08/04/2019 01:55:06
8 | RealKeys=0
9 | EffectiveKeys=0
10 | DebugSecs=1
11 |
--------------------------------------------------------------------------------
/Chapter06/mobile/Win32/Debug/uFrmMobile.dcu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter06/mobile/Win32/Debug/uFrmMobile.dcu
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~10~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Size.Width = 297.000000000000000000
36 | Size.Height = 23.000000000000000000
37 | Size.PlatformDefault = False
38 | Text = 'Label1'
39 | TabOrder = 8
40 | end
41 | object TetheringAppProfile1: TTetheringAppProfile
42 | Manager = TetheringManager1
43 | Text = 'TetheringAppProfile1'
44 | Group = 'Packt'
45 | Actions = <>
46 | Resources = <
47 | item
48 | Name = 'Photo'
49 | IsPublic = True
50 | ResType = Stream
51 | end>
52 | Left = 240
53 | Top = 176
54 | end
55 | object TetheringManager1: TTetheringManager
56 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
57 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
58 | Password = 'delphi'
59 | Text = 'TetheringManager1'
60 | AllowedAdapters = 'Network'
61 | Left = 240
62 | Top = 232
63 | end
64 | object ActionList1: TActionList
65 | Left = 152
66 | Top = 120
67 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
68 | Category = 'Media Library'
69 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
70 | end
71 | end
72 | end
73 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~11~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Size.Width = 297.000000000000000000
36 | Size.Height = 23.000000000000000000
37 | Size.PlatformDefault = False
38 | Text = 'Label1'
39 | TabOrder = 8
40 | end
41 | object TetheringAppProfile1: TTetheringAppProfile
42 | Manager = TetheringManager1
43 | Text = 'TetheringAppProfile1'
44 | Group = 'Packt'
45 | Actions = <>
46 | Resources = <
47 | item
48 | Name = 'Photo'
49 | IsPublic = True
50 | ResType = Stream
51 | end>
52 | Left = 240
53 | Top = 176
54 | end
55 | object TetheringManager1: TTetheringManager
56 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
57 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
58 | OnEndAutoConnect = TetheringManager1EndAutoConnect
59 | Password = 'delphi'
60 | Text = 'TetheringManager1'
61 | AllowedAdapters = 'Network'
62 | Left = 240
63 | Top = 232
64 | end
65 | object ActionList1: TActionList
66 | Left = 152
67 | Top = 120
68 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
69 | Category = 'Media Library'
70 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
71 | end
72 | end
73 | end
74 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~12~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 354
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Size.Width = 193.000000000000000000
36 | Size.Height = 23.000000000000000000
37 | Size.PlatformDefault = False
38 | Text = 'Label1'
39 | TabOrder = 8
40 | end
41 | object TetheringAppProfile1: TTetheringAppProfile
42 | Manager = TetheringManager1
43 | Text = 'TetheringAppProfile1'
44 | Group = 'Packt'
45 | Actions = <>
46 | Resources = <
47 | item
48 | Name = 'Photo'
49 | IsPublic = True
50 | ResType = Stream
51 | end>
52 | Left = 240
53 | Top = 176
54 | end
55 | object TetheringManager1: TTetheringManager
56 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
57 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
58 | OnEndAutoConnect = TetheringManager1EndAutoConnect
59 | Password = 'delphi'
60 | Text = 'TetheringManager1'
61 | AllowedAdapters = 'Network'
62 | Left = 240
63 | Top = 232
64 | end
65 | object ActionList1: TActionList
66 | Left = 152
67 | Top = 120
68 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
69 | Category = 'Media Library'
70 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
71 | end
72 | end
73 | end
74 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~13~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 354
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Size.Width = 193.000000000000000000
36 | Size.Height = 23.000000000000000000
37 | Size.PlatformDefault = False
38 | Text = 'Label1'
39 | TabOrder = 8
40 | end
41 | object TetheringAppProfile1: TTetheringAppProfile
42 | Manager = TetheringManager1
43 | Text = 'TetheringAppProfile1'
44 | Group = 'Packt'
45 | Actions = <>
46 | Resources = <
47 | item
48 | Name = 'Photo'
49 | IsPublic = True
50 | ResType = Stream
51 | end>
52 | Left = 240
53 | Top = 176
54 | end
55 | object TetheringManager1: TTetheringManager
56 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
57 | OnEndAutoConnect = TetheringManager1EndAutoConnect
58 | Password = 'delphi'
59 | Text = 'TetheringManager1'
60 | AllowedAdapters = 'Network'
61 | Left = 240
62 | Top = 232
63 | end
64 | object ActionList1: TActionList
65 | Left = 152
66 | Top = 120
67 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
68 | Category = 'Media Library'
69 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
70 | end
71 | end
72 | end
73 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~4~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Position.X = 8.000000000000000000
23 | Position.Y = 56.000000000000000000
24 | Size.Width = 121.000000000000000000
25 | Size.Height = 44.000000000000000000
26 | Size.PlatformDefault = False
27 | TabOrder = 4
28 | Text = 'Take Photo'
29 | OnClick = btnPhotoClick
30 | end
31 | object TetheringAppProfile1: TTetheringAppProfile
32 | Manager = TetheringManager1
33 | Text = 'TetheringAppProfile1'
34 | Group = 'Packt'
35 | Enabled = False
36 | Actions = <>
37 | Resources = <>
38 | Left = 240
39 | Top = 176
40 | end
41 | object TetheringManager1: TTetheringManager
42 | Password = 'delphi'
43 | Text = 'TetheringManager1'
44 | Enabled = False
45 | AllowedAdapters = 'Network'
46 | Left = 240
47 | Top = 232
48 | end
49 | object ActionList1: TActionList
50 | Left = 152
51 | Top = 120
52 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
53 | Category = 'Media Library'
54 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~5~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Position.X = 8.000000000000000000
23 | Position.Y = 56.000000000000000000
24 | Size.Width = 121.000000000000000000
25 | Size.Height = 44.000000000000000000
26 | Size.PlatformDefault = False
27 | TabOrder = 4
28 | Text = 'Take Photo'
29 | OnClick = btnPhotoClick
30 | end
31 | object Label1: TLabel
32 | Position.X = 136.000000000000000000
33 | Position.Y = 16.000000000000000000
34 | Text = 'Label1'
35 | TabOrder = 8
36 | end
37 | object TetheringAppProfile1: TTetheringAppProfile
38 | Manager = TetheringManager1
39 | Text = 'TetheringAppProfile1'
40 | Group = 'Packt'
41 | Actions = <>
42 | Resources = <>
43 | Left = 240
44 | Top = 176
45 | end
46 | object TetheringManager1: TTetheringManager
47 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
48 | Password = 'delphi'
49 | Text = 'TetheringManager1'
50 | AllowedAdapters = 'Network'
51 | Left = 240
52 | Top = 232
53 | end
54 | object ActionList1: TActionList
55 | Left = 152
56 | Top = 120
57 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
58 | Category = 'Media Library'
59 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
60 | end
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~6~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Position.X = 8.000000000000000000
23 | Position.Y = 56.000000000000000000
24 | Size.Width = 121.000000000000000000
25 | Size.Height = 44.000000000000000000
26 | Size.PlatformDefault = False
27 | TabOrder = 4
28 | Text = 'Take Photo'
29 | OnClick = btnPhotoClick
30 | end
31 | object Label1: TLabel
32 | Position.X = 136.000000000000000000
33 | Position.Y = 16.000000000000000000
34 | Text = 'Label1'
35 | TabOrder = 8
36 | end
37 | object TetheringAppProfile1: TTetheringAppProfile
38 | Manager = TetheringManager1
39 | Text = 'TetheringAppProfile1'
40 | Group = 'Packt'
41 | Actions = <>
42 | Resources = <>
43 | Left = 240
44 | Top = 176
45 | end
46 | object TetheringManager1: TTetheringManager
47 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
48 | Password = 'delphi'
49 | Text = 'TetheringManager1'
50 | AllowedAdapters = 'Network'
51 | Left = 240
52 | Top = 232
53 | end
54 | object ActionList1: TActionList
55 | Left = 152
56 | Top = 120
57 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
58 | Category = 'Media Library'
59 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
60 | end
61 | end
62 | end
63 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~7~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Enabled = False
24 | Position.X = 8.000000000000000000
25 | Position.Y = 56.000000000000000000
26 | Size.Width = 121.000000000000000000
27 | Size.Height = 44.000000000000000000
28 | Size.PlatformDefault = False
29 | TabOrder = 4
30 | Text = 'Take Photo'
31 | OnClick = btnPhotoClick
32 | end
33 | object Label1: TLabel
34 | Position.X = 136.000000000000000000
35 | Position.Y = 16.000000000000000000
36 | Text = 'Label1'
37 | TabOrder = 8
38 | end
39 | object TetheringAppProfile1: TTetheringAppProfile
40 | Manager = TetheringManager1
41 | Text = 'TetheringAppProfile1'
42 | Group = 'Packt'
43 | Actions = <>
44 | Resources = <>
45 | Left = 240
46 | Top = 176
47 | end
48 | object TetheringManager1: TTetheringManager
49 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
50 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
51 | Password = 'delphi'
52 | Text = 'TetheringManager1'
53 | AllowedAdapters = 'Network'
54 | Left = 240
55 | Top = 232
56 | end
57 | object ActionList1: TActionList
58 | Left = 152
59 | Top = 120
60 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
61 | Category = 'Media Library'
62 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
63 | end
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~8~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Enabled = False
24 | Position.X = 8.000000000000000000
25 | Position.Y = 56.000000000000000000
26 | Size.Width = 121.000000000000000000
27 | Size.Height = 44.000000000000000000
28 | Size.PlatformDefault = False
29 | TabOrder = 4
30 | Text = 'Take Photo'
31 | OnClick = btnPhotoClick
32 | end
33 | object Label1: TLabel
34 | Position.X = 136.000000000000000000
35 | Position.Y = 16.000000000000000000
36 | Text = 'Label1'
37 | TabOrder = 8
38 | end
39 | object TetheringAppProfile1: TTetheringAppProfile
40 | Manager = TetheringManager1
41 | Text = 'TetheringAppProfile1'
42 | Group = 'Packt'
43 | Actions = <>
44 | Resources = <>
45 | Left = 240
46 | Top = 176
47 | end
48 | object TetheringManager1: TTetheringManager
49 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
50 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
51 | Password = 'delphi'
52 | Text = 'TetheringManager1'
53 | AllowedAdapters = 'Network'
54 | Left = 240
55 | Top = 232
56 | end
57 | object ActionList1: TActionList
58 | Left = 152
59 | Top = 120
60 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
61 | Category = 'Media Library'
62 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
63 | end
64 | end
65 | end
66 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.fmx.~9~:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Text = 'Label1'
36 | TabOrder = 8
37 | end
38 | object TetheringAppProfile1: TTetheringAppProfile
39 | Manager = TetheringManager1
40 | Text = 'TetheringAppProfile1'
41 | Group = 'Packt'
42 | Actions = <>
43 | Resources = <>
44 | Left = 240
45 | Top = 176
46 | end
47 | object TetheringManager1: TTetheringManager
48 | OnEndManagersDiscovery = TetheringManager1EndManagersDiscovery
49 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
50 | Password = 'delphi'
51 | Text = 'TetheringManager1'
52 | AllowedAdapters = 'Network'
53 | Left = 240
54 | Top = 232
55 | end
56 | object ActionList1: TActionList
57 | Left = 152
58 | Top = 120
59 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
60 | Category = 'Media Library'
61 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
62 | end
63 | end
64 | end
65 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~10~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | procedure Check;
34 | end;
35 |
36 | var
37 | Form1: TForm1;
38 |
39 | implementation
40 |
41 | {$R *.fmx}
42 |
43 | uses
44 | System.Tether.TCPProtocol;
45 |
46 | procedure TForm1.btnConectarClick(Sender: TObject);
47 | begin
48 | TetheringManager1.AutoConnect();
49 | Check;
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ManagerIdentifier;
61 |
62 | end;
63 |
64 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
65 | begin
66 | if PhotoStream = nil then
67 | PhotoStream := TMemoryStream.Create;
68 |
69 | Try
70 | PhotoStream.Position := 0;
71 | Image.SaveToStream(PhotoStream);
72 | PhotoStream.Position := 0;
73 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
74 | Except
75 | On E : Exception do
76 | ShowMessage(E.Message);
77 | End;
78 | end;
79 |
80 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
81 | const ARemoteManagers: TTetheringManagerInfoList);
82 | begin
83 | //btnPhoto.Enabled := True;
84 | end;
85 |
86 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
87 | const ARemoteIdentifier: string; var Password: string);
88 | begin
89 | Password := 'delphi';
90 | end;
91 |
92 | end.
93 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~11~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | procedure Check;
34 | end;
35 |
36 | var
37 | Form1: TForm1;
38 |
39 | implementation
40 |
41 | {$R *.fmx}
42 |
43 | uses
44 | System.Tether.TCPProtocol;
45 |
46 | procedure TForm1.btnConectarClick(Sender: TObject);
47 | begin
48 | TetheringManager1.AutoConnect();
49 | Check;
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ProfileGroup;
61 | end;
62 |
63 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
64 | begin
65 | if PhotoStream = nil then
66 | PhotoStream := TMemoryStream.Create;
67 |
68 | Try
69 | PhotoStream.Position := 0;
70 | Image.SaveToStream(PhotoStream);
71 | PhotoStream.Position := 0;
72 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
73 | Except
74 | On E : Exception do
75 | ShowMessage(E.Message);
76 | End;
77 | end;
78 |
79 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
80 | const ARemoteManagers: TTetheringManagerInfoList);
81 | begin
82 | //btnPhoto.Enabled := True;
83 | end;
84 |
85 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
86 | const ARemoteIdentifier: string; var Password: string);
87 | begin
88 | Password := 'delphi';
89 | end;
90 |
91 | end.
92 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~12~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | procedure TetheringManager1EndAutoConnect(Sender: TObject);
29 | private
30 | { Private declarations }
31 | PhotoStream : TMemoryStream;
32 | public
33 | { Public declarations }
34 | procedure Check;
35 | end;
36 |
37 | var
38 | Form1: TForm1;
39 |
40 | implementation
41 |
42 | {$R *.fmx}
43 |
44 | uses
45 | System.Tether.TCPProtocol;
46 |
47 | procedure TForm1.btnConectarClick(Sender: TObject);
48 | begin
49 | TetheringManager1.AutoConnect();
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ProfileGroup;
61 | end;
62 |
63 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
64 | begin
65 | if PhotoStream = nil then
66 | PhotoStream := TMemoryStream.Create;
67 |
68 | Try
69 | PhotoStream.Position := 0;
70 | Image.SaveToStream(PhotoStream);
71 | PhotoStream.Position := 0;
72 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
73 | Except
74 | On E : Exception do
75 | ShowMessage(E.Message);
76 | End;
77 | end;
78 |
79 | procedure TForm1.TetheringManager1EndAutoConnect(Sender: TObject);
80 | begin
81 | Check;
82 | end;
83 |
84 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
85 | const ARemoteManagers: TTetheringManagerInfoList);
86 | begin
87 | //btnPhoto.Enabled := True;
88 | end;
89 |
90 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
91 | const ARemoteIdentifier: string; var Password: string);
92 | begin
93 | Password := 'delphi';
94 | end;
95 |
96 | end.
97 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~13~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndAutoConnect(Sender: TObject);
27 | private
28 | { Private declarations }
29 | PhotoStream : TMemoryStream;
30 | public
31 | { Public declarations }
32 | procedure Check;
33 | end;
34 |
35 | var
36 | Form1: TForm1;
37 |
38 | implementation
39 |
40 | {$R *.fmx}
41 |
42 | uses
43 | System.Tether.TCPProtocol;
44 |
45 | procedure TForm1.btnConectarClick(Sender: TObject);
46 | begin
47 | TetheringManager1.AutoConnect();
48 | end;
49 |
50 | procedure TForm1.btnPhotoClick(Sender: TObject);
51 | begin
52 | TakePhotoFromCameraAction1.Execute;
53 | end;
54 |
55 | procedure TForm1.Check;
56 | begin
57 | if TetheringManager1.RemoteProfiles.Count > 0 then
58 | Label1.Text := TetheringManager1.RemoteProfiles[0].ProfileGroup;
59 | end;
60 |
61 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
62 | begin
63 | if PhotoStream = nil then
64 | PhotoStream := TMemoryStream.Create;
65 |
66 | Try
67 | PhotoStream.Position := 0;
68 | Image.SaveToStream(PhotoStream);
69 | PhotoStream.Position := 0;
70 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
71 | Except
72 | On E : Exception do
73 | ShowMessage(E.Message);
74 | End;
75 | end;
76 |
77 | procedure TForm1.TetheringManager1EndAutoConnect(Sender: TObject);
78 | begin
79 | Check;
80 | end;
81 |
82 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
83 | const ARemoteIdentifier: string; var Password: string);
84 | begin
85 | Password := 'delphi';
86 | end;
87 |
88 | end.
89 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~4~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | private
27 | { Private declarations }
28 | PhotoStream : TMemoryStream;
29 | public
30 | { Public declarations }
31 | end;
32 |
33 | var
34 | Form1: TForm1;
35 |
36 | implementation
37 |
38 | {$R *.fmx}
39 |
40 | procedure TForm1.btnConectarClick(Sender: TObject);
41 | begin
42 | TetheringManager1.AutoConnect();
43 | end;
44 |
45 | procedure TForm1.btnPhotoClick(Sender: TObject);
46 | begin
47 | TakePhotoFromCameraAction1.Execute;
48 | end;
49 |
50 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
51 | begin
52 | if PhotoStream = nil then
53 | PhotoStream := TMemoryStream.Create;
54 |
55 | PhotoStream.Position := 0;
56 | Image.SaveToStream(PhotoStream);
57 | PhotoStream.Position := 0;
58 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
59 | end;
60 |
61 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
62 | const ARemoteIdentifier: string; var Password: string);
63 | begin
64 | Password := 'delphi';
65 | end;
66 |
67 | end.
68 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~5~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | private
27 | { Private declarations }
28 | PhotoStream : TMemoryStream;
29 | public
30 | { Public declarations }
31 | end;
32 |
33 | var
34 | Form1: TForm1;
35 |
36 | implementation
37 |
38 | {$R *.fmx}
39 |
40 | procedure TForm1.btnConectarClick(Sender: TObject);
41 | begin
42 | TetheringManager1.AutoConnect();
43 | end;
44 |
45 | procedure TForm1.btnPhotoClick(Sender: TObject);
46 | begin
47 | TakePhotoFromCameraAction1.Execute;
48 | end;
49 |
50 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
51 | begin
52 | if PhotoStream = nil then
53 | PhotoStream := TMemoryStream.Create;
54 |
55 | Try
56 | PhotoStream.Position := 0;
57 | Image.SaveToStream(PhotoStream);
58 | PhotoStream.Position := 0;
59 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
60 | Except
61 | On E : Exception do
62 | ShowMessage(E.Message);
63 | End;
64 | end;
65 |
66 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
67 | const ARemoteIdentifier: string; var Password: string);
68 | begin
69 | Password := 'delphi';
70 | end;
71 |
72 | end.
73 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~6~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | end;
34 |
35 | var
36 | Form1: TForm1;
37 |
38 | implementation
39 |
40 | {$R *.fmx}
41 |
42 | procedure TForm1.btnConectarClick(Sender: TObject);
43 | begin
44 | TetheringManager1.AutoConnect();
45 | end;
46 |
47 | procedure TForm1.btnPhotoClick(Sender: TObject);
48 | begin
49 | TakePhotoFromCameraAction1.Execute;
50 | end;
51 |
52 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
53 | begin
54 | if PhotoStream = nil then
55 | PhotoStream := TMemoryStream.Create;
56 |
57 | Try
58 | PhotoStream.Position := 0;
59 | Image.SaveToStream(PhotoStream);
60 | PhotoStream.Position := 0;
61 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
62 | Except
63 | On E : Exception do
64 | ShowMessage(E.Message);
65 | End;
66 | end;
67 |
68 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
69 | const ARemoteManagers: TTetheringManagerInfoList);
70 | begin
71 | btnPhoto.Enabled := True;
72 | end;
73 |
74 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
75 | const ARemoteIdentifier: string; var Password: string);
76 | begin
77 | Password := 'delphi';
78 | end;
79 |
80 | end.
81 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~7~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | end;
34 |
35 | var
36 | Form1: TForm1;
37 |
38 | implementation
39 |
40 | {$R *.fmx}
41 |
42 | uses
43 | System.Tether.NetworkAdapter;
44 |
45 | procedure TForm1.btnConectarClick(Sender: TObject);
46 | begin
47 | TetheringManager1.AutoConnect();
48 | end;
49 |
50 | procedure TForm1.btnPhotoClick(Sender: TObject);
51 | begin
52 | TakePhotoFromCameraAction1.Execute;
53 | end;
54 |
55 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
56 | begin
57 | if PhotoStream = nil then
58 | PhotoStream := TMemoryStream.Create;
59 |
60 | Try
61 | PhotoStream.Position := 0;
62 | Image.SaveToStream(PhotoStream);
63 | PhotoStream.Position := 0;
64 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
65 | Except
66 | On E : Exception do
67 | ShowMessage(E.Message);
68 | End;
69 | end;
70 |
71 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
72 | const ARemoteManagers: TTetheringManagerInfoList);
73 | begin
74 | btnPhoto.Enabled := True;
75 | end;
76 |
77 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
78 | const ARemoteIdentifier: string; var Password: string);
79 | begin
80 | Password := 'delphi';
81 | end;
82 |
83 | end.
84 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~8~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | procedure Check;
34 | end;
35 |
36 | var
37 | Form1: TForm1;
38 |
39 | implementation
40 |
41 | {$R *.fmx}
42 |
43 | uses
44 | System.Tether.NetworkAdapter;
45 |
46 | procedure TForm1.btnConectarClick(Sender: TObject);
47 | begin
48 | TetheringManager1.AutoConnect();
49 | Check;
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ManagerIdentifier;
61 |
62 | end;
63 |
64 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
65 | begin
66 | if PhotoStream = nil then
67 | PhotoStream := TMemoryStream.Create;
68 |
69 | Try
70 | PhotoStream.Position := 0;
71 | Image.SaveToStream(PhotoStream);
72 | PhotoStream.Position := 0;
73 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
74 | Except
75 | On E : Exception do
76 | ShowMessage(E.Message);
77 | End;
78 | end;
79 |
80 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
81 | const ARemoteManagers: TTetheringManagerInfoList);
82 | begin
83 | btnPhoto.Enabled := True;
84 | end;
85 |
86 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
87 | const ARemoteIdentifier: string; var Password: string);
88 | begin
89 | Password := 'delphi';
90 | end;
91 |
92 | end.
93 |
--------------------------------------------------------------------------------
/Chapter06/mobile/__history/uFrmMobile.pas.~9~:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | procedure btnPhotoClick(Sender: TObject);
22 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
23 | procedure btnConectarClick(Sender: TObject);
24 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
25 | const ARemoteIdentifier: string; var Password: string);
26 | procedure TetheringManager1EndManagersDiscovery(const Sender: TObject;
27 | const ARemoteManagers: TTetheringManagerInfoList);
28 | private
29 | { Private declarations }
30 | PhotoStream : TMemoryStream;
31 | public
32 | { Public declarations }
33 | procedure Check;
34 | end;
35 |
36 | var
37 | Form1: TForm1;
38 |
39 | implementation
40 |
41 | {$R *.fmx}
42 |
43 | uses
44 | System.Tether.TCPProtocol;
45 |
46 | procedure TForm1.btnConectarClick(Sender: TObject);
47 | begin
48 | TetheringManager1.AutoConnect();
49 | Check;
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ManagerIdentifier;
61 |
62 | end;
63 |
64 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
65 | begin
66 | if PhotoStream = nil then
67 | PhotoStream := TMemoryStream.Create;
68 |
69 | Try
70 | PhotoStream.Position := 0;
71 | Image.SaveToStream(PhotoStream);
72 | PhotoStream.Position := 0;
73 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
74 | Except
75 | On E : Exception do
76 | ShowMessage(E.Message);
77 | End;
78 | end;
79 |
80 | procedure TForm1.TetheringManager1EndManagersDiscovery(const Sender: TObject;
81 | const ARemoteManagers: TTetheringManagerInfoList);
82 | begin
83 | btnPhoto.Enabled := True;
84 | end;
85 |
86 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
87 | const ARemoteIdentifier: string; var Password: string);
88 | begin
89 | Password := 'delphi';
90 | end;
91 |
92 | end.
93 |
--------------------------------------------------------------------------------
/Chapter06/mobile/uFrmMobile.fmx:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 354
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 3
11 | object btnConectar: TButton
12 | Position.X = 8.000000000000000000
13 | Position.Y = 8.000000000000000000
14 | Size.Width = 121.000000000000000000
15 | Size.Height = 44.000000000000000000
16 | Size.PlatformDefault = False
17 | TabOrder = 2
18 | Text = 'Connect'
19 | OnClick = btnConectarClick
20 | end
21 | object btnPhoto: TButton
22 | Cancel = True
23 | Position.X = 8.000000000000000000
24 | Position.Y = 56.000000000000000000
25 | Size.Width = 121.000000000000000000
26 | Size.Height = 44.000000000000000000
27 | Size.PlatformDefault = False
28 | TabOrder = 4
29 | Text = 'Take Photo'
30 | OnClick = btnPhotoClick
31 | end
32 | object Label1: TLabel
33 | Position.X = 136.000000000000000000
34 | Position.Y = 16.000000000000000000
35 | Size.Width = 193.000000000000000000
36 | Size.Height = 23.000000000000000000
37 | Size.PlatformDefault = False
38 | Text = 'Label1'
39 | TabOrder = 8
40 | end
41 | object Button1: TButton
42 | Action = Action1
43 | Enabled = True
44 | ImageIndex = -1
45 | Position.X = 9.000000000000000000
46 | Position.Y = 104.000000000000000000
47 | Size.Width = 120.000000000000000000
48 | Size.Height = 44.000000000000000000
49 | Size.PlatformDefault = False
50 | TabOrder = 13
51 | Text = 'Open Calc'
52 | end
53 | object TetheringAppProfile1: TTetheringAppProfile
54 | Manager = TetheringManager1
55 | Text = 'TetheringAppProfile1'
56 | Group = 'Packt'
57 | Actions = <
58 | item
59 | Name = 'Calc'
60 | IsPublic = True
61 | Kind = Mirror
62 | Action = Action1
63 | NotifyUpdates = False
64 | end>
65 | Resources = <
66 | item
67 | Name = 'Photo'
68 | IsPublic = True
69 | ResType = Stream
70 | end>
71 | Left = 240
72 | Top = 176
73 | end
74 | object TetheringManager1: TTetheringManager
75 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
76 | OnEndAutoConnect = TetheringManager1EndAutoConnect
77 | Password = 'delphi'
78 | Text = 'TetheringManager1'
79 | AllowedAdapters = 'Network'
80 | Left = 240
81 | Top = 232
82 | end
83 | object ActionList1: TActionList
84 | Left = 152
85 | Top = 120
86 | object TakePhotoFromCameraAction1: TTakePhotoFromCameraAction
87 | Category = 'Media Library'
88 | OnDidFinishTaking = TakePhotoFromCameraAction1DidFinishTaking
89 | end
90 | object Action1: TAction
91 | Text = 'Action1'
92 | end
93 | end
94 | end
95 |
--------------------------------------------------------------------------------
/Chapter06/mobile/uFrmMobile.pas:
--------------------------------------------------------------------------------
1 | unit uFrmMobile;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Actions, FMX.ActnList, FMX.StdActns,
9 | FMX.MediaLibrary.Actions, FMX.Controls.Presentation, FMX.StdCtrls,
10 | System.Tether.Manager, System.Tether.AppProfile;
11 |
12 | type
13 | TForm1 = class(TForm)
14 | TetheringAppProfile1: TTetheringAppProfile;
15 | TetheringManager1: TTetheringManager;
16 | btnConectar: TButton;
17 | ActionList1: TActionList;
18 | TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
19 | btnPhoto: TButton;
20 | Label1: TLabel;
21 | Button1: TButton;
22 | Action1: TAction;
23 | procedure btnPhotoClick(Sender: TObject);
24 | procedure TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
25 | procedure btnConectarClick(Sender: TObject);
26 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
27 | const ARemoteIdentifier: string; var Password: string);
28 | procedure TetheringManager1EndAutoConnect(Sender: TObject);
29 | private
30 | { Private declarations }
31 | PhotoStream : TMemoryStream;
32 | public
33 | { Public declarations }
34 | procedure Check;
35 | end;
36 |
37 | var
38 | Form1: TForm1;
39 |
40 | implementation
41 |
42 | {$R *.fmx}
43 |
44 | uses
45 | System.Tether.TCPProtocol;
46 |
47 | procedure TForm1.btnConectarClick(Sender: TObject);
48 | begin
49 | TetheringManager1.AutoConnect();
50 | end;
51 |
52 | procedure TForm1.btnPhotoClick(Sender: TObject);
53 | begin
54 | TakePhotoFromCameraAction1.Execute;
55 | end;
56 |
57 | procedure TForm1.Check;
58 | begin
59 | if TetheringManager1.RemoteProfiles.Count > 0 then
60 | Label1.Text := TetheringManager1.RemoteProfiles[0].ProfileGroup;
61 | end;
62 |
63 | procedure TForm1.TakePhotoFromCameraAction1DidFinishTaking(Image: TBitmap);
64 | begin
65 | if PhotoStream = nil then
66 | PhotoStream := TMemoryStream.Create;
67 |
68 | Try
69 | PhotoStream.Position := 0;
70 | Image.SaveToStream(PhotoStream);
71 | PhotoStream.Position := 0;
72 | TetheringAppProfile1.Resources.Items[0].Value := PhotoStream;
73 | Except
74 | On E : Exception do
75 | ShowMessage(E.Message);
76 | End;
77 | end;
78 |
79 | procedure TForm1.TetheringManager1EndAutoConnect(Sender: TObject);
80 | begin
81 | Check;
82 | end;
83 |
84 | procedure TForm1.TetheringManager1RequestManagerPassword(const Sender: TObject;
85 | const ARemoteIdentifier: string; var Password: string);
86 | begin
87 | Password := 'delphi';
88 | end;
89 |
90 | end.
91 |
--------------------------------------------------------------------------------
/Chapter06/uFrmCap6_Server.fmx:
--------------------------------------------------------------------------------
1 | object FrmCap6: TFrmCap6
2 | Left = 0
3 | Top = 0
4 | Caption = 'Form1'
5 | ClientHeight = 480
6 | ClientWidth = 640
7 | FormFactor.Width = 320
8 | FormFactor.Height = 480
9 | FormFactor.Devices = [Desktop]
10 | DesignerMasterStyle = 0
11 | object Image1: TImage
12 | MultiResBitmap = <
13 | item
14 | end>
15 | Align = Client
16 | Size.Width = 640.000000000000000000
17 | Size.Height = 480.000000000000000000
18 | Size.PlatformDefault = False
19 | end
20 | object TetheringManager1: TTetheringManager
21 | OnRequestManagerPassword = TetheringManager1RequestManagerPassword
22 | Password = 'delphi'
23 | Text = 'TetheringManager1'
24 | AllowedAdapters = 'Network'
25 | Left = 352
26 | Top = 192
27 | end
28 | object TetheringAppProfile1: TTetheringAppProfile
29 | Manager = TetheringManager1
30 | Text = 'TetheringAppProfile'
31 | Group = 'Packt'
32 | Actions = <
33 | item
34 | Name = 'Calc'
35 | IsPublic = True
36 | Action = Action1
37 | NotifyUpdates = False
38 | end>
39 | Resources = <
40 | item
41 | Name = 'Photo'
42 | IsPublic = True
43 | Kind = Mirror
44 | ResType = Stream
45 | OnResourceReceived = TetheringAppProfile1Resources0ResourceReceived
46 | end>
47 | Left = 352
48 | Top = 248
49 | end
50 | object ActionList1: TActionList
51 | Left = 240
52 | Top = 248
53 | object Action1: TAction
54 | Text = 'Action1'
55 | OnExecute = Action1Execute
56 | end
57 | end
58 | end
59 |
--------------------------------------------------------------------------------
/Chapter06/uFrmCap6_Server.pas:
--------------------------------------------------------------------------------
1 | unit uFrmCap6_Server;
2 |
3 | interface
4 |
5 | uses
6 | System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
7 | FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, IPPeerClient,
8 | IPPeerServer, System.Tether.Manager, System.Tether.AppProfile, FMX.Objects,
9 | System.Actions, FMX.ActnList, Winapi.ShellAPI, Winapi.Windows,
10 | FMX.Controls.Presentation, FMX.StdCtrls;
11 |
12 | type
13 | TFrmCap6 = class(TForm)
14 | TetheringManager1: TTetheringManager;
15 | TetheringAppProfile1: TTetheringAppProfile;
16 | Image1: TImage;
17 | ActionList1: TActionList;
18 | Action1: TAction;
19 | procedure TetheringManager1RequestManagerPassword(const Sender: TObject;
20 | const ARemoteIdentifier: string; var Password: string);
21 | procedure TetheringAppProfile1Resources0ResourceReceived(
22 | const Sender: TObject; const AResource: TRemoteResource);
23 | procedure Action1Execute(Sender: TObject);
24 | private
25 | { Private declarations }
26 | public
27 | { Public declarations }
28 | end;
29 |
30 | var
31 | FrmCap6: TFrmCap6;
32 |
33 | implementation
34 |
35 | {$R *.fmx}
36 |
37 | uses
38 | System.Tether.NetworkAdapter;
39 |
40 | procedure TFrmCap6.Action1Execute(Sender: TObject);
41 | begin
42 | ShellExecute(0,'open', PChar('C:\Windows\System32\calc.exe'), '',
43 | nil, SW_ShowNormal)
44 | end;
45 |
46 | procedure TFrmCap6.TetheringAppProfile1Resources0ResourceReceived(
47 | const Sender: TObject; const AResource: TRemoteResource);
48 | begin
49 | TThread.Synchronize(nil, procedure
50 | var
51 | LSize : Int64;
52 | begin
53 | Try
54 | LSize := AResource.Value.AsStream.Size;
55 | AResource.Value.AsStream.Position := 0;
56 | Image1.Bitmap.LoadFromStream(AResource.Value.AsStream);
57 | image1.Repaint;
58 | Except
59 |
60 | End;
61 | end);
62 | end;
63 |
64 | procedure TFrmCap6.TetheringManager1RequestManagerPassword(
65 | const Sender: TObject; const ARemoteIdentifier: string; var Password: string);
66 | begin
67 | Password := 'delphi';
68 | end;
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/Chapter07/ConverterRS.dpk:
--------------------------------------------------------------------------------
1 | package ConverterRS;
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 | emsserverapi,
34 | xmlrtl,
35 | dbrtl,
36 | soaprtl,
37 | inet;
38 |
39 | contains
40 | uConverterRADServer in 'uConverterRADServer.pas' {CurrencyResource1: TDataModule},
41 | Converter in 'Converter.pas';
42 |
43 | end.
44 |
--------------------------------------------------------------------------------
/Chapter07/ConverterRS.dproj.local:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2019/03/11 09:42:04.000.074,=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
5 | 2019/03/11 10:09:41.000.486,=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
6 | 2019/04/16 09:51:04.000.849,=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
7 | 2019/04/16 12:14:23.000.518,=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
8 | 2019/04/23 03:27:30.342,=emsserverapi.dcp
9 | 2019/04/23 03:27:30.374,=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
10 | 2019/04/23 04:36:29.365,=C:\Users\William\Documents\Embarcadero\Studio\Projects\converter.pas
11 | 2019/04/23 04:40:59.399,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\uConverterRADServer.pas=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.pas
12 | 2019/04/23 04:40:59.399,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\uConverterRADServer.dfm=C:\Users\William\Documents\Embarcadero\Studio\Projects\Unit1.dfm
13 | 2019/04/23 04:41:20.538,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\ConverterRS.pas=C:\Users\William\Documents\Embarcadero\Studio\Projects\converter.pas
14 | 2019/04/23 04:41:39.419,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\ConverterRadS.dproj=C:\Users\William\Documents\Embarcadero\Studio\Projects\Project1.dproj
15 | 2019/04/23 04:41:49.774,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\Converter.pas=D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\ConverterRS.pas
16 | 2019/04/23 04:42:01.003,D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\ConverterRS.dproj=D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\ConverterRadS.dproj
17 | 2019/04/23 04:47:01.047,=xmlrtl.dcp
18 | 2019/04/23 04:47:01.062,=dbrtl.dcp
19 | 2019/04/23 04:47:01.074,=soaprtl.dcp
20 | 2019/04/23 04:47:01.091,=inet.dcp
21 | 2019/04/23 05:59:37.250,=D:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\Unit1.pas
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Chapter07/ConverterRS.identcache:
--------------------------------------------------------------------------------
1 | LD:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\Converter.pas Nc:\program files (x86)\embarcadero\studio\20.0\SOURCE\XML\Xml.Win.msxmldom.pas Sc:\program files (x86)\embarcadero\studio\20.0\source\rtl\common\System.Classes.pas VD:\Projetos\Delphi-Programming-Projects-master\07 - RAD Server\uConverterRADServer.pas
--------------------------------------------------------------------------------
/Chapter07/ConverterRS.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PacktPublishing/Delphi-Programming-Projects/682359398d83c4ed5acd29dd880e0b29f58b6da5/Chapter07/ConverterRS.res
--------------------------------------------------------------------------------
/Chapter07/ConverterRS.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinsDefaultPainters=1
6 |
--------------------------------------------------------------------------------
/Chapter07/ConverterRadS.skincfg:
--------------------------------------------------------------------------------
1 | [ExpressSkins]
2 | Default=1
3 | ShowNotifications=1
4 | Enabled=1
5 | dxSkinsDefaultPainters=1
6 |
--------------------------------------------------------------------------------
/Chapter07/Link.txt:
--------------------------------------------------------------------------------
1 | Link
--------------------------------------------------------------------------------
/Chapter07/uConverterRADServer.dfm:
--------------------------------------------------------------------------------
1 | object CurrencyResource1: TCurrencyResource1
2 | OldCreateOrder = False
3 | OnCreate = DataModuleCreate
4 | OnDestroy = DataModuleDestroy
5 | Height = 150
6 | Width = 215
7 | object HTTPRIO1: THTTPRIO
8 | WSDLLocation = 'http://currencyconverter.kowabunga.net/converter.asmx?WSDL'
9 | Service = 'Converter'
10 | Port = 'ConverterSoap'
11 | Converter.Options = [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soCacheMimeResponse, soUTF8EncodeXML]
12 | Left = 88
13 | Top = 64
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/Chapter07/uConverterRADServer.pas:
--------------------------------------------------------------------------------
1 | unit uConverterRADServer;
2 |
3 | // EMS Resource Module
4 |
5 | interface
6 |
7 | uses
8 | System.SysUtils, System.Classes, System.JSON,
9 | EMS.Services, EMS.ResourceAPI, EMS.ResourceTypes, Soap.InvokeRegistry,
10 | Soap.Rio, Soap.SOAPHTTPClient, Converter;
11 |
12 | type
13 | [ResourceName('Currency')]
14 | TCurrencyResource1 = class(TDataModule)
15 | HTTPRIO1: THTTPRIO;
16 | procedure DataModuleCreate(Sender: TObject);
17 | procedure DataModuleDestroy(Sender: TObject);
18 | private
19 | FwsConverter: ConverterSoap;
20 | procedure SetwsConverter(const Value: ConverterSoap);
21 | public
22 | property wsConverter : ConverterSoap read FwsConverter write SetwsConverter;
23 | published
24 | procedure Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse);
25 | [ResourceSuffix('{item}')]
26 | procedure GetItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse);
27 | end;
28 |
29 | implementation
30 |
31 | {%CLASSGROUP 'System.Classes.TPersistent'}
32 |
33 | {$R *.dfm}
34 |
35 | uses
36 | Xml.xmldom, Xml.omnixmldom, XSBuiltIns;
37 |
38 | procedure TCurrencyResource1.DataModuleCreate(Sender: TObject);
39 | begin
40 | wsConverter := HTTPRIO1 as ConverterSoap;
41 | end;
42 |
43 | procedure TCurrencyResource1.DataModuleDestroy(Sender: TObject);
44 | begin
45 | wsConverter := nil;
46 | end;
47 |
48 | procedure TCurrencyResource1.Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse);
49 | begin
50 | // Sample code
51 | DefaultDOMVendor := sOmniXmlVendor;
52 | AResponse.Body.SetValue(TJSONString.Create( DateToStr(wsConverter.GetLastUpdateDate.AsDateTime)), True) ;
53 | end;
54 |
55 | procedure TCurrencyResource1.GetItem(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse);
56 | var
57 | LItem: string;
58 | Amount : TXSDecimal;
59 | begin
60 | if AContext.User = nil then
61 | EEMSHTTPError.RaiseUnauthorized('', 'User Required');
62 | if not AContext.User.Groups.Contains('testgroup') then
63 | EEMSHTTPError.RaiseForbidden('','Test Group Required');
64 |
65 | DefaultDOMVendor := sOmniXmlVendor;
66 | LItem := ARequest.Params.Values['item'];
67 | Amount := TXSDecimal.Create;
68 | Amount.DecimalString := LItem;
69 |
70 | AResponse.Body.SetValue(TJSONString.Create(
71 | wsConverter.GetConversionAmount('USD','BRL',DateTimeToXSDateTime(Date-2),Amount).DecimalString ), True)
72 | end;
73 |
74 | procedure TCurrencyResource1.SetwsConverter(const Value: ConverterSoap);
75 | begin
76 | FwsConverter := Value;
77 | end;
78 |
79 | procedure Register;
80 | begin
81 | RegisterResource(TypeInfo(TCurrencyResource1));
82 | end;
83 |
84 | initialization
85 | Register;
86 | end.
87 |
88 |
89 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Packt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Delphi Programming Projects
5 |
6 |
7 |
8 | This is the code repository for [Delphi Programming Projects](https://www.packtpub.com/application-development/delphi-programming-projects?utm_source=github&utm_medium=repository&utm_campaign=9781789130553), published by Packt.
9 |
10 | **Build a range of exciting projects by exploring cross-platform development and microservices**
11 |
12 | ## What is this book about?
13 | Delphi is a cross-platform programming language and software development kit that supports rapid application development for Microsoft Windows, Apple Mac OS X, Android, and iOS.
14 |
15 | This book covers the following exciting features:
16 | * Get to grips with the advanced features of RTL.
17 | * Understand how to deal with the change of paradigm between multiplatform projects.
18 | * Acquire knowledge of building microservices using the RAD Server.
19 | * Understand how to implement design patterns in Delphi.
20 | * Explore FireMonkey to create GUI applications.
21 |
22 | If you feel this book is for you, get your [copy](https://www.amazon.com/dp/1789808898) today!
23 |
24 |
26 |
27 | ## Instructions and Navigations
28 | All of the code is organized into folders. For example, Chapter02.
29 |
30 | The code will look like the following:
31 | ```
32 | procedure TForm1.DoDidFinish(Image: TBitmap);
33 | begin
34 | ImgInsta.Bitmap.Assign(Image);
35 | end;
36 | ```
37 |
38 | **Following is what you need for this book:**
39 | This book is for developers, programmers, and IT professionals who want to learn the best market practices by implementing practical projects. Prior knowledge of the Delphi language is a must.
40 |
41 | With the following software and hardware list you can run all code files present in the book (Chapter 1-7).
42 | ### Software and Hardware List
43 | | Sr. No. | Software required | OS required |
44 | | -------- | ------------------------------------ | ----------------------------------- |
45 | | 1 | Delphi 10.3 Community Edition | Windows, Mac OS X, and Linux (Any) |
46 | | 2 | Delphi 10.3 Enterprise Edition | Windows, Mac OS X, and Linux (Any) |
47 | | 3 | SQL Server 2008 R2 Express Edition | Windows, Mac OS X, and Linux (Any) |
48 | | 4 | PostgreSQL 9.3 | Windows, Mac OS X, and Linux (Any) |
49 |
50 | We also provide a PDF file that has color images of the screenshots/diagrams used in this book. [Click here to download it](https://www.packtpub.com/sites/default/files/downloads/9781789130553_ColorImages.pdf).
51 |
52 | ### Related products
53 | * Hands-On Design Patterns with Delphi [[Packt]](https://www.packtpub.com/application-development/hands-design-patterns-delphi?utm_source=github&utm_medium=repository&utm_campaign=9781789343243) [[Amazon]](https://www.amazon.com/dp/1789343240)
54 |
55 | * Delphi Cookbook - Third Edition [[Packt]](https://www.packtpub.com/application-development/delphi-cookbook-third-edition?utm_source=github&utm_medium=repository&utm_campaign=9781788621304) [[Amazon]](https://www.amazon.com/dp/1788621301)
56 |
57 | ## Get to Know the Author
58 | **William Duarte**
59 | is a Delphi Certified Developer and Embarcadero Regional MVP Coordinator. He began his career in 2005 as a programmer. He was recognized as an internationally certified Retail Technical Consultant by Retail Pro in 2007. He is a specialist in commercial automation and desktop/mobile development, and the author of a book in Portuguese—Delphi for Android and iOS, by Brasport, 2015. He is currently working as a consultant for the Brazilian Navy and retail chain stores.
60 | ### Suggestions and Feedback
61 | [Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions.
62 | ### Download a free PDF
63 |
64 | If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.
65 |
https://packt.link/free-ebook/9781789130553
--------------------------------------------------------------------------------