/
KeyboardControl.cs
120 lines (91 loc) · 3.79 KB
/
KeyboardControl.cs
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
//using System.Linq;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using Sunflower.Geometry;
namespace Sunflower.Application {
public class KeyboardControl {
public SunflowerWindow SunflowerWindow { get; private set; }
public KeyboardControl(SunflowerWindow poincareWindow) {
SunflowerWindow = poincareWindow;
SunflowerWindow.Keyboard.KeyDown += Keyboard_KeyDown;
SunflowerWindow.Keyboard.KeyRepeat = true;
}
private void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) {
bool isShift = SunflowerWindow.Keyboard[Key.LShift] || SunflowerWindow.Keyboard[Key.RShift];
bool isCtrl = SunflowerWindow.Keyboard[Key.LControl] || SunflowerWindow.Keyboard[Key.RControl];
switch (e.Key) {
case Key.Number1:
case Key.Keypad1:
SunflowerWindow.Actors[0].Modulo += isShift ? -1 : 1;
break;
case Key.Number2:
case Key.Keypad2:
SunflowerWindow.Actors[1].Modulo += isShift ? -1 : 1;
break;
case Key.Number3:
case Key.Keypad3:
SunflowerWindow.Actors[2].Modulo += isShift ? -1 : 1;
break;
case Key.Number4:
case Key.Keypad4:
SunflowerWindow.Actors[0].Slope *= isShift ? 1 / 1.5 : 1.5;
break;
case Key.Number5:
case Key.Keypad5:
SunflowerWindow.Actors[1].Slope *= isShift ? 1 / 1.5 : 1.5;
break;
case Key.Number6:
case Key.Keypad6:
SunflowerWindow.Actors[2].Slope *= isShift ? 1 / 1.5 : 1.5;
break;
case Key.Number7:
case Key.Keypad7:
SunflowerWindow.Actors[0].Speed *= (isShift ? 1 / 1.5 : 1.5) * (isCtrl ? -1 : 1);
break;
case Key.Number8:
case Key.Keypad8:
SunflowerWindow.Actors[1].Speed *= (isShift ? 1 / 1.5 : 1.5) * (isCtrl ? -1 : 1);
break;
case Key.Number9:
case Key.Keypad9:
SunflowerWindow.Actors[2].Speed *= (isShift ? 1 / 1.5 : 1.5) * (isCtrl ? -1 : 1);
break;
case Key.S:
ModuloActor.SwapSortedAll();
break;
case Key.L:
SunflowerWindow.Slope *= isShift ? 1 / 1.5 : 1.5;
break;
case Key.P:
SunflowerWindow.Speed *= isShift ? 1 / 1.5 : 1.5;
break;
case Key.F:
SunflowerWindow.ToggleFullscreen();
break;
case Key.Escape:
SunflowerWindow.Exit();
break;
case Key.R:
SunflowerWindow.Offset = Complex.Zero;
SunflowerWindow.AngleOffset = 0;
SunflowerWindow.Reset();
break;
case Key.I:
SunflowerWindow.IsInverting = !SunflowerWindow.IsInverting;
SunflowerWindow.Reset();
break;
case Key.M:
SunflowerWindow.IsMoving = !SunflowerWindow.IsMoving;
break;
case Key.Tab:
break;
}
}
}
}