-
Notifications
You must be signed in to change notification settings - Fork 9
/
DzNoteEditorReg.pas
87 lines (68 loc) · 1.93 KB
/
DzNoteEditorReg.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
unit DzNoteEditorReg;
interface
uses DesignEditors, DesignIntf;
type
TDzNoteEditorStringsEdit = class(TPropertyEditor)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
end;
TDzNotepadPropDbClick = class(TDefaultEditor)
public
procedure EditProperty(const Prop: IProperty; var Continue: Boolean); override;
end;
procedure Register;
implementation
uses System.Classes, Data.DB, Vcl.Forms, System.SysUtils,
UFrmNoteEditor, DzNotepad;
procedure Register;
begin
RegisterComponents('Digao', [TDzNotepad]);
RegisterPropertyEditor(TypeInfo(TStrings), nil, '', TDzNoteEditorStringsEdit);
RegisterPropertyEditor(TypeInfo(TStrings), TDataSet, 'SQL', TDzNoteEditorStringsEdit);
RegisterPropertyEditor(TypeInfo(TStrings), TDzNotepad, 'Lines', TDzNoteEditorStringsEdit);
RegisterComponentEditor(TDzNotepad, TDzNotepadPropDbClick);
end;
//
procedure TDzNoteEditorStringsEdit.Edit;
var Form: TFrmNoteEditor;
C: TPersistent;
begin
C := GetComponent(0);
Form := TFrmNoteEditor.Create(Application);
try
Form.Design := Designer;
Form.PStr := TStrings(GetOrdValue);
Form.LbTitle.Caption := Format('%s.%s (%s)', [C.GetNamePath, GetName, C.ClassName]);
Form.ShowModal;
finally
Form.Free;
end;
end;
function TDzNoteEditorStringsEdit.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
function TDzNoteEditorStringsEdit.GetValue: string;
var S: TStrings;
X: Integer;
begin
S := TStrings(GetOrdValue);
X := S.Count;
if X = 0 then
Result := '(Empty)' else
if X = 1 then
Result := '(1 line)' else
Result := Format('(%d lines)', [X]);
end;
//
procedure TDzNotepadPropDbClick.EditProperty(const Prop: IProperty; var Continue: Boolean);
begin
if Prop.GetName = 'Lines' then
begin
Prop.Edit;
Continue := False;
end;
end;
end.