private void Form1_KeyPress(object sender, KeyPressEventArgs e) { switch (e.KeyChar) { // Press 'i' to zoom in. case 'i': m_framework.Zoom(2); Invalidate(); break; // Press 'o' to zoom out. case 'o': m_framework.Zoom(0.5); Invalidate(); break; // Press 'r' to rotate right. case 'r': m_framework.Rotate(10); Invalidate(); break; // Press 'l' to rotate left. case 'l': m_framework.Rotate(-10); Invalidate(); break; // Press 'p' to toggle perspective mode. case 'p': m_framework.SetPerspective(!m_framework.Perspective()); Invalidate(); break; } }
private void Window_MouseWheel(object sender, MouseWheelEventArgs e) { int zoom_count = e.Delta / 120; double zoom = Math.Sqrt(2); if (zoom_count == 0) { zoom_count = e.Delta >= 0 ? 1 : -1; } zoom = Math.Pow(zoom, zoom_count); Point p = e.GetPosition(Application.Current.MainWindow); if (p.X < ActualWidth && p.Y < ActualHeight) { m_framework.ZoomAt(zoom, (int)p.X, (int)p.Y, CartoType.CoordType.Screen); } else { m_framework.Zoom(zoom); } }