1
0
mirror of synced 2024-12-22 09:13:07 +01:00
x2utils/X2UtService.GUIContext.pas
Mark van Renswoude 1e7a087355 Support for Delphi 10.2 Tokyo
Added packages
Changed hardcoded IFDEF to CompilerVersion comparison
2017-07-06 17:05:07 +02:00

71 lines
1.3 KiB
ObjectPascal

unit X2UtService.GUIContext;
interface
uses
System.Classes,
X2UtService.Intf;
type
TX2ServiceContextGUI = class(TInterfacedObject, IX2ServiceContext, IX2InteractiveServiceContext)
protected
procedure StartService(AService: IX2Service); virtual;
public
constructor Create(AService: IX2Service);
{ IX2ServiceContext }
function GetMode: TX2ServiceMode;
{ IX2InteractiveServiceContext }
procedure RunInteractive(AProc: TThreadProcedure);
end;
implementation
uses
Vcl.Forms,
X2UtService.GUIContext.Form;
{ TX2ServiceContextGUI }
constructor TX2ServiceContextGUI.Create(AService: IX2Service);
begin
inherited Create;
StartService(AService);
end;
function TX2ServiceContextGUI.GetMode: TX2ServiceMode;
begin
Result := smInteractive;
end;
procedure TX2ServiceContextGUI.StartService(AService: IX2Service);
var
serviceForm: TX2ServiceContextGUIForm;
begin
Application.Initialize;
Application.MainFormOnTaskBar := True;
Application.CreateForm(TX2ServiceContextGUIForm, serviceForm);
serviceForm.Caption := AService.DisplayName;
serviceForm.Context := Self;
serviceForm.Service := AService;
Application.Run;
end;
procedure TX2ServiceContextGUI.RunInteractive(AProc: TThreadProcedure);
begin
TThread.Queue(nil, AProc);
end;
end.