-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoti.cs
286 lines (259 loc) · 10.2 KB
/
Noti.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
/*
* Say Hello to Roovle
* The code f*cker
*/
namespace BandaGaraxxjata
{
public class Noti : System.Windows.Forms.Panel
{
private static int totalNotes = 36;//Roovle sets limits to the total notes
private string path = @"Resources\Images\";
//Roovle sets paths for images
private int min = 20;
private int interval = 15;
public struct nota
{
public int y;
public int duration;
public string accidental;
public int pitch;
public string mod;
};
private static nota[] noti = new nota[totalNotes];
//Roovle makes an array of structures
public nota[] xebaNoti
{
get { return noti; }
set { noti = value; }
}//And gets happy about it
public Noti()
{
for (int i = 0; i < xebaNoti.Length; i++)
{
xebaNoti[i].duration = 0;
xebaNoti[i].accidental = "blank";//blank = sole and # = sharp
xebaNoti[i].y = 0;
xebaNoti[i].pitch = 0;
xebaNoti[i].mod = null;
}//Roovle inits all notes with zeros and nulls
}
public void drawNote(PaintEventArgs hagu, int id, int x, int y, string acc, string mod)
{
pingiNota(hagu, id, x, y, acc, mod);
}
public void drawNote(PaintEventArgs hagu)
{
pingiCleff(hagu);
}
private void pingiNota(PaintEventArgs picasso, int id, int x, int y, string acc, string mod)
{
Bitmap mappa = new Bitmap(path + id + mod + ".png");
Bitmap sharp = new Bitmap(path + acc + ".bmp");
//Bitmap ledger = new Bitmap(path + line + ".bmp");
//Bitmap rest = new Bitmap(path + mistrieh + "r.bmp");
sharp.MakeTransparent(); //ghax nisthi mix xemx!
picasso.Graphics.DrawImage(mappa, x, y, mappa.Width, mappa.Height);
//picasso.Graphics.DrawImage(ledger, x, y, ledger.Width, ledger.Height);
//picasso.Graphics.DrawImage(rest, x, 45, rest.Width, rest.Height);
picasso.Graphics.DrawImage(sharp, x-5, y-5, sharp.Width, sharp.Height);
}
private void pingiCleff(PaintEventArgs picasso)
{
Bitmap cleff = new Bitmap(path + "treble.png");
//cleff.MakeTransparent(); //Roovle demands transperency which is not needed
picasso.Graphics.DrawImage(cleff, 50, 23, cleff.Width, cleff.Height);
}
private int noteToInt(int nota)
{
int position = -1; //Roovle spitts a -1 when disgusted by your data
for (int i = min; i <= ((interval * 7) + min); i += interval)
{
if (nota >= (i - 1) && nota <= (i + 1))
position = i - 28;//Roovle happy with lines
else if (!(i == ((interval * 7) + min)))
{
if (nota >= (2 + i) && nota <= (i + interval + 2))
position = i - 20;//Roovle happy with empty spaces
}
}
return position;//Roovle emmits answer
}
public int yToPitch(int y, string acc)
{
int pitch = 0; //Roovle spitts a 0 when disgusted by your data
int[] ommok = { 25, 24, 22, 20, 18, 17, 15, 13, 12, 10, 8, 6, 5, 3, 1 };
if ((y >= min) && (y <= ((interval * 7) + min)))
{
for (int i = min; i <= ((interval * 7) + min); i += interval)
{
if (y >= (i - 1) && y <= (i + 1))
{//Roovle happy with lines
pitch = ommok[(2 * ((i - min) / 15))];
break;
}
else if (y >= (2 + i) && y <= (i + interval - 2))
{//Roovle happy with empty spaces
pitch = ommok[((2 * ((i - min) / 15)) + 1)];
break;
}
}
if (acc == "#") { if (pitch != 25) pitch++; }
}
return pitch; //Roovle emmits answer
}
public int pitchToY(int pitch)
{
int[] ommok = { 25, 24, 22, 20, 18, 17, 15, 13, 12, 10, 8, 6, 5, 3, 1 };
//Possible natural notes in Roovle's mother's purse
int index = -1;
for (int i = 0; i < ommok.Length; i++)
{
if (pitch == ommok[i])
{
index = i;//Roovle found index for a natural note
break;
}
}
if (index == -1)
{//The note wasn't in your mother's purse
for (int i = 0; i < ommok.Length - 1; i++)
{
if ((pitch > ommok[i + 1]) && ((pitch < ommok[i])))
{
index = i + 1;//Roovle found the index of an accidental
break;
}
}
}
if (pitch <= 25 && pitch >= 1 && index != 1)
{
for (int i = min; i <= ((interval * 7) + min); i += interval)
{
if ((2 * ((i - min) / 15)) == index)
return i - 28;
if (((2 * ((i - min) / 15)) + 1) == index)
return i - 20;
}
}
return 0;
}
public int msToDuration(int ms)
{
if (ms == 0)
return 0;
else if (ms <= 63 && ms > 0)
return 1;
else if (ms <= 125 && ms > 63)
return 2;
else if (ms <= 250 && ms > 125)
return 3;
else if (ms <= 500 && ms > 250)
return 4;
else return 5;
}
private int locationToX(int x)
{
int position = -1;
if (x >= 110 & x <= 820)
{
for (int i = 110; i <= 820; i += 20)
{
if ((x >= (i - 9)) && (x <= (i + 9)))
position = (i - 110) / 20;
}
}
return position;
}
public void changeNote(int x)
{
ibdelTulTaNota(x);
//Askes the great Roovle to change the epic note
}
public void changeNote(int x, bool acc)
{
ibdelAccTaNota(x, acc);
//Askes the great Roovle to change the accident of a note
}
public void changeNote(int x, int y)
{
zidJewMexxiNota(x, y);
//Askes the great Roovle to add or move an epic note
}
public void changeNote(int i, int pitch, int ms, string acc)
{
zidNota(i, pitch, ms, acc);
//Askes the great Roovle to add or move an epic note
}
private void ibdelTulTaNota(int x)
{
int identita = locationToX(x);//Roovle knows where your mum lives
if (identita != -1)//Roovle only works with good data
{
//First things first, Roovle changes the note, coz he has big furry balls
if (xebaNoti[identita].duration == 5)//Roovle first checks if the the note is a whole note
xebaNoti[identita].duration = 0; //If true, it goes back to nothing, coz, banana
else xebaNoti[identita].duration++;//Else Roovle just increments the id counter
}
}
private void ibdelAccTaNota(int x, bool acc)
{
int identita = locationToX(x);//Roovle knows where you live
if (identita != -1)//Roovle only works with good data
{
if (xebaNoti[identita].accidental == "#")
{
xebaNoti[identita].pitch--;
xebaNoti[identita].accidental = "blank";
}
else
{
xebaNoti[identita].accidental = "#";
xebaNoti[identita].pitch++;
}
}
}
private void zidJewMexxiNota(int x, int y) //Roovle approved code
{
int _y = noteToInt(y);
int identita = locationToX(x);//Roovle knows where you live
if (_y != -1 && identita != -1)//Roovle only works with good data
{
xebaNoti[identita].y = _y; //Roovle sets new location
xebaNoti[identita].pitch = yToPitch(y,xebaNoti[identita].accidental);
if (xebaNoti[identita].duration == 0)
xebaNoti[identita].duration = 3; //Roovle sets new note
//Roovle chose the Crotchet as it's the most used note
if (_y <= 45)
{
xebaNoti[identita].y = _y + 21;
xebaNoti[identita].mod = "i";
}
else xebaNoti[identita].mod = null;
}
}
private void zidNota(int identita, int pitch, int ms, string acc) //Roovle approved code
{
int y = pitchToY(pitch);
if (pitch != -1 && identita != -1)//Roovle only works with good data
{
xebaNoti[identita].y = y; //Roovle sets new location
xebaNoti[identita].pitch = pitch;
xebaNoti[identita].duration = msToDuration(ms); //Roovle sets new note
//Roovle chose the Crotchet as it's the most used note
if (y <= 45)
{
xebaNoti[identita].y = y + 21;
xebaNoti[identita].mod = "i";
}
else xebaNoti[identita].mod = null;
xebaNoti[identita].accidental = acc;
}
}
}
}