home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 September
/
Chip_2002-09_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
XMLCOMP.ZIP
/
DnXmlEditors.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-06-07
|
3KB
|
140 lines
unit DnXmlEditors;
interface
{$I DnXml.inc}
uses
Controls, {$ifdef DNXML_D6} DesignEditors, DesignIntf {$else} DsgnIntf {$endif};
type
TDnXmlWriterEditor = class(TComponentEditor)
public
function GetVerbCount: Integer; override;
function GetVerb(aIndex: Integer): string; override;
procedure ExecuteVerb(aIndex: Integer); override;
end;
TDnXmlReaderEditor = class(TComponentEditor)
public
function GetVerbCount: Integer; override;
function GetVerb(aIndex: Integer): string; override;
procedure ExecuteVerb(aIndex: Integer); override;
end;
TDnXmlDictionaryEditor = class(TComponentEditor)
public
function GetVerbCount: Integer; override;
function GetVerb(aIndex: Integer): string; override;
procedure ExecuteVerb(aIndex: Integer); override;
end;
procedure Register;
implementation
uses
Forms, SysUtils, Dialogs, DnXmlDictionaryEditorForm, DnXmlComponentChooserForm,
DnXml;
procedure Register;
begin
RegisterComponentEditor(TDnXmlWriter, TDnXmlWriterEditor);
RegisterComponentEditor(TDnXmlReader, TDnXmlReaderEditor);
RegisterComponentEditor(TDnXmlDictionary, TDnXmlDictionaryEditor);
end;
{ TDnXmlWriterEditor }
procedure TDnXmlWriterEditor.ExecuteVerb(aIndex: Integer);
var dlg: TSaveDialog;
begin
Assert(Component is TDnXmlWriter);
dlg := nil;
with TfmDnXmlComponentChooser.Create(Application) do
try
Designer := Self.Designer;
if (ShowModal = mrOk) and (Selected <> nil) then
begin
dlg := TSaveDialog.Create(Application);
dlg.DefaultExt := 'xml';
dlg.Filter := 'Xml Files (*.xml)|*.xml';
if dlg.Execute then
TDnXmlWriter(Component).ToXmlFile(dlg.Filename, Selected);
end;
finally
dlg.Free;
Free;
end;
end;
function TDnXmlWriterEditor.GetVerb(aIndex: Integer): string;
begin
result := 'Save to xml...';
end;
function TDnXmlWriterEditor.GetVerbCount: Integer;
begin
result := 1;
end;
{ TDnXmlReaderEditor }
procedure TDnXmlReaderEditor.ExecuteVerb(aIndex: Integer);
var dlg: TOpenDialog;
begin
Assert(Component is TDnXmlReader);
dlg := nil;
with TfmDnXmlComponentChooser.Create(Application) do
try
Designer := Self.Designer;
if (ShowModal = mrOk) and (Selected <> nil) then
begin
dlg := TOpenDialog.Create(Application);
dlg.DefaultExt := 'xml';
dlg.Filter := 'Xml Files (*.xml)|*.xml';
if dlg.Execute then
TDnXmlReader(Component).FromXmlFileAssign(dlg.FileName, Selected);
end;
finally
dlg.Free;
Free;
end;
end;
function TDnXmlReaderEditor.GetVerb(aIndex: Integer): string;
begin
result := 'Load from xml...';
end;
function TDnXmlReaderEditor.GetVerbCount: Integer;
begin
result := 1;
end;
{ TDnXmlDictionaryEditor }
procedure TDnXmlDictionaryEditor.ExecuteVerb(aIndex: Integer);
var form: TfmDnXmlDictionaryEditor;
begin
form := TfmDnXmlDictionaryEditor.Create(Application);
try
form.Dictionary := Component as TDnXmlDictionary;
form.ShowModal;
finally
form.Free;
end;
end;
function TDnXmlDictionaryEditor.GetVerb(aIndex: Integer): string;
begin
result := 'Show contents...';
end;
function TDnXmlDictionaryEditor.GetVerbCount: Integer;
begin
result := 1;
end;
end.