Click here to Skip to main content
15,868,016 members
Home / Discussions / C#
   

C#

 
AnswerRe: The file version maintain utility Pin
Pete O'Hanlon12-Feb-14 2:16
subeditorPete O'Hanlon12-Feb-14 2:16 
GeneralRe: The file version maintain utility Pin
OriginalGriff14-Feb-14 22:27
mveOriginalGriff14-Feb-14 22:27 
QuestionHelp needed XNA and Window Forms Pin
larsp77712-Feb-14 0:57
larsp77712-Feb-14 0:57 
AnswerRe: Help needed XNA and Window Forms Pin
DaveyM6912-Feb-14 1:09
professionalDaveyM6912-Feb-14 1:09 
GeneralRe: Help needed XNA and Window Forms Pin
larsp77712-Feb-14 1:13
larsp77712-Feb-14 1:13 
GeneralRe: Help needed XNA and Window Forms Pin
DaveyM6912-Feb-14 1:39
professionalDaveyM6912-Feb-14 1:39 
GeneralRe: Help needed XNA and Window Forms Pin
larsp77712-Feb-14 4:34
larsp77712-Feb-14 4:34 
GeneralRe: Help needed XNA and Window Forms Pin
Pete O'Hanlon12-Feb-14 4:50
subeditorPete O'Hanlon12-Feb-14 4: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 1:40
protectorMarco Bertschi12-Feb-14 1:40 
QuestionRegEx problem with Escape sequences Pin
Marco Bertschi11-Feb-14 23:30
protectorMarco Bertschi11-Feb-14 23:30 
SuggestionRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter11-Feb-14 23:39
professionalKornfeld Eliyahu Peter11-Feb-14 23:39 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi11-Feb-14 23:53
protectorMarco Bertschi11-Feb-14 23:53 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter11-Feb-14 23:57
professionalKornfeld Eliyahu Peter11-Feb-14 23:57 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 0:09
protectorMarco Bertschi12-Feb-14 0:09 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 0:25
professionalKornfeld Eliyahu Peter12-Feb-14 0:25 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 1:06
protectorMarco Bertschi12-Feb-14 1:06 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 1:11
professionalKornfeld Eliyahu Peter12-Feb-14 1:11 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 1:17
protectorMarco Bertschi12-Feb-14 1:17 
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 1:39
protectorMarco Bertschi12-Feb-14 1:39 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 1:46
professionalKornfeld Eliyahu Peter12-Feb-14 1:46 
AnswerRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 10:13
professionalKornfeld Eliyahu Peter12-Feb-14 10:13 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 21:11
protectorMarco Bertschi12-Feb-14 21:11 
GeneralRe: RegEx problem with Escape sequences Pin
Kornfeld Eliyahu Peter12-Feb-14 21:36
professionalKornfeld Eliyahu Peter12-Feb-14 21:36 
GeneralRe: RegEx problem with Escape sequences Pin
Marco Bertschi12-Feb-14 22:00
protectorMarco Bertschi12-Feb-14 22: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.