git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@1046 0c75b7a4-871f-7646-8a2f-f78d34cc349f
150 lines
3.7 KiB
ObjectPascal
150 lines
3.7 KiB
ObjectPascal
unit uDMBase;
|
|
|
|
interface
|
|
|
|
uses
|
|
Controls, SyncObjs, PngImageList, JvComponent, JvNavigationPane, TBXSwitcher,
|
|
TBXOffice2003Theme, Classes, ImgList, SysUtils,
|
|
DataAbstract4_Intf, uDADataTable, JvAppStorage, JvAppRegistryStorage, cxintl,
|
|
JvComponentBase, cxIntlPrintSys3, JvLogFile, dxPSGlbl, dxPSUtl, dxPrnPg,
|
|
dxBkgnd, dxWrap, dxPrnDev, dxPgsDlg, dxPSCore;
|
|
|
|
type
|
|
TdmBase = class(TDataModule)
|
|
SmallImages: TPngImageList;
|
|
StyleManager: TJvNavPaneStyleManager;
|
|
TBXSwitcher: TTBXSwitcher;
|
|
JvLogFile: TJvLogFile;
|
|
cxIntl: TcxIntl;
|
|
cxIntlPrintSys3: TcxIntlPrintSys3;
|
|
dxPrintStyleManager1: TdxPrintStyleManager;
|
|
dxPrintStyleManager1Style1: TdxPSPrintStyle;
|
|
procedure DAClientDataModuleCreate(Sender: TObject);
|
|
procedure DataModuleDestroy(Sender: TObject);
|
|
private
|
|
FOnThemeChange: TNotifyEvent;
|
|
FEscribirLog : TCriticalSection;
|
|
procedure IniciarLog;
|
|
procedure DetenerLog;
|
|
procedure InitStyleManager;
|
|
procedure OnTBXThemeChange(Sender: TObject);
|
|
procedure LeerConfiguracion;
|
|
public
|
|
procedure EscribirLog(const AMensaje : String);
|
|
procedure SalvarConfiguracion;
|
|
property OnThemeChange: TNotifyEvent read FOnThemeChange write
|
|
FOnThemeChange;
|
|
end;
|
|
|
|
var
|
|
dmBase: TdmBase = nil;
|
|
|
|
implementation
|
|
|
|
{$R *.DFM}
|
|
|
|
uses
|
|
uDataModuleConexion, Dialogs, TBX, TBXThemes, Forms, Windows,
|
|
JclFileUtils, cxControls, uDataModuleConfiguracion,
|
|
SHFolder, uSistemaFunc, uAppInfoUtils;
|
|
|
|
{
|
|
*********************************** TdmBase ************************************
|
|
}
|
|
procedure TdmBase.DAClientDataModuleCreate(Sender: TObject);
|
|
begin
|
|
IniciarLog;
|
|
|
|
TBXSwitcher.OnThemeChange := OnTBXThemeChange;
|
|
TBXSetTheme('Office2003');
|
|
|
|
LeerConfiguracion;
|
|
end;
|
|
|
|
procedure TdmBase.IniciarLog;
|
|
var
|
|
ALogFileName : String;
|
|
begin
|
|
FEscribirLog := TCriticalSection.Create;
|
|
|
|
ALogFileName := GetSpecialFolderPath(CSIDL_APPDATA); //[Current Users]\Application Data
|
|
ALogFileName := ALogFileName + PathDelim + 'Rodax Software' + PathDelim + 'FactuGES' + PathDelim;
|
|
if SysUtils.ForceDirectories(ALogFileName) then
|
|
begin
|
|
JvLogFile.Active := False;
|
|
JvLogFile.FileName := ALogFileName + 'ClientLog.txt';
|
|
JvLogFile.AutoSave := True;
|
|
JvLogFile.Active := True;
|
|
JvLogFile.Clear;
|
|
end
|
|
else
|
|
raise Exception.Create('Error al crear directorio para Log: ' + IntToStr(GetLastError));
|
|
end;
|
|
|
|
|
|
procedure TdmBase.InitStyleManager;
|
|
begin
|
|
if not USE_THEMES then
|
|
begin
|
|
TBXSwitcher.EnableXPStyles := False;
|
|
StyleManager.Theme := nptStandard;
|
|
end
|
|
else begin
|
|
TBXSwitcher.EnableXPStyles := True;
|
|
with StyleManager do
|
|
begin
|
|
if CurrentTheme is TTBXOffice2003Theme then
|
|
begin
|
|
case GetOffice2003Scheme of
|
|
osBlue : Theme := nptXPBlue;
|
|
osMetallic : Theme := nptXPSilver;
|
|
osGreen : Theme := nptXPOlive;
|
|
else
|
|
Theme := nptStandard;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TdmBase.LeerConfiguracion;
|
|
begin
|
|
dmConfiguracion.LeerConfiguracion;
|
|
end;
|
|
|
|
procedure TdmBase.OnTBXThemeChange(Sender: TObject);
|
|
begin
|
|
InitStyleManager;
|
|
|
|
if Assigned(FOnThemeChange) then
|
|
FOnThemeChange(Sender);
|
|
end;
|
|
|
|
procedure TdmBase.SalvarConfiguracion;
|
|
begin
|
|
dmConfiguracion.SalvarConfiguracion;
|
|
end;
|
|
|
|
procedure TdmBase.DataModuleDestroy(Sender: TObject);
|
|
begin
|
|
DetenerLog;
|
|
end;
|
|
|
|
procedure TdmBase.DetenerLog;
|
|
begin
|
|
FreeAndNIL(FEscribirLog);
|
|
end;
|
|
|
|
procedure TdmBase.EscribirLog(const AMensaje: String);
|
|
begin
|
|
FEscribirLog.Acquire;
|
|
try
|
|
JvLogFile.Add(AMensaje);
|
|
finally
|
|
FEscribirLog.Release;
|
|
end;
|
|
end;
|
|
|
|
end.
|