-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathOpenWire.Design.pas
More file actions
100 lines (86 loc) · 3.6 KB
/
OpenWire.Design.pas
File metadata and controls
100 lines (86 loc) · 3.6 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
////////////////////////////////////////////////////////////////////////////////
// //
// This software is supplied under the terms of a license agreement or //
// nondisclosure agreement with Mitov Software and may not be copied //
// or disclosed except in accordance with the terms of that agreement. //
// Copyright(c) 2002-2025 Mitov Software. All Rights Reserved. //
// //
////////////////////////////////////////////////////////////////////////////////
unit OpenWire.Design;
{$IFDEF __DELPHI_DESIGN__}
{$DEFINE VCL_EDITORS}
{$ELSE}
{$IFNDEF __VSDESIGN__}
{$DEFINE FORM_EDITORS}
{$ENDIF}
{$ENDIF}
interface
uses
Mitov.Design, Mitov.Containers.List;
type
TOWPinListOwnerPropertyEditor = class( TSinglePropertyEditor )
{$IFNDEF VCL_EDITORS}
protected
function GetStringValuesInternal( const AObjectsList : IObjectArrayList = NIL ) : IStringArrayList; override;
public
function GetDisplayValues( const AObjectsList : IObjectArrayList = NIL ) : IStringArrayList; override;
procedure SetStringValue( const AValue : String ); override;
{$ENDIF}
end;
//---------------------------------------------------------------------------
{$IFDEF FORM_EDITORS}
procedure Register;
{$ENDIF}
//---------------------------------------------------------------------------
implementation
uses
System.SysUtils, System.Rtti, OWPins, Mitov.Utils;
{$IFNDEF VCL_EDITORS}
function TOWPinListOwnerPropertyEditor.GetDisplayValues( const AObjectsList : IObjectArrayList = NIL ) : IStringArrayList;
begin
Result := GetStringValues( AObjectsList );
for var AValue in GetInstanceValues( AObjectsList ) do
begin
var ACount := AValue.AsType<TOWPinListOwner>.Count;
if( ACount = 1 ) then
Result.Add( '1 Item' )
else
Result.Add( ACount.ToString() + ' Items' );
end;
end;
//---------------------------------------------------------------------------
function TOWPinListOwnerPropertyEditor.GetStringValuesInternal( const AObjectsList : IObjectArrayList = NIL ) : IStringArrayList;
begin
Result := TStringArrayList.Create();
for var AValue in GetInstanceValues( AObjectsList ) do
Result.Add( AValue.AsType<TOWPinListOwner>.Count.ToString());
end;
//---------------------------------------------------------------------------
procedure TOWPinListOwnerPropertyEditor.SetStringValue( const AValue : String );
var
AModification : IManagedSection;
begin
var APinList := GetInstanceValues()[ 0 ].AsType<TOWPinListOwner>;
var ANewValue := StrToIntDef( AValue, APinList.Count );
if( ANewValue <> APinList.Count ) then
begin
AModification := BeginModify( False );
APinList.Count := ANewValue;
// Modified();
end;
end;
{$ENDIF}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
{$IFDEF FORM_EDITORS}
procedure Register;
begin
RegisterPropertyEditor( TypeInfo(TOWPin), NIL, '', THiddenEditor );
RegisterPropertyEditor( TypeInfo(TOWPinList), NIL, '', THiddenEditor );
RegisterPropertyEditor( TypeInfo(TOWPinListOwner), NIL, '', TOWPinListOwnerPropertyEditor );
end;
{$ENDIF}
//---------------------------------------------------------------------------
end.