📄 fsignatures.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 fSignatures;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, account, ActnList;
type
TfrmSignatures = class(TForm)
lstSignatures: TListBox;
Label1: TLabel;
cmdNew: TButton;
cmdDelete: TButton;
cmdClose: TButton;
ActionList1: TActionList;
actNew: TAction;
actDelete: TAction;
actEdit: TAction;
cmdRename: TButton;
procedure cmdCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure actNewExecute(Sender: TObject);
procedure actDeleteExecute(Sender: TObject);
procedure actEditExecute(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure lstSignaturesDblClick(Sender: TObject);
procedure FormHide(Sender: TObject);
procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
procedure actDeleteUpdate(Sender: TObject);
procedure actEditUpdate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmSignatures: TfrmSignatures;
implementation
uses
mailBox, fMyInputBox, fMain, fSignatureEdit, signatures, gnugettext, defFldrs;
{$R *.dfm}
procedure TfrmSignatures.cmdCloseClick(Sender: TObject);
begin
frmMailbox.Profile.Signatures.Save;
Self.Close;
end;
procedure TfrmSignatures.FormShow(Sender: TObject);
var i: Integer;
begin
//translate me
TranslateComponent(Self);
lstSignatures.Clear;
for i := 0 to frmMailbox.Profile.Signatures.Count - 1 do
lstSignatures.Items.AddObject(
frmMailbox.Profile.Signatures.Signature[i].Name, Pointer(i));
//read self position & size
frmMailbox.Profile.Config.ReadControlSettings(Self);
end;
procedure TfrmSignatures.actNewExecute(Sender: TObject);
begin
frmSignatureEdit.txtSignatureName.Text := '';
frmSignatureEdit.txtSignature.Lines.Text := '';
frmSignatureEdit.ShowModal;
if not frmSignatureEdit.Cancled then begin
frmMailbox.Profile.Signatures.Add(frmSignatureEdit.txtSignatureName.Text,
frmSignatureEdit.txtSignature.Lines.Text);
lstSignatures.Items.AddObject(frmSignatureEdit.txtSignatureName.Text,
Pointer(lstSignatures.Items.Count))
end;
end;
procedure TfrmSignatures.actDeleteExecute(Sender: TObject);
var i: Integer;
begin
i := MessageDlg(Format(_('Are you sure you want to delete ''%s''?'),
[lstSignatures.Items.Strings[lstSignatures.ItemIndex]]), mtConfirmation,
[mbYes, mbNo], 0);
if i = mrYes then begin
frmMailbox.Profile.Signatures.Delete(
Integer(lstSignatures.Items.Objects[lstSignatures.ItemIndex]));
lstSignatures.Items.Delete(lstSignatures.ItemIndex);
end;
end;
procedure TfrmSignatures.actEditExecute(Sender: TObject);
var s: TSignature;
begin
frmSignatureEdit.txtSignatureName.Text :=
frmMailbox.Profile.Signatures.Signature[Integer(
lstSignatures.Items.Objects[lstSignatures.ItemIndex])].name;
frmSignatureEdit.txtSignature.Lines.Text :=
frmMailbox.Profile.Signatures.Signature[Integer(
lstSignatures.Items.Objects[lstSignatures.ItemIndex])].signature;
frmSignatureEdit.ShowModal;
if not frmSignatureEdit.Cancled then begin
s:=frmMailbox.Profile.Signatures.Signature[Integer(
lstSignatures.Items.Objects[lstSignatures.ItemIndex])];
s.name := frmSignatureEdit.txtSignatureName.Text;
s.signature := frmSignatureEdit.txtSignature.Lines.Text;
lstSignatures.Items.Strings[lstSignatures.ItemIndex] :=
frmSignatureEdit.txtSignatureName.Text;
end;
end;
procedure TfrmSignatures.FormClose(Sender: TObject; var Action: TCloseAction);
begin
frmMailbox.Profile.Signatures.Save;
end;
procedure TfrmSignatures.lstSignaturesDblClick(Sender: TObject);
begin
actEdit.Execute;
end;
procedure TfrmSignatures.FormHide(Sender: TObject);
begin
//write self position & size
frmMailbox.Profile.Config.WriteControlSettings(Self);
end;
procedure TfrmSignatures.FormShortCut(var Msg: TWMKey;
var Handled: Boolean);
begin
if msg.CharCode = 27 then begin
Self.Close;
Handled := True;
end;
end;
procedure TfrmSignatures.actDeleteUpdate(Sender: TObject);
begin
if lstSignatures.ItemIndex >=0 then
actDelete.Enabled := True
else
actDelete.Enabled := False;
end;
procedure TfrmSignatures.actEditUpdate(Sender: TObject);
begin
if lstSignatures.ItemIndex >=0 then
actEdit.Enabled := True
else
actEdit.Enabled := False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -