File: ZoomWindow.cs

package info (click to toggle)
quickroute-gps 2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 19,576 kB
  • sloc: cs: 74,488; makefile: 72; sh: 43
file content (50 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download | duplicates (3)
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using QuickRoute.BusinessEntities;

namespace QuickRoute.Controls
{
  public partial class ZoomWindow : UserControl
  {
    private PointD center;
    private double zoom = 1;

    public PointD Center
    {
      get { return center; }
      set { center = value; }
    }

    public double Zoom
    {
      get { return zoom; }
      set { zoom = value; }
    }


    public ZoomWindow()
    {
      InitializeComponent();
    }

    public void Draw(Document document)
    {
      Image image = document.Map.Image;

      Graphics g = this.CreateGraphics();
      RectangleF destRect = new RectangleF(0F, 0F, (float)this.Width, (float)this.Height);
      RectangleF srcRect = new RectangleF(
        (float)(center.X - this.Width / zoom / 2),
        (float)(center.Y - this.Height / zoom / 2),
        (float)(this.Width / zoom), 
        (float)(this.Height / zoom));

      g.DrawImage(image, destRect, srcRect, GraphicsUnit.Pixel);
    }
  }
}