private void onKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Home) { LevelView.Center(); } else if (e.KeyCode == Keys.Oemplus) { LevelView.ZoomIn(LevelView.EditorToScreen(MousePosition)); } else if (e.KeyCode == Keys.OemMinus) { LevelView.ZoomOut(LevelView.EditorToScreen(MousePosition)); } else if (e.KeyCode == Keys.Left) { LevelView.Pan(new PointF(32, 0)); foreach (var ed in LayerEditors) { ed.UpdateDrawOffset(LevelView.ScreenToEditor(new Point(0, 0))); } } else if (e.KeyCode == Keys.Right) { LevelView.Pan(new PointF(-32, 0)); foreach (var ed in LayerEditors) { ed.UpdateDrawOffset(LevelView.ScreenToEditor(new Point(0, 0))); } } else if (e.KeyCode == Keys.Up) { LevelView.Pan(new PointF(0, 32)); foreach (var ed in LayerEditors) { ed.UpdateDrawOffset(LevelView.ScreenToEditor(new Point(0, 0))); } } else if (e.KeyCode == Keys.Down) { LevelView.Pan(new PointF(0, -32)); foreach (var ed in LayerEditors) { ed.UpdateDrawOffset(LevelView.ScreenToEditor(new Point(0, 0))); } } else if (mouseMode == MouseMode.Normal && e.KeyCode == Keys.Space) { mouseMode = MouseMode.Pan; } else if (mouseMode == MouseMode.Normal && e.KeyCode == Keys.C) { mouseMode = MouseMode.Camera; } else { //Call the layer event LayerEditors[Ogmo.LayersWindow.CurrentLayerIndex].OnKeyDown(e.KeyCode); } }
private void onMouseMove(object sender, MouseEventArgs e) { //Pan the camera if in move mode if (mousePanMode) { if (mouseMode == MouseMode.Camera) { //Update the camera position Level.CameraPosition = LevelView.ScreenToEditor(e.Location); foreach (var ed in LayerEditors) { ed.UpdateDrawOffset(Level.CameraPosition); } } else { LevelView.Pan(new Point(e.Location.X - lastMousePoint.X, e.Location.Y - lastMousePoint.Y)); lastMousePoint = e.Location; } } //Update the mouse coord display MousePosition = LevelView.ScreenToEditor(e.Location); Point mouseDraw = Ogmo.Project.LayerDefinitions[Ogmo.LayersWindow.CurrentLayerIndex].SnapToGrid(MousePosition); Point gridPos = Ogmo.Project.LayerDefinitions[Ogmo.LayersWindow.CurrentLayerIndex].ConvertToGrid(MousePosition); Ogmo.MainWindow.MouseCoordinatesLabel.Text = "Mouse: ( " + mouseDraw.X.ToString() + ", " + mouseDraw.Y.ToString() + " )"; Ogmo.MainWindow.GridCoordinatesLabel.Text = "Grid: ( " + gridPos.X.ToString() + ", " + gridPos.Y.ToString() + " )"; //Call the layer event LayerEditors[Ogmo.LayersWindow.CurrentLayerIndex].OnMouseMove(MousePosition); }