1
0
mirror of synced 2024-11-15 00:43:50 +00:00
unitswitcher/Source/CmpSwObjects.pas

61 lines
1.1 KiB
ObjectPascal
Raw Normal View History

unit CmpSwObjects;
interface
uses
ToolsAPI,
BaseSwObjects;
type
TCmpSwComponent = class(TBaseSwItem)
private
FComponent: IOTAComponent;
FName: String;
protected
function GetName(): String; override;
public
constructor Create(AComponent: IOTAComponent);
procedure Activate(const AClearSelection: Boolean);
class function TryCreate(AComponent: IOTAComponent): TCmpSwComponent;
end;
implementation
uses
SysUtils;
{ TCmpSwComponent }
class function TCmpSwComponent.TryCreate(AComponent: IOTAComponent): TCmpSwComponent;
begin
Result := TCmpSwComponent.Create(AComponent);
if Length(Result.Name) = 0 then
FreeAndNil(Result);
end;
constructor TCmpSwComponent.Create(AComponent: IOTAComponent);
begin
inherited Create();
FComponent := AComponent;
FComponent.GetPropValueByName('Name', FName);
end;
procedure TCmpSwComponent.Activate(const AClearSelection: Boolean);
begin
FComponent.Select(not AClearSelection);
end;
function TCmpSwComponent.GetName(): String;
begin
Result := FName;
end;
end.