Visual Studio autogenerated code
-
...yes, thatwould be true
-
It's not a big horror, its just funny to see it on Visual Studio. The correct implementation would be:
private void Form1\_KeyDown(object sender, KeyEventArgs e) { switch(e.KeyCode) { case System.Windows.Forms.Keys.Up: // Subir oscilador // Subir break; case System.Windows.Forms.Keys.Down: // Bajar oscilador // Bajar break; case System.Windows.Forms.Keys.Left: // Izquierda break; case System.Windows.Forms.Keys.Right: // Derecha break; case System.Windows.Forms.Keys.Enter: // Entrar break; } }
-
...yes, thatwould be true
Even if multiple keys where able to be captured at the same time, using many == will not be a solution. After all, if the keys where combined using the | operator, as happens with flags, the right way to check the values will be using: if ((parameter & condition) == condition) or if ((parameter & condition) != 0) But that's not the case with keys. So, this is an ugly code (but not an horror in my opinion).
-
it is a horror that this visible code is so poor. :mad: What about the non-visible code. Shame on Microsoft!!! X|
Press F1 for help or google it. Greetings from Germany
-
If the first
if
is true, for example, why bother testing all the others which follow? It's dopey code.Steve
That many bunch of
if
s could have been elegantly presented with a decentswitch
block.Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep! -
I mean the code we cant look at, like the soruce code of windwos or Office. :-\
Press F1 for help or google it. Greetings from Germany
KarstenK wrote:
we cant look at, like the soruce code of windwos or Office
But we can feel it and enjoy it with timely patches and service packs.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep! -
adgonz wrote:
multiple events are fired.
The application goes haywire and user runs amuck helter-skelter.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep! -
KarstenK wrote:
we cant look at, like the soruce code of windwos or Office
But we can feel it and enjoy it with timely patches and service packs.
Vasudevan Deepak Kumar Personal Homepage
Tech Gossips
The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep! -
I don't see any horror here. What do you want to do if you need to check for those keys?