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
| procedure TForm1.ArcDial1Change(Sender: TObject);
var i,ng,s : integer;
Angle : single;
begin
GridLayout1.BeginUpdate;
GridLayout1.DeleteChildren;
Angle:=Trunc(ArcDial1.Value)*-1;
ng:=Trunc(GridLayout1.Width/10);
s:=Trunc(Angle)-(ng div 2);
for i:= s to Trunc(Angle)+(ng div 2)
do DrawGraduation(GridLayout1,round(degnormalize(i)));
GridLayout1.EndUpdate;
end;
procedure TForm1.drawgraduation(const P : TGridLayout; d : integer);
var PRectangle : TRectangle;
begin
PRectangle:= TRectangle.Create(P);
with PRectangle do
begin
Width:=4;
with TText.Create(PRectangle) do
begin
Height:=20;
Width:=30;
Align:=TAlignLayout.Center;
Parent:=PRectangle;
Margins.Top:=50;
Font.Style:=[TFontStyle.fsBold];
case d of
0 : Text:=North;
45 : Text:=NorthEast;
90 : Text:=East;
135: Text:=SouthEast;
180: Text:=South;
225: Text:=SouthWest;
270: Text:=West;
315: Text:=NorthWest;
else begin
if (d mod 10)=0 then begin
Text:=Format('%d°',[d]);
Margins.Top:=30;
Font.Style:=[TFontStyle.fsItalic];
end;
end;
end;
end;
Margins.Bottom:=8;
if (d mod 10)=0 then Margins.Bottom:=0
else if (d mod 5)=0 then Margins.Bottom:=5;
margins.left:=3;
margins.Right:=4;
Stroke.Kind:=TBrushKind.None;
Fill.Color:=TAlphaColors.Black;
Align:=TAlignLayout.Top;
end;
P.AddObject(pRectangle);
end; |
Partager