There's a heck of a lot of code going on here, and it certainly appears as though you're violating SRP here. Rather than doing things like this, I would look to implement separate classes that do what you need to do - each class would then decide whether it was the one that handled the case. There's even a name for this, as a pattern; it's called the Chain Of Responsibility. So, you would end up with something like this:
Off topic with regards to your question but is your key testing code correct?
I assume the intention of the following code is to allow A or Alt-A
if ((e.KeyCode == Keys.A || (e.Alt && e.KeyCode == Keys.A))
The first condition does not test for modifier keys so would be true for A with any combination of modifiers keys (including none). Due to shortcut evaluation the second condition will be evaluated only if the first is false, that is if the Key is NOT A and I'm sure you can see the problem with that. Even if it was evaluated the condition does not exclude additional modifiers so Ctrl-Alt-A would be allowed.
The solution is to test the key and the modifiers separately. Specifically the modifiers test should be for none or just Alt.
I really hate using anonymous types because they just make your code harder to debug and understand. I strongly suggest replacing the anonymous type with an actual class. I see no reason why you need to use a anonymous type here.
Anonymous types are good for use inside the method where it's defined, not really for passing around to other methods.
The reason being is that you have to define your anonymous type all over again just so you can cast the value back to that type. That's doubling your work and introducing another opportunity to introduce bugs into your code. This is especially true in this case because if you change the type definition, you have to do it in multiple places. YUK!
hi i want to have text(textbox8) show on form 1 (frmLogin)
shown on form2(files) textbox (textbox1)
my code: textbox1.Text = textbox8.text ,,, error,,,,name(textbox8) login form does not exist in current context
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
Yes, you should check the result of the MessageBox.Show message, and perhaps put a better message, and extra button, so the user can continue or cancel. Alternatively, if this error is unrecoverable, you should just exit aftger the message is dismissed by the user.
I don't know, it all depends on what the application is doing at the time, and what it is supposed to do in these circumstances. You may want to close the main form and then open some other form for further work, or you may just want to close the program.
okay so this is my problem , i have a button on a form and 2 textboxes,and what i want to do is "create a admin account" where i type into the text boxes "example" username :admin password :admin " and then have it moved on to the next form and if the password/username is incorrect have a message popping up. the messagebox isnt a problem, i just dont know about the username,and will i be able to do it without sql (temporary)?
Hello. I know there is a way to enable and disable speech recognition because you can do pretty much anything in c#. I am stuck on how to enable and disable speech recognition by using my voice. This is the scenario that I want to achieve.
When I say start listening I want my program to accept voice commands. When I say stop listening I want my program to reject all voice commands, apart from "start listening", however only listen out for the command "start listening" to enable full voice command control again.
Does anyone have any ideas on how I can go about doing this?