Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TNTDScreen.ShowMap;
- var XTopMap,YTopMap:integer;
- var XCenter,YCenter:integer;
- var Rect:TRect;
- var MapBitmap:TBitmap;
- var i:integer;
- var Zoom: integer;
- var ZoomedHalfWidth,ZoomedHalfHeight:integer;
- begin
- if NTDSystem.MapInfo.ShowMap then
- try
- Zoom:=NTDSystem.MapInfo.Zoom;
- //
- ZoomedHalfWidth:=(Width div 2) div Zoom;
- ZoomedHalfHeight:=(Height div 2) div Zoom;
- //
- XTopMap:=(Width*(100-NTDSystem.MapInfo.SquarePercent)) div 100;
- YTopMap:=(Height*(100-NTDSystem.MapInfo.SquarePercent)) div 100;
- XCenter:=((Width-XTopMap) div 2)-ZoomedHalfWidth;
- YCenter:=((Height-YTopMap) div 2)-ZoomedHalfHeight;
- //init map bitmap
- MapBitmap:=TBitmap.Create;
- MapBitmap.Height:=Height-YTopMap;
- MapBitmap.Width:=Width-XTopMap;
- //write map region
- Rect.Left:=0;
- Rect.Top:=0;
- Rect.Right:=Width;
- Rect.Bottom:=Height;
- //
- MapBitmap.Canvas.Pen.Color:=clBlack;
- MapBitmap.Canvas.Brush.Color:=clSilver;
- MapBitmap.Canvas.Rectangle(Rect);
- //
- //write lines
- If (NTDSystem.N_Links>0) then
- for i:=1 to NTDSystem.N_Links do
- begin
- if NTDSystem.Links[i].TypeLink=1 then
- MapBitmap.Canvas.Pen.Color:=clBlack;
- if NTDSystem.Links[i].TypeLink=2 then
- MapBitmap.Canvas.Pen.Color:=clBlue;
- if NTDSystem.Links[i].TypeLink=3 then
- MapBitmap.Canvas.Pen.Color:=clYellow;
- MapBitmap.Canvas.MoveTo(XCenter+(NTDSystem.Links[i].P1.X div Zoom),YCenter+(NTDSystem.Links[i].P1.Y div Zoom));
- MapBitmap.Canvas.LineTo(XCenter+(NTDSystem.Links[i].P2.X div Zoom),YCenter+(NTDSystem.Links[i].P2.Y div Zoom));
- end;
- //
- //write hosts
- If (NTDSystem.N_Hosts>0) then
- for i:=1 to NTDSystem.N_Hosts do
- begin
- Rect.Left:=XCenter+((NTDSystem.Hosts[i].X+StartCord.X) div Zoom)-2;
- Rect.Top:=YCenter+((NTDSystem.Hosts[i].Y+StartCord.Y) div Zoom)-2;
- Rect.Right:=Rect.Left+3;
- Rect.Bottom:=Rect.Top+3;
- if NTDSystem.Hosts[i].testing=0 then
- begin
- MapBitmap.Canvas.Pen.Color:=clBlack;
- MapBitmap.Canvas.Brush.Color:=clBlack;
- end
- else
- begin
- case (NTDSystem.Hosts[i].Status) of
- 1:
- begin
- MapBitmap.Canvas.Pen.Color:=clGreen;
- MapBitmap.Canvas.Brush.Color:=clGreen;
- end;
- 2:
- begin
- MapBitmap.Canvas.Pen.Color:=clBlue;
- MapBitmap.Canvas.Brush.Color:=clBlue;
- end;
- 3:
- begin
- MapBitmap.Canvas.Pen.Color:=clYellow;
- MapBitmap.Canvas.Brush.Color:=clYellow;
- end;
- 4:
- begin
- MapBitmap.Canvas.Pen.Color:=clRed;
- MapBitmap.Canvas.Brush.Color:=clRed;
- end;
- end;
- end;
- MapBitmap.Canvas.Rectangle(Rect);
- end;
- //write red cross
- MapBitmap.Canvas.Pen.Color:=clRed;
- MapBitmap.Canvas.MoveTo(ZoomedHalfWidth+XCenter-3,ZoomedHalfHeight+YCenter);
- MapBitmap.Canvas.LineTo(ZoomedHalfWidth+XCenter+4,ZoomedHalfHeight+YCenter);
- MapBitmap.Canvas.MoveTo(ZoomedHalfWidth+XCenter,ZoomedHalfHeight+YCenter-3);
- MapBitmap.Canvas.LineTo(ZoomedHalfWidth+XCenter,ZoomedHalfHeight+YCenter+4);
- //
- //write green screen area
- MapBitmap.Canvas.Pen.Color:=clGray;
- MapBitmap.Canvas.Pen.Style:=psDot;
- MapBitmap.Canvas.Brush.Style:=bsClear;
- Rect.Left:=XCenter;
- Rect.Top:=YCenter;
- Rect.Right:=XCenter+(Width div Zoom);
- Rect.Bottom:=YCenter+(Height div Zoom);
- MapBitmap.Canvas.Rectangle(Rect);
- //
- MapBitmap.Canvas.Font.Size:=10;
- MapBitmap.Canvas.TextOut(3,3,'Загальна схема');
- //
- WritedPicture.Bitmap.Canvas.Draw(XTopMap,YTopMap,MapBitmap);
- finally
- MapBitmap.Free;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement