unit XData.Design.Register;

interface

procedure Register;

implementation

{$R dclxdata.dcr}
{$R XData.Wizard.res}

uses
  WinApi.Windows, System.Classes, System.SysUtils, Data.DB, DesignIntf, StrEdit,
  ToolsAPI, DateUtils, Aurelius.Bind.Dataset,
  XData.Comp.Server, XData.Comp.ConnectionPool, XData.Design.Editors,
  XData.Web.Dataset, XData.Web.Client, XData.Web.Connection,
  XData.Web.JsonDataset, XData.Design.WebDatasetEditor,
  XData.Wizard.Vcl, XData.Wizard.Console;

const
  {$I ..\XDataVersion.INC}

procedure RegisterSplashScreen;
var
  BitmapHandle: HBITMAP;
begin
  Assert(SplashScreenServices <> nil);
  BitmapHandle := LoadBitmap(FindResourceHInstance(HInstance), 'XDATASPLASH');

  SplashScreenServices.AddPluginBitmap('TMS XData ' + XDataVersion,
    BitmapHandle,
    {$IFDEF TRIAL}
    True, 'Trial version'
    {$ELSE}
    False, 'Registered version'
    {$ENDIF}
  );
end;

procedure Register;
var
  lVclAppWizard: IOTAProjectWizard100;
//  lConsoleAppWizard: IOTAProjectWizard100;
begin
  RegisterSplashScreen;
  RegisterComponents('TMS XData', [TXDataWebDataset, TXDataWebConnection, TXDataWebClient]);
  RegisterComponents('TMS XData', [TXDataServer, TXDataConnectionPool]);
  RegisterSelectionEditor(TXDataServer, TXDataServerSelectionEditor);
  RegisterSelectionEditor(TXDataConnectionPool, TXDataConnectionPoolSelectionEditor);
  RegisterPropertyEditor(TypeInfo(TStrings), TXDataWebConnectionDesignData, 'Headers', TValueListProperty);
  RegisterPropertyEditor(TypeInfo(string), TXDataWebDataset, 'EntitySetName', TEntitySetNameProperty);
  RegisterFields([TXDataWebEntityField, TXDataWebDatasetField]);

  lVclAppWizard := TTMSXDataVclApplicationWizard.Create;
  RegisterPackageWizard(lVclAppWizard);

//  lConsoleAppWizard := TTMSXDataConsoleApplicationWizard.Create;
//  RegisterPackageWizard(lConsoleAppWizard);
end;

var
  AboutBoxServices: IOTAAboutBoxServices = nil;
  AboutBoxIndex: Integer = 0;

procedure RegisterAboutBox;
var
  BitmapHandle: HBITMAP;
begin
  Supports(BorlandIDEServices, IOTAAboutBoxServices, AboutBoxServices);
  Assert(AboutBoxServices <> nil);
  BitmapHandle := LoadBitmap(FindResourceHInstance(HInstance), 'XDATASPLASH');
  AboutBoxIndex := AboutBoxServices.AddPluginInfo(
    'TMS XData ' + XDataVersion,
    Format(
    'TMS XData ' + XDataVersion + #13#10 +
    'REST/JSON/Web Framework for Delphi'#13#10 +
    '(c) 2014-%d tmssoftware.com bvba'#13#10 +
    'All Rights Reserved.', [YearOf(Now)]),
    BitmapHandle,
    {$IFDEF TRIAL}
    True, 'Trial version'
    {$ELSE}
    False, 'Registered version'
    {$ENDIF}
  );
end;

procedure UnregisterAboutBox;
begin
  if (AboutBoxIndex <> 0) and (AboutBoxServices <> nil) then
  begin
    AboutBoxServices.RemovePluginInfo(AboutBoxIndex);
    AboutBoxIndex := 0;
    AboutBoxServices := nil;
  end;
end;

initialization
  RegisterAboutBox;

finalization
  UnregisterAboutBox;

end.