Listening to the Event registeration of a control and callinf Invalidate - Critical Isue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H
I am having a custom control which is having a Drag Event
Now what i want to do is I want to call "Invalidate" on my control when the user of the control registers for this event. Because the requirement is like if there is a listner to this event then i have to draw a texture where he can drag
Any idea how to listen to the user registering the event and then call invalidate
It has to be the other way also if he deletes the registration code. from the editor the control should invalidate and remove the texture

IT VERY CRITICAL AND COMPLEX. .......dOES ANYBODY HAS FACED THIS CHALLENGE

-Nilesh
 
Nilesh,

You can specify the add and remove code for your event handler like this:

public event EventHandler EventName {
add {
//code here for attaching event and invalidating or whatever
}
remove {
//code here for detaching event and invalidating or whatever
}
}

HTH,
Kent

Nilesh said:
Hi
I am having a custom control which is having a Drag Event.
Now what i want to do is I want to call "Invalidate" on my control when
the user of the control registers for this event. Because the requirement is
like if there is a listner to this event then i have to draw a texture where
he can drag.
Any idea how to listen to the user registering the event and then call invalidate?
It has to be the other way also if he deletes the registration code. from
the editor the control should invalidate and remove the texture?
 
Hi Kent,
Thanks a lot for the reply. But am not getting what are you suggesting
exactly.

I have a event declaration as follows:
public event MouseEventHandler TextureBorderDragging;
I am implementing that event as in MouseDown as
if (TextureBorderDragging!=null)
{
new TextureBorderDragging();
}

Now what i want is when a user registers to this event (i.e when there
is a listner) i will have to draw a texture and invalidate.

How to incorporate this and where to I am not getting ur suggestion can
u elaborate a little bit.
 
I may have misunderstood your question. If you are trying to invoke any
listeners in your MouseDown handler, you simply need to write:

if (TextureBorderDragging != null) {
TextureBorderDragging(this, e);
}

where e is your MouseEventArgs instance. Now whenever the MouseDown event
fires, the TextureBorderDragging event will fire too.

Is that what you're after?

Kent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top