private void MainWindow_MouseClick(object sender, MouseEventArgs e) { var screenThing = GetScreenThing(e.X, e.Y); if (screenThing is C64Sprite thing) { var s = thing; if ((e.Button & MouseButtons.Left) > 0) { if (s == Sprites[0]) { PickSpriteClick(sprite1ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[1]) { PickSpriteClick(sprite2ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[2]) { PickSpriteClick(sprite3ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[3]) { PickSpriteClick(sprite4ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[4]) { PickSpriteClick(sprite5ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[5]) { PickSpriteClick(sprite6ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[6]) { PickSpriteClick(sprite7ToolStripMenuItem, new EventArgs()); return; } if (s == Sprites[7]) { PickSpriteClick(sprite8ToolStripMenuItem, new EventArgs()); return; } return; } } screenThing = ColorPicker.HitTest(e.X, e.Y); if (screenThing != null) { var c = (ColorPickerCell)screenThing; if ((e.Button & MouseButtons.Left) > 0) { void SetCol(int i) { if (Configuration.InputMethod == InputMethod.KeyboardInputMethod) { SpriteEditor.SetPixelAtCursor(i); } ColorPicker.SelectedColor = i; Invalidate(); } if (c == ColorPicker.GetColorCell(0)) { SetCol(0); } if (c == ColorPicker.GetColorCell(1)) { SetCol(1); } if (CurrentSprite.Multicolor && c == ColorPicker.GetColorCell(2)) { SetCol(2); } if (CurrentSprite.Multicolor && c == ColorPicker.GetColorCell(3)) { SetCol(3); } } else if ((e.Button & MouseButtons.Right) > 0) { if (c == ColorPicker.GetColorCell(0)) { if (Configuration.InputMethod == InputMethod.MouseInputMethod) { ColorPicker.SelectedColor = 0; } pickBackgroundColorToolStripMenuItem_Click(null, new EventArgs()); } if (c == ColorPicker.GetColorCell(1)) { if (Configuration.InputMethod == InputMethod.MouseInputMethod) { ColorPicker.SelectedColor = 1; } pickForegroundColorToolStripMenuItem_Click(null, new EventArgs()); } if (c == ColorPicker.GetColorCell(2)) { if (Configuration.InputMethod == InputMethod.MouseInputMethod && CurrentSprite.Multicolor) { ColorPicker.SelectedColor = 2; } pickExtraColor1ToolStripMenuItem_Click(null, new EventArgs()); } if (c == ColorPicker.GetColorCell(3)) { if (Configuration.InputMethod == InputMethod.MouseInputMethod && CurrentSprite.Multicolor) { ColorPicker.SelectedColor = 3; } pickExtraColor2ToolStripMenuItem_Click(null, new EventArgs()); } } } }
private void MainWindow_KeyDown(object sender, KeyEventArgs e) { void Handled() { e.Handled = true; e.SuppressKeyPress = true; Invalidate(); } void SetCol(int i) { SpriteEditor.SetPixelAtCursor(i); ColorPicker.SelectedColor = i; e.Handled = true; e.SuppressKeyPress = true; Invalidate(); } switch (e.KeyCode) { case Keys.Up: SpriteEditor.MoveCursor(0, -1); Handled(); break; case Keys.Down: SpriteEditor.MoveCursor(0, 1); Handled(); break; case Keys.Left: SpriteEditor.MoveCursor(CurrentSprite.Multicolor ? -2 : -1, 0); Handled(); break; case Keys.Right: SpriteEditor.MoveCursor(CurrentSprite.Multicolor ? 2 : 1, 0); Handled(); break; case Keys.Enter: SpriteEditor.MoveCursor(0, 1); SpriteEditor.SetCursorX(0); Handled(); break; case Keys.Home: SpriteEditor.SetCursorX(0); Handled(); break; case Keys.End: SpriteEditor.SetCursorX(CurrentSprite.Multicolor ? 22 : 23); Handled(); break; case Keys.PageUp: SpriteEditor.SetCursorY(0); Handled(); break; case Keys.PageDown: SpriteEditor.SetCursorY(20); Handled(); break; case Keys.D1: switch (Configuration.InputMethod) { case InputMethod.KeyboardInputMethod: PushUndoState(); SetCol(0); break; case InputMethod.MouseInputMethod: ColorPicker.SelectedColor = 0; Invalidate(); break; } break; case Keys.D2: switch (Configuration.InputMethod) { case InputMethod.KeyboardInputMethod: PushUndoState(); SetCol(1); break; case InputMethod.MouseInputMethod: ColorPicker.SelectedColor = 1; Invalidate(); break; } break; case Keys.D3: if (!CurrentSprite.Multicolor) { return; } switch (Configuration.InputMethod) { case InputMethod.KeyboardInputMethod: PushUndoState(); SetCol(2); break; case InputMethod.MouseInputMethod: ColorPicker.SelectedColor = 2; Invalidate(); break; } break; case Keys.D4: if (!CurrentSprite.Multicolor) { return; } switch (Configuration.InputMethod) { case InputMethod.KeyboardInputMethod: PushUndoState(); SetCol(3); break; case InputMethod.MouseInputMethod: ColorPicker.SelectedColor = 3; Invalidate(); break; } break; } }