| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- { $HDR$}
- {**********************************************************************}
- { Unit archived using Team Coherence }
- { Team Coherence is Copyright 2002 by Quality Software Components }
- { }
- { For further information / comments, visit our WEB site at }
- { http://www.TeamCoherence.com }
- {**********************************************************************}
- {}
- { $Log: 23210: ApplicationConfiguration.pas
- {
- { Rev 1.0 09/11/2003 3:19:50 PM Jeremy Darling
- { Added to project for a place to store application configuration information.
- }
- unit ApplicationConfiguration;
- interface
- uses
- Graphics,
- IniFiles,
- SysUtils,
- Classes;
- type
- TLogColors=class(TStringList)
- private
- function GetColors(shortname: string): TColor;
- procedure SetColors(shortname: string; const Value: TColor);
- public
- property Colors[shortname:string]:TColor read GetColors write SetColors;
- end;
- TApplicationConfig = class
- private
- FLogColors: TLogColors;
- public
- property LogColors : TLogColors read FLogColors;
- procedure LoadFromIni(Ini : TIniFile);
- procedure SaveToIni(Ini : TIniFile);
- constructor Create;
- destructor Destroy; override;
- end;
- implementation
- { TApplicationConfig }
- constructor TApplicationConfig.Create;
- begin
- inherited;
- FLogColors := TLogColors.Create;
- end;
- destructor TApplicationConfig.Destroy;
- begin
- FLogColors.Free;
- inherited;
- end;
- procedure TApplicationConfig.LoadFromIni(Ini: TIniFile);
- var
- i,
- v : Integer;
- n : String;
- sl: TStringList;
- begin
- sl := TStringList.Create;
- try
- Ini.ReadSection('LOGCOLORS', sl);
- for i := 0 to sl.Count -1 do
- begin
- n := sl[i];
- v := Ini.ReadInteger('LOGCOLORS', n, Integer(LogColors.Colors[n]));
- LogColors[i] := n;
- LogColors.Colors[n] := TColor(v);
- end;
- finally
- sl.Free;
- end;
- end;
- procedure TApplicationConfig.SaveToIni(Ini: TIniFile);
- var
- i : Integer;
- begin
- for i := 0 to LogColors.Count -1 do
- begin
- Ini.WriteInteger('LOGCOLORS', LogColors[i], Integer(LogColors.Colors[LogColors[i]]));
- end;
- end;
- { TLogColors }
- function TLogColors.GetColors(shortname: string): TColor;
- begin
- if indexof(shortname) > -1 then
- result := TColor(Pointer(Objects[indexof(shortname)]))
- else
- result := clBlack;
- end;
- procedure TLogColors.SetColors(shortname: string; const Value: TColor);
- begin
- if indexof(shortname) = -1 then
- AddObject(shortname, pointer(value))
- else
- Objects[indexof(shortname)] := pointer(value);
- end;
- end.
-
|