📄 rounpic.pas
字号:
procedure TRounPic.ParentKeyUp(ACanvas:TCanvas;CursorNum:Integer;
var Key: Word; mouse: TPoint; Shift: TShiftState);
begin
end;
//图象改变
procedure TRounPic.PicChangeing(ACanvas:TCanvas; mouseInPos: MOUSE_POS; chooseRect:TRect;
mouseDownOldX, mouseDownOldY, mouseOldX, mouseOldY, mouseX, mouseY:Integer);
var
mouseDiffX: Integer;
mouseDiffY: Integer;
tempStartPoint, tempEndPoint: TPoint;
Center:TPoint;
pp: array[1..3] of TPoint;
procedure ChangPointXY; //坐标变换
var
tmpWhPoint:TPoint;
begin
pp[1]:=tempstartpoint;
pp[2]:=tempendpoint;
tmpWhPoint.X :=Round((EndPos.X-StartPos.X) * fRoundRate[0]);
tmpWhPoint.Y :=Round((EndPos.Y-StartPos.Y) * fRoundRate[1]);
pp[3]:=tmpwhPoint;
LptoDp(ACanvas.Handle,pp[1],3);
tempstartpoint:=pp[1];
tempendpoint:=pp[2];
tmpwhPoint:=pp[3];
DrawRounPic(ACanvas, tempStartPoint, tempEndPoint,tmpwhPoint);
end;
begin
RounKeyState:=GetPicKeyState;
//坐标变换
pp[1]:=Point(mouseDownOldX,mouseDownOldY);
pp[2]:=Point(mouseOldX, mouseOldY);
pp[3]:=Point(mouseX, mouseY);
DPtoLP(ACanvas.Handle, pp, 3);
mouseDownOldX := pp[1].x;
mouseDownOldY := pp[1].y;
mouseOldX := pp[2].x;
mouseOldY := pp[2].y;
mouseX := pp[3].x;
mouseY := pp[3].y;
//设置绘图方式
ACanvas.Pen.Width := 1;
ACanvas.Pen.Mode := pmXor;
ACanvas.Pen.Style := psDot;
ACanvas.Brush.Style := bsClear;
//计算选择图元的宽度和高度
case mouseInPos of
POS_LEFTTOP: // :Integer = 1 ; //左上
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y + mouseDiffY);
tempendPoint :=Point(endPos.x - mouseDiffX, endPos.y - mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y + mouseDiffY);
tempendPoint :=Point(endPos.x - mouseDiffX, endPos.y - mouseDiffY);
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y + mouseDiffY);
tempEndPoint :=endPos;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y + mouseDiffY);
tempEndPoint := endPos; //+ mouseDiffX;
//坐标变换
ChangPointXY;
end;
end;
POS_RIGHTTOP: // :Integer = 2 ; //右上
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x - mouseDiffX, startPos.y + mouseDiffY);
tempendPoint :=Point(endPos.x + mouseDiffX, endPos.y - mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x - mouseDiffX, startPos.y + mouseDiffY);
tempendPoint :=Point(endPos.x + mouseDiffX, endPos.y - mouseDiffY);
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y;
//坐标变换
ChangPointXY;
end;
end;
POS_RIGHTBOTTOM: // :Integer = 3 ; //右下
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x - mouseDiffX, startPos.y - mouseDiffY);
tempendPoint :=Point(endPos.x + mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x - mouseDiffX, startPos.y - mouseDiffY);
tempendPoint :=Point(endPos.x + mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y+MouseDiffY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end;
end;
POS_LEFTBOTTOM: // :Integer = 4 ; //左下
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y - mouseDiffY);
tempendPoint :=Point(endPos.x - mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint :=Point(startPos.x + mouseDiffX, startPos.y - mouseDiffY);
tempendPoint :=Point(endPos.x - mouseDiffX, endPos.y + mouseDiffY);
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X:=endpos.X;
tempendPoint.Y:=endpos.Y+MouseDiffY;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X+MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X:=endpos.X;
tempendPoint.Y:=endpos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end;
end;
POS_CENTERTOP: // :Integer = 5 ; //上中
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y-MouseDiffY;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y-MouseDiffY;
//坐标变换
ChangPointXY;
end else begin
//清除前一次
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint:=endpos;
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y+MouseDiffY;
tempendPoint:=endpos;
//坐标变换
ChangPointXY;
end;
end;
POS_RIGHTCENTER: // :Integer = 6 ; //右中
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X-MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X :=EndPos.X+MouseDiffX;
tempendPoint.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X-MouseDiffX;
tempStartPoint.Y:=StartPos.Y;
tempendPoint.X :=EndPos.X+MouseDiffX;
tempendPoint.Y :=EndPos.Y;
//坐标变换
ChangPointXY;
end else begin
//清除前一次
mouseDiffX := mouseOldX - mouseDownOldX;
//mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y;
ChangPointXY;
//绘制当前虚线图元
mouseDiffX := mouseX - mouseDownOldX;
//mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint:=StartPos;
tempendPoint.X:=endpos.X+MouseDiffX;
tempendPoint.Y:=endpos.Y;
//坐标变换
ChangPointXY;
end;
end;
POS_CENTERBUTTOM: // :Integer = 7 ; //下中
begin
if (ssCtrl in RounKeyState) then begin
//清除前一次
Center :=Point ((StartPos.x + Endpos.x) div 2,(StartPos.y + Endpos.y) div 2);
//mouseDiffX := mouseOldX - mouseDownOldX;
mouseDiffY := mouseOldY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y-MousediffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
//绘制当前虚线图元
//mouseDiffX := mouseX - mouseDownOldX;
mouseDiffY := mouseY - mouseDownOldY;
//绘制图元
tempStartPoint.X:=StartPos.X;
tempStartPoint.Y:=StartPos.Y-MouseDiffY;
tempendPoint.X :=EndPos.X;
tempendPoint.Y :=EndPos.Y+MouseDiffY;
//坐标变换
ChangPointXY;
end else begin
//清除前一次
//mouseDiffX := mouseOldX - mouseDownOldX;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -