Click here to Skip to main content
15,896,153 members
Home / Discussions / C#
   

C#

 
GeneralRe: What am I doing wrong?? Sending serialized objects with Async Sockets.. Pin
Peter_in_27807-Nov-10 15:31
professionalPeter_in_27807-Nov-10 15:31 
GeneralRe: What am I doing wrong?? Sending serialized objects with Async Sockets.. Pin
Jacob D Dixon8-Nov-10 17:56
Jacob D Dixon8-Nov-10 17:56 
GeneralRe: What am I doing wrong?? Sending serialized objects with Async Sockets.. Pin
RaviRanjanKr7-Nov-10 16:47
professionalRaviRanjanKr7-Nov-10 16:47 
GeneralRe: What am I doing wrong?? Sending serialized objects with Async Sockets.. Pin
Jacob D Dixon8-Nov-10 17:57
Jacob D Dixon8-Nov-10 17:57 
GeneralRe: What am I doing wrong?? Sending serialized objects with Async Sockets.. Pin
Member 1841422-Mar-11 22:48
Member 1841422-Mar-11 22:48 
QuestionUSer Control Error Pin
SRJ925-Nov-10 17:19
SRJ925-Nov-10 17:19 
AnswerRe: USer Control Error Pin
OriginalGriff5-Nov-10 22:54
mveOriginalGriff5-Nov-10 22:54 
AnswerRe: USer Control Error Pin
_Erik_5-Nov-10 23:15
_Erik_5-Nov-10 23:15 
First of all, it would be good to know if this is Windows.Forms or WPF, becouse the possible solutions might be different.

I guess your usrMenu1 object is an instance of your user control. You have defined a new delegate for the ClickMenu event, so the target method receives an string. It is not strictily bad, the code compiles and works, but it is not the best practice. You should better follow the structure of all event delegates defined in .NET, I mean, the target method should receive two parameters, you know, (object sender, EventArgs e), and if you need to pass some aditional data, you just have to extend EventArgs class subclassing it and adding what you need. The problem here might be in the code which raises the ClickMenu event, and you have not posted it here, or might be in the KeyDown event handler you have posted becouse there are several mistakes in it. That said, I would like to help you improve this code a little.

In this case, instead of a strange ClickMenu event which sends a string I would have defined two different events using the "standard" delegate EventHandler: one for Start button and another one for Settings button.

On the other hand, there is a huge optimization job you should do on your code. These composed conditions are always false, and the code of these if blocks do never execute:

if (e.KeyCode == Keys.Up && e.KeyCode == Keys.Right) // this is always false


Considering this, you do not need the if blocks to set the values to the four bool variables you are using, these four lines would do the same:

U = e.KeyCode != Keys.Down;
D = e.KeyCode != Keys.Up;
L = e.KeyCode != Keys.Right;
R = e.KeyCode != Keys.Left;


So setting Player.Normal and Player.Direction properties might be done with a switch.
QuestionSocket error on service stop Pin
Jacob D Dixon5-Nov-10 14:40
Jacob D Dixon5-Nov-10 14:40 
AnswerRe: Socket error on service stop Pin
RaviRanjanKr5-Nov-10 19:08
professionalRaviRanjanKr5-Nov-10 19:08 
GeneralRe: Socket error on service stop [modified] Pin
Jacob D Dixon6-Nov-10 5:32
Jacob D Dixon6-Nov-10 5:32 
QuestionUnit testing Pin
Tichaona J5-Nov-10 7:51
Tichaona J5-Nov-10 7:51 
AnswerRe: Unit testing Pin
fjdiewornncalwe5-Nov-10 8:12
professionalfjdiewornncalwe5-Nov-10 8:12 
AnswerRe: Unit testing Pin
Dave Kreskowiak5-Nov-10 9:43
mveDave Kreskowiak5-Nov-10 9:43 
GeneralRe: Unit testing Pin
Tichaona J5-Nov-10 12:00
Tichaona J5-Nov-10 12:00 
GeneralRe: Unit testing Pin
Pete O'Hanlon5-Nov-10 12:07
mvePete O'Hanlon5-Nov-10 12:07 
GeneralRe: Unit testing Pin
Dave Kreskowiak5-Nov-10 14:08
mveDave Kreskowiak5-Nov-10 14:08 
AnswerRe: Unit testing Pin
David Ewen8-Nov-10 14:07
professionalDavid Ewen8-Nov-10 14:07 
QuestionBadly behaving COM object. Pin
jbradshaw5-Nov-10 3:12
jbradshaw5-Nov-10 3:12 
AnswerRe: Badly behaving COM object. Pin
OriginalGriff5-Nov-10 3:33
mveOriginalGriff5-Nov-10 3:33 
AnswerRe: Badly behaving COM object. Pin
Abhinav S5-Nov-10 3:36
Abhinav S5-Nov-10 3:36 
AnswerRe: Badly behaving COM object. Pin
_Erik_5-Nov-10 3:38
_Erik_5-Nov-10 3:38 
AnswerRe: Badly behaving COM object. Pin
Pete O'Hanlon5-Nov-10 3:43
mvePete O'Hanlon5-Nov-10 3:43 
QuestionWorking with own libaries Pin
neus835-Nov-10 2:28
neus835-Nov-10 2:28 
AnswerRe: Working with own libaries Pin
Abhinav S5-Nov-10 2:45
Abhinav S5-Nov-10 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.