的
的士
Unregistered / Unconfirmed
GUEST, unregistred user!
相关代码如下:
{ 移动 }
procedure TLine.Move(offsetX, offsetY: Integer);
begin
Canvas.Pen.Mode := pmNotXor;
{ 首次移动,保存原来的线段位置 }
if not FMoving then
begin
FOldBeginPoint := FBeginPoint;
FOldEndPoint := FEndPoint;
end
{ 如果正在移动,则擦除原来的线段 }
else begin
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
{ 设置移动后的线段位置,并以虚线画出来 }
SetBeginEndPoint(Point(FBeginPoint.X + offsetX, FBeginPoint.Y + offsetY),
Point(FEndPoint.X + offsetX, FEndPoint.Y + offsetY));
Canvas.Pen.Style := psDot;
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
FMoving := True;
end;
{ 根据当前坐标位置改变线段大小 }
procedure TLine.ReSize(ACurPoint: TPoint);
begin
Canvas.Pen.Mode := pmNotXor;
{ 首次改变线段的大小,保存原来线段的位置 }
if (not FChangingBeginPoint) and (not FChangingEndPoint) then
begin
FOldBeginPoint := FBeginPoint;
FOldEndPoint := FEndPoint;
end
{ 擦除上次画的线段 }
else begin
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
if not FChangingBeginPoint then
FChangingBeginPoint := PtInRect(FSelectBlock1, ACurPoint);
if not FChangingEndPoint then
FChangingEndPoint := PtInRect(FSelectBlock2, ACurPoint);
if FChangingBeginPoint then SetBeginPoint(ACurPoint);
if FChangingEndPoint then SetEndPoint(ACurPoint);
Canvas.Pen.Style := psDot;
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
{ 设置线段的起始位置和终止位置 }
procedure TLine.SetBeginEndPoint(ABeginPoint, AEndPoint: TPoint);
begin
SetBeginPoint(ABeginPoint);
SetEndPoint(AEndPoint);
end;
{-------------------- Private --------------------}
{ 设置线段的开始位置 }
procedure TLine.SetBeginPoint(Value: TPoint);
begin
if (Value.X <> FBeginPoint.X) or (Value.Y <> FBeginPoint.Y) then
begin
FBeginPoint := Value;
FSelectBlock1 := Rect(FBeginPoint.X - 3, FBeginPoint.Y - 3,
FBeginPoint.X + 4, FBeginPoint.Y + 4);
end;
end;
{ 设置线段的结束位置 }
procedure TLine.SetEndPoint(Value: TPoint);
begin
if (Value.X <> FEndPoint.X) or (Value.Y <> FEndPoint.Y) then
begin
FEndPoint := Value;
FSelectBlock2 := Rect(FEndPoint.X - 3, FEndPoint.Y - 3,
FEndPoint.X + 4, FEndPoint.Y + 4);
end;
end;
{ 移动 }
procedure TLine.Move(offsetX, offsetY: Integer);
begin
Canvas.Pen.Mode := pmNotXor;
{ 首次移动,保存原来的线段位置 }
if not FMoving then
begin
FOldBeginPoint := FBeginPoint;
FOldEndPoint := FEndPoint;
end
{ 如果正在移动,则擦除原来的线段 }
else begin
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
{ 设置移动后的线段位置,并以虚线画出来 }
SetBeginEndPoint(Point(FBeginPoint.X + offsetX, FBeginPoint.Y + offsetY),
Point(FEndPoint.X + offsetX, FEndPoint.Y + offsetY));
Canvas.Pen.Style := psDot;
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
FMoving := True;
end;
{ 根据当前坐标位置改变线段大小 }
procedure TLine.ReSize(ACurPoint: TPoint);
begin
Canvas.Pen.Mode := pmNotXor;
{ 首次改变线段的大小,保存原来线段的位置 }
if (not FChangingBeginPoint) and (not FChangingEndPoint) then
begin
FOldBeginPoint := FBeginPoint;
FOldEndPoint := FEndPoint;
end
{ 擦除上次画的线段 }
else begin
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
if not FChangingBeginPoint then
FChangingBeginPoint := PtInRect(FSelectBlock1, ACurPoint);
if not FChangingEndPoint then
FChangingEndPoint := PtInRect(FSelectBlock2, ACurPoint);
if FChangingBeginPoint then SetBeginPoint(ACurPoint);
if FChangingEndPoint then SetEndPoint(ACurPoint);
Canvas.Pen.Style := psDot;
Canvas.MoveTo(FBeginPoint.X, FBeginPoint.Y);
Canvas.LineTo(FEndPoint.X, FEndPoint.Y);
end;
{ 设置线段的起始位置和终止位置 }
procedure TLine.SetBeginEndPoint(ABeginPoint, AEndPoint: TPoint);
begin
SetBeginPoint(ABeginPoint);
SetEndPoint(AEndPoint);
end;
{-------------------- Private --------------------}
{ 设置线段的开始位置 }
procedure TLine.SetBeginPoint(Value: TPoint);
begin
if (Value.X <> FBeginPoint.X) or (Value.Y <> FBeginPoint.Y) then
begin
FBeginPoint := Value;
FSelectBlock1 := Rect(FBeginPoint.X - 3, FBeginPoint.Y - 3,
FBeginPoint.X + 4, FBeginPoint.Y + 4);
end;
end;
{ 设置线段的结束位置 }
procedure TLine.SetEndPoint(Value: TPoint);
begin
if (Value.X <> FEndPoint.X) or (Value.Y <> FEndPoint.Y) then
begin
FEndPoint := Value;
FSelectBlock2 := Rect(FEndPoint.X - 3, FEndPoint.Y - 3,
FEndPoint.X + 4, FEndPoint.Y + 4);
end;
end;