Advertisement
Guest User

Untitled

a guest
Aug 4th, 2010
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.90 KB | None | 0 0
  1. procedure TNTDScreen.ShowMap;
  2. var XTopMap,YTopMap:integer;
  3. var XCenter,YCenter:integer;
  4. var Rect:TRect;
  5. var MapBitmap:TBitmap;
  6. var i:integer;
  7. var Zoom: integer;
  8. var ZoomedHalfWidth,ZoomedHalfHeight:integer;
  9. begin
  10. if NTDSystem.MapInfo.ShowMap then
  11.   try
  12.     Zoom:=NTDSystem.MapInfo.Zoom;
  13.     //
  14.     ZoomedHalfWidth:=(Width div 2) div Zoom;
  15.     ZoomedHalfHeight:=(Height div 2) div Zoom;
  16.     //
  17.     XTopMap:=(Width*(100-NTDSystem.MapInfo.SquarePercent)) div 100;
  18.     YTopMap:=(Height*(100-NTDSystem.MapInfo.SquarePercent)) div 100;
  19.     XCenter:=((Width-XTopMap) div 2)-ZoomedHalfWidth;
  20.     YCenter:=((Height-YTopMap) div 2)-ZoomedHalfHeight;
  21.     //init map bitmap
  22.     MapBitmap:=TBitmap.Create;
  23.     MapBitmap.Height:=Height-YTopMap;
  24.     MapBitmap.Width:=Width-XTopMap;
  25.     //write map region
  26.     Rect.Left:=0;
  27.     Rect.Top:=0;
  28.     Rect.Right:=Width;
  29.     Rect.Bottom:=Height;
  30.     //
  31.     MapBitmap.Canvas.Pen.Color:=clBlack;
  32.     MapBitmap.Canvas.Brush.Color:=clSilver;
  33.     MapBitmap.Canvas.Rectangle(Rect);
  34.  
  35.     //
  36.     //write lines
  37.     If (NTDSystem.N_Links>0) then
  38.       for i:=1 to NTDSystem.N_Links do
  39.         begin
  40.         if NTDSystem.Links[i].TypeLink=1 then
  41.         MapBitmap.Canvas.Pen.Color:=clBlack;
  42.         if NTDSystem.Links[i].TypeLink=2 then
  43.         MapBitmap.Canvas.Pen.Color:=clBlue;
  44.         if NTDSystem.Links[i].TypeLink=3 then
  45.         MapBitmap.Canvas.Pen.Color:=clYellow;
  46.  
  47.         MapBitmap.Canvas.MoveTo(XCenter+(NTDSystem.Links[i].P1.X div Zoom),YCenter+(NTDSystem.Links[i].P1.Y div Zoom));
  48.         MapBitmap.Canvas.LineTo(XCenter+(NTDSystem.Links[i].P2.X div Zoom),YCenter+(NTDSystem.Links[i].P2.Y div Zoom));
  49.         end;
  50.  
  51.     //
  52.     //write hosts
  53.  
  54.     If (NTDSystem.N_Hosts>0) then
  55.       for i:=1 to NTDSystem.N_Hosts do
  56.         begin
  57.         Rect.Left:=XCenter+((NTDSystem.Hosts[i].X+StartCord.X) div Zoom)-2;
  58.         Rect.Top:=YCenter+((NTDSystem.Hosts[i].Y+StartCord.Y) div Zoom)-2;
  59.         Rect.Right:=Rect.Left+3;
  60.         Rect.Bottom:=Rect.Top+3;
  61.         if NTDSystem.Hosts[i].testing=0 then
  62.           begin
  63.           MapBitmap.Canvas.Pen.Color:=clBlack;
  64.           MapBitmap.Canvas.Brush.Color:=clBlack;
  65.           end
  66.         else
  67.           begin
  68.           case (NTDSystem.Hosts[i].Status) of
  69.             1:
  70.               begin
  71.               MapBitmap.Canvas.Pen.Color:=clGreen;
  72.               MapBitmap.Canvas.Brush.Color:=clGreen;
  73.               end;
  74.             2:
  75.               begin
  76.               MapBitmap.Canvas.Pen.Color:=clBlue;
  77.               MapBitmap.Canvas.Brush.Color:=clBlue;
  78.               end;
  79.             3:
  80.               begin
  81.               MapBitmap.Canvas.Pen.Color:=clYellow;
  82.               MapBitmap.Canvas.Brush.Color:=clYellow;
  83.               end;
  84.             4:
  85.               begin
  86.               MapBitmap.Canvas.Pen.Color:=clRed;
  87.               MapBitmap.Canvas.Brush.Color:=clRed;
  88.               end;
  89.           end;
  90.           end;
  91.  
  92.         MapBitmap.Canvas.Rectangle(Rect);
  93.         end;
  94.  
  95.     //write red cross
  96.     MapBitmap.Canvas.Pen.Color:=clRed;
  97.     MapBitmap.Canvas.MoveTo(ZoomedHalfWidth+XCenter-3,ZoomedHalfHeight+YCenter);
  98.     MapBitmap.Canvas.LineTo(ZoomedHalfWidth+XCenter+4,ZoomedHalfHeight+YCenter);
  99.     MapBitmap.Canvas.MoveTo(ZoomedHalfWidth+XCenter,ZoomedHalfHeight+YCenter-3);
  100.     MapBitmap.Canvas.LineTo(ZoomedHalfWidth+XCenter,ZoomedHalfHeight+YCenter+4);
  101.     //
  102.     //write green screen area
  103.     MapBitmap.Canvas.Pen.Color:=clGray;
  104.     MapBitmap.Canvas.Pen.Style:=psDot;
  105.     MapBitmap.Canvas.Brush.Style:=bsClear;
  106.     Rect.Left:=XCenter;
  107.     Rect.Top:=YCenter;
  108.     Rect.Right:=XCenter+(Width div Zoom);
  109.     Rect.Bottom:=YCenter+(Height div Zoom);
  110.     MapBitmap.Canvas.Rectangle(Rect);
  111.     //
  112.     MapBitmap.Canvas.Font.Size:=10;
  113.     MapBitmap.Canvas.TextOut(3,3,'Загальна схема');
  114.     //
  115.     WritedPicture.Bitmap.Canvas.Draw(XTopMap,YTopMap,MapBitmap);
  116.  
  117.   finally
  118.     MapBitmap.Free;
  119.   end;
  120. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement