private void Form_Grid_MouseDoubleClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { this.Refresh(); } if (e.Button == MouseButtons.Left) { if (e.X - OPoint.X >= GridTotalLenth || e.Y - OPoint.Y >= GridTotalLenth) { return; } if (e.X - OPoint.X < 0 || e.Y - OPoint.Y < 0) { return; } int xnum = e.X - (e.X - OPoint.X) % MapPanelEditor.GridLenth; int ynum = e.Y - (e.Y - OPoint.Y) % MapPanelEditor.GridLenth; int index = (xnum - OPoint.X) / MapPanelEditor.GridLenth + (ynum - OPoint.Y) / MapPanelEditor.GridLenth * 40; Point Point_Temp = new Point(xnum, ynum); MapEditor.SelectedIndex = index; this.Refresh(); UpdateDataMapView?.Invoke(this, EventArgs.Empty); this.Refresh(); } }
private void Form_Grid_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Space) { SpaceKeyDown?.Invoke(this, EventArgs.Empty); this.Refresh(); } else { if (e.KeyCode == Keys.A) { MapEditor.SelectedIndex--; } else if (e.KeyCode == Keys.D) { MapEditor.SelectedIndex++; } else if (e.KeyCode == Keys.W) { MapEditor.SelectedIndex = MapEditor.SelectedIndex -= 40; if (MapEditor.SelectedIndex < 0) { MapEditor.SelectedIndex = MapEditor.SelectedIndex += 40; } } else if (e.KeyCode == Keys.S) { MapEditor.SelectedIndex = MapEditor.SelectedIndex += 40; if (MapEditor.SelectedIndex >= MapPanelEditor.PictureTotal) { MapEditor.SelectedIndex = MapEditor.SelectedIndex -= 40; } } if (MapEditor.SelectedIndex < 0) { MapEditor.SelectedIndex = 0; } else if (MapEditor.SelectedIndex >= MapPanelEditor.PictureTotal) { MapEditor.SelectedIndex = MapPanelEditor.PictureTotal - 1; } UpdateDataMapView?.Invoke(this, EventArgs.Empty); } }