Click here to Skip to main content
15,564,534 members
Home / Discussions / C#
   

C#

 
AnswerRe: The file version maintain utility Pin
Pete O'Hanlon12-Feb-14 3:16
mvaPete O'Hanlon12-Feb-14 3:16 
GeneralRe: The file version maintain utility Pin
OriginalGriff14-Feb-14 23:27
mvaOriginalGriff14-Feb-14 23:27 
QuestionHelp needed XNA and Window Forms Pin
larsp77712-Feb-14 1:57
larsp77712-Feb-14 1:57 
AnswerRe: Help needed XNA and Window Forms Pin
DaveyM6912-Feb-14 2:09
professionalDaveyM6912-Feb-14 2:09 
GeneralRe: Help needed XNA and Window Forms Pin
larsp77712-Feb-14 2:13
larsp77712-Feb-14 2:13 
GeneralRe: Help needed XNA and Window Forms Pin
DaveyM6912-Feb-14 2:39
professionalDaveyM6912-Feb-14 2:39 
GeneralRe: Help needed XNA and Window Forms Pin
larsp77712-Feb-14 5:34
larsp77712-Feb-14 5:34 
GeneralRe: Help needed XNA and Window Forms Pin
Pete O'Hanlon12-Feb-14 5:50
mvaPete O'Hanlon12-Feb-14 5:50 
larsp777 wrote:
The name 'HandleGameEvent' does not exist in the current context but I suppose something is missing
You are missing the event handler itself. Assuming that it just passed across EventArgs, the handler would look like this:
C#
private void HandleGameEvent(object sender, EventArgs e)
{
}
larsp777 wrote:
If it isn´t in range I want to send a bool or something to my form so I can e.g. enable or disable a button.
A simple event args class that looks like this should help:
C#
public class GameRangeEventArgs : EventArgs
{
   public GameRangeEventArgs(bool isInRange) : base()
   {
     IsInRange = isInRange;
   }
   public bool IsInRange { get; private set; }
}
Now, in your Game, you would declare this as:
C#
public event EventHandler<GameRangeEventArgs> GameRangeEvent;
To use this from your game code, I would typically have a helper method that looks like this:
C#
private void RaiseGameRangeEvent(bool isInRange)
{
  var handler = GameRangeEvent;
  if (handler != null)
  {
    handler(this, new GameRangeEventArgs(isInRange));
  }
}
Now, in your code you simply call this method and the event is raised if there is an event handler attached to it in the form. So, what would this look like in the form? Well, you will have something like this:
C#
game.GameRangeEvent += HandleGameRangeEvent;
...
private void HandleGameRangeEvent(object sender, GameRangeEventArgs e)
{
}

AnswerRe: Help needed XNA and Window Forms Pin
Marco Bertschi12-Feb-14 2:40
professionalMarco Bertschi12-Feb-14 2:40 
QuestionRegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 0:30
professionalMarco Bertschi12-Feb-14 0:30 
SuggestionRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 0:39
professionalKornfeld Eliyahu Peter12-Feb-14 0:39 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 0:53
professionalMarco Bertschi12-Feb-14 0:53 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 0:57
professionalKornfeld Eliyahu Peter12-Feb-14 0:57 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 1:09
professionalMarco Bertschi12-Feb-14 1:09 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 1:25
professionalKornfeld Eliyahu Peter12-Feb-14 1:25 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 2:06
professionalMarco Bertschi12-Feb-14 2:06 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 2:11
professionalKornfeld Eliyahu Peter12-Feb-14 2:11 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 2:17
professionalMarco Bertschi12-Feb-14 2:17 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 2:25
professionalKornfeld Eliyahu Peter12-Feb-14 2:25 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 2:39
professionalMarco Bertschi12-Feb-14 2:39 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 2:46
professionalKornfeld Eliyahu Peter12-Feb-14 2:46 
AnswerRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 11:13
professionalKornfeld Eliyahu Peter12-Feb-14 11:13 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 22:11
professionalMarco Bertschi12-Feb-14 22:11 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 22:36
professionalKornfeld Eliyahu Peter12-Feb-14 22:36 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 23:00
professionalMarco Bertschi12-Feb-14 23:00 

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.