⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signatures.pas

📁 siMail, siMail, siMail, siMail
💻 PAS
字号:
(*
# (C) Copyright 2003
# Miha Vrhovnik, miha.vrhovnik@cordia.si
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# The Initial Developer of the Original Code is Miha Vrhovnik (Slovenia).
# Portions created by Miha Vrhovnik are Copyright (c)2003.
# All Rights Reserved.
#==============================================================================
# Contributor(s):
#==============================================================================
# History: see whats new.txt from distribution package
#==============================================================================
*)
unit signatures;

interface

uses Classes, SysUtils, OmniMyXMLPersistent, OmniXML;

type TSignature = class(TCollectionItem)
  private
    FSignature: String;
    FName: String;
  published
    property Name: String read FName write FName;
    property Signature: String read FSignature write FSignature;
end;

type TSignatures = class(TCollection)
  private
    FFileName: String;
    function  GetSignature(Index: Integer): TSignature;
    procedure SetSignature(Index: Integer; const Value: TSignature);
  public
    property  Signature[Index: Integer]: TSignature read GetSignature write SetSignature;
    function  Add(sigName, signature: String): TSignature;
    procedure Save;
    function  Find(signatureName: String): String;
    constructor Create(fileName: String);
    destructor  Destroy; override;
  published
end;

implementation

{ TSignatures }

function TSignatures.Add(sigName, signature: String): TSignature;
begin
  Result := (inherited Add) as TSignature;
  Result.Name := sigName;
  Result.Signature := signature;
end;

constructor TSignatures.Create(fileName: String);
begin
  inherited Create(TSignature);

  FFileName := fileName;
  Clear;
  if FileExists(FFileName) then
    TOmniMyXMLReader.LoadFromFile(Self, fileName);
end;

destructor TSignatures.Destroy;
begin
  Save;

  inherited Destroy;
end;

function TSignatures.Find(signatureName: String): String;
var i: Integer;
begin
  Result := '';
  for i := 0 to Count - 1 do begin
    if Signature[i].name = signatureName then begin
      Result := Signature[i].signature;
      break;
    end;
  end;
end;

function TSignatures.GetSignature(Index: Integer): TSignature;
begin
  Result:=(inherited GetItem(Index)) as TSignature
end;

procedure TSignatures.Save;
begin
  TOmniMyXMLWriter.SaveToFile(Self, FFileName, ofIndent);
end;

procedure TSignatures.SetSignature(Index: Integer; const Value: TSignature);
begin
  inherited SetItem(Index, Value);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -