unit Aurelius.Design.Register;

interface

procedure Register;

implementation

uses
  Windows, SysUtils, Classes, DB, DesignIntf, ToolsApi, DateUtils,
  Aurelius.Bind.Dataset,
  Aurelius.Comp.Connection,
  Aurelius.Design.DatasetEditor,
  Aurelius.Design.DatasetDesigner,
  Aurelius.Design.Editors,

  // Adapters available at design-time
  Aurelius.Drivers.FireDacRtti,

  // Drivers available
  Aurelius.Drivers.SQLite,
  Aurelius.Drivers.MSSQL;

procedure Register;
begin
  ForceDemandLoadState(dlDisable); // Aurelius is very lightweight package, no problem. Change this if it becomes "heavy"
  RegisterComponents('TMS Aurelius', [TAureliusDataset, TAureliusConnection]);
  RegisterComponentEditor(TAureliusDataset, TAureliusDataSetEditor);

  RegisterComponentEditor(TAureliusConnection, TAureliusConnectionEditor);
  RegisterSelectionEditor(TAureliusConnection, TAureliusConnectionSelectionEditor);
  RegisterPropertyEditor(TypeInfo(string), TAureliusConnection, 'DriverName', TAureliusDriverNameProperty);
  RegisterPropertyEditor(TypeInfo(string), TAureliusConnection, 'AdapterName', TAureliusAdapterNameProperty);
  RegisterPropertyEditor(TypeInfo(string), TAureliusConnection, 'SQLDialect', TAureliusSQLDialectProperty);
  RegisterPropertyEditor(TypeInfo(TComponent), TAureliusConnection, 'AdaptedConnection', TAureliusAdaptedConnectionProperty);
  RegisterFields([TAureliusEntityField]);
end;

const
  AureliusVersion = '4.2';

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

procedure RegisterAboutBox;
var
  BitmapHandle: HBITMAP;
begin
  Supports(BorlandIDEServices, IOTAAboutBoxServices, AboutBoxServices);
  Assert(AboutBoxServices <> nil);
  BitmapHandle := LoadBitmap(FindResourceHInstance(HInstance), 'AURELIUSSPLASH');
  AboutBoxIndex := AboutBoxServices.AddPluginInfo(
      'TMS Aurelius ' + AureliusVersion,
    Format(
      'TMS Aurelius ' + AureliusVersion + #13#10 +
      'Object-Relational Mapping Framework for Delphi'#13#10 +
      '(c) 2012-%d tmssoftware.com bvba'#13#10 +
      'All Rights Reserved.', [YearOf(Now)]),
      BitmapHandle,
      {$IFDEF TRIAL}
      True, 'Trial version'
      {$ELSE}
        {$IFDEF FREE}
        False, 'Free edition'
        {$ELSE}
        False, 'Registered'
        {$ENDIF}
      {$ENDIF}
  );
end;

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

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

  SplashScreenServices.AddPluginBitmap('TMS Aurelius ' + AureliusVersion,
    BitmapHandle,
    {$IFDEF TRIAL}
    True, 'Trial version'
    {$ELSE}
      {$IFDEF FREE}
      False, 'Free edition'
      {$ELSE}
      False, 'Registered'
      {$ENDIF}
    {$ENDIF}
  );
end;

initialization
  RegisterSplashScreen;
  RegisterAboutBox;

finalization
  UnregisterAboutBox;

end.
