📄 unodelabel.pas
字号:
unit uNodeLabel;
interface
uses StdCtrls, Graphics, ExtCtrls, Classes, SysUtils;
{uses WinUtils, Windows, SysUtils, Classes,
Controls, Forms, Graphics, StdCtrls;
}
type
TNodeLabel = Class(TCustomLabel)
private
fNumber: String;
fX: Word;
fY: Word;
fParentWidth: Word;
fParentHeight: Word;
fHaveChild: Boolean;
// fNodeIndex: Integer;
// fPicture: TPicture;
fPictureFile: String;
fParentNode: String;
// fURL: String;
fIP: String;
fPort: Word;
fVIP: String;
fVPort: Word;
fPromptLevel: Smallint;
fDataInUpDpt: Boolean;
fCityDataBase: String;
fCityLevel: Smallint;
// procedure SetPicture(Value: TPicture);
function GetURL: String;
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function NodeEvaluate(sNode: TNodeLabel): integer;
published
property Caption;
property Left;
property Top;
property Width;
property Height;
property Color;
property OnClick;
property Font;
property OnMouseDown;
property PopupMenu;
property AutoSize;
property Name;
property PromptLevel: Smallint Read fPromptLevel Write fPromptLevel;
property Number: String Read fNumber Write fNumber;
property X: Word Read fX Write fX;
property Y: Word Read fY Write fY;
// property NodeIndex: Integer Read fNodeIndex Write fNodeIndex;
property ParentWidth: Word Read fParentWidth Write fParentWidth;
property ParentHeight: Word Read fParentHeight Write fParentHeight;
property HaveChild: Boolean Read fHaveChild Write fHaveChild;
// property Picture: TPicture Read fPicture Write SetPicture;
property PictureFile: String Read fPictureFile Write fPictureFile;
property ParentNode: String Read fParentNode write fParentNode;
// property URL: String Read fURL write fURL;
property URL: String Read GetURL;
property IP: String Read fIP Write fIP;
property Port: Word Read fPort Write fPort;
property VIP: String Read fVIP Write fVIP;
property VPort: Word Read fVPort Write fVPort;
property DataInUpDpt: Boolean read fDataInUpDpt write fDataInUpDpt;
property CityDataBase: String Read fCityDataBase Write fCityDataBase;
property CityLevel: Smallint Read fCityLevel Write fCityLevel;
end;
ANodeLabel = Array of TNodeLabel;
function NodeEvaluate(sNode: TNodeLabel; var tNode: TNodeLabel): integer;
function AddNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel): Integer;
function InsertNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel;
const index: Integer=0): Integer;
function ModifyNodeLabel(var ANL: ANodeLabel; const index: Integer;
Node: TNodeLabel): Integer;
function DeleteNodeLabel(var ANL: ANodeLabel; const index: Integer): Integer; overload;
function DeleteNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel): Integer; overload;
function DeleteAllNodeLabel(var ANL: ANodeLabel): Integer;
function IndexOfNodeLabel(ANL:ANodeLabel; Node: TNodeLabel): Integer;
function CompareNodeLabel(Node:TNodeLabel;const Number:String): Boolean; overload;
function CompareNodeLabel(Node1,Node2:TNodeLabel): Boolean; overload;
function CompareCompleteNodeLabel(Node1,Node2:TNodeLabel): Boolean;
function ExistsNodeLabel(ANL: ANodeLabel;const Number:String): Boolean; overload;
function ExistsNodeLabel(ANL: ANodeLabel;Node:TNodeLabel): Boolean; overload;
implementation
{ TNodeLabel }
constructor TNodeLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
// fPicture := TPicture.Create;
fParentNode := '';
fPromptLevel := 0;
end;
destructor TNodeLabel.Destroy;
begin
// fPicture.Free;
inherited Destroy;
end;
function TNodeLabel.GetURL: String;
begin
if fVIP<>'' then
begin
if fVPort<>0 then
begin
if fPort<>0 then
Result := 'http://'+fVIP+':'+trim(inttostr(fVPort))+
'/scripts/Jglr.dll/soap/IJGLR?realhost='+
fIP+#38+'realport='+inttostr(fPort)
else
Result := 'http://'+fVIP+':'+trim(inttostr(fVPort))+
'/scripts/Jglr.dll/soap/IJGLR?realhost='+
fIP+#38+'realport=80';
end
else
begin
if fPort<>0 then
Result := 'http://'+fVIP+
'/scripts/Jglr.dll/soap/IJGLR?realhost='+
fIP+#38+'realport='+inttostr(fPort)
else
Result := 'http://'+fVIP+
'/scripts/Jglr.dll/soap/IJGLR?realhost='+
fIP+#38+'realport=80';
end;
end
else
begin
if fPort<>0 then
Result := 'http://'+fIP+':'+trim(inttostr(fPort))+
'/scripts/Jglr.dll/soap/IJGLR'
else
Result := 'http://'+fIP+
'/scripts/Jglr.dll/soap/IJGLR';
end;
end;
function TNodeLabel.NodeEvaluate(sNode: TNodeLabel): integer;
begin
if (sNode = nil) then
begin
Result := -2;
exit;
end;
try
Number := sNode.Number ;
X := sNode.X;
Y := sNode.Y;
Caption := sNode.Caption;
Left := sNode.Left;
Top := sNode.Top;
Width := sNode.Width;
Height := sNode.Height;
// NodeIndex := sNode.NodeIndex ;
ParentWidth := sNode.ParentWidth;
ParentHeight := sNode.ParentHeight ;
HaveChild := sNode.HaveChild;
// Picture := sNode.Picture;
PictureFile := sNode.PictureFile;
ParentNode := sNode.ParentNode;
// URL := sNode.URL;
IP := sNode.IP;
VIP := sNode.VIP;
Port := sNode.Port;
VPort := SNode.VPort;
DataInUpDpt := sNode.DataInUpDpt;
CityDataBase := sNode.CityDataBase;
CityLevel := sNode.CityLevel;
OnClick := sNode.OnClick;
OnMouseDown := sNode.OnMouseDown ;
AutoSize := sNode.AutoSize;
PopupMenu := sNode.PopupMenu;
Parent := sNode.Parent;
Result :=0;
except
Result := -1;
end;
end;
{procedure TNodeLabel.SetPicture(Value: TPicture);
begin
fPicture.Assign(Value);
end;
}
function NodeEvaluate(sNode: TNodeLabel;
var tNode: TNodeLabel): integer;
begin
if (sNode = nil) then // or (tNode = nil) then
begin
Result := -2;
exit;
end;
try
if tNode = nil then
tNode := TNodeLabel.Create(nil);
tNode.Number := sNode.Number ;
tNode.X := sNode.X;
tNode.Y := sNode.Y;
tNode.Caption := sNode.Caption;
tNode.Left := sNode.Left;
tNode.Top := sNode.Top;
tNode.Width := sNode.Width;
tNode.Height := sNode.Height;
// tNode.NodeIndex := sNode.NodeIndex ;
tNode.ParentWidth := sNode.ParentWidth;
tNode.ParentHeight := sNode.ParentHeight ;
tNode.HaveChild := sNode.HaveChild;
// tNode.Picture := sNode.Picture;
tNode.PictureFile := sNode.PictureFile;
tNode.ParentNode := sNode.ParentNode;
// tNode.URL := sNode.URL;
tNode.IP := sNode.IP;
tNode.VIP := sNode.VIP;
tNode.Port := sNode.Port;
tNode.VPort := SNode.VPort;
tNode.DataInUpDpt := sNode.DataInUpDpt;
tNode.CityDataBase := sNode.CityDataBase;
tNode.CityLevel := sNode.CityLevel;
tNode.OnClick := sNode.OnClick;
tNode.OnMouseDown := sNode.OnMouseDown ;
tNode.AutoSize := sNode.AutoSize;
tNode.PopupMenu := sNode.PopupMenu;
tNode.Parent := sNode.Parent;
Result :=0;
except
Result := -1;
end;
end;
function AddNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel): Integer;
var
i: Integer;
begin
if ExistsNodeLabel(ANL,Node) then
begin
Result :=1;
exit;
end;
try
i := High(ANL)+1;
SetLength(ANL,i+1);
ANL[i] := Node;
Result := 0;
// ANL[i] := TNodeLabel.Create(nil);
// Result := ANL[i].NodeEvaluate(Node);
except
Result := -1;
end;
end;
function InsertNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel;
const index: Integer=0): Integer;
var
i, iC, iD: Integer;
begin
if index <0 then
begin
Result :=1;
exit
end;
if ExistsNodeLabel(ANL,Node) then
begin
Result :=2;
exit;
end;
try
iC := High(ANL)+1;
iD := index;
if index >iC-1 then
iD := iC;
SetLength(ANL,iC+1);
for i:= iC downto index+1 do
ANL[i] := ANL[i-1];
ANL[ID] := Node;
{ ANL[iC] := TNodeLabel.Create(nil);
for i:= iC downto index+1 do
ANL[i].NodeEvaluate(ANL[i-1]);
ANL[ID].NodeEvaluate(Node);
}
Result := 0;
except
Result := -1;
end;
end;
function ModifyNodeLabel(var ANL: ANodeLabel; const index: Integer;
Node: TNodeLabel): Integer;
var
iC: Integer;
begin
iC := High(ANL);
if (index <0) or (index>iC) then
begin
Result :=1;
exit
end;
if not CompareNodeLabel(ANL[index],Node.Number) then
begin
if ExistsNodeLabel(ANL,Node) then
begin
Result :=2;
exit;
end;
end;
try
ANL[index].Free;
ANL[index] := Node;
result := 0;
// Result := ANL[index].NodeEvaluate(Node);
except
Result := -1;
end;
end;
function DeleteNodeLabel(var ANL: ANodeLabel; const index: Integer): Integer;
var
i, iC: Integer;
begin
ic := High(ANL);
if (index <0) or (index> iC) then
begin
Result := 1;
exit
end;
try
ANL[index].Free;
for i:=index to iC-1 do
ANL[i] := ANL[i+1];
// ANL[i].NodeEvaluate(ANL[i+1]);
// ANL[iC].Free;
SetLength(ANL,iC);
Result := 0;
except
Result := -1;
end;
end;
function DeleteNodeLabel(var ANL: ANodeLabel; Node: TNodeLabel): Integer;
var
i: Integer;
begin
i := IndexOfNodeLabel(ANL,Node);
if i<0 then
begin
Result := 1;
exit;
end;
Result := DeleteNodeLabel(ANL,i);
end;
function DeleteAllNodeLabel(var ANL: ANodeLabel): Integer;
var
i, iC: Integer;
begin
iC := High(ANL);
try
for i:=iC downto 0 do
ANL[i].Free;
SetLength(ANL,0);
Result :=0;
except
Result :=-1;
end;
end;
function IndexOfNodeLabel(ANL:ANodeLabel; Node: TNodeLabel): Integer;
var
i, iC: Integer;
begin
Result := -1;
iC := High(ANL);
for i:= 0 to iC do
begin
if CompareNodeLabel(ANL[i],Node) then
begin
Result := i;
break;
end;
end;
end;
function CompareNodeLabel(Node:TNodeLabel;const Number:String): Boolean;
begin
if (Node.Number = Number) then
Result := True
else
Result := False;
end;
function CompareNodeLabel(Node1,Node2:TNodeLabel): Boolean;
begin
if (Node1.Number = Node2.Number) then
Result := True
else
Result := False;
end;
function CompareCompleteNodeLabel(Node1,Node2:TNodeLabel): Boolean;
begin
if (Node1.Number = Node2.Number) and
(Node1.Caption = Node2.Caption) and
(Node1.Number = Node2.Number) and
(Node1.X = Node2.X) and
(Node1.Y = Node2.Y) and
(Node1.Caption = Node2.Caption) and
(Node1.Left = Node2.Left) and
(Node1.Top = Node2.Top) and
(Node1.Width = Node2.Width) and
(Node1.Height = Node2.Height) and
// (Node1.NodeIndex = Node2.NodeIndex ) and
(Node1.ParentWidth = Node2.ParentWidth) and
(Node1.ParentHeight = Node2.ParentHeight ) and
(Node1.HaveChild = Node2.HaveChild) and
// (Node1.Picture = Node2.Picture) and
(Node1.PictureFile = Node2.PictureFile) and
(Node1.ParentNode = Node2.ParentNode) and
// (Node1.URL = Node2.URL) and
(Node1.IP = Node2.IP) and
(Node1.VIP = Node2.VIP) and
(Node1.Port = Node2.Port) and
(Node1.VPort = Node2.VPort) and
(Node1.CityDataBase = Node2.CityDataBase) and
(Node1.DataInUpDpt = Node2.DataInUpDpt) and
(Node1.CityLevel = Node2.CityLevel) and
(@Node1.OnClick = @Node2.OnClick) and
(@Node1.OnMouseDown = @Node2.OnMouseDown ) and
(Node1.AutoSize = Node2.AutoSize) and
(Node1.PopupMenu = Node2.PopupMenu) then
Result := True
else
Result := False;
end;
function ExistsNodeLabel(ANL: ANodeLabel;const Number:String): Boolean; overload;
var
i, iC: Integer;
begin
Result := False;
iC := High(ANL);
for i:= 0 to iC do
if ANL[i].Number = Number then
begin
Result := True;
break;
end;
end;
function ExistsNodeLabel(ANL: ANodeLabel;Node:TNodeLabel): Boolean; overload;
var
i, iC: Integer;
begin
Result := False;
iC := High(ANL);
for i:= 0 to iC do
if ANL[i].Number = Node.Number then
begin
Result := True;
break;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -